aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2013-01-17 00:44:02 (EST)
committerzzhongwei2013-01-17 00:44:02 (EST)
commitadf3b88b08c56614cd22924e8b0d948280420d61 (patch)
tree29713c6146c231ea6ebfca33e7c85e5cfef0af22
parentd6637a870803aad527386afc0aa3747c6cf97d56 (diff)
downloadorg.eclipse.pdt-adf3b88b08c56614cd22924e8b0d948280420d61.zip
org.eclipse.pdt-adf3b88b08c56614cd22924e8b0d948280420d61.tar.gz
org.eclipse.pdt-adf3b88b08c56614cd22924e8b0d948280420d61.tar.bz2
398352: ctrl+click does not work for static class field
https://bugs.eclipse.org/bugs/show_bug.cgi?id=398352
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPSelectionEngine.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPSelectionEngine.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPSelectionEngine.java
index 15a1f24..46ad979 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPSelectionEngine.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/PHPSelectionEngine.java
@@ -529,12 +529,75 @@ public class PHPSelectionEngine extends ScriptSelectionEngine {
ClassInstanceCreation newNode = (ClassInstanceCreation) node;
Expression className = newNode.getClassName();
+
if ((className instanceof SimpleReference || className instanceof FullyQualifiedReference)) {
IEvaluatedType evaluatedType = PHPTypeInferenceUtils
.resolveExpression(sourceModule, node);
return getConstructorsIfAny(extractClasses(PHPModelUtils
.getTypes(evaluatedType.getTypeName(),
sourceModule, offset, null, null)));
+ } else if ((className instanceof StaticFieldAccess)) {
+ StaticFieldAccess staticFieldAccess = (StaticFieldAccess) className;
+ if ((offset >= staticFieldAccess.getDispatcher()
+ .sourceStart())
+ && (offset <= staticFieldAccess.getDispatcher()
+ .sourceEnd())) {
+ className = staticFieldAccess.getDispatcher();
+ IEvaluatedType evaluatedType = PHPTypeInferenceUtils
+ .resolveExpression(sourceModule, className);
+ return extractClasses(PHPModelUtils.getTypes(
+ evaluatedType.getTypeName(), sourceModule,
+ offset, null, null));
+ } else if ((offset >= staticFieldAccess.getField()
+ .sourceStart())
+ && (offset <= staticFieldAccess.getField()
+ .sourceEnd())) {
+ className = staticFieldAccess.getField();
+
+ String fieldName = null;
+ ASTNode field = staticFieldAccess.getField();
+ if (field instanceof VariableReference) {
+ fieldName = ((VariableReference) field)
+ .getName();
+ }
+ if (fieldName != null
+ && staticFieldAccess.getDispatcher() != null) {
+ IEvaluatedType dispatcherType = PHPTypeInferenceUtils
+ .resolveExpression(sourceModule,
+ parsedUnit, context,
+ staticFieldAccess
+ .getDispatcher());
+ if (dispatcherType != null) {
+ IModelElement[] elements = PHPTypeInferenceUtils
+ .getModelElements(
+ dispatcherType,
+ (ISourceModuleContext) context,
+ offset);
+ List<IModelElement> fields = new LinkedList<IModelElement>();
+ if (elements != null) {
+ for (IModelElement element : elements) {
+ if (element instanceof IType) {
+ IType type = (IType) element;
+ try {
+ fields.addAll(Arrays
+ .asList(PHPModelUtils
+ .getTypeField(
+ type,
+ fieldName,
+ true)));
+ } catch (ModelException e) {
+ PHPCorePlugin.log(e);
+ }
+ }
+ }
+ }
+ return fields
+ .toArray(new IModelElement[fields
+ .size()]);
+ }
+ }
+ }
+
}
}
// Class name in declaration