.fromString(typeName);
if (type == null) {
if (typeName
.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) != -1
|| currentNamespace == null) {
type = new PHPClassType(
typeName);
} else {
type = new PHPClassType(
currentNamespace
.getElementName(),
typeName);
}
}
types.add(type);
}
// if (namespace == null
// || namespace.getName().equals("")) {
// types.add(new PHPClassType(reference
// .getName()));
// } else {
// types.add(new
// PHPClassType(namespace.getName(),
// reference.getName()));
// }
}
found = true;
}
return !found;
}
public boolean visit(TypeDeclaration s)
throws Exception {
this.currentType = s;
return !found;
}
public boolean endvisit(TypeDeclaration s)
throws Exception {
this.currentType = null;
return super.endvisit(s);
}
public boolean visit(ASTNode n) throws Exception {
return !found;
}
});
} catch (Exception e) {
if (DLTKCore.DEBUG) {
e.printStackTrace();
}
}
if (types.size() == 1) {
result = types.get(0);
} else if (types.size() > 1) {
result = new AmbiguousType(
types.toArray(new IEvaluatedType[types.size()]));
}
}
} else {
String parentNamespace = null;
// Check current context - if we are under some namespace:
if (context instanceof INamespaceContext) {
parentNamespace = ((INamespaceContext) context).getNamespace();
}
String fullyQualifiedName;
// If the namespace was prefixed explicitly - use it:
if (typeReference instanceof FullyQualifiedReference) {
fullyQualifiedName = ((FullyQualifiedReference) typeReference)
.getFullyQualifiedName();
} else {
fullyQualifiedName = typeReference.getName();
className = PHPModelUtils
.extractElementName(fullyQualifiedName);
}
ISourceModule sourceModule = ((ISourceModuleContext) context)
.getSourceModule();
int offset = typeReference.sourceStart();
String extractedNamespace = PHPModelUtils.extractNamespaceName(
fullyQualifiedName, sourceModule, offset);
if (extractedNamespace != null) {
parentNamespace = extractedNamespace;
className = PHPModelUtils.getRealName(fullyQualifiedName,
sourceModule, offset, className);
}
if (PHPModelUtils.isInUseTraitStatement(
((ISourceModuleContext) context).getRootNode(),
typeReference.sourceStart())) {
if (parentNamespace != null) {
result = new PHPTraitType(parentNamespace, className);
} else {
result = new PHPTraitType(className);
}
} else {
if (parentNamespace != null) {
result = new PHPClassType(parentNamespace, className);
} else {
result = new PHPClassType(className);
}
}
}
return IGoal.NO_GOALS;