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);
    }
  }
示例#2
0
  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 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(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(MethodDeclaration method) throws Exception {
    methodGlobalVars.pop();
    declarations.pop();

    for (PHPSourceElementRequestorExtension visitor : extensions) {
      visitor.endvisit(method);
    }
    return super.endvisit(method);
  }
示例#6
0
  public boolean endvisit(MethodDeclaration method) throws Exception {
    methodGlobalVars.pop();
    declarations.pop();

    for (PhpIndexingVisitorExtension visitor : extensions) {
      visitor.endvisit(method);
    }

    endvisitGeneral(method);
    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;
  }
示例#9
0
 public void endvisitGeneral(ASTNode node) throws Exception {
   fNodes.pop();
 }
 public boolean endvisit(ConstantDeclaration declaration) throws Exception {
   fRequestor.exitField(declaration.sourceEnd() - 1);
   fInfoStack.pop();
   return true;
 }
 public boolean endvisit(CatchClause catchClause) throws Exception {
   fRequestor.exitField(catchClause.sourceEnd() - 1);
   fInfoStack.pop();
   return true;
 }