summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorDawid Pakuła2013-10-21 02:54:37 (EDT)
committer Dawid Pakuła2013-10-21 02:54:37 (EDT)
commitb7cf7c63817184022936a7a94a177113261fc040 (patch)
treef9579c24e77073b544a76f1e4034aeeaff0c8fb4
parent3e9f2e69cf3691865997f8fa262dca6d75b532e6 (diff)
downloadorg.eclipse.pdt-b7cf7c63817184022936a7a94a177113261fc040.zip
org.eclipse.pdt-b7cf7c63817184022936a7a94a177113261fc040.tar.gz
org.eclipse.pdt-b7cf7c63817184022936a7a94a177113261fc040.tar.bz2
Bug 417904 - Option 1, special interface to access IProblemIdentifier in IQuickFixProcessorrefs/changes/75/17575/1
Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=417904 Change-Id: Id07431e06450bc9d78db336e6a46fa85673e7af6 Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/compare/TextMergeViewer.java4
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/IProblemLocation.java3
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/IQuickFixProcessorExtension.java26
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/PHPCorrectionProcessor.java32
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/ProblemLocation.java18
5 files changed, 72 insertions, 11 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/compare/TextMergeViewer.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/compare/TextMergeViewer.java
index 30322ca..121d32e 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/compare/TextMergeViewer.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/compare/TextMergeViewer.java
@@ -4747,6 +4747,10 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
}
return null;
}
+
+ public int getChangesCount() {
+ return 0;
+ }
};
}
if (adapter == OutlineViewerCreator.class) {
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/IProblemLocation.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/IProblemLocation.java
index 62ffb2a..f7f3620 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/IProblemLocation.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/IProblemLocation.java
@@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.php.internal.ui.text.correction;
+import org.eclipse.dltk.compiler.problem.IProblemIdentifier;
import org.eclipse.php.internal.core.ast.nodes.ASTNode;
import org.eclipse.php.internal.core.ast.nodes.Program;
@@ -60,6 +61,8 @@ public interface IProblemLocation {
*/
int getProblemId();
+ IProblemIdentifier getProblemIdentifier();
+
/**
* Returns the original arguments recorded into the problem.
*
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/IQuickFixProcessorExtension.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/IQuickFixProcessorExtension.java
new file mode 100644
index 0000000..2e0e35b
--- /dev/null
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/IQuickFixProcessorExtension.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Zend Technologies
+ *******************************************************************************/
+package org.eclipse.php.internal.ui.text.correction;
+
+import org.eclipse.dltk.compiler.problem.IProblemIdentifier;
+import org.eclipse.dltk.core.ISourceModule;
+
+/**
+ * This extension add access to {@link IProblemIdentifier} instead of int in
+ * hasCorrections()
+ *
+ * @since 3.2.1
+ */
+public interface IQuickFixProcessorExtension {
+ public boolean hasCorrections(ISourceModule unit,
+ IProblemIdentifier identifier);
+}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/PHPCorrectionProcessor.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/PHPCorrectionProcessor.java
index a339fd4..8e586da 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/PHPCorrectionProcessor.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/PHPCorrectionProcessor.java
@@ -18,6 +18,7 @@ import java.util.Scanner;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.*;
+import org.eclipse.dltk.compiler.problem.IProblemIdentifier;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.ui.DLTKUIPlugin;
import org.eclipse.dltk.ui.editor.IScriptAnnotation;
@@ -95,10 +96,10 @@ public class PHPCorrectionProcessor implements
return fgContributedAssistProcessors;
}
- public static boolean hasCorrections(ISourceModule cu, int problemId,
- String markerType) {
+ public static boolean hasCorrections(ISourceModule cu,
+ IProblemIdentifier identifier, String markerType) {
ContributedProcessorDescriptor[] processors = getCorrectionProcessors();
- SafeHasCorrections collector = new SafeHasCorrections(cu, problemId);
+ SafeHasCorrections collector = new SafeHasCorrections(cu, identifier);
for (int i = 0; i < processors.length; i++) {
if (processors[i].canHandleMarkerType(markerType)) {
collector.process(processors[i]);
@@ -119,12 +120,9 @@ public class PHPCorrectionProcessor implements
if (annotation instanceof IScriptAnnotation) {
IScriptAnnotation javaAnnotation = (IScriptAnnotation) annotation;
if (javaAnnotation.getId() != null) {
- Scanner problemScanner = new Scanner(javaAnnotation.getId().name());
ISourceModule cu = javaAnnotation.getSourceModule();
- if (problemScanner.hasNextInt() && cu != null) {
- return hasCorrections(cu, problemScanner.nextInt(),
- javaAnnotation.getMarkerType());
- }
+ return hasCorrections(cu, javaAnnotation.getId(),
+ javaAnnotation.getMarkerType());
}
}
@@ -503,11 +501,20 @@ public class PHPCorrectionProcessor implements
SafeCorrectionProcessorAccess {
private final ISourceModule fCu;
private final int fProblemId;
+ private final IProblemIdentifier fIdentifier;
private boolean fHasCorrections;
- public SafeHasCorrections(ISourceModule cu, int problemId) {
+ public SafeHasCorrections(ISourceModule cu,
+ IProblemIdentifier identifier) {
fCu = cu;
- fProblemId = problemId;
+ Scanner problemScanner = new Scanner(identifier.name());
+ if (problemScanner.hasNextInt()) {
+ fProblemId = problemScanner.nextInt();
+ } else {
+ fProblemId = -1;
+ }
+ this.fIdentifier = identifier;
+
fHasCorrections = false;
}
@@ -521,6 +528,11 @@ public class PHPCorrectionProcessor implements
.getProcessor(fCu, IQuickFixProcessor.class);
if (processor != null && processor.hasCorrections(fCu, fProblemId)) {
fHasCorrections = true;
+ } else if (processor != null
+ && processor instanceof IQuickFixProcessorExtension
+ && ((IQuickFixProcessorExtension) processor)
+ .hasCorrections(fCu, fIdentifier)) {
+ fHasCorrections = true;
}
}
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/ProblemLocation.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/ProblemLocation.java
index 0639303..59d21b0 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/ProblemLocation.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/text/correction/ProblemLocation.java
@@ -15,6 +15,7 @@ import java.util.Scanner;
import org.eclipse.dltk.compiler.problem.CategorizedProblem;
import org.eclipse.dltk.compiler.problem.IProblem;
+import org.eclipse.dltk.compiler.problem.IProblemIdentifier;
import org.eclipse.dltk.core.IScriptModelMarker;
import org.eclipse.dltk.ui.editor.IScriptAnnotation;
import org.eclipse.dltk.ui.editor.ScriptMarkerAnnotation;
@@ -33,6 +34,7 @@ public class ProblemLocation implements IProblemLocation {
private final int fLength;
private final boolean fIsError;
private final String fMarkerType;
+ private final IProblemIdentifier fIdentifier;
public ProblemLocation(int offset, int length, IScriptAnnotation annotation) {
if (annotation.getId() != null) {
@@ -42,8 +44,10 @@ public class ProblemLocation implements IProblemLocation {
} else {
fId = -1;
}
+ fIdentifier = annotation.getId();
} else {
fId = -1;
+ fIdentifier = null;
}
fArguments = annotation.getArguments();
fOffset = offset;
@@ -64,13 +68,21 @@ public class ProblemLocation implements IProblemLocation {
fLength = length;
fIsError = isError;
fMarkerType = markerType;
+ fIdentifier = null;
}
public ProblemLocation(IProblem problem) {
if (problem.getID() != null) {
- fId = Integer.parseInt(problem.getID().name());
+ Scanner scan = new Scanner(problem.getID().name());
+ if (scan.hasNextInt()) {
+ fId = scan.nextInt();
+ } else {
+ fId = -1;
+ }
+ fIdentifier = problem.getID();
} else {
fId = -1;
+ fIdentifier = null;
}
fArguments = problem.getArguments();
fOffset = problem.getSourceStart();
@@ -91,6 +103,10 @@ public class ProblemLocation implements IProblemLocation {
return fId;
}
+ public IProblemIdentifier getProblemIdentifier() {
+ return fIdentifier;
+ }
+
/*
* (non-Javadoc)
*