public boolean visit(TypeDeclaration type) throws Exception { if (type instanceof NamespaceDeclaration) { NamespaceDeclaration namespaceDecl = (NamespaceDeclaration) type; fLastNamespace = namespaceDecl; fLastUseParts.clear(); if (namespaceDecl.isGlobal()) { return true; } } type.setModifiers(markAsDeprecated(type.getModifiers(), type)); // In case we are entering a nested element if (!declarations.empty() && declarations.peek() instanceof MethodDeclaration) { if (fLastNamespace == null) { deferredDeclarations.add(type); } else { deferredNamespacedDeclarations.add(type); } return false; } declarations.push(type); for (PHPSourceElementRequestorExtension visitor : extensions) { visitor.visit(type); } return super.visit(type); }
public boolean visit(CallExpression call) throws Exception { FieldDeclaration constantDecl = ASTUtils.getConstantDeclaration(call); if (constantDecl != null) { // In case we are entering a nested element if (!declarations.empty() && declarations.peek() instanceof MethodDeclaration) { deferredDeclarations.add(constantDecl); return visitGeneral(call); } visit((FieldDeclaration) constantDecl); } else { int argsCount = 0; CallArgumentsList args = call.getArgs(); if (args != null && args.getChilds() != null) { argsCount = args.getChilds().size(); } modifyReference( call, new ReferenceInfo( IModelElement.METHOD, call.sourceStart(), call.sourceEnd() - call.sourceStart(), call.getName(), Integer.toString(argsCount), null)); } return visitGeneral(call); }
public boolean visit(Assignment assignment) throws Exception { Expression left = assignment.getVariable(); if (left instanceof FieldAccess) { // class variable ($this->a = .) FieldAccess fieldAccess = (FieldAccess) left; Expression dispatcher = fieldAccess.getDispatcher(); if (dispatcher instanceof VariableReference && "$this".equals(((VariableReference) dispatcher).getName())) { // $NON-NLS-1$ Expression field = fieldAccess.getField(); if (field instanceof SimpleReference) { SimpleReference var = (SimpleReference) field; int modifiers = Modifiers.AccPublic; int offset = var.sourceStart(); int length = var.sourceEnd() - offset; StringBuilder metadata = new StringBuilder(); if (fCurrentQualifier != null) { metadata.append(fCurrentQualifierCounts.get(fCurrentQualifier)); metadata.append(";"); // $NON-NLS-1$ } modifyDeclaration( assignment, new DeclarationInfo( IModelElement.FIELD, modifiers, offset, length, offset, length, '$' + var.getName(), metadata.length() == 0 ? null : metadata.toString(), null, fCurrentQualifier, fCurrentParent)); } } } else if (left instanceof VariableReference) { int modifiers = Modifiers.AccPublic | Modifiers.AccGlobal; if (!declarations.empty() && declarations.peek() instanceof MethodDeclaration && !methodGlobalVars.peek().contains(((VariableReference) left).getName())) { return visitGeneral(assignment); } int offset = left.sourceStart(); int length = left.sourceEnd() - offset; modifyDeclaration( assignment, new DeclarationInfo( IModelElement.FIELD, modifiers, offset, length, offset, length, ((VariableReference) left).getName(), null, null, null, null)); } return visitGeneral(assignment); }
protected void modifyMethodInfo( MethodDeclaration methodDeclaration, ISourceElementRequestor.MethodInfo mi) { ASTNode parentDeclaration = null; // find declaration that was before this method: declarations.pop(); if (!declarations.empty()) { parentDeclaration = declarations.peek(); } declarations.push(methodDeclaration); mi.isConstructor = mi.name.equalsIgnoreCase(CONSTRUCTOR_NAME) || (parentDeclaration instanceof ClassDeclaration && mi.name.equalsIgnoreCase(((ClassDeclaration) parentDeclaration).getName())); if (fCurrentClass == null || fCurrentClass == fLastNamespace) { mi.modifiers |= Modifiers.AccGlobal; } if (!Flags.isPrivate(mi.modifiers) && !Flags.isProtected(mi.modifiers) && !Flags.isPublic(mi.modifiers)) { mi.modifiers |= Modifiers.AccPublic; } mi.parameterTypes = processParameterTypes(methodDeclaration); mi.returnType = processReturnType(methodDeclaration); // modify method info if needed by extensions for (PHPSourceElementRequestorExtension extension : extensions) { extension.modifyMethodInfo(methodDeclaration, mi); } }
public boolean visit(CallExpression call) throws Exception { FieldDeclaration constantDecl = ASTUtils.getConstantDeclaration(call); if (constantDecl != null) { // In case we are entering a nested element if (!declarations.empty() && declarations.peek() instanceof MethodDeclaration) { deferredDeclarations.add(constantDecl); return false; } visit((FieldDeclaration) constantDecl); } else { int argsCount = 0; CallArgumentsList args = call.getArgs(); if (args != null && args.getChilds() != null) { argsCount = args.getChilds().size(); } fRequestor.acceptMethodReference( call.getName(), argsCount, call.getCallName().sourceStart(), call.getCallName().sourceEnd()); } return true; }
public boolean visit(Assignment assignment) throws Exception { Expression left = assignment.getVariable(); if (left instanceof FieldAccess) { // class variable ($this->a = .) FieldAccess fieldAccess = (FieldAccess) left; Expression dispatcher = fieldAccess.getDispatcher(); if (dispatcher instanceof VariableReference && "$this" //$NON-NLS-1$ .equals(((VariableReference) dispatcher).getName())) { Expression field = fieldAccess.getField(); if (field instanceof SimpleReference) { SimpleReference ref = (SimpleReference) field; ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo(); info.modifiers = Modifiers.AccPublic; info.name = '$' + ref.getName(); info.nameSourceEnd = ref.sourceEnd() - 1; info.nameSourceStart = ref.sourceStart(); info.declarationStart = assignment.sourceStart(); fInfoStack.push(info); fRequestor.enterField(info); fNodes.push(assignment); } } } else if (left instanceof VariableReference && !(left instanceof ArrayVariableReference)) { if (!declarations.empty()) { ASTNode parentDeclaration = declarations.peek(); if (parentDeclaration instanceof MethodDeclaration && methodGlobalVars.peek().contains(((VariableReference) left).getName()) || parentDeclaration == fLastNamespace) { deferredDeclarations.add(assignment); return false; } } if (!fInfoStack.isEmpty() && fInfoStack.peek() instanceof ISourceElementRequestor.FieldInfo) { if (!fDeferredVariables.containsKey(fInfoStack.peek())) { fDeferredVariables.put(fInfoStack.peek(), new LinkedList<Assignment>()); } fDeferredVariables.get(fInfoStack.peek()).add(assignment); return false; } ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo(); info.modifiers = Modifiers.AccPublic; info.name = ((VariableReference) left).getName(); info.nameSourceEnd = left.sourceEnd() - 1; info.nameSourceStart = left.sourceStart(); info.declarationStart = assignment.sourceStart(); fInfoStack.push(info); if (assignment.getOperatorType() == Assignment.OP_EQUAL) { fRequestor.enterField(info); } else { ISourceElementRequestor sourceElementRequestor = (ISourceElementRequestor) fRequestor; sourceElementRequestor.enterFieldCheckDuplicates(info); } fNodes.push(assignment); } return true; }
public boolean visit(GlobalStatement s) throws Exception { if (!declarations.empty() && declarations.peek() instanceof MethodDeclaration) { for (Expression var : s.getVariables()) { if (var instanceof ReferenceExpression) { var = ((ReferenceExpression) var).getVariable(); } if (var instanceof SimpleReference) { methodGlobalVars.peek().add(((SimpleReference) var).getName()); } } } return visitGeneral(s); }
public boolean visit(MethodDeclaration method) throws Exception { methodGlobalVars.add(new HashSet<String>()); ASTNode parentDeclaration = null; if (!declarations.empty()) { parentDeclaration = declarations.peek(); } // In case we are entering a nested element - just add to the deferred // list // and get out of the nested element visiting process if (parentDeclaration instanceof MethodDeclaration) { if (fLastNamespace == null) { deferredDeclarations.add(method); } else { deferredNamespacedDeclarations.add(method); } return false; } if (parentDeclaration instanceof InterfaceDeclaration) { method.setModifier(Modifiers.AccAbstract); } method.setModifiers(markAsDeprecated(method.getModifiers(), method)); declarations.push(method); for (PHPSourceElementRequestorExtension visitor : extensions) { visitor.visit(method); } boolean visit = visitMethodDeclaration(method); if (visit) { // Process method argument (local variable) declarations: List<Argument> arguments = method.getArguments(); for (Argument arg : arguments) { ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo(); info.name = arg.getName(); info.modifiers = Modifiers.AccPublic; info.nameSourceStart = arg.getNameStart(); info.nameSourceEnd = arg.getNameEnd() - 1; info.declarationStart = arg.sourceStart(); fRequestor.enterField(info); fRequestor.exitField(arg.sourceEnd() - 1); } } return visit; }
public MethodDeclaration getCurrentMethod() { ASTNode currDecleration = declarations.peek(); if (currDecleration instanceof MethodDeclaration) { return (MethodDeclaration) currDecleration; } return null; }
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 endvisit(TypeDeclaration type) throws Exception { if (type instanceof NamespaceDeclaration) { NamespaceDeclaration namespaceDecl = (NamespaceDeclaration) type; while (deferredNamespacedDeclarations != null && !deferredNamespacedDeclarations.isEmpty()) { final ASTNode[] declarations = deferredNamespacedDeclarations.toArray( new ASTNode[deferredNamespacedDeclarations.size()]); deferredNamespacedDeclarations.clear(); for (ASTNode deferred : declarations) { deferred.traverse(this); } } fCurrentNamespace = null; // there are no nested namespaces fCurrentQualifier = null; fLastUseParts.clear(); if (namespaceDecl.isGlobal()) { return visitGeneral(type); } } else { fCurrentParent = null; } declarations.pop(); // resolve more type member declarations resolveMagicMembers(type); for (PhpIndexingVisitorExtension visitor : extensions) { visitor.endvisit(type); } endvisitGeneral(type); return true; }
public boolean visit(PHPFieldDeclaration declaration) throws Exception { // This is variable declaration: ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo(); info.modifiers = declaration.getModifiers(); info.name = declaration.getName(); SimpleReference var = declaration.getRef(); info.nameSourceEnd = var.sourceEnd() - 1; info.nameSourceStart = var.sourceStart(); info.declarationStart = declaration.getDeclarationStart(); info.modifiers = markAsDeprecated(info.modifiers, declaration); PHPDocBlock doc = declaration.getPHPDoc(); if (doc != null) { for (PHPDocTag tag : doc.getTags(PHPDocTag.VAR)) { // do it like for // PHPDocumentationContentAccess#handleBlockTags(List tags): // variable name can be optional, but if present keep only // the good ones if (tag.getVariableReference() != null && !tag.getVariableReference().getName().equals(declaration.getName())) { continue; } if (tag.getTypeReferences().size() > 0) { info.type = PHPModelUtils.appendTypeReferenceNames(tag.getTypeReferences()); break; } } } fInfoStack.push(info); fRequestor.enterField(info); return true; }
public boolean endvisit(TypeDeclaration type) throws Exception { if (type instanceof NamespaceDeclaration) { NamespaceDeclaration namespaceDecl = (NamespaceDeclaration) type; while (deferredNamespacedDeclarations != null && !deferredNamespacedDeclarations.isEmpty()) { final ASTNode[] declarations = deferredNamespacedDeclarations.toArray( new ASTNode[deferredNamespacedDeclarations.size()]); deferredNamespacedDeclarations.clear(); for (ASTNode deferred : declarations) { deferred.traverse(this); } } fLastNamespace = null; // there are no nested namespaces if (namespaceDecl.isGlobal()) { return true; } } declarations.pop(); // resolve more type member declarations resolveMagicMembers(type); for (PHPSourceElementRequestorExtension visitor : extensions) { visitor.endvisit(type); } return super.endvisit(type); }
public boolean endvisit(MethodDeclaration method) throws Exception { methodGlobalVars.pop(); declarations.pop(); for (PHPSourceElementRequestorExtension visitor : extensions) { visitor.endvisit(method); } return super.endvisit(method); }
public boolean endvisit(MethodDeclaration method) throws Exception { methodGlobalVars.pop(); declarations.pop(); for (PhpIndexingVisitorExtension visitor : extensions) { visitor.endvisit(method); } endvisitGeneral(method); return true; }
public boolean visit(CatchClause catchClause) throws Exception { ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo(); info.modifiers = Modifiers.AccPublic; SimpleReference var = catchClause.getVariable(); info.name = var.getName(); info.nameSourceEnd = var.sourceEnd() - 1; info.nameSourceStart = var.sourceStart(); info.declarationStart = catchClause.sourceStart(); fInfoStack.push(info); fRequestor.enterField(info); return true; }
public boolean visit(ConstantDeclaration declaration) throws Exception { ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo(); info.modifiers = Modifiers.AccConstant | Modifiers.AccPublic | Modifiers.AccFinal; ConstantReference constantName = declaration.getConstantName(); info.name = ASTUtils.stripQuotes(constantName.getName()); info.nameSourceEnd = constantName.sourceEnd() - 1; info.nameSourceStart = constantName.sourceStart(); info.declarationStart = declaration.sourceStart(); info.modifiers = markAsDeprecated(info.modifiers, declaration); fInfoStack.push(info); fRequestor.enterField(info); return true; }
public boolean endvisit(LambdaFunctionDeclaration lambdaMethod) throws Exception { methodGlobalVars.pop(); this.fInMethod = false; if (!fNodes.isEmpty() && fNodes.peek() == lambdaMethod) { fRequestor.exitMethod(lambdaMethod.sourceEnd() - 1); fInfoStack.pop(); fNodes.pop(); } for (PHPSourceElementRequestorExtension visitor : extensions) { visitor.endvisit(lambdaMethod); } return true; }
public boolean endvisit(Assignment assignment) throws Exception { if (!fNodes.isEmpty() && fNodes.peek() == assignment) { fRequestor.exitField(assignment.sourceEnd() - 1); fNodes.pop(); ElementInfo currentField = fInfoStack.pop(); if (fDeferredVariables.containsKey(currentField)) { for (Assignment assign : fDeferredVariables.get(currentField)) { assign.traverse(this); } fDeferredVariables.remove(currentField); } } return true; }
private boolean visitMethodDeclaration(MethodDeclaration method) throws Exception { this.fNodes.push(method); List<?> args = method.getArguments(); String[] parameter = new String[args.size()]; String[] initializers = new String[args.size()]; for (int a = 0; a < args.size(); a++) { Argument arg = (Argument) args.get(a); parameter[a] = arg.getName(); if (arg.getInitialization() != null) { if (arg.getInitialization() instanceof Literal) { Literal scalar = (Literal) arg.getInitialization(); initializers[a] = scalar.getValue(); } else { initializers[a] = DEFAULT_VALUE; } } } ISourceElementRequestor.MethodInfo mi = new ISourceElementRequestor.MethodInfo(); mi.parameterNames = parameter; mi.name = method.getName(); mi.modifiers = method.getModifiers(); mi.nameSourceStart = method.getNameStart(); mi.nameSourceEnd = method.getNameEnd() - 1; mi.declarationStart = method.sourceStart(); mi.parameterInitializers = initializers; modifyMethodInfo(method, mi); fInfoStack.push(mi); this.fRequestor.enterMethod(mi); this.fInMethod = true; this.fCurrentMethod = method; 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; }
public boolean endvisit(CatchClause catchClause) throws Exception { fRequestor.exitField(catchClause.sourceEnd() - 1); fInfoStack.pop(); return true; }
public boolean endvisit(ConstantDeclaration declaration) throws Exception { fRequestor.exitField(declaration.sourceEnd() - 1); fInfoStack.pop(); return true; }
public boolean visit(TypeDeclaration type) throws Exception { if (type instanceof NamespaceDeclaration) { NamespaceDeclaration namespaceDecl = (NamespaceDeclaration) type; fCurrentNamespace = namespaceDecl; fLastUseParts.clear(); if (namespaceDecl.isGlobal()) { return visitGeneral(type); } declarations.push(type); int modifiers = type.getModifiers() | Modifiers.AccNameSpace; fCurrentQualifier = type.getName(); Integer count = fCurrentQualifierCounts.get(fCurrentQualifier); count = count != null ? count + 1 : 1; fCurrentQualifierCounts.put(fCurrentQualifier, count); modifiers = markAsDeprecated(modifiers, type); StringBuilder metadata = new StringBuilder(); if (fCurrentQualifier != null) { metadata.append(fCurrentQualifierCounts.get(fCurrentQualifier)); metadata.append(";"); // $NON-NLS-1$ } modifyDeclaration( type, new DeclarationInfo( IModelElement.PACKAGE_DECLARATION, modifiers, type.sourceStart(), type.sourceEnd() - type.sourceStart(), type.getNameStart(), type.getNameEnd() - type.getNameStart(), type.getName(), metadata.length() == 0 ? null : metadata.toString(), encodeDocInfo(type), null, null)); } else { Declaration parentDeclaration = null; if (!declarations.empty()) { parentDeclaration = declarations.peek(); } declarations.push(type); if (!(parentDeclaration instanceof NamespaceDeclaration)) { type.setModifier(Modifiers.AccGlobal); } // In case we are entering a nested element if (parentDeclaration instanceof MethodDeclaration) { if (fCurrentNamespace == null) { deferredDeclarations.add(type); } else { deferredNamespacedDeclarations.add(type); } return visitGeneral(type); } int modifiers = type.getModifiers(); fCurrentParent = type.getName(); String[] superClasses = processSuperClasses(type); StringBuilder metadata = new StringBuilder(); if (fCurrentQualifier != null) { metadata.append(fCurrentQualifierCounts.get(fCurrentQualifier)); metadata.append(";"); // $NON-NLS-1$ } for (int i = 0; i < superClasses.length; ++i) { metadata.append(superClasses[i]); if (i < superClasses.length - 1) { metadata.append(","); // $NON-NLS-1$ } } modifiers = markAsDeprecated(modifiers, type); modifyDeclaration( type, new DeclarationInfo( IModelElement.TYPE, modifiers, type.sourceStart(), type.sourceEnd() - type.sourceStart(), type.getNameStart(), type.getNameEnd() - type.getNameStart(), type.getName(), metadata.length() == 0 ? null : metadata.toString(), encodeDocInfo(type), fCurrentQualifier, null)); } for (PhpIndexingVisitorExtension visitor : extensions) { visitor.visit(type); } return visitGeneral(type); }
@SuppressWarnings("unchecked") public boolean visit(MethodDeclaration method) throws Exception { fNodes.push(method); methodGlobalVars.add(new HashSet<String>()); int modifiers = method.getModifiers(); PHPDocBlock doc = null; if (method instanceof IPHPDocAwareDeclaration) { IPHPDocAwareDeclaration declaration = (IPHPDocAwareDeclaration) method; doc = declaration.getPHPDoc(); } Declaration parentDeclaration = null; if (!declarations.empty()) { parentDeclaration = declarations.peek(); } declarations.push(method); // In case we are entering a nested element - just add to the deferred // list // and get out of the nested element visiting process if (parentDeclaration instanceof MethodDeclaration) { if (fCurrentNamespace == null) { deferredDeclarations.add(method); } else { deferredNamespacedDeclarations.add(method); } return visitGeneral(method); } if (parentDeclaration instanceof InterfaceDeclaration) { method.setModifier(Modifiers.AccAbstract); } String methodName = method.getName(); // Determine whether this method represents constructor: if (methodName.equalsIgnoreCase(CONSTRUCTOR_NAME) || (parentDeclaration instanceof ClassDeclaration && methodName.equalsIgnoreCase(((ClassDeclaration) parentDeclaration).getName()))) { modifiers |= IPHPModifiers.Constructor; } if (parentDeclaration == null || (parentDeclaration instanceof TypeDeclaration && parentDeclaration == fCurrentNamespace)) { modifiers |= Modifiers.AccGlobal; } if (!Flags.isPrivate(modifiers) && !Flags.isProtected(modifiers) && !Flags.isPublic(modifiers)) { modifiers |= Modifiers.AccPublic; } modifiers = markAsDeprecated(modifiers, method); StringBuilder metadata = new StringBuilder(); if (fCurrentQualifier != null) { metadata.append(fCurrentQualifierCounts.get(fCurrentQualifier)); metadata.append(";"); // $NON-NLS-1$ } List<Argument> arguments = method.getArguments(); if (arguments != null) { Iterator<Argument> i = arguments.iterator(); while (i.hasNext()) { Argument arg = (Argument) i.next(); String type = NULL_VALUE; if (arg instanceof FormalParameter) { FormalParameter fp = (FormalParameter) arg; if (fp.getParameterType() != null) { if (fp.getParameterType().getName() != null) { type = fp.getParameterType().getName(); } } } if (type == NULL_VALUE && doc != null) { type = getParamType(doc, arg.getName(), type); } metadata.append(type); metadata.append(PARAMETER_SEPERATOR); metadata.append(arg.getName()); metadata.append(PARAMETER_SEPERATOR); String defaultValue = NULL_VALUE; if (arg.getInitialization() != null) { if (arg.getInitialization() instanceof Literal) { Literal scalar = (Literal) arg.getInitialization(); defaultValue = scalar.getValue(); } else { defaultValue = DEFAULT_VALUE; } } metadata.append(defaultValue); if (i.hasNext()) { metadata.append(","); // $NON-NLS-1$ } } } // Add method declaration: modifyDeclaration( method, new DeclarationInfo( IModelElement.METHOD, modifiers, method.sourceStart(), method.sourceEnd() - method.sourceStart(), method.getNameStart(), method.getNameEnd() - method.getNameStart(), methodName, metadata.length() == 0 ? null : metadata.toString(), encodeDocInfo(method), fCurrentQualifier, fCurrentParent)); for (PhpIndexingVisitorExtension visitor : extensions) { visitor.visit(method); } return visitGeneral(method); }
public boolean visit(LambdaFunctionDeclaration lambdaMethod) throws Exception { fNodes.push(lambdaMethod); methodGlobalVars.add(new HashSet<String>()); // Declaration parentDeclaration = null; // if (!declarations.empty() // && declarations.peek() instanceof MethodDeclaration) { // parentDeclaration = declarations.peek(); // // In case we are entering a nested element - just add to the // // deferred list and get out of the nested element visiting process // deferredDeclarations.add(lambdaMethod); // return visitGeneral(lambdaMethod); // } Collection<FormalParameter> arguments = lambdaMethod.getArguments(); StringBuilder metadata = new StringBuilder(); String[] parameters; if (arguments != null) { parameters = new String[arguments.size()]; Iterator<FormalParameter> i = arguments.iterator(); int indx = 0; while (i.hasNext()) { Argument arg = (Argument) i.next(); metadata.append(arg.getName()); parameters[indx] = arg.getName(); indx++; if (i.hasNext()) { metadata.append(","); // $NON-NLS-1$ } } } else { parameters = new String[0]; } // Add method declaration: for (PHPSourceElementRequestorExtension visitor : extensions) { visitor.visit(lambdaMethod); } ISourceElementRequestor.MethodInfo mi = new ISourceElementRequestor.MethodInfo(); mi.parameterNames = parameters; mi.name = PHPCoreConstants.ANONYMOUS; mi.modifiers = Modifiers.AccPublic; if (lambdaMethod.isStatic()) { mi.modifiers |= Modifiers.AccStatic; } mi.nameSourceStart = lambdaMethod.sourceStart(); mi.nameSourceEnd = lambdaMethod.sourceEnd(); mi.declarationStart = mi.nameSourceStart; mi.isConstructor = false; fInfoStack.push(mi); this.fRequestor.enterMethod(mi); this.fInMethod = true; for (Argument arg : arguments) { ISourceElementRequestor.FieldInfo info = new ISourceElementRequestor.FieldInfo(); info.name = arg.getName(); info.modifiers = Modifiers.AccPublic; info.nameSourceStart = arg.getNameStart(); info.nameSourceEnd = arg.getNameEnd() - 1; info.declarationStart = arg.sourceStart(); fRequestor.enterField(info); fRequestor.exitField(arg.sourceEnd() - 1); } return true; }
public boolean visitGeneral(ASTNode node) throws Exception { fNodes.push(node); return true; }
public void endvisitGeneral(ASTNode node) throws Exception { fNodes.pop(); }