Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorggurfinke2008-02-05 12:27:38 -0500
committerggurfinke2008-02-05 12:27:38 -0500
commite6800919b7ac9921849126128780d8bb4ce1f18b (patch)
tree389b92f1e9790b7a57691c3bbcf304bcdd4fd326
parent3b9456968ca7d584d461a6134bd1f6fa6248487f (diff)
downloadorg.eclipse.pdt-EXPERIMENTAL_DLTK_15012008.tar.gz
org.eclipse.pdt-EXPERIMENTAL_DLTK_15012008.tar.xz
org.eclipse.pdt-EXPERIMENTAL_DLTK_15012008.zip
added search declarationsEXPERIMENTAL_DLTK_15012008
-rw-r--r--plugins/org.eclipse.php.core/plugin.xml8
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/parser/PHPSourceElementRequestor.java159
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinBuildVisitor.java36
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinElementInfo.java194
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPMatchLocatorParser.java92
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPSearchFactory.java27
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/sourceModel/IConstant.java7
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/sourceModel/IInterface.java7
8 files changed, 397 insertions, 133 deletions
diff --git a/plugins/org.eclipse.php.core/plugin.xml b/plugins/org.eclipse.php.core/plugin.xml
index 4d51d55e1..db13ddb89 100644
--- a/plugins/org.eclipse.php.core/plugin.xml
+++ b/plugins/org.eclipse.php.core/plugin.xml
@@ -153,5 +153,13 @@
priority="0">
</mixin>
</extension>
+ <extension
+ point="org.eclipse.dltk.core.search">
+ <seachFactory
+ class="org.eclipse.php.internal.core.search.PHPSearchFactory"
+ nature="org.eclipse.php.core.PHPNature"
+ priority="0">
+ </seachFactory>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/parser/PHPSourceElementRequestor.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/parser/PHPSourceElementRequestor.java
index c76b6f89e..2c9daa187 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/parser/PHPSourceElementRequestor.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/compiler/ast/parser/PHPSourceElementRequestor.java
@@ -1,11 +1,170 @@
package org.eclipse.php.internal.core.compiler.ast.parser;
+import java.util.Stack;
+
+import org.eclipse.dltk.ast.Modifiers;
+import org.eclipse.dltk.ast.declarations.Declaration;
+import org.eclipse.dltk.ast.declarations.MethodDeclaration;
+import org.eclipse.dltk.ast.declarations.TypeDeclaration;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.references.ConstantReference;
+import org.eclipse.dltk.ast.references.SimpleReference;
+import org.eclipse.dltk.ast.references.VariableReference;
+import org.eclipse.dltk.ast.statements.Statement;
import org.eclipse.dltk.compiler.ISourceElementRequestor;
import org.eclipse.dltk.compiler.SourceElementRequestVisitor;
+import org.eclipse.php.internal.core.compiler.ast.nodes.Assignment;
+import org.eclipse.php.internal.core.compiler.ast.nodes.ClassConstantDeclaration;
+import org.eclipse.php.internal.core.compiler.ast.nodes.FieldAccess;
+import org.eclipse.php.internal.core.compiler.ast.nodes.PHPFieldDeclaration;
public class PHPSourceElementRequestor extends SourceElementRequestVisitor {
+ /*
+ * This should replace the need for fInClass, fInMethod and fCurrentMethod
+ * since in php the type declarations can be nested.
+ */
+ protected Stack<Declaration> declarations = new Stack<Declaration>();
+
public PHPSourceElementRequestor(ISourceElementRequestor requestor) {
super(requestor);
}
+
+ protected MethodDeclaration getCurrentMethod() {
+ Declaration currDecleration = declarations.peek();
+ if (currDecleration instanceof MethodDeclaration) {
+ return (MethodDeclaration) currDecleration;
+ }
+ return null;
+ }
+
+ public boolean endvisit(MethodDeclaration method) throws Exception {
+ declarations.pop();
+ return super.endvisit(method);
+ }
+
+ public boolean endvisit(TypeDeclaration type) throws Exception {
+ declarations.pop();
+ return super.endvisit(type);
+ }
+
+ public boolean visit(MethodDeclaration method) throws Exception {
+ declarations.push(method);
+ return super.visit(method);
+ }
+
+ public boolean visit(TypeDeclaration type) throws Exception {
+ declarations.push(type);
+ return super.visit(type);
+ }
+
+ public boolean visit(PHPFieldDeclaration declaration) throws Exception {
+ ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo();
+ info.modifiers = declaration.getModifiers();
+ info.name = declaration.getName();
+ SimpleReference var = declaration.getRef();
+ info.nameSourceEnd = var.sourceEnd() - 1;
+ info.nameSourceStart = var.sourceStart();
+ info.declarationStart = declaration.sourceStart();
+ fRequestor.enterField(info);
+ return true;
+ }
+
+ public boolean endvisit(PHPFieldDeclaration declaration) throws Exception {
+ fRequestor.exitField(declaration.sourceEnd() - 1);
+ return true;
+ }
+
+ public boolean visit(ClassConstantDeclaration declaration) throws Exception {
+ ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo();
+ info.modifiers = Modifiers.AccConstant;
+ ConstantReference constantName = declaration.getConstantName();
+ info.name = constantName.getName();
+ info.nameSourceEnd = constantName.sourceEnd() - 1;
+ info.nameSourceStart = constantName.sourceStart();
+ info.declarationStart = declaration.sourceStart();
+ fRequestor.enterField(info);
+ return true;
+ }
+
+ public boolean endvisit(ClassConstantDeclaration declaration) throws Exception {
+ fRequestor.exitField(declaration.sourceEnd() - 1);
+ return true;
+ }
+
+ public boolean visit(Assignment assignment) throws Exception {
+ Expression left = assignment.getVariable();
+ if (left instanceof FieldAccess) { // class variable ($this->a = .)
+ FieldAccess fieldAccess = (FieldAccess) left;
+ Expression dispatcher = fieldAccess.getDispatcher();
+ if (dispatcher instanceof VariableReference && "$this".equals(((VariableReference) dispatcher).getName())) { //$NON-NLS-1$
+ Expression field = fieldAccess.getField();
+ if (field instanceof SimpleReference) {
+ SimpleReference ref = (SimpleReference) field;
+ ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo();
+ info.modifiers = Modifiers.AccDefault;
+ info.name = ref.getName();
+ info.nameSourceEnd = ref.sourceEnd() - 1;
+ info.nameSourceStart = ref.sourceStart();
+ info.declarationStart = assignment.sourceStart();
+ fRequestor.enterField(info);
+ fNodes.push(assignment);
+ }
+ }
+ }
+ return true;
+ }
+
+ public boolean endvisit(Assignment assignment) throws Exception {
+ if (!fNodes.isEmpty() && fNodes.peek() == assignment) {
+ fRequestor.exitField(assignment.sourceEnd() - 1);
+ fNodes.pop();
+ }
+ return true;
+ }
+
+ public boolean visit(Statement node) throws Exception {
+ String clasName = node.getClass().getName();
+ if (clasName.equals(PHPFieldDeclaration.class.getName())) {
+ return visit((PHPFieldDeclaration) node);
+ }
+ if (clasName.equals(ClassConstantDeclaration.class.getName())) {
+ return visit((ClassConstantDeclaration) node);
+ }
+ // if (clasName.equals(CallExpression.class.getName())) {//for define("A","A");
+ // return visit((ClassConstantDeclaration) node);
+ // }
+
+ return true;
+ }
+
+ public boolean endvisit(Statement node) throws Exception {
+ String clasName = node.getClass().getName();
+ if (clasName.equals(PHPFieldDeclaration.class.getName())) {
+ return endvisit((PHPFieldDeclaration) node);
+ }
+ if (clasName.equals(ClassConstantDeclaration.class.getName())) {
+ return endvisit((ClassConstantDeclaration) node);
+ }
+ // if (clasName.equals(CallExpression.class.getName())) {//for define("A","A");
+ // return endvisit((ClassConstantDeclaration) node);
+ // }
+ return true;
+ }
+
+ public boolean visit(Expression node) throws Exception {
+ String clasName = node.getClass().getName();
+ if (clasName.equals(Assignment.class.getName())) {
+ return visit((Assignment) node);
+ }
+ return true;
+ }
+
+ public boolean endvisit(Expression node) throws Exception {
+ String clasName = node.getClass().getName();
+ if (clasName.equals(Assignment.class.getName())) {
+ return endvisit((Assignment) node);
+ }
+ return true;
+ }
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinBuildVisitor.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinBuildVisitor.java
index 8b5bcc532..d1452c32d 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinBuildVisitor.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinBuildVisitor.java
@@ -10,20 +10,14 @@ 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.ast.statements.Statement;
-import org.eclipse.dltk.core.IField;
-import org.eclipse.dltk.core.IMethod;
-import org.eclipse.dltk.core.IModelElement;
-import org.eclipse.dltk.core.ISourceModule;
-import org.eclipse.dltk.core.IType;
-import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.core.*;
import org.eclipse.dltk.core.mixin.IMixinRequestor;
import org.eclipse.dltk.core.mixin.MixinModel;
import org.eclipse.dltk.core.mixin.IMixinRequestor.ElementInfo;
import org.eclipse.php.internal.core.compiler.ast.nodes.*;
-import org.eclipse.php.internal.core.sourceModel.IConstant;
-import org.eclipse.php.internal.core.sourceModel.IInterface;
public class PHPMixinBuildVisitor extends ASTVisitor {
@@ -54,7 +48,7 @@ public class PHPMixinBuildVisitor extends ASTVisitor {
public abstract String reportVariable(String name, IField object);
- public abstract String reportConstant(String name, IConstant object);
+ public abstract String reportConstant(String name, IField object);
public abstract String reportType(String name, IType object, boolean isInterface);
@@ -81,7 +75,7 @@ public class PHPMixinBuildVisitor extends ASTVisitor {
}
public String reportType(String name, IType object, boolean isInterface) {
- return report(name + CLASS_SUFFIX, isInterface ? PHPMixinElementInfo.createInterface((IInterface) object) : PHPMixinElementInfo.createClass(object));
+ return report(name + CLASS_SUFFIX, isInterface ? PHPMixinElementInfo.createInterface(object) : PHPMixinElementInfo.createClass(object));
}
public String reportVariable(String name, IField object) {
@@ -89,7 +83,7 @@ public class PHPMixinBuildVisitor extends ASTVisitor {
return report(name, PHPMixinElementInfo.createVariable(object));
}
- public String reportConstant(String name, IConstant object) {
+ public String reportConstant(String name, IField object) {
// Report global constant:
return report(name + CONSTANT_SUFFIX, PHPMixinElementInfo.createConstant(object));
}
@@ -129,7 +123,7 @@ public class PHPMixinBuildVisitor extends ASTVisitor {
return report(getClassKey() + MixinModel.SEPARATOR + name, info);
}
- public String reportConstant(String name, IConstant object) {
+ public String reportConstant(String name, IField object) {
// Report class constant:
return report(getClassKey() + MixinModel.SEPARATOR + name + CONSTANT_SUFFIX, PHPMixinElementInfo.createConstant(object));
}
@@ -178,7 +172,7 @@ public class PHPMixinBuildVisitor extends ASTVisitor {
return report(getClassKey() + MixinModel.SEPARATOR + '$' + name, info);
}
- public String reportConstant(String name, IConstant object) {
+ public String reportConstant(String name, IField object) {
// Constant defined inside of method is a part of global scope:
return sourceModuleScope.reportConstant(name, object);
}
@@ -221,11 +215,11 @@ public class PHPMixinBuildVisitor extends ASTVisitor {
return key;
}
- private void reportVariableDeclaration(VariableReference var) throws Exception {
+ private void reportVariableDeclaration(SimpleReference var) throws Exception {
reportVariableDeclaration(var, scopes.peek());
}
- private void reportVariableDeclaration(VariableReference var, Scope scope) throws Exception {
+ private void reportVariableDeclaration(SimpleReference var, Scope scope) throws Exception {
if(scope == null){
throw new Exception("Scope should not be null");
}
@@ -289,7 +283,7 @@ public class PHPMixinBuildVisitor extends ASTVisitor {
public boolean visit(CallExpression expr) throws Exception {
if ("define".equals(expr.getName())) { //$NON-NLS-1$
// report global constant:
- IConstant obj = null;
+ IField obj = null;
List args = expr.getArgs().getChilds();
if (args.size() > 1) {
ASTNode firstArg = (ASTNode) args.get(0);
@@ -298,7 +292,7 @@ public class PHPMixinBuildVisitor extends ASTVisitor {
String name = constant.getValue();
if (moduleAvailable) {
IModelElement element = findModelElementFor(constant);
- obj = (IConstant) element;
+ obj = (IField) element;
}
Scope scope = scopes.peek();
scope.reportConstant(stripQuotes(name), obj);
@@ -317,8 +311,8 @@ public class PHPMixinBuildVisitor extends ASTVisitor {
Expression dispatcher = fieldAccess.getDispatcher();
if (dispatcher instanceof VariableReference && "$this".equals(((VariableReference) dispatcher).getName())) { //$NON-NLS-1$
Expression field = fieldAccess.getField();
- if (field instanceof VariableReference) {
- reportVariableDeclaration((VariableReference) field);
+ if (field instanceof SimpleReference) {
+ reportVariableDeclaration((SimpleReference) field);
}
}
}
@@ -349,11 +343,11 @@ public class PHPMixinBuildVisitor extends ASTVisitor {
}
public boolean visit(ClassConstantDeclaration decl) throws Exception {
- IConstant obj = null;
+ IField obj = null;
String name = decl.getConstantName().getName();
if (moduleAvailable) {
IModelElement element = findModelElementFor(decl);
- obj = (IConstant) element;
+ obj = (IField) element;
}
Scope scope = scopes.peek();
scope.reportConstant(stripQuotes(name), obj);
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinElementInfo.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinElementInfo.java
index 45d40b3b3..26319c7a0 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinElementInfo.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinElementInfo.java
@@ -1,98 +1,96 @@
-package org.eclipse.php.internal.core.mixin;
-
-import org.eclipse.dltk.core.IField;
-import org.eclipse.dltk.core.IMethod;
-import org.eclipse.dltk.core.IType;
-import org.eclipse.php.internal.core.sourceModel.IConstant;
-import org.eclipse.php.internal.core.sourceModel.IInterface;
-
-public class PHPMixinElementInfo {
-
- public static final int K_CLASS = 0;
- public static final int K_INTERFACE = 1;
- public static final int K_METHOD = 2;
- public static final int K_VARIABLE = 3;
- public static final int K_CONSTANT = 4;
- public static final int K_INCLUDE = 5;
-
- private int kind = 0;
- private Object object = null;
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + kind;
- result = prime * result + ((object == null) ? 0 : object.hashCode());
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final PHPMixinElementInfo other = (PHPMixinElementInfo) obj;
- if (kind != other.kind)
- return false;
- if (object == null) {
- if (other.object != null)
- return false;
- } else if (!object.equals(other.object))
- return false;
- return true;
- }
-
- public PHPMixinElementInfo(int kind, Object object) {
- super();
- this.kind = kind;
- this.object = object;
- }
-
- public int getKind() {
- return kind;
- }
-
- public void setKind(int kind) {
- this.kind = kind;
- }
-
- public Object getObject() {
- return object;
- }
-
- public void setObject(Object object) {
- this.object = object;
- }
-
- public static PHPMixinElementInfo createClass(IType type) {
- return new PHPMixinElementInfo(K_CLASS, type);
- }
-
- public static PHPMixinElementInfo createInterface(IInterface type) {
- return new PHPMixinElementInfo(K_INTERFACE, type);
- }
-
- public static PHPMixinElementInfo createMethod(IMethod m) {
- return new PHPMixinElementInfo(K_METHOD, m);
- }
-
- public static PHPMixinElementInfo createInclude(String key) {
- return new PHPMixinElementInfo(K_INCLUDE, key);
- }
-
- public static PHPMixinElementInfo createVariable(IField type) {
- return new PHPMixinElementInfo(K_VARIABLE, type);
- }
-
- public static PHPMixinElementInfo createConstant(IConstant type) {
- return new PHPMixinElementInfo(K_CONSTANT, type);
- }
-}
+package org.eclipse.php.internal.core.mixin;
+
+import org.eclipse.dltk.core.IField;
+import org.eclipse.dltk.core.IMethod;
+import org.eclipse.dltk.core.IType;
+
+public class PHPMixinElementInfo {
+
+ public static final int K_CLASS = 0;
+ public static final int K_INTERFACE = 1;
+ public static final int K_METHOD = 2;
+ public static final int K_VARIABLE = 3;
+ public static final int K_CONSTANT = 4;
+ public static final int K_INCLUDE = 5;
+
+ private int kind = 0;
+ private Object object = null;
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + kind;
+ result = prime * result + ((object == null) ? 0 : object.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final PHPMixinElementInfo other = (PHPMixinElementInfo) obj;
+ if (kind != other.kind)
+ return false;
+ if (object == null) {
+ if (other.object != null)
+ return false;
+ } else if (!object.equals(other.object))
+ return false;
+ return true;
+ }
+
+ public PHPMixinElementInfo(int kind, Object object) {
+ super();
+ this.kind = kind;
+ this.object = object;
+ }
+
+ public int getKind() {
+ return kind;
+ }
+
+ public void setKind(int kind) {
+ this.kind = kind;
+ }
+
+ public Object getObject() {
+ return object;
+ }
+
+ public void setObject(Object object) {
+ this.object = object;
+ }
+
+ public static PHPMixinElementInfo createClass(IType type) {
+ return new PHPMixinElementInfo(K_CLASS, type);
+ }
+
+ public static PHPMixinElementInfo createInterface(IType type) {
+ return new PHPMixinElementInfo(K_INTERFACE, type);
+ }
+
+ public static PHPMixinElementInfo createMethod(IMethod m) {
+ return new PHPMixinElementInfo(K_METHOD, m);
+ }
+
+ public static PHPMixinElementInfo createInclude(String key) {
+ return new PHPMixinElementInfo(K_INCLUDE, key);
+ }
+
+ public static PHPMixinElementInfo createVariable(IField type) {
+ return new PHPMixinElementInfo(K_VARIABLE, type);
+ }
+
+ public static PHPMixinElementInfo createConstant(IField type) {
+ return new PHPMixinElementInfo(K_CONSTANT, type);
+ }
+}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPMatchLocatorParser.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPMatchLocatorParser.java
new file mode 100644
index 000000000..f10a35e7f
--- /dev/null
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPMatchLocatorParser.java
@@ -0,0 +1,92 @@
+package org.eclipse.php.internal.core.search;
+
+import org.eclipse.dltk.ast.ASTNode;
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.Modifiers;
+import org.eclipse.dltk.ast.declarations.FieldDeclaration;
+import org.eclipse.dltk.ast.declarations.MethodDeclaration;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.ast.declarations.TypeDeclaration;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.references.ConstantReference;
+import org.eclipse.dltk.ast.references.SimpleReference;
+import org.eclipse.dltk.ast.references.VariableReference;
+import org.eclipse.dltk.core.SourceParserUtil;
+import org.eclipse.dltk.core.search.matching.MatchLocator;
+import org.eclipse.dltk.core.search.matching.MatchLocatorParser;
+import org.eclipse.dltk.core.search.matching.PossibleMatch;
+import org.eclipse.php.internal.core.compiler.ast.nodes.Assignment;
+import org.eclipse.php.internal.core.compiler.ast.nodes.ClassConstantDeclaration;
+import org.eclipse.php.internal.core.compiler.ast.nodes.FieldAccess;
+
+public class PHPMatchLocatorParser extends MatchLocatorParser {
+
+ public PHPMatchLocatorParser(MatchLocator locator) {
+ super(locator);
+ }
+
+ public ModuleDeclaration parse(PossibleMatch possibleMatch) {
+ ModuleDeclaration module = SourceParserUtil.getModuleDeclaration((org.eclipse.dltk.core.ISourceModule) possibleMatch.getModelElement(), null);
+ return module;
+ }
+
+ private ASTVisitor visitor = new ASTVisitor() {
+
+ public boolean visitGeneral(ASTNode s) throws Exception {
+ processStatement(s);
+ return true;
+ }
+
+ public boolean visit(MethodDeclaration s) throws Exception {
+ getPatternLocator().match(processMethod(s), getNodeSet());
+ return true;
+ }
+
+ public boolean visit(TypeDeclaration s) throws Exception {
+ getPatternLocator().match(processType(s), getNodeSet());
+ return true;
+ }
+ };
+
+ public void parseBodies(ModuleDeclaration unit) {
+ try {
+ unit.traverse(this.visitor);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private MethodDeclaration processMethod(MethodDeclaration m) {
+ return m;
+ }
+
+ private TypeDeclaration processType(TypeDeclaration t) {
+ return t;
+ }
+
+ private void processStatement(ASTNode node) {
+ if (node instanceof FieldDeclaration) {
+ getPatternLocator().match((FieldDeclaration) node, getNodeSet());
+ } else if (node instanceof ClassConstantDeclaration) {
+ ClassConstantDeclaration constDecl = (ClassConstantDeclaration) node;
+ ConstantReference constantName = constDecl.getConstantName();
+ FieldDeclaration decl = new FieldDeclaration(constantName.getName(), constantName.sourceStart(), constantName.sourceEnd(), constDecl.sourceStart(), constDecl.sourceEnd());
+ decl.setModifiers(Modifiers.AccConstant);
+ getPatternLocator().match(decl, getNodeSet());
+ } else if(node instanceof Assignment){
+ Expression left = ((Assignment)node).getVariable();
+ if (left instanceof FieldAccess) { // class variable ($this->a = .)
+ FieldAccess fieldAccess = (FieldAccess) left;
+ Expression dispatcher = fieldAccess.getDispatcher();
+ if (dispatcher instanceof VariableReference && "$this".equals(((VariableReference) dispatcher).getName())) { //$NON-NLS-1$
+ Expression field = fieldAccess.getField();
+ if (field instanceof SimpleReference) {
+ SimpleReference ref = (SimpleReference) field;
+ FieldDeclaration decl = new FieldDeclaration(ref.getName(), ref.sourceStart(), ref.sourceEnd(), node.sourceStart(), node.sourceEnd());
+ getPatternLocator().match(decl, getNodeSet());
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPSearchFactory.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPSearchFactory.java
new file mode 100644
index 000000000..fb2b032a7
--- /dev/null
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/search/PHPSearchFactory.java
@@ -0,0 +1,27 @@
+package org.eclipse.php.internal.core.search;
+
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.dltk.core.ISearchFactory;
+import org.eclipse.dltk.core.search.*;
+import org.eclipse.dltk.core.search.indexing.SourceIndexerRequestor;
+import org.eclipse.dltk.core.search.matching.MatchLocator;
+
+public class PHPSearchFactory implements ISearchFactory {
+
+ public MatchLocator createMatchLocator(SearchPattern pattern, SearchRequestor requestor, IDLTKSearchScope scope, SubProgressMonitor monitor) {
+ return new MatchLocator(pattern, requestor, scope, monitor);
+ }
+
+ public IMatchLocatorParser createMatchParser(MatchLocator locator) {
+ return new PHPMatchLocatorParser(locator);
+ }
+
+ public DLTKSearchParticipant createSearchParticipant() {
+ return new DLTKSearchParticipant();
+ }
+
+ public SourceIndexerRequestor createSourceRequestor() {
+ return new SourceIndexerRequestor();
+ }
+
+}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/sourceModel/IConstant.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/sourceModel/IConstant.java
deleted file mode 100644
index df867b7d9..000000000
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/sourceModel/IConstant.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.eclipse.php.internal.core.sourceModel;
-
-import org.eclipse.dltk.core.IField;
-
-public interface IConstant extends IField {
-
-}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/sourceModel/IInterface.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/sourceModel/IInterface.java
deleted file mode 100644
index 3b988a67b..000000000
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/sourceModel/IInterface.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.eclipse.php.internal.core.sourceModel;
-
-import org.eclipse.dltk.core.IType;
-
-public interface IInterface extends IType {
-
-}

Back to the top