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 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); // } final Collection<FormalParameter> arguments = lambdaMethod.getArguments(); final StringBuilder metadata = new StringBuilder(); final String[] parameters = new String[arguments.size()]; // if (arguments != null) { final Iterator<FormalParameter> i = arguments.iterator(); int indx = 0; while (i.hasNext()) { final Argument arg = i.next(); metadata.append(arg.getName()); parameters[indx] = arg.getName(); indx++; if (i.hasNext()) { metadata.append(","); } } // } // Add method declaration: for (final PHPSourceElementRequestorExtension visitor : extensions) { visitor.visit(lambdaMethod); } final ISourceElementRequestor.MethodInfo mi = new ISourceElementRequestor.MethodInfo(); mi.parameterNames = parameters; mi.name = PHPCoreConstants.ANONYMOUS; mi.modifiers = Modifiers.AccPublic; mi.nameSourceStart = lambdaMethod.sourceStart(); mi.nameSourceEnd = lambdaMethod.sourceEnd(); mi.declarationStart = mi.nameSourceStart; mi.isConstructor = false; this.fRequestor.enterMethod(mi); this.fInMethod = true; for (final Argument arg : arguments) { final 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; }