Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormspector2008-10-28 10:50:10 -0400
committermspector2008-10-28 10:50:10 -0400
commit2e343e1af6f7fc37de7446eabb74d1434abadf85 (patch)
tree92d621afb6f88d1b6186e069f0267cc57b4029eb
parent7ea0870e0a2eda62e25ca052c897d0cdd2368205 (diff)
downloadorg.eclipse.pdt-2e343e1af6f7fc37de7446eabb74d1434abadf85.tar.gz
org.eclipse.pdt-2e343e1af6f7fc37de7446eabb74d1434abadf85.tar.xz
org.eclipse.pdt-2e343e1af6f7fc37de7446eabb74d1434abadf85.zip
Fix performance issues
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/PHPCorePlugin.java21
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/ast/nodes/FunctionBinding.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/CodeAssistUtils.java12
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPCompletionEngine.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/filenetwork/FileNetworkUtility.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinBuildVisitor.java23
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinModel.java87
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java7
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPTypeInferenceUtils.java7
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/AbstractPHPGoalEvaluator.java11
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/ClassVariableDeclarationEvaluator.java4
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/ConstantDeclarationEvaluator.java14
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/GlobalVariableReferencesEvaluator.java6
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodElementReturnTypeEvaluator.java5
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodReturnTypeEvaluator.java13
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/StaticConstantAccessEvaluator.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocClassVariableEvaluator.java2
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocMethodReturnTypeEvaluator.java15
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/ConstantDeclarationGoal.java5
19 files changed, 159 insertions, 81 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/PHPCorePlugin.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/PHPCorePlugin.java
index b5b38ebff..b6bf8e90f 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/PHPCorePlugin.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/PHPCorePlugin.java
@@ -16,10 +16,7 @@ import java.util.Hashtable;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
-import org.eclipse.dltk.core.DLTKCore;
-import org.eclipse.dltk.core.IBuildpathEntry;
-import org.eclipse.dltk.core.IScriptProject;
-import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.core.*;
import org.eclipse.dltk.internal.core.ModelManager;
import org.eclipse.php.internal.core.includepath.IncludePathManager;
import org.eclipse.php.internal.core.phpModel.PHPModelUtil;
@@ -41,7 +38,7 @@ public class PHPCorePlugin extends Plugin {
//The shared instance.
private static PHPCorePlugin plugin;
-
+
/**
* The constructor.
*/
@@ -153,11 +150,24 @@ public class PHPCorePlugin extends Plugin {
}
scriptProject.setRawBuildpath(newPath.toArray(new IBuildpathEntry[newPath.size()]), new NullProgressMonitor());
}
+
+ private final ListenerList shutdownListeners = new ListenerList();
+
+ public void addShutdownListener(IShutdownListener listener) {
+ shutdownListeners.add(listener);
+ }
/**
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception {
+
+ Object[] listeners = shutdownListeners.getListeners();
+ for (int i = 0; i < listeners.length; ++i) {
+ ((IShutdownListener) listeners[i]).shutdown();
+ }
+ shutdownListeners.clear();
+
super.stop(context);
ResourcesPlugin.getWorkspace().removeResourceChangeListener(fProjectConvertListener);
plugin = null;
@@ -220,6 +230,7 @@ public class PHPCorePlugin extends Plugin {
* @see #getDefaultOptions()
* @see JavaCorePreferenceInitializer for changing default settings
*/
+ @SuppressWarnings("unchecked")
public static Hashtable getOptions() {
return ModelManager.getModelManager().getOptions();
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/ast/nodes/FunctionBinding.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/ast/nodes/FunctionBinding.java
index 9b5198b82..3444831ac 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/ast/nodes/FunctionBinding.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/ast/nodes/FunctionBinding.java
@@ -54,7 +54,7 @@ public class FunctionBinding implements IFunctionBinding {
*/
public ITypeBinding[] getExceptionTypes() {
// Get an array of PHPDocFields
- IModelElement[] methodDoc = PHPMixinModel.getInstance().getMethodDoc(modelElement.getDeclaringType().getElementName(), modelElement.getElementName());
+ IModelElement[] methodDoc = PHPMixinModel.getInstance(modelElement.getScriptProject()).getMethodDoc(modelElement.getDeclaringType().getElementName(), modelElement.getElementName());
ArrayList<ITypeBinding> exeptions = new ArrayList<ITypeBinding>();
for (IModelElement element : methodDoc) {
PHPDocField docField = (PHPDocField) element;
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/CodeAssistUtils.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/CodeAssistUtils.java
index f4236b6a0..d70b04e5d 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/CodeAssistUtils.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/CodeAssistUtils.java
@@ -490,10 +490,11 @@ public class CodeAssistUtils {
/**
* Checks whether function with given name exists.
* @param functionName
+ * @param scriptProject
* @return
*/
- public static boolean isFunctionCall(String functionName) {
- IModelElement[] functions = PHPMixinModel.getInstance().getFunction(functionName);
+ public static boolean isFunctionCall(String functionName, IScriptProject scriptProject) {
+ IModelElement[] functions = scriptProject == null ? PHPMixinModel.getWorkspaceInstance().getFunction(functionName) : PHPMixinModel.getInstance(scriptProject).getFunction(functionName);
return functions.length > 0;
}
@@ -894,12 +895,12 @@ public class CodeAssistUtils {
IDLTKLanguageToolkit toolkit = PHPLanguageToolkit.getDefault();
boolean isVariable = prefix.startsWith("$"); //$NON-NLS-1$
-
+
+ IScriptProject scriptProject = sourceModule.getScriptProject();
IDLTKSearchScope scope;
if (currentFileOnly) {
scope = SearchEngine.createSearchScope(sourceModule);
} else {
- IScriptProject scriptProject = sourceModule.getScriptProject();
if (scriptProject != null) {
scope = SearchEngine.createSearchScope(scriptProject);
} else {
@@ -909,7 +910,8 @@ public class CodeAssistUtils {
if (!currentFileOnly && isVariable) {
// search variables using mixin model:
- IModelElement[] variables = PHPMixinModel.getInstance().getVariable(prefix + WILDCARD, null, null, scope);
+ PHPMixinModel mixinModel = scriptProject == null ? PHPMixinModel.getWorkspaceInstance() : PHPMixinModel.getInstance(scriptProject);
+ IModelElement[] variables = mixinModel.getVariable(prefix + WILDCARD, null, null, scope);
return variables == null ? EMPTY : variables;
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPCompletionEngine.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPCompletionEngine.java
index beffe4a7a..810509234 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPCompletionEngine.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPCompletionEngine.java
@@ -398,7 +398,7 @@ public class PHPCompletionEngine extends ScriptCompletionEngine {
return;
}
- if (hasWhitespaceAtEnd && CodeAssistUtils.isFunctionCall(lastWord)) {
+ if (hasWhitespaceAtEnd && CodeAssistUtils.isFunctionCall(lastWord, sourceModule.getScriptProject())) {
// the current position is between the end of a function call and open bracket.
return;
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/filenetwork/FileNetworkUtility.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/filenetwork/FileNetworkUtility.java
index f737283de..465457eaf 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/filenetwork/FileNetworkUtility.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/filenetwork/FileNetworkUtility.java
@@ -94,7 +94,7 @@ public class FileNetworkUtility {
ISourceModule file = root.getFile();
// Find all includes to the current source module in mixin:
- IModelElement[] includes = PHPMixinModel.getInstance().getInclude(file.getPath().lastSegment());
+ IModelElement[] includes = PHPMixinModel.getWorkspaceInstance().getInclude(file.getPath().lastSegment());
for (IModelElement e : includes) {
IncludeField include = (IncludeField) e;
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 d7697dd5e..fcf9fe120 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
@@ -25,31 +25,13 @@ 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.dltk.internal.core.ModelElement;
import org.eclipse.php.internal.core.Logger;
-import org.eclipse.php.internal.core.compiler.ast.nodes.ASTNodeKinds;
-import org.eclipse.php.internal.core.compiler.ast.nodes.Assignment;
-import org.eclipse.php.internal.core.compiler.ast.nodes.CatchClause;
-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.ForEachStatement;
-import org.eclipse.php.internal.core.compiler.ast.nodes.FormalParameter;
-import org.eclipse.php.internal.core.compiler.ast.nodes.GlobalStatement;
-import org.eclipse.php.internal.core.compiler.ast.nodes.IPHPDocAwareDeclaration;
-import org.eclipse.php.internal.core.compiler.ast.nodes.Include;
-import org.eclipse.php.internal.core.compiler.ast.nodes.ListVariable;
-import org.eclipse.php.internal.core.compiler.ast.nodes.PHPDocBlock;
-import org.eclipse.php.internal.core.compiler.ast.nodes.PHPFieldDeclaration;
-import org.eclipse.php.internal.core.compiler.ast.nodes.Scalar;
+import org.eclipse.php.internal.core.compiler.ast.nodes.*;
import org.eclipse.php.internal.core.compiler.ast.parser.ASTUtils;
import org.eclipse.php.internal.core.typeinference.FakeField;
@@ -247,6 +229,7 @@ public class PHPMixinBuildVisitor extends ASTVisitor {
}
protected String report(String key, PHPMixinElementInfo object) {
+ PHPMixinModel.clearKeysCache(key);
ElementInfo info = new IMixinRequestor.ElementInfo();
info.key = key;
info.object = object;
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinModel.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinModel.java
index 2b5ac8890..9959d8163 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinModel.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/mixin/PHPMixinModel.java
@@ -10,36 +10,73 @@
*******************************************************************************/
package org.eclipse.php.internal.core.mixin;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.IShutdownListener;
import org.eclipse.dltk.core.mixin.IMixinElement;
import org.eclipse.dltk.core.mixin.MixinModel;
import org.eclipse.dltk.core.search.IDLTKSearchScope;
+import org.eclipse.php.internal.core.PHPCorePlugin;
import org.eclipse.php.internal.core.PHPLanguageToolkit;
-public class PHPMixinModel {
+public class PHPMixinModel implements IShutdownListener {
- private static PHPMixinModel instance = new PHPMixinModel();
+ private static final Map<IScriptProject, PHPMixinModel> instances = new HashMap<IScriptProject, PHPMixinModel>();
+ private static PHPMixinModel instance;
private final MixinModel model;
- private PHPMixinModel() {
- model = new MixinModel(PHPLanguageToolkit.getDefault());
- }
-
- public static PHPMixinModel getInstance() {
- return instance;
+ public static PHPMixinModel getWorkspaceInstance() {
+ synchronized (instances) {
+ if (instance == null)
+ instance = new PHPMixinModel(null);
+ return instance;
+ }
}
- public static MixinModel getRawInstance() {
- return getInstance().getRawModel();
+ public static PHPMixinModel getInstance(IScriptProject project) {
+ Assert.isNotNull(project);
+ synchronized (instances) {
+ PHPMixinModel mixinModel = (PHPMixinModel) instances.get(project);
+ if (mixinModel == null) {
+ mixinModel = new PHPMixinModel(project);
+ instances.put(project, mixinModel);
+ }
+ return mixinModel;
+ }
}
public MixinModel getRawModel() {
return model;
}
+ /**
+ * @param key
+ * @return
+ */
+ public static void clearKeysCache(String key) {
+ synchronized (instances) {
+ if (instance != null) {
+ instance.getRawModel().clearKeysCache(key);
+ }
+ for (Iterator<PHPMixinModel> i = instances.values().iterator(); i.hasNext();) {
+ PHPMixinModel mixinModel = i.next();
+ mixinModel.getRawModel().clearKeysCache(key);
+ }
+ }
+ }
+
+ private PHPMixinModel(IScriptProject project) {
+ model = new MixinModel(PHPLanguageToolkit.getDefault(), project);
+ PHPCorePlugin.getDefault().addShutdownListener(this);
+ }
+
+ public void shutdown() {
+ model.stop();
+ }
+
private IModelElement[] filterElements(IMixinElement[] elements, int kind, IDLTKSearchScope scope) {
List<IModelElement> filtered = new LinkedList<IModelElement>();
for (IMixinElement element : elements) {
@@ -62,10 +99,10 @@ public class PHPMixinModel {
public IModelElement[] getMethod(String className, String methodName) {
return getMethod(className, methodName, null);
}
-
+
public IModelElement[] getMethod(String className, String methodName, IDLTKSearchScope scope) {
if (className == null) {
- return getFunction(methodName);
+ return getFunction(methodName, scope);
}
IMixinElement[] elements = model.find(className + PHPMixinParser.CLASS_SUFFIX + MixinModel.SEPARATOR + methodName);
return filterElements(elements, PHPMixinElementInfo.K_METHOD, scope);
@@ -74,10 +111,10 @@ public class PHPMixinModel {
public IModelElement[] getMethodDoc(String className, String methodName) {
return getMethodDoc(className, methodName, null);
}
-
+
public IModelElement[] getMethodDoc(String className, String methodName, IDLTKSearchScope scope) {
if (className == null) {
- return getFunctionDoc(methodName);
+ return getFunctionDoc(methodName, scope);
}
IMixinElement[] elements = model.find(className + PHPMixinParser.CLASS_SUFFIX + MixinModel.SEPARATOR + methodName);
return filterElements(elements, PHPMixinElementInfo.K_PHPDOC, scope);
@@ -86,7 +123,7 @@ public class PHPMixinModel {
public IModelElement[] getFunction(String functionName) {
return getFunction(functionName, null);
}
-
+
public IModelElement[] getFunction(String functionName, IDLTKSearchScope scope) {
IMixinElement[] elements = model.find(MixinModel.SEPARATOR + functionName);
return filterElements(elements, PHPMixinElementInfo.K_METHOD, scope);
@@ -95,7 +132,7 @@ public class PHPMixinModel {
public IModelElement[] getFunctionDoc(String functionName) {
return getFunctionDoc(functionName, null);
}
-
+
public IModelElement[] getFunctionDoc(String functionName, IDLTKSearchScope scope) {
IMixinElement[] elements = model.find(MixinModel.SEPARATOR + functionName);
return filterElements(elements, PHPMixinElementInfo.K_PHPDOC, scope);
@@ -104,7 +141,7 @@ public class PHPMixinModel {
public IModelElement[] getClass(String className) {
return getClass(className, null);
}
-
+
public IModelElement[] getClass(String className, IDLTKSearchScope scope) {
IMixinElement[] elements = model.find(className + PHPMixinParser.CLASS_SUFFIX);
return filterElements(elements, PHPMixinElementInfo.K_CLASS | PHPMixinElementInfo.K_INTERFACE, scope);
@@ -113,7 +150,7 @@ public class PHPMixinModel {
public IModelElement[] getClassDoc(String className) {
return getClassDoc(className, null);
}
-
+
public IModelElement[] getClassDoc(String className, IDLTKSearchScope scope) {
IMixinElement[] elements = model.find(className + PHPMixinParser.CLASS_SUFFIX);
return filterElements(elements, PHPMixinElementInfo.K_PHPDOC, scope);
@@ -136,7 +173,7 @@ public class PHPMixinModel {
public IModelElement[] getVariable(String variableName, String methodName, String typeName) {
return getVariable(variableName, methodName, typeName, null);
}
-
+
public IModelElement[] getVariable(String variableName, String methodName, String typeName, IDLTKSearchScope scope) {
return filterElements(internalGetVariable(variableName, methodName, typeName), PHPMixinElementInfo.K_VARIABLE, scope);
}
@@ -144,7 +181,7 @@ public class PHPMixinModel {
public IModelElement[] getVariableDoc(String variableName, String methodName, String typeName) {
return getVariableDoc(variableName, methodName, typeName, null);
}
-
+
public IModelElement[] getVariableDoc(String variableName, String methodName, String typeName, IDLTKSearchScope scope) {
return filterElements(internalGetVariable(variableName, methodName, typeName), PHPMixinElementInfo.K_PHPDOC, scope);
}
@@ -160,7 +197,7 @@ public class PHPMixinModel {
public IModelElement[] getConstant(String constantName, String typeName) {
return getConstant(constantName, typeName, null);
}
-
+
public IModelElement[] getConstant(String constantName, String typeName, IDLTKSearchScope scope) {
return filterElements(internalGetConstant(constantName, typeName), PHPMixinElementInfo.K_CONSTANT, scope);
}
@@ -168,7 +205,7 @@ public class PHPMixinModel {
public IModelElement[] getConstantDoc(String constantName, String typeName) {
return getConstantDoc(constantName, typeName, null);
}
-
+
public IModelElement[] getConstantDoc(String constantName, String typeName, IDLTKSearchScope scope) {
return filterElements(internalGetConstant(constantName, typeName), PHPMixinElementInfo.K_PHPDOC_FOR_CONSTANT, scope);
}
@@ -176,7 +213,7 @@ public class PHPMixinModel {
public IModelElement[] getInclude(String fileName) {
return getInclude(fileName, null);
}
-
+
public IModelElement[] getInclude(String fileName, IDLTKSearchScope scope) {
IMixinElement[] elements = model.find(fileName + PHPMixinParser.INCLUDE_SUFFIX);
return filterElements(elements, PHPMixinElementInfo.K_INCLUDE, scope);
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java
index 477178f31..b4372f9be 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPModelUtils.java
@@ -48,7 +48,7 @@ public class PHPModelUtils {
String key = PHPMixinBuildVisitor.restoreKeyByNode(sourceModule, unit, node);
if (key != null) {
- IMixinElement[] elements = PHPMixinModel.getRawInstance().find(key);
+ IMixinElement[] elements = PHPMixinModel.getInstance(sourceModule.getScriptProject()).getRawModel().find(key);
if (elements.length > 0) {
Object[] allObjects = elements[0].getAllObjects();
for (Object obj : allObjects) {
@@ -101,14 +101,15 @@ public class PHPModelUtils {
throw new NullPointerException();
}
- IDLTKSearchScope scope = SearchEngine.createSuperHierarchyScope(type);
+ final IDLTKSearchScope scope = SearchEngine.createSuperHierarchyScope(type);
SearchPattern pattern = SearchPattern.createPattern(name, IDLTKSearchConstants.METHOD, IDLTKSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH, PHPLanguageToolkit.getDefault());
final List<PHPDocField> docs = new LinkedList<PHPDocField>();
new SearchEngine().search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, scope, new SearchRequestor() {
public void acceptSearchMatch(SearchMatch match) throws CoreException {
IMethod method = (IMethod) match.getElement();
- IModelElement[] methodDoc = PHPMixinModel.getInstance().getMethodDoc(method.getDeclaringType().getElementName(), method.getElementName());
+ IScriptProject scriptProject = method.getScriptProject();
+ IModelElement[] methodDoc = PHPMixinModel.getInstance(scriptProject).getMethodDoc(method.getDeclaringType().getElementName(), method.getElementName(), SearchEngine.createSearchScope(scriptProject));
for (IModelElement doc : methodDoc) {
docs.add((PHPDocField) doc);
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPTypeInferenceUtils.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPTypeInferenceUtils.java
index 3c8a982fd..9d08c890d 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPTypeInferenceUtils.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPTypeInferenceUtils.java
@@ -20,8 +20,11 @@ import java.util.Set;
import org.eclipse.dltk.ast.ASTNode;
import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.SourceParserUtil;
+import org.eclipse.dltk.core.search.IDLTKSearchScope;
+import org.eclipse.dltk.core.search.SearchEngine;
import org.eclipse.dltk.evaluation.types.AmbiguousType;
import org.eclipse.dltk.evaluation.types.ModelClassType;
import org.eclipse.dltk.evaluation.types.MultiTypeType;
@@ -110,7 +113,9 @@ public class PHPTypeInferenceUtils {
return new IModelElement[] { ((ModelClassType)type).getTypeDeclaration() };
}
if (type instanceof PHPClassType) {
- elements = PHPMixinModel.getInstance().getClass(((PHPClassType)type).getTypeName());
+ IScriptProject scriptProject = context.getSourceModule().getScriptProject();
+ IDLTKSearchScope scope = SearchEngine.createSearchScope(scriptProject);
+ elements = PHPMixinModel.getInstance(scriptProject).getClass(((PHPClassType)type).getTypeName(), scope);
}
else if (type instanceof AmbiguousType) {
List<IModelElement> tmpList = new LinkedList<IModelElement>();
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/AbstractPHPGoalEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/AbstractPHPGoalEvaluator.java
index 59f08185f..106cfb96b 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/AbstractPHPGoalEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/AbstractPHPGoalEvaluator.java
@@ -14,8 +14,11 @@ import java.util.HashSet;
import java.util.Set;
import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.IType;
+import org.eclipse.dltk.core.search.IDLTKSearchScope;
+import org.eclipse.dltk.core.search.SearchEngine;
import org.eclipse.dltk.evaluation.types.AmbiguousType;
import org.eclipse.dltk.ti.goals.GoalEvaluator;
import org.eclipse.dltk.ti.goals.IGoal;
@@ -41,16 +44,20 @@ public abstract class AbstractPHPGoalEvaluator extends GoalEvaluator {
if (instanceType instanceof PHPClassType) {
PHPClassType classType = (PHPClassType) instanceType;
- IModelElement[] elements = PHPMixinModel.getInstance().getClass(classType.getTypeName());
+ IScriptProject scriptProject = currentModule.getScriptProject();
+ IDLTKSearchScope scope = SearchEngine.createSearchScope(scriptProject);
+ IModelElement[] elements = PHPMixinModel.getInstance(scriptProject).getClass(classType.getTypeName(), scope);
for (IModelElement e : elements) {
types.add((IType) e);
}
} else if (instanceType instanceof AmbiguousType) {
AmbiguousType ambiguousType = (AmbiguousType) instanceType;
+ IScriptProject scriptProject = currentModule.getScriptProject();
+ IDLTKSearchScope scope = SearchEngine.createSearchScope(scriptProject);
for (IEvaluatedType type : ambiguousType.getPossibleTypes()) {
if (type instanceof PHPClassType) {
PHPClassType classType = (PHPClassType) type;
- IModelElement[] elements = PHPMixinModel.getInstance().getClass(classType.getTypeName());
+ IModelElement[] elements = PHPMixinModel.getInstance(scriptProject).getClass(classType.getTypeName(), scope);
for (IModelElement e : elements) {
types.add((IType) e);
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/ClassVariableDeclarationEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/ClassVariableDeclarationEvaluator.java
index 65de119ca..9b816957d 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/ClassVariableDeclarationEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/ClassVariableDeclarationEvaluator.java
@@ -152,7 +152,9 @@ public class ClassVariableDeclarationEvaluator extends AbstractPHPGoalEvaluator
*/
private void resolveMagicClassVariableDeclaration(IType[] types, String variableName) {
for (IType type : types) {
- final IModelElement[] elements = PHPMixinModel.getInstance().getClassDoc(type.getElementName());
+ IScriptProject scriptProject = type.getScriptProject();
+ IDLTKSearchScope scope = SearchEngine.createSearchScope(scriptProject);
+ final IModelElement[] elements = PHPMixinModel.getInstance(scriptProject).getClassDoc(type.getElementName(), scope);
for (IModelElement e : elements) {
final PHPDocBlock docBlock = ((PHPDocField) e).getDocBlock();
for (PHPDocTag tag : docBlock.getTags()) {
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/ConstantDeclarationEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/ConstantDeclarationEvaluator.java
index 213a356a8..4d1291c11 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/ConstantDeclarationEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/ConstantDeclarationEvaluator.java
@@ -19,7 +19,10 @@ import org.eclipse.dltk.ast.expressions.CallExpression;
import org.eclipse.dltk.ast.expressions.Expression;
import org.eclipse.dltk.ast.statements.Statement;
import org.eclipse.dltk.core.*;
+import org.eclipse.dltk.core.search.IDLTKSearchScope;
+import org.eclipse.dltk.core.search.SearchEngine;
import org.eclipse.dltk.ti.GoalState;
+import org.eclipse.dltk.ti.ISourceModuleContext;
import org.eclipse.dltk.ti.goals.ExpressionTypeGoal;
import org.eclipse.dltk.ti.goals.GoalEvaluator;
import org.eclipse.dltk.ti.goals.IGoal;
@@ -42,8 +45,17 @@ public class ConstantDeclarationEvaluator extends GoalEvaluator {
ConstantDeclarationGoal typedGoal = (ConstantDeclarationGoal) goal;
String constantName = typedGoal.getConstantName();
String typeName = typedGoal.getTypeName();
+
+ IDLTKSearchScope scope = null;
+ IScriptProject scriptProject = null;
+ ISourceModuleContext sourceModuleContext = (ISourceModuleContext) goal.getContext();
+ if (sourceModuleContext != null) {
+ scriptProject = sourceModuleContext.getSourceModule().getScriptProject();
+ scope = SearchEngine.createSearchScope(scriptProject);
+ }
- IModelElement[] elements = PHPMixinModel.getInstance().getConstant(constantName, typeName);
+ PHPMixinModel mixinModel = scriptProject == null ? PHPMixinModel.getWorkspaceInstance() : PHPMixinModel.getInstance(scriptProject);
+ IModelElement[] elements = mixinModel.getConstant(constantName, typeName, scope);
Map<ISourceModule, SortedSet<ISourceRange>> offsets = new HashMap<ISourceModule, SortedSet<ISourceRange>>();
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/GlobalVariableReferencesEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/GlobalVariableReferencesEvaluator.java
index f62150c4f..27604df4f 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/GlobalVariableReferencesEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/GlobalVariableReferencesEvaluator.java
@@ -23,6 +23,8 @@ import org.eclipse.dltk.ast.references.VariableReference;
import org.eclipse.dltk.ast.statements.Block;
import org.eclipse.dltk.ast.statements.Statement;
import org.eclipse.dltk.core.*;
+import org.eclipse.dltk.core.search.IDLTKSearchScope;
+import org.eclipse.dltk.core.search.SearchEngine;
import org.eclipse.dltk.evaluation.types.UnknownType;
import org.eclipse.dltk.internal.core.SourceField;
import org.eclipse.dltk.ti.*;
@@ -62,7 +64,9 @@ public class GlobalVariableReferencesEvaluator extends GoalEvaluator {
boolean exploreOtherFiles = true;
// Find all global variables from mixin
- IModelElement[] elements = PHPMixinModel.getInstance().getVariable(variableName, null, null);
+ IScriptProject scriptProject = sourceModuleContext.getSourceModule().getScriptProject();
+ IDLTKSearchScope scope = SearchEngine.createSearchScope(scriptProject);
+ IModelElement[] elements = PHPMixinModel.getInstance(scriptProject).getVariable(variableName, null, null, scope);
Map<ISourceModule, SortedSet<ISourceRange>> offsets = new HashMap<ISourceModule, SortedSet<ISourceRange>>();
Comparator<ISourceRange> sourceRangeComparator = new Comparator<ISourceRange>() {
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodElementReturnTypeEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodElementReturnTypeEvaluator.java
index 37f5d8a92..82cdf132a 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodElementReturnTypeEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodElementReturnTypeEvaluator.java
@@ -19,6 +19,8 @@ import org.eclipse.dltk.ast.declarations.MethodDeclaration;
import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
import org.eclipse.dltk.ast.expressions.Expression;
import org.eclipse.dltk.core.*;
+import org.eclipse.dltk.core.search.IDLTKSearchScope;
+import org.eclipse.dltk.core.search.SearchEngine;
import org.eclipse.dltk.ti.GoalState;
import org.eclipse.dltk.ti.IContext;
import org.eclipse.dltk.ti.goals.ExpressionTypeGoal;
@@ -114,7 +116,8 @@ public class MethodElementReturnTypeEvaluator extends AbstractPHPGoalEvaluator {
}
IType type = (IType) parent;
- final IModelElement[] elements = PHPMixinModel.getInstance().getClassDoc(type.getElementName());
+ IDLTKSearchScope scope = SearchEngine.createSearchScope(type);
+ final IModelElement[] elements = PHPMixinModel.getInstance(type.getScriptProject()).getClassDoc(type.getElementName(), scope);
for (IModelElement e : elements) {
final PHPDocBlock docBlock = ((PHPDocField) e).getDocBlock();
for (PHPDocTag tag : docBlock.getTags()) {
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodReturnTypeEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodReturnTypeEvaluator.java
index b30c2c901..ba5ae15c0 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodReturnTypeEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodReturnTypeEvaluator.java
@@ -13,10 +13,9 @@ package org.eclipse.php.internal.core.typeinference.evaluators;
import java.util.*;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.dltk.core.DLTKCore;
-import org.eclipse.dltk.core.IMethod;
-import org.eclipse.dltk.core.IModelElement;
-import org.eclipse.dltk.core.IType;
+import org.eclipse.dltk.core.*;
+import org.eclipse.dltk.core.search.IDLTKSearchScope;
+import org.eclipse.dltk.core.search.SearchEngine;
import org.eclipse.dltk.ti.GoalState;
import org.eclipse.dltk.ti.InstanceContext;
import org.eclipse.dltk.ti.goals.IGoal;
@@ -57,14 +56,16 @@ public class MethodReturnTypeEvaluator extends AbstractPHPGoalEvaluator {
IType[] types = getTypes(typedContext.getInstanceType(), typedContext.getSourceModule());
if (types.length == 0) {
- IModelElement[] elements = PHPMixinModel.getInstance().getFunction(methodName);
+ IScriptProject scriptProject = typedContext.getSourceModule().getScriptProject();
+ IDLTKSearchScope scope = SearchEngine.createSearchScope(scriptProject);
+ IModelElement[] elements = PHPMixinModel.getInstance(scriptProject).getFunction(methodName, scope);
for (IModelElement e : elements) {
methods.add((IMethod) e);
}
} else {
for (IType type : types) {
try {
- IModelElement[] elements = PHPMixinModel.getInstance().getMethod(type.getElementName(), methodName);
+ IModelElement[] elements = PHPMixinModel.getInstance(type.getScriptProject()).getMethod(type.getElementName(), methodName);
if (elements.length == 0) {
elements = PHPModelUtils.getClassMethod(type, methodName, null);
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/StaticConstantAccessEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/StaticConstantAccessEvaluator.java
index 223c128ef..7a4dc8268 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/StaticConstantAccessEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/StaticConstantAccessEvaluator.java
@@ -37,7 +37,7 @@ public class StaticConstantAccessEvaluator extends GoalEvaluator {
Expression dispatcher = expr.getDispatcher();
if (dispatcher instanceof TypeReference) {
TypeReference typeReference = (TypeReference) dispatcher;
- return new IGoal[] { new ConstantDeclarationGoal(expr.getConstant().getName(), typeReference.getName()) };
+ return new IGoal[] { new ConstantDeclarationGoal(goal.getContext(), expr.getConstant().getName(), typeReference.getName()) };
}
return IGoal.NO_GOALS;
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocClassVariableEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocClassVariableEvaluator.java
index 41a2b393c..4284ac18c 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocClassVariableEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocClassVariableEvaluator.java
@@ -52,7 +52,7 @@ public class PHPDocClassVariableEvaluator extends AbstractPHPGoalEvaluator {
Set<PHPDocField> docs = new HashSet<PHPDocField>();
for (IType type : types) {
- IModelElement[] elements = PHPMixinModel.getInstance().getVariableDoc(variableName, null, type.getElementName());
+ IModelElement[] elements = PHPMixinModel.getInstance(type.getScriptProject()).getVariableDoc(variableName, null, type.getElementName());
for (IModelElement e : elements) {
docs.add((PHPDocField) e);
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocMethodReturnTypeEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocMethodReturnTypeEvaluator.java
index dffd82167..e84131c1c 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocMethodReturnTypeEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/phpdoc/PHPDocMethodReturnTypeEvaluator.java
@@ -20,7 +20,10 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.dltk.ast.references.SimpleReference;
import org.eclipse.dltk.core.DLTKCore;
import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.IType;
+import org.eclipse.dltk.core.search.IDLTKSearchScope;
+import org.eclipse.dltk.core.search.SearchEngine;
import org.eclipse.dltk.evaluation.types.AmbiguousType;
import org.eclipse.dltk.ti.GoalState;
import org.eclipse.dltk.ti.IContext;
@@ -75,18 +78,22 @@ public class PHPDocMethodReturnTypeEvaluator extends GoalEvaluator {
List<IType> types = new LinkedList<IType>();
if (instanceType instanceof AmbiguousType) {
AmbiguousType ambiguousType = (AmbiguousType) instanceType;
+ IScriptProject scriptProject = typedGontext.getSourceModule().getScriptProject();
+ IDLTKSearchScope scope = SearchEngine.createSearchScope(scriptProject);
for (IEvaluatedType type : ambiguousType.getPossibleTypes()) {
if (type instanceof PHPClassType) {
PHPClassType classType = (PHPClassType) type;
- IModelElement[] classes = PHPMixinModel.getInstance().getClass(classType.getTypeName());
+ IModelElement[] classes = PHPMixinModel.getInstance(scriptProject).getClass(classType.getTypeName(), scope);
for (IModelElement c : classes) {
types.add((IType) c);
}
}
}
} else {
+ IScriptProject scriptProject = typedGontext.getSourceModule().getScriptProject();
+ IDLTKSearchScope scope = SearchEngine.createSearchScope(scriptProject);
PHPClassType classType = (PHPClassType) instanceType;
- IModelElement[] classes = PHPMixinModel.getInstance().getClass(classType.getTypeName());
+ IModelElement[] classes = PHPMixinModel.getInstance(scriptProject).getClass(classType.getTypeName(), scope);
for (IModelElement c : classes) {
types.add((IType) c);
}
@@ -104,7 +111,9 @@ public class PHPDocMethodReturnTypeEvaluator extends GoalEvaluator {
}
}
} else {
- IModelElement[] elements = PHPMixinModel.getInstance().getFunctionDoc(methodName);
+ IScriptProject scriptProject = typedGontext.getSourceModule().getScriptProject();
+ IDLTKSearchScope scope = SearchEngine.createSearchScope(scriptProject);
+ IModelElement[] elements = PHPMixinModel.getInstance(scriptProject).getFunctionDoc(methodName, scope);
for (IModelElement e : elements) {
docs.add((PHPDocField) e);
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/ConstantDeclarationGoal.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/ConstantDeclarationGoal.java
index 6a080f776..fd9fbfd84 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/ConstantDeclarationGoal.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/ConstantDeclarationGoal.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.php.internal.core.typeinference.goals;
+import org.eclipse.dltk.ti.IContext;
import org.eclipse.dltk.ti.goals.AbstractGoal;
public class ConstantDeclarationGoal extends AbstractGoal {
@@ -17,8 +18,8 @@ public class ConstantDeclarationGoal extends AbstractGoal {
private String constantName;
private String typeName;
- public ConstantDeclarationGoal(String constantName, String typeName) {
- super(null);
+ public ConstantDeclarationGoal(IContext context, String constantName, String typeName) {
+ super(context);
this.constantName = constantName;
this.typeName = typeName;
}

Back to the top