Package com.sun.source.tree

Examples of com.sun.source.tree.Tree


  };
     
  @Override
  public Description matchAnnotation(AnnotationTree annotationTree, VisitorState state) {
    if (injectOrAssistedInjectMatcher.matches(annotationTree, state)) {
      Tree treeWithAnnotation = state.getPath().getParentPath().getParentPath().getLeaf();
      if (ASTHelpers.getSymbol(treeWithAnnotation).isConstructor()
          && constructorWithInjectMatcher.matches((MethodTree) treeWithAnnotation, state)
          && constructorWithAssistedInjectMatcher.matches((MethodTree) treeWithAnnotation, state)) {
        return describeMatch(annotationTree, SuggestedFix.delete(annotationTree));
      }
View Full Code Here


      @SuppressWarnings("unchecked"// TODO(user): this should take a Class<T>
      @Override
      public boolean matches(Tree t, VisitorState state) {
        TreePath path = state.getPath().getParentPath();
        while (path != null) {
          Tree node = path.getLeaf();
          if (matcher.matches((T) node, state)) {
            return true;
          }
          path = path.getParentPath();
        }
View Full Code Here

  public static Matcher<MethodTree> methodReturns(final Type returnType) {
    return new Matcher<MethodTree>() {
      @Override
      public boolean matches(MethodTree methodTree, VisitorState state) {
        Tree returnTree = methodTree.getReturnType();
        if (returnTree == null) {
          // This is a constructor, it has no return type.
          return false;
        }
        Type methodReturnType = ASTHelpers.getType(returnTree);
View Full Code Here

        state.getTypes().isAssignable(returnType, identifierType)) {
      // Fix by assigning the assigning the result of the call to the root receiver reference.
      fix = SuggestedFix.prefixWith(methodInvocationTree, identifierStr + " = ");
    } else {
      // Unclear what the programmer intended.  Delete since we don't know what else to do.
      Tree parent = state.getPath().getParentPath().getLeaf();
      fix = SuggestedFix.delete(parent);
    }
    return describeMatch(methodInvocationTree, fix);
  }
View Full Code Here

    this.annotationClassName = annotationClassName;
  }

  @Override
  public boolean matches(AnnotationTree annotationTree, VisitorState state) {
    Tree type = annotationTree.getAnnotationType();
    if (type.getKind() == Tree.Kind.IDENTIFIER && type instanceof JCTree.JCIdent) {
      JCTree.JCIdent jcIdent = (JCTree.JCIdent) type;
      return jcIdent.sym.getQualifiedName().toString().equals(annotationClassName);
    } else {
      return false;
    }
View Full Code Here

  @Override
  public boolean matches(T stmt, VisitorState state) {
    // TODO(user): should re-use Enclosing.BlockOrCase
    // find enclosing block
    TreePath path = state.getPath();
    Tree prev = null;
    Tree curr = path.getLeaf();     // initialized to curr node (if stmt)
    boolean found = false;
    while (path != null) {
      prev = curr;
      path = path.getParentPath();
      curr = path.getLeaf();
      if (curr.getKind() == Kind.BLOCK) {
        found = true;
        break;
      }
    }
    assert(found);      // should always find an enclosing block
View Full Code Here

      this.matcher = matcher;
    }

    @Override
    public boolean matches(T unused, VisitorState state) {
      Tree enclosing = state.findEnclosing(CaseTree.class, BlockTree.class);
      if (enclosing == null) {
        return false;
      }
      final List<? extends StatementTree> statements;
      if (enclosing instanceof BlockTree) {
View Full Code Here

  }

  @Override
  public Description matchVariable(VariableTree tree, VisitorState state) {
    ExpressionTree initializer = stripCheckNotNull(tree.getInitializer(), state);
    Tree parent = state.getPath().getParentPath().getLeaf();

    // must be a static class variable with member select initializer
    if (initializer == null || initializer.getKind() != MEMBER_SELECT || parent.getKind() != CLASS
        || !tree.getModifiers().getFlags().contains(STATIC)) {
      return Description.NO_MATCH;
    }

    MemberSelectTree rhs = (MemberSelectTree) initializer;
View Full Code Here

   * Case 4: Otherwise suggest deleting the assignment.
   */
  public Description describeForAssignment(AssignmentTree assignmentTree, VisitorState state) {

    // the statement that is the parent of the self-assignment expression
    Tree parent = state.getPath().getParentPath().getLeaf();

    // default fix is to delete assignment
    Fix fix = SuggestedFix.delete(parent);

    ExpressionTree lhs = assignmentTree.getVariable();
View Full Code Here

     */
    @Override
    public boolean matches(T tree, VisitorState state) {

      TreePath path = state.getPath();
      Tree prevTree = path.getLeaf();

      while (path != null && path.getLeaf().getKind() != Kind.METHOD
          && path.getLeaf().getKind() != Kind.COMPILATION_UNIT) {
        prevTree = path.getLeaf();
        path = path.getParentPath();
View Full Code Here

TOP

Related Classes of com.sun.source.tree.Tree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.