Package com.sun.source.tree

Examples of com.sun.source.tree.MemberSelectTree


    if (!methodSelect(
        instanceMethod(Matchers.<ExpressionTree>isSubtypeOf("java.lang.Class"), "getAnnotation"))
        .matches(tree, state)) {
      return Description.NO_MATCH;
    }
    MemberSelectTree memTree = (MemberSelectTree) tree.getArguments().get(0);
    TypeSymbol annotation = ASTHelpers.getSymbol(memTree.getExpression()).type.tsym;

    Retention retention = ASTHelpers.getAnnotation(annotation, Retention.class);
    if (retention != null && retention.value().equals(RUNTIME)) {
      return Description.NO_MATCH;
    }
View Full Code Here


  public Description matchMethodInvocation(MethodInvocationTree methodInvocationTree, VisitorState state) {
    if (!matcher.matches(methodInvocationTree, state)) {
      return Description.NO_MATCH;
    }

    MemberSelectTree method =
        (MemberSelectTree) methodInvocationTree.getMethodSelect();

    List<? extends ExpressionTree> arguments =
        methodInvocationTree.getArguments();
    MethodInvocationTree stringFormat = (MethodInvocationTree) arguments.get(1);
View Full Code Here

    if (initializer == null || initializer.getKind() != MEMBER_SELECT || parent.getKind() != CLASS
        || !tree.getModifiers().getFlags().contains(STATIC)) {
      return Description.NO_MATCH;
    }

    MemberSelectTree rhs = (MemberSelectTree) initializer;
    Symbol rhsClass = ASTHelpers.getSymbol(rhs.getExpression());
    Symbol lhsClass = ASTHelpers.getSymbol(parent);
    if (rhsClass != null && lhsClass != null
        && rhsClass.equals(lhsClass) && rhs.getIdentifier().contentEquals(tree.getName())) {
      return describeForVarDecl(tree, state);
    }
    return Description.NO_MATCH;
  }
View Full Code Here

    if (mst.getKind() == Tree.Kind.IDENTIFIER) {
      return ((IdentifierTree) mst).getName().contentEquals("super");
    }

    if (mst.getKind() == Tree.Kind.MEMBER_SELECT) {
      MemberSelectTree selectTree = (MemberSelectTree) mst;

      if (selectTree.getExpression().getKind() != Tree.Kind.IDENTIFIER) {
        return false;
      }

      return ((IdentifierTree) selectTree.getExpression()).getName().contentEquals("super");
    }

    return false;
  }
View Full Code Here

   * @return true iff if tree is a field access expression (implicit or explicit).
   */
  public static boolean isFieldAccess(Tree tree) {
    if (tree.getKind().equals(Tree.Kind.MEMBER_SELECT)) {
      // explicit field access
      MemberSelectTree memberSelect = (MemberSelectTree) tree;
      Element el = TreeUtils.elementFromUse(memberSelect);
      return el.getKind().isField();
    } else if (tree.getKind().equals(Tree.Kind.IDENTIFIER)) {
      // implicit field access
      IdentifierTree ident = (IdentifierTree) tree;
View Full Code Here

   * @return The name of the field accessed by <code>tree</code>.
   */
  public static String getFieldName(Tree tree) {
    assert isFieldAccess(tree);
    if (tree.getKind().equals(Tree.Kind.MEMBER_SELECT)) {
      MemberSelectTree mtree = (MemberSelectTree) tree;
      return mtree.getIdentifier().toString();
    } else {
      IdentifierTree itree = (IdentifierTree) tree;
      return itree.getName().toString();
    }
  }
View Full Code Here

   * @return true iff if tree is a method access expression (implicit or explicit).
   */
  public static boolean isMethodAccess(Tree tree) {
    if (tree.getKind().equals(Tree.Kind.MEMBER_SELECT)) {
      // explicit method access
      MemberSelectTree memberSelect = (MemberSelectTree) tree;
      Element el = TreeUtils.elementFromUse(memberSelect);
      return el.getKind() == ElementKind.METHOD || el.getKind() == ElementKind.CONSTRUCTOR;
    } else if (tree.getKind().equals(Tree.Kind.IDENTIFIER)) {
      // implicit method access
      IdentifierTree ident = (IdentifierTree) tree;
View Full Code Here

   * @return The name of the method accessed by <code>tree</code>.
   */
  public static String getMethodName(Tree tree) {
    assert isMethodAccess(tree);
    if (tree.getKind().equals(Tree.Kind.MEMBER_SELECT)) {
      MemberSelectTree mtree = (MemberSelectTree) tree;
      return mtree.getIdentifier().toString();
    } else {
      IdentifierTree itree = (IdentifierTree) tree;
      return itree.getName().toString();
    }
  }
View Full Code Here

   * Returns true if and only if the given {@code tree} represents a field access of the given {@link VariableElement}
   * .
   */
  public static boolean isSpecificFieldAccess(Tree tree, VariableElement var) {
    if (tree instanceof MemberSelectTree) {
      MemberSelectTree memSel = (MemberSelectTree) tree;
      Element field = TreeUtils.elementFromUse(memSel);
      return field.equals(var);
    } else if (tree instanceof IdentifierTree) {
      IdentifierTree idTree = (IdentifierTree) tree;
      Element field = TreeUtils.elementFromUse(idTree);
View Full Code Here

    if (!(tree.getMethodSelect() instanceof MemberSelectTree)) {
      // check for Outer.this check
      return true;
    }

    MemberSelectTree select = (MemberSelectTree) tree.getMethodSelect();
    if (GeneratorConstants.SUPER.equals(select.getExpression().toString())) {
      context.addError(tree, "You cannot call the super method if that belongs to a @SyntheticType");
      return true;
    }
    return false;
  }
View Full Code Here

TOP

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

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.