String className = typeReference.getName();
if (isSelfOrStatic()) {
if (context instanceof MethodContext) {
MethodContext methodContext = (MethodContext) context;
IEvaluatedType instanceType = methodContext.getInstanceType();
if (instanceType instanceof PHPClassType) {
result = instanceType;
}
}
} else if (isParent()) { //$NON-NLS-1$
if (context instanceof MethodContext) {
final MethodContext methodContext = (MethodContext) context;
ModuleDeclaration rootNode = methodContext.getRootNode();
ISourceModule sourceModule = ((ISourceModuleContext) context)
.getSourceModule();
final IType currentNamespace = PHPModelUtils
.getCurrentNamespace(sourceModule,
rootNode.sourceStart());
final ModuleDeclaration moduleDeclaration = SourceParserUtil
.getModuleDeclaration(sourceModule);
final MethodDeclaration methodDecl = methodContext
.getMethodNode();
// Look for parent class types:
final List<IEvaluatedType> types = new LinkedList<IEvaluatedType>();
try {
rootNode.traverse(new ASTVisitor() {
private TypeDeclaration currentType;
private boolean found;
public boolean visit(MethodDeclaration s)
throws Exception {
if (s == methodDecl
&& currentType instanceof ClassDeclaration) {
ClassDeclaration classDecl = (ClassDeclaration) currentType;
ASTListNode superClasses = classDecl
.getSuperClasses();
List childs = superClasses.getChilds();
for (Iterator iterator = childs.iterator(); iterator
.hasNext();) {
ASTNode node = (ASTNode) iterator.next();
NamespaceReference namespace = null;
SimpleReference reference = null;
if (node instanceof SimpleReference) {
reference = (SimpleReference) node;
String typeName = reference.getName();
if (reference instanceof FullyQualifiedReference) {
FullyQualifiedReference ref = (FullyQualifiedReference) node;
namespace = ref.getNamespace();
}
if (namespace != null
&& !namespace.getName().equals(
"")) { //$NON-NLS-1$
String nsName = namespace.getName();
if (nsName.equals("\\")) { //$NON-NLS-1$
typeName = nsName + typeName;
} else {
if (nsName
.startsWith("namespace\\")) { //$NON-NLS-1$
nsName = nsName.replace(
"namespace\\", ""); //$NON-NLS-1$ //$NON-NLS-2$
}
typeName = nsName
+ NamespaceReference.NAMESPACE_SEPARATOR
+ typeName;
}
}
if (typeName
.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) > 0) {
// check if the first part
// is an
// alias,then get the full
// name
String prefix = typeName.substring(
0,
typeName.indexOf(NamespaceReference.NAMESPACE_SEPARATOR));
final Map<String, UsePart> result = PHPModelUtils
.getAliasToNSMap(
prefix,
moduleDeclaration,
reference
.sourceStart(),
currentNamespace,
true);
if (result.containsKey(prefix)) {
String fullName = result
.get(prefix)
.getNamespace()
.getFullyQualifiedName();
typeName = typeName.replace(
prefix, fullName);
}
} else if (typeName
.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) < 0) {
String prefix = typeName;
final Map<String, UsePart> result = PHPModelUtils
.getAliasToNSMap(
prefix,
moduleDeclaration,
reference
.sourceStart(),
currentNamespace,
true);
if (result.containsKey(prefix)) {
String fullName = result
.get(prefix)
.getNamespace()
.getFullyQualifiedName();
typeName = fullName;
}
}
IEvaluatedType type = PHPSimpleTypes
.fromString(typeName);
if (type == null) {
if (typeName
.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) != -1
|| currentNamespace == null) {