public boolean visit(LambdaFunctionDeclaration s) throws Exception { Map<String, String> parameters = createInitialParameters(s); parameters.put("isReference", Boolean.toString(s.isReference())); if (s.isStatic()) { parameters.put("isStatic", Boolean.toString(s.isStatic())); } xmlWriter.startTag("LambdaFunctionDeclaration", parameters); xmlWriter.startTag("Arguments", new HashMap<String, String>()); for (FormalParameter p : s.getArguments()) { p.traverse(this); } xmlWriter.endTag("Arguments"); Collection<? extends Expression> lexicalVars = s.getLexicalVars(); if (lexicalVars != null) { xmlWriter.startTag("LexicalVars", new HashMap<String, String>()); for (Expression var : lexicalVars) { var.traverse(this); } xmlWriter.endTag("LexicalVars"); } s.getBody().traverse(this); return false; }
public boolean visit(FormalParameter s) throws Exception { Map<String, String> parameters = createInitialParameters(s); parameters.put("isMandatory", Boolean.toString(s.isMandatory())); xmlWriter.startTag("FormalParameter", parameters); return true; }
@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); }