public boolean endvisit(AnonymousClassDeclaration anonymousClassDeclaration) throws Exception { this.fInClass = false; if (!fNodes.isEmpty() && fNodes.peek() == anonymousClassDeclaration) { fRequestor.exitType(anonymousClassDeclaration.sourceEnd() - 1); fInfoStack.pop(); fNodes.pop(); } declarations.pop(); for (PHPSourceElementRequestorExtension visitor : extensions) { visitor.endvisit(anonymousClassDeclaration); } return true; }
public boolean visit(AnonymousClassDeclaration anonymousClassDeclaration) throws Exception { ASTNode parentDeclaration = null; if (!declarations.empty()) { parentDeclaration = declarations.peek(); } if (parentDeclaration instanceof TypeDeclaration) { return false; } fNodes.push(anonymousClassDeclaration); declarations.push(anonymousClassDeclaration); for (PHPSourceElementRequestorExtension visitor : extensions) { visitor.visit(anonymousClassDeclaration); } List<String> superClasses = new ArrayList<String>(); String name = null; if (anonymousClassDeclaration.getSuperClass() != null) { name = String.format( ANONYMOUS_CLASS_TEMPLATE, anonymousClassDeclaration.getSuperClass().getName()); String superClass = processNameNode(anonymousClassDeclaration.getSuperClass()); if (superClass != null) { superClasses.add(superClass); } } if (anonymousClassDeclaration.getInterfaceList() != null && !anonymousClassDeclaration.getInterfaceList().isEmpty()) { if (name == null) { name = String.format( ANONYMOUS_CLASS_TEMPLATE, anonymousClassDeclaration.getInterfaceList().get(0).getName()); } for (TypeReference reference : anonymousClassDeclaration.getInterfaceList()) { String interfaceName = processNameNode(reference); if (interfaceName != null) { superClasses.add(interfaceName); } } } if (name == null) { name = String.format(ANONYMOUS_CLASS_TEMPLATE, PHPCoreConstants.ANONYMOUS); } ISourceElementRequestor.TypeInfo mi = new ISourceElementRequestor.TypeInfo(); mi.name = name; mi.modifiers = Modifiers.AccPrivate | IPHPModifiers.AccAnonymous; if (fLastInstanceCreation != null) { Expression className = fLastInstanceCreation.getClassName(); mi.nameSourceStart = className.sourceStart(); mi.nameSourceEnd = className.sourceEnd() - 1; } mi.declarationStart = mi.nameSourceStart; mi.superclasses = superClasses.toArray(new String[0]); fInfoStack.push(mi); this.fRequestor.enterType(mi); this.fInClass = true; return true; }