aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacek Pospychala2012-10-31 09:26:59 (EDT)
committerJacek Pospychala2012-10-31 09:26:59 (EDT)
commit8eb1bb2aa8410cc6dd1c78baa1964f2b7444d8de (patch)
treef5d2fd0d67f950c6ed6e0a4585053e4ae564fbca
parent6b8270c572ee5fa69a98ce619e5639c04ab5d26e (diff)
downloadorg.eclipse.pdt-8eb1bb2aa8410cc6dd1c78baa1964f2b7444d8de.zip
org.eclipse.pdt-8eb1bb2aa8410cc6dd1c78baa1964f2b7444d8de.tar.gz
org.eclipse.pdt-8eb1bb2aa8410cc6dd1c78baa1964f2b7444d8de.tar.bz2
Bug 393228 - templates show in codeassist when completing a type field
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateCompletionProcessor.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateCompletionProcessor.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateCompletionProcessor.java
index a4a8a96..c658960 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateCompletionProcessor.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateCompletionProcessor.java
@@ -102,6 +102,18 @@ public class PhpTemplateCompletionProcessor extends
enclosingMethod = (IMethod) enclosingElement;
}
+ boolean isFieldAccess = false;
+
+ try {
+ if (offset > 2) {
+ String accessPrefix = document.get(offset - 2, 2);
+ if ("->".equals(accessPrefix) || "::".equals(accessPrefix)) {
+ isFieldAccess = true;
+ }
+ }
+ } catch (BadLocationException e) {
+ }
+
// find the most outer enclosing type if exists
while (enclosingElement != null
&& !(enclosingElement instanceof IType)) {
@@ -110,11 +122,13 @@ public class PhpTemplateCompletionProcessor extends
enclosingType = (IType) enclosingElement;
if (enclosingMethod == null && enclosingType == null) {
+
contextIds
.add(PhpTemplateContextType.PHP_STATEMENTS_CONTEXT_TYPE_ID);
contextIds
.add(PhpTemplateContextType.PHP_GLOBAL_MEMBERS_CONTEXT_TYPE_ID);
- } else if (enclosingMethod == null && enclosingType != null) {
+ } else if (enclosingMethod == null && enclosingType != null
+ && !isFieldAccess) {
if (!PHPFlags.isNamespace(enclosingType.getFlags())) {
contextIds
.add(PhpTemplateContextType.PHP_TYPE_MEMBERS_CONTEXT_TYPE_ID);
@@ -128,7 +142,8 @@ public class PhpTemplateCompletionProcessor extends
contextIds
.add(PhpTemplateContextType.PHP_GLOBAL_MEMBERS_CONTEXT_TYPE_ID);
}
- } else if (enclosingMethod != null && enclosingType != null) {
+ } else if (enclosingMethod != null && enclosingType != null
+ && !isFieldAccess) {
if (!PHPFlags.isNamespace(enclosingType.getFlags())) {
contextIds
.add(PhpTemplateContextType.PHP_TYPE_METHOD_STATEMENTS_CONTEXT_TYPE_ID);