Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormspector2009-02-19 13:01:18 +0000
committermspector2009-02-19 13:01:18 +0000
commitabf4064173f7c81044bdf52ac0948cd36fab1fdc (patch)
treeaf6e77b79a1005a480be9289832a6548a5735110
parentd44fb4c209c791bb85297354d296ef4f459f58fb (diff)
downloadorg.eclipse.pdt-20090219-0930.tar.gz
org.eclipse.pdt-20090219-0930.tar.xz
org.eclipse.pdt-20090219-0930.zip
fixed some unit testsv20090219-0930
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/codeassist/CodeAssistUtils.java28
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPClassType.java14
2 files changed, 27 insertions, 15 deletions
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 1d38f8595..7f9efca32 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
@@ -642,21 +642,23 @@ public class CodeAssistUtils {
int functionNameStart = PHPTextSequenceUtilities.readIdentifierStartIndex(phpVersion, statementText, functionNameEnd, false);
String functionName = statementText.subSequence(functionNameStart, functionNameEnd).toString();
- IType classData = PHPModelUtils.getCurrentType(sourceModule, offset);
- if (classData != null) { //if its a clss function
- return getFunctionReturnType(classData, functionName, offset);
- }
-
- // if its a non class function
- Set<IType> returnTypes = new LinkedHashSet<IType>();
- IModelElement[] functions = getGlobalMethods(sourceModule, functionName, EXACT_NAME);
- for (IModelElement function : functions) {
- IType[] types = getFunctionReturnType((IMethod) function, offset);
- if (types != null) {
- returnTypes.addAll(Arrays.asList(types));
+ try {
+ IMethod[] functions = PHPTypeInferenceUtils.getMethods(functionName, sourceModule, offset);
+ // if its a non class function
+ Set<IType> returnTypes = new LinkedHashSet<IType>();
+ for (IModelElement function : functions) {
+ IType[] types = getFunctionReturnType((IMethod) function, offset);
+ if (types != null) {
+ returnTypes.addAll(Arrays.asList(types));
+ }
+ }
+ return returnTypes.toArray(new IType[returnTypes.size()]);
+ } catch (ModelException e) {
+ if (DLTKCore.DEBUG_COMPLETION) {
+ e.printStackTrace();
}
}
- return returnTypes.toArray(new IType[returnTypes.size()]);
+
}
return EMPTY_TYPES;
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPClassType.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPClassType.java
index de1ec2477..ee4b4bcc3 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPClassType.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/PHPClassType.java
@@ -35,9 +35,15 @@ public class PHPClassType extends ClassType implements IClassType {
// detect the namespace prefix:
int i = typeName.lastIndexOf(NamespaceReference.NAMESPACE_SEPARATOR);
if (i != -1) {
+ if (typeName.charAt(0) != NamespaceReference.NAMESPACE_SEPARATOR) {
+ // make the type name fully qualified:
+ typeName = new StringBuilder().append(NamespaceReference.NAMESPACE_SEPARATOR).append(typeName).toString();
+ i += 1;
+ }
this.namespace = typeName.substring(0, i);
+ } else {
+ this.typeName = typeName;
}
- this.typeName = typeName;
}
/**
@@ -48,8 +54,12 @@ public class PHPClassType extends ClassType implements IClassType {
throw new IllegalArgumentException();
}
- this.namespace = namespace;
+ // make the namespace fully qualified
+ if (namespace.charAt(0) != NamespaceReference.NAMESPACE_SEPARATOR) {
+ namespace = NamespaceReference.NAMESPACE_SEPARATOR + namespace;
+ }
+ this.namespace = namespace;
this.typeName = new StringBuilder(namespace)
.append(NamespaceReference.NAMESPACE_SEPARATOR).append(typeName).toString();
}

Back to the top