aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2013-03-26 04:58:08 (EDT)
committerzzhongwei2013-03-26 04:58:08 (EDT)
commit31285d2646eab09d986bfe7f75451554b713c1e3 (patch)
treec235a885f4574940088faccd5538e9febc9b709f
parent001f5cc49de044c3d15851ea793e6c0d59cdeaf1 (diff)
downloadorg.eclipse.pdt-31285d2646eab09d986bfe7f75451554b713c1e3.zip
org.eclipse.pdt-31285d2646eab09d986bfe7f75451554b713c1e3.tar.gz
org.eclipse.pdt-31285d2646eab09d986bfe7f75451554b713c1e3.tar.bz2
Some strategies are exclusive,then add flag to escape other strategies
to report proposals.
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/CompletionFlag.java7
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ICompletionReporter.java6
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/IPHPCompletionRequestor.java11
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java12
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java17
5 files changed, 45 insertions, 8 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/CompletionFlag.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/CompletionFlag.java
new file mode 100644
index 0000000..c7cf9fe
--- /dev/null
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/CompletionFlag.java
@@ -0,0 +1,7 @@
+package org.eclipse.php.internal.core.codeassist;
+
+public final class CompletionFlag {
+ public static final int DEFAULT = 1;
+ public static final int STOP_REPORT_TYPE = 1 << 1;
+
+}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ICompletionReporter.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ICompletionReporter.java
index ed7101f..3cd70bc 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ICompletionReporter.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/ICompletionReporter.java
@@ -28,9 +28,9 @@ import org.eclipse.dltk.internal.core.SourceRange;
public interface ICompletionReporter {
public final static int RELEVANCE_KEYWORD = 10000000;
- public final static int RELEVANCE_METHOD = 1000000;
- public final static int RELEVANCE_CLASS = 100000;
- public final static int RELEVANCE_VAR = 10000;
+ public final static int RELEVANCE_VAR = 1000000;
+ public final static int RELEVANCE_METHOD = 100000;
+ public final static int RELEVANCE_CLASS = 10000;
public final static int RELEVANCE_CONST = 1000;
public final static int RELEVANCE_ADJUST = 100;
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/IPHPCompletionRequestor.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/IPHPCompletionRequestor.java
index b90e6e4..3666403 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/IPHPCompletionRequestor.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/IPHPCompletionRequestor.java
@@ -51,4 +51,15 @@ public interface IPHPCompletionRequestor {
* @return document offset
*/
public void setOffset(int offset);
+
+ /**
+ * This is used in ICompletionStrategy,if this method return
+ * true,ICompletionStrategy.apply() should return immediately
+ *
+ * @param flag
+ * @return
+ */
+ public boolean filter(int flag);
+
+ public void addFlag(int flag);
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java
index 2984b58..f447d9b 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/strategies/GlobalTypesStrategy.java
@@ -24,10 +24,7 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.php.core.codeassist.ICompletionContext;
import org.eclipse.php.core.compiler.PHPFlags;
import org.eclipse.php.internal.core.PHPCorePlugin;
-import org.eclipse.php.internal.core.codeassist.AliasType;
-import org.eclipse.php.internal.core.codeassist.CodeAssistUtils;
-import org.eclipse.php.internal.core.codeassist.ICompletionReporter;
-import org.eclipse.php.internal.core.codeassist.ProposalExtraInfo;
+import org.eclipse.php.internal.core.codeassist.*;
import org.eclipse.php.internal.core.codeassist.contexts.AbstractCompletionContext;
import org.eclipse.php.internal.core.codeassist.contexts.NamespaceMemberContext;
import org.eclipse.php.internal.core.codeassist.contexts.UseNameContext;
@@ -85,6 +82,13 @@ public class GlobalTypesStrategy extends GlobalElementStrategy {
ICompletionContext context = getContext();
AbstractCompletionContext abstractContext = (AbstractCompletionContext) context;
+ if (abstractContext.getCompletionRequestor() instanceof IPHPCompletionRequestor) {
+ IPHPCompletionRequestor phpCompletionRequestor = (IPHPCompletionRequestor) abstractContext
+ .getCompletionRequestor();
+ if (phpCompletionRequestor.filter(CompletionFlag.STOP_REPORT_TYPE)) {
+ return;
+ }
+ }
if (abstractContext.getPrefixWithoutProcessing().trim().length() == 0) {
return;
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java
index 2186a7d..0876e2d 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/contentassist/PHPCompletionProposalCollector.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.php.core.compiler.PHPFlags;
import org.eclipse.php.internal.core.PHPVersion;
import org.eclipse.php.internal.core.codeassist.AliasType;
+import org.eclipse.php.internal.core.codeassist.CompletionFlag;
import org.eclipse.php.internal.core.codeassist.IPHPCompletionRequestor;
import org.eclipse.php.internal.core.codeassist.ProposalExtraInfo;
import org.eclipse.php.internal.core.compiler.ast.nodes.NamespaceReference;
@@ -39,6 +40,7 @@ public class PHPCompletionProposalCollector extends
private IDocument document;
private boolean explicit;
private int offset;
+ private int flags = CompletionFlag.DEFAULT;
public PHPCompletionProposalCollector(IDocument document, ISourceModule cu,
boolean explicit) {
@@ -335,9 +337,22 @@ public class PHPCompletionProposalCollector extends
// if (ProposalExtraInfo.STUB.equals(proposal.getExtraInfo())) {
// return Integer.MAX_VALUE;
// }
- if (ProposalExtraInfo.isMagicMethod(proposal.getExtraInfo())) {
+ if (proposal.getModelElement() instanceof IMethod
+ && ProposalExtraInfo.isMagicMethod(proposal.getExtraInfo())) {
return -1;
}
+ if (proposal.getModelElement() instanceof IField
+ && ProposalExtraInfo.isMagicMethod(proposal.getExtraInfo())) {
+ return Integer.MAX_VALUE;
+ }
return super.computeRelevance(proposal);
}
+
+ public boolean filter(int flag) {
+ return (flags & flag) != 0;
+ }
+
+ public void addFlag(int flag) {
+ flags |= flag;
+ }
}