Package com.sun.tools.javac.tree.JCTree

Examples of com.sun.tools.javac.tree.JCTree.JCMethodDecl


                                " within frame " + frame);
                    }
                    return;

                case METHOD: {
                    JCMethodDecl frameMethod = (JCMethodDecl) frame;
                    p.pos = frame.pos;
                    if (frameMethod.thrown.contains(tree)) {
                        p.type = TargetType.THROWS;
                        p.type_index = frameMethod.thrown.indexOf(tree);
                    } else if (frameMethod.restype == tree) {
                        p.type = TargetType.METHOD_RETURN;
                    } else if (frameMethod.typarams.contains(tree)) {
                        p.type = TargetType.METHOD_TYPE_PARAMETER;
                        p.parameter_index = frameMethod.typarams.indexOf(tree);
                    } else {
                        Assert.error("Could not determine position of tree " + tree +
                                " within frame " + frame);
                    }
                    return;
                }

                case PARAMETERIZED_TYPE: {
                    List<JCTree> newPath = path.tail;

                    if (((JCTypeApply)frame).clazz == tree) {
                        // generic: RAW; noop
                    } else if (((JCTypeApply)frame).arguments.contains(tree)) {
                        JCTypeApply taframe = (JCTypeApply) frame;
                        int arg = taframe.arguments.indexOf(tree);
                        p.location = p.location.prepend(new TypePathEntry(TypePathEntryKind.TYPE_ARGUMENT, arg));

                        Type typeToUse;
                        if (newPath.tail != null && newPath.tail.head.hasTag(Tag.NEWCLASS)) {
                            // If we are within an anonymous class instantiation, use its type,
                            // because it contains a correctly nested type.
                            typeToUse = newPath.tail.head.type;
                        } else {
                            typeToUse = taframe.type;
                        }

                        locateNestedTypes(typeToUse, p);
                    } else {
                        Assert.error("Could not determine type argument position of tree " + tree +
                                " within frame " + frame);
                    }

                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
                    return;
                }

                case MEMBER_REFERENCE: {
                    JCMemberReference mrframe = (JCMemberReference) frame;

                    if (mrframe.expr == tree) {
                        switch (mrframe.mode) {
                        case INVOKE:
                            p.type = TargetType.METHOD_REFERENCE;
                            break;
                        case NEW:
                            p.type = TargetType.CONSTRUCTOR_REFERENCE;
                            break;
                        default:
                            Assert.error("Unknown method reference mode " + mrframe.mode +
                                    " for tree " + tree + " within frame " + frame);
                        }
                        p.pos = frame.pos;
                    } else if (mrframe.typeargs != null &&
                            mrframe.typeargs.contains(tree)) {
                        int arg = mrframe.typeargs.indexOf(tree);
                        p.type_index = arg;
                        switch (mrframe.mode) {
                        case INVOKE:
                            p.type = TargetType.METHOD_REFERENCE_TYPE_ARGUMENT;
                            break;
                        case NEW:
                            p.type = TargetType.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT;
                            break;
                        default:
                            Assert.error("Unknown method reference mode " + mrframe.mode +
                                    " for tree " + tree + " within frame " + frame);
                        }
                        p.pos = frame.pos;
                    } else {
                        Assert.error("Could not determine type argument position of tree " + tree +
                                " within frame " + frame);
                    }
                    return;
                }

                case ARRAY_TYPE: {
                    ListBuffer<TypePathEntry> index = new ListBuffer<>();
                    index = index.append(TypePathEntry.ARRAY);
                    List<JCTree> newPath = path.tail;
                    while (true) {
                        JCTree npHead = newPath.tail.head;
                        if (npHead.hasTag(JCTree.Tag.TYPEARRAY)) {
                            newPath = newPath.tail;
                            index = index.append(TypePathEntry.ARRAY);
                        } else if (npHead.hasTag(JCTree.Tag.ANNOTATED_TYPE)) {
                            newPath = newPath.tail;
                        } else {
                            break;
                        }
                    }
                    p.location = p.location.prependList(index.toList());
                    resolveFrame(newPath.head, newPath.tail.head, newPath, p);
                    return;
                }

                case TYPE_PARAMETER:
                    if (path.tail.tail.head.hasTag(JCTree.Tag.CLASSDEF)) {
                        JCClassDecl clazz = (JCClassDecl)path.tail.tail.head;
                        p.type = TargetType.CLASS_TYPE_PARAMETER_BOUND;
                        p.parameter_index = clazz.typarams.indexOf(path.tail.head);
                        p.bound_index = ((JCTypeParameter)frame).bounds.indexOf(tree);
                        if (((JCTypeParameter)frame).bounds.get(0).type.isInterface()) {
                            // Account for an implicit Object as bound 0
                            p.bound_index += 1;
                        }
                    } else if (path.tail.tail.head.hasTag(JCTree.Tag.METHODDEF)) {
                        JCMethodDecl method = (JCMethodDecl)path.tail.tail.head;
                        p.type = TargetType.METHOD_TYPE_PARAMETER_BOUND;
                        p.parameter_index = method.typarams.indexOf(path.tail.head);
                        p.bound_index = ((JCTypeParameter)frame).bounds.indexOf(tree);
                        if (((JCTypeParameter)frame).bounds.get(0).type.isInterface()) {
                            // Account for an implicit Object as bound 0
View Full Code Here


            while (curr.head.getTag() != Tag.METHODDEF &&
                    curr.head.getTag() != Tag.LAMBDA) {
                curr = curr.tail;
            }
            if (curr.head.getTag() == Tag.METHODDEF) {
                JCMethodDecl method = (JCMethodDecl)curr.head;
                return method.params.indexOf(param);
            } else if (curr.head.getTag() == Tag.LAMBDA) {
                JCLambda lambda = (JCLambda)curr.head;
                return lambda.params.indexOf(param);
            } else {
View Full Code Here

        System.out.println("enum constants " + classDoc.enumConstants());
        if (classDoc.enumConstants() != null)
          System.out.println("enum constants " + classDoc.enumConstants().length);
        System.out.println("method " + methodName + " is synthetic:"  + methodDoc.isSynthetic());
        */
        JCMethodDecl method = null;
        try
        {
          method = parser.getMethod(classImplementation, methodName, parameterClassnames);
        }
        catch (Exception ex)
View Full Code Here

          for( JCTree member : typeClass.getMembers())
          {
            System.out.println("got member \n" + member);
            if (member instanceof JCMethodDecl)
            {
              JCMethodDecl method = (JCMethodDecl) member;
              System.out.println(sourcecodeString.substring(member.getStartPosition(), method.body.endpos + 1));
            }
           
          }
         
View Full Code Here

    StringBuilder methods = new StringBuilder();
    for( JCTree member : classImplementation.getMembers())
    {
      if (member instanceof JCMethodDecl)
      {
        JCMethodDecl method = (JCMethodDecl) member;
        methods.append(method.name).append(", ");
        if (method.name.toString().equals(methodname))
        {
          List<JCVariableDecl>parameterlist = method.params;
          if(parameterClassnames.length == parameterlist.size())
View Full Code Here

      // o.super(arg1, ...)
      //
      // which is a method invocation (!) to the actual constructor

      // the method call is guaranteed to return nonnull
      JCMethodDecl anonConstructor = (JCMethodDecl) TreeInfo.declarationFor(newClassTree.constructor, newClassTree);
      assert anonConstructor != null;
      assert anonConstructor.body.stats.size() == 1;
      JCExpressionStatement stmt = (JCExpressionStatement) anonConstructor.body.stats.head;
      JCTree.JCMethodInvocation superInvok = (JCMethodInvocation) stmt.expr;
      return (ExecutableElement) TreeInfo.symbol(superInvok.meth);
View Full Code Here

         *  in a constructor call.
         *  @param tree   The application node
         *  @param env    The environment current at the application.
         */
        boolean checkFirstConstructorStat(JCMethodInvocation tree, Env<AttrContext> env) {
            JCMethodDecl enclMethod = env.enclMethod;
            if (enclMethod != null && enclMethod.name == names.init) {
                JCBlock body = enclMethod.body;
                if (body.stats.head.getTag() == JCTree.EXEC &&
                    ((JCExpressionStatement) body.stats.head).expr == tree)
                    return true;
View Full Code Here

                //Define the next() method for the Iterator
                fields.add(makeNextMethod(iteratedType));
                //Define the inner iterator class

                JCMethodDecl getIterator = makeGetIterator(iteratedType);
                JCExpression iterable = makeAnonymousIterable(iteratedType, getIterator);
                for (Substitution subs : fieldSubst) {
                    subs.close();
                }
                return iterable;
View Full Code Here

                                        make().Type(syms().ceylonFinishedType))),
                                make().Block(0, List.<JCStatement>of(make().Exec(make().Assign(iteratorResultName.makeIdent(),
                                        transformedElement)))),
                                null),
                        make().Return(iteratorResultName.makeIdent())));
                JCMethodDecl nextMethod = nextMdb.build();
               
                // new AbstractIterator()
                JCNewClass iteratorClass = make().NewClass(null,
                        null,
                        make().TypeApply(make().QualIdent(syms().ceylonAbstractIteratorType.tsym),
View Full Code Here

            }
           
            // if required, generate the $call$typed method
            MethodDefinitionBuilder callTypedMethod = makeCallTypedMethod();
            if (callTypedMethod != null) {
                JCMethodDecl callTyped = callTypedMethod.build();
                if (callTyped.params.size() != numParams) {
                    throw new BugException();
                }
                classBody.append(callTyped);
            }
View Full Code Here

TOP

Related Classes of com.sun.tools.javac.tree.JCTree.JCMethodDecl

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.