@Override
  protected String[] processSuperClasses(TypeDeclaration type) {
    final ASTListNode superClasses = type.getSuperClasses();
    if (superClasses == null) {
      return new String[] {};
    }
    final List superClassNames = superClasses.getChilds();
    final List<String> result = new ArrayList<String>(superClassNames.size());
    final Iterator iterator = superClassNames.iterator();
    while (iterator.hasNext()) {
      final Object nameNode = iterator.next();

      String name;
      if (nameNode instanceof FullyQualifiedReference) {
        final FullyQualifiedReference fullyQualifiedName = (FullyQualifiedReference) nameNode;
        name = fullyQualifiedName.getFullyQualifiedName();
        if (fullyQualifiedName.getNamespace() != null) {
          final String namespace = fullyQualifiedName.getNamespace().getName();
          if (name.charAt(0) == NamespaceReference.NAMESPACE_SEPARATOR) {
            name = name.substring(1);
          } else if (fLastUseParts.containsKey(namespace)) {
            name =
                new StringBuilder(
                        fLastUseParts.get(namespace).getNamespace().getFullyQualifiedName())
                    .append(NamespaceReference.NAMESPACE_SEPARATOR)
                    .append(fullyQualifiedName.getName())
                    .toString();
          } else if (fLastNamespace != null) {
            name =
                new StringBuilder(fLastNamespace.getName())
                    .append(NamespaceReference.NAMESPACE_SEPARATOR)
                    .append(name)
                    .toString();
          }
        } else if (fLastUseParts.containsKey(name)) {
          name = fLastUseParts.get(name).getNamespace().getFullyQualifiedName();
          if (name.charAt(0) == NamespaceReference.NAMESPACE_SEPARATOR) {
            name = name.substring(1);
          }
        } else {
          if (fLastNamespace != null) {
            name =
                new StringBuilder(fLastNamespace.getName())
                    .append(NamespaceReference.NAMESPACE_SEPARATOR)
                    .append(name)
                    .toString();
          }
        }
        result.add(name);
      } else if (nameNode instanceof SimpleReference) {
        result.add(((SimpleReference) nameNode).getName());
      }
    }
    return result.toArray(new String[result.size()]);
  }
 public boolean visit(UseStatement declaration) throws Exception {
   final Collection<UsePart> parts = declaration.getParts();
   for (final UsePart part : parts) {
     String name = null;
     if (part.getAlias() != null) {
       name = part.getAlias().getName();
     } else {
       name = part.getNamespace().getName();
       final int index = name.lastIndexOf(NamespaceReference.NAMESPACE_SEPARATOR);
       if (index >= 0) {
         name = name.substring(index + 1);
       }
     }
     final ImportInfo info = new ImportInfo();
     String containerName;
     if (fLastNamespace == null) {
       containerName = GLOBAL_NAMESPACE_CONTAINER_NAME;
     } else {
       containerName = fLastNamespace.getName();
     }
     info.containerName = containerName;
     info.name = part.getNamespace().getFullyQualifiedName();
     info.sourceStart = part.getNamespace().sourceStart();
     info.sourceEnd = part.getNamespace().sourceEnd();
     fRequestor.acceptImport(info);
     fLastUseParts.put(name, part);
   }
   return true;
 }
  @Override
  public boolean endvisit(TypeDeclaration type) throws Exception {
    if (type instanceof NamespaceDeclaration) {
      final NamespaceDeclaration namespaceDecl = (NamespaceDeclaration) type;
      fLastNamespace = null; // there are no nested namespaces
      if (namespaceDecl.isGlobal()) {
        return true;
      }
    }

    declarations.pop();

    // resolve more type member declarations
    resolveMagicMembers(type);

    for (final PHPSourceElementRequestorExtension visitor : extensions) {
      visitor.endvisit(type);
    }

    return super.endvisit(type);
  }
  @Override
  public boolean visit(TypeDeclaration type) throws Exception {
    if (type instanceof NamespaceDeclaration) {
      final NamespaceDeclaration namespaceDecl = (NamespaceDeclaration) type;
      fLastNamespace = namespaceDecl;
      fLastUseParts.clear();
      if (namespaceDecl.isGlobal()) {
        return true;
      }
    }

    // In case we are entering a nested element
    if (!declarations.empty() && declarations.peek() instanceof MethodDeclaration) {
      deferredDeclarations.add(type);
      return false;
    }

    declarations.push(type);

    for (final PHPSourceElementRequestorExtension visitor : extensions) {
      visitor.visit(type);
    }
    return super.visit(type);
  }