aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2012-08-13 02:46:52 (EDT)
committerzzhongwei2012-08-13 02:46:52 (EDT)
commit164ef40b7c09ee69ba6c8fdaa3fb61073d5858c4 (patch)
tree5f3a24d011fbf1e6b956105c2248fb7660fbe23b
parentf065b2561e32ab43997765a5f715d452f0cf72fd (diff)
downloadorg.eclipse.pdt-164ef40b7c09ee69ba6c8fdaa3fb61073d5858c4.zip
org.eclipse.pdt-164ef40b7c09ee69ba6c8fdaa3fb61073d5858c4.tar.gz
org.eclipse.pdt-164ef40b7c09ee69ba6c8fdaa3fb61073d5858c4.tar.bz2
ZSTD-1985References search is not working for instance variables
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPMatchLocator.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPMatchLocator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPMatchLocator.java
index 497e010..3e686c3 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPMatchLocator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPMatchLocator.java
@@ -20,6 +20,8 @@ import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
import org.eclipse.dltk.ast.declarations.TypeDeclaration;
import org.eclipse.dltk.ast.expressions.CallExpression;
import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.references.SimpleReference;
+import org.eclipse.dltk.ast.references.VariableReference;
import org.eclipse.dltk.compiler.env.lookup.Scope;
import org.eclipse.dltk.compiler.util.HashtableOfIntValues;
import org.eclipse.dltk.core.DLTKCore;
@@ -30,6 +32,7 @@ import org.eclipse.dltk.core.search.SearchMatch;
import org.eclipse.dltk.core.search.SearchPattern;
import org.eclipse.dltk.core.search.matching.MatchLocator;
import org.eclipse.dltk.core.search.matching.PatternLocator;
+import org.eclipse.dltk.internal.core.search.matching.FieldPattern;
import org.eclipse.dltk.internal.core.search.matching.MatchingNodeSet;
import org.eclipse.dltk.internal.core.search.matching.MethodPattern;
import org.eclipse.dltk.internal.core.search.matching.OrPattern;
@@ -253,6 +256,47 @@ public class PHPMatchLocator extends MatchLocator {
}
@Override
+ public SearchMatch newFieldReferenceMatch(IModelElement enclosingElement,
+ int accuracy, int offset, int length, ASTNode reference) {
+
+ if (pattern instanceof FieldPattern
+ && (reference instanceof VariableReference || reference instanceof SimpleReference)) {
+ ISourceModule module = (ISourceModule) enclosingElement
+ .getAncestor(IModelElement.SOURCE_MODULE);
+ if (module != null) {
+ try {
+ IModelElement[] elements = module.codeSelect(
+ reference.sourceStart(), 0);
+ for (int i = 0; i < elements.length; i++) {
+ if (pattern.focus != null) {
+ if (pattern.focus.equals(elements[i])) {
+ return super.newFieldReferenceMatch(
+ enclosingElement, accuracy, offset,
+ length, reference);
+ }
+ } else {
+ FieldPattern methodPattern = (FieldPattern) pattern;
+ if (new String(methodPattern.name)
+ .equals(elements[i].getElementName())) {
+ return super.newFieldReferenceMatch(
+ enclosingElement, accuracy, offset,
+ length, reference);
+ }
+
+ }
+ }
+ } catch (ModelException e) {
+ e.printStackTrace();
+ }
+ }
+ } else if (pattern instanceof OrPattern) {
+ return super.newFieldReferenceMatch(enclosingElement, accuracy,
+ offset, length, reference);
+ }
+ return null;
+ }
+
+ @Override
public SearchMatch newMethodReferenceMatch(IModelElement enclosingElement,
int accuracy, int offset, int length, boolean isConstructor,
boolean isSynthetic, ASTNode reference) {