Package javax.lang.model.element

Examples of javax.lang.model.element.Element


    return false;
  }

  public static boolean isSynthetic(Tree tree) {

    /* @Nullable */Element e = InternalUtils.symbol(tree);
    if (e == null || !(e instanceof Symbol)) {
      return false;
    }

    if ((((/* @NonNull */Symbol) e).flags() & Flags.GENERATEDCONSTR) != 0) {
View Full Code Here


    }
    return false;
  }

  public static boolean isSyntheticConstructor(Tree tree) {
    Element e = InternalUtils.symbol(tree);
    if (e == null || e.getKind() != ElementKind.CONSTRUCTOR) {
      return false;
    }
    return isSynthetic(tree);
  }
View Full Code Here

    if (tree instanceof LiteralTree) {
      return true;
    }

    if (TreeUtils.isUseOfElement(tree)) {
      Element elt = TreeUtils.elementFromUse(tree);
      return ElementUtils.isCompileTimeConstant(elt);
    } else if (TreeUtils.isStringConcatenation(tree)) {
      BinaryTree binOp = (BinaryTree) tree;
      return isCompileTimeString(binOp.getLeftOperand()) && isCompileTimeString(binOp.getRightOperand());
    } else {
View Full Code Here

   */
  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;
      Element el = TreeUtils.elementFromUse(ident);
      return el.getKind().isField() && !ident.getName().contentEquals("this") && !ident.getName().contentEquals("super");
    }
    return false;
  }
View Full Code Here

   */
  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;
      // The field "super" and "this" are also legal methods
      if (ident.getName().contentEquals("super") || ident.getName().contentEquals("this")) {
        return true;
      }
      Element el = TreeUtils.elementFromUse(ident);
      return el.getKind() == ElementKind.METHOD || el.getKind() == ElementKind.CONSTRUCTOR;
    }
    return false;
  }
View Full Code Here

   * .
   */
  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);
      return field.equals(var);
    } else {
      return false;
    }
  }
View Full Code Here

*/
public class MemberSelectServerSideCheck implements CheckContributor<MemberSelectTree> {

  @Override
  public Void visit(CheckVisitor visitor, MemberSelectTree tree, GenerationContext<Void> context) {
    Element element = TreeUtils.elementFromUse(tree);

    if (element != null && element.getAnnotation(ServerSide.class) != null) {
      context.addError(tree, "You cannot access fields annotated with @ServerSide in a client code");
    }

    return null;
  }
View Full Code Here

      }
    }, null);
  }

  public static Void checkGlobalScope(final ExpressionTree tree, final String name, final GenerationContext<Void> context) {
    Element fieldElement = TreeUtils.elementFromUse(tree);
    if (fieldElement == null || fieldElement.getKind() != ElementKind.FIELD) {
      // only meant for fields
      return null;
    }

    if (GeneratorConstants.THIS.equals(name)) {
View Full Code Here

  private void checkMember(Tree member, GenerationContext<Void> context) {
    if (member instanceof BlockTree || InternalUtils.isSyntheticConstructor(member)) {
      return;
    }
    Element memberElement = JavaNodes.elementFromDeclaration(member);
    if (!JavaNodes.isStatic(memberElement)) {
      context.addError(member, "Only static constructions can be used in a @GlobalScope class");
    }

  }
View Full Code Here

    return true;
  }

  @Override
  public Void visit(CheckVisitor visitor, IdentifierTree tree, GenerationContext<Void> context) {
    Element fieldElement = TreeUtils.elementFromUse(tree);
    if (!isRegularInstanceField(fieldElement, tree)) {
      return null;
    }

    ClassTree enclosingClassTree = enclosingClassSkipAnonymousInitializer(context.getCurrentPath());

    TypeElement currentScopeClassElement = TreeUtils.elementFromDeclaration(enclosingClassTree);
    TypeElement fieldOwnerElement = (TypeElement) fieldElement.getEnclosingElement();
    if (isOuterType(context, fieldOwnerElement, currentScopeClassElement)) {
      context.addError(
          tree,
          "In Javascript you cannot access a field from the outer type. "
              + "You should define a variable var that=this outside your function definition and use the property of this object. The field: "
View Full Code Here

TOP

Related Classes of javax.lang.model.element.Element

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.