Package javax.lang.model.element

Examples of javax.lang.model.element.Element


        return getDeclaredTypeName(comp, false);
      }
      mirror = box ? box(mirror) : mirror;
      if (isPrimitive(mirror))
        return ((PrimitiveType)mirror).toString();
      Element elem = processingEnv.getTypeUtils().asElement(mirror);
      if (elem == null)
          throw new RuntimeException(_loc.get("mmg-no-type", mirror).getMessage());
        return elem.toString();
    }
View Full Code Here


  /**
   * generate Type.method
   */
  private JS generateStaticRef(MemberReferenceTree tree, GenerationContext<JS> context, ExecutableElement methodElement) {
    JavaScriptBuilder<JS> js = context.js();
    Element type = methodElement.getEnclosingElement();
    JS typeName = js.name(context.getNames().getTypeName(context, type));
    return js.property(typeName, tree.getName());
  }
View Full Code Here

  /**
   * generate function() {return Type.prototype.method.call(arguments[0], arguments[1], ...);}
   */
  private JS generateInstanceRef(MemberReferenceTree tree, GenerationContext<JS> context, ExecutableElement methodElement) {
    JavaScriptBuilder<JS> js = context.js();
    Element type = methodElement.getEnclosingElement();
    JS typeName = js.name(context.getNames().getTypeName(context, type));
    JS proto = js.property(typeName, JavascriptKeywords.PROTOTYPE);
    JS method = js.property(proto, tree.getName());
    JS methoCall = js.property(method, "call");
    // + 1 because first is the object to which the method is applied
View Full Code Here

  /**
   * generate function() {new Type(arguments[0], arguments[1]);}
   */
  private JS generateConstructorRef(GenerationContext<JS> context, ExecutableElement methodElement) {
    JavaScriptBuilder<JS> js = context.js();
    Element type = methodElement.getEnclosingElement();

    JS typeName = js.name(context.getNames().getTypeName(context, type));
    JS newExpr = context.js().newExpression(typeName, generateArguments(context, methodElement.getParameters().size()));
    return js.function(null, Collections.emptyList(), js.returnStatement(newExpr));
  }
View Full Code Here

  }

  @Override
  public JS visit(WriterVisitor<JS> visitor, MemberReferenceTree tree, GenerationContext<JS> context) {
    ExecutableElement methodElement = (ExecutableElement) context.getTrees().getElement(context.getCurrentPath());
    Element qualifierElement = context.getTrees().getElement(new TreePath(context.getCurrentPath(), tree.getQualifierExpression()));

    // System.out.println(tree + ":left:" + tree.getQualifierExpression().getClass() + ", kind:" +
    // qualifierElemenet.getKind());
    if (tree.getMode() == ReferenceMode.INVOKE) {
      if (qualifierElement.getKind() == ElementKind.CLASS) {
        if (JavaNodes.isStatic(methodElement)) {
          return generateStaticRef(tree, context, methodElement);
        }
        return generateInstanceRef(tree, context, methodElement);
      }
View Full Code Here

import com.sun.source.util.TreePath;

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

    TreePath enclosingLambdaPath = TreeUtils.enclosingPathOfType(context.getCurrentPath(), LambdaExpressionTree.class);
View Full Code Here

import com.sun.source.util.TreePath;

public class MethodAccessFromLambdaCheck implements CheckContributor<MethodInvocationTree> {
  @Override
  public Void visit(CheckVisitor visitor, MethodInvocationTree tree, GenerationContext<Void> context) {
    Element methodElement = TreeUtils.elementFromUse(tree);
    if (JavaNodes.isStatic(methodElement)) {
      // only instance methods
      return null;
    }
    String name = MethodInvocationWriter.buildMethodName(tree);
View Full Code Here

   * @param method
   *            the {@link com.sun.source.util.TreePath} for a node that may be an anonymous constructor
   * @return true if the given path points to an anonymous constructor, false if it does not
   */
  public static boolean isAnonymousConstructor(final MethodTree method) {
    /* @Nullable */Element e = InternalUtils.symbol(method);
    if (e == null || !(e instanceof Symbol)) {
      return false;
    }

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

      JCExpressionStatement stmt = (JCExpressionStatement) anonConstructor.body.stats.head;
      JCTree.JCMethodInvocation superInvok = (JCMethodInvocation) stmt.expr;
      return (ExecutableElement) TreeInfo.symbol(superInvok.meth);
    }

    Element e = newClassTree.constructor;

    assert e instanceof ExecutableElement;

    return (ExecutableElement) e;
  }
View Full Code Here

  public static boolean isVarArg(Tree tree) {
    if (!(tree instanceof VariableTree)) {
      return false;
    }

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

    if ((((/* @NonNull */Symbol) e).flags() & Flags.VARARGS) != 0) {
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.