Package com.sun.source.tree

Examples of com.sun.source.tree.VariableTree


  @Override
  public Description matchTry(TryTree tree, VisitorState state) {
    if (tryTreeMatches(tree, state)) {
      CatchTree firstCatch = tree.getCatches().get(0);
      VariableTree catchParameter = firstCatch.getParameter();
      return describeMatch(firstCatch,
          SuggestedFix.replace(catchParameter, "Exception " + catchParameter.getName()));
    } else {
      return Description.NO_MATCH;
    }
  }
View Full Code Here


      // TODO(user): this could be supported - only the last catch would need
      // to be checked - it would either be Throwable or Error.
      return false;
    }
    CatchTree catchTree = catches.get(0);
    VariableTree catchType = catchTree.getParameter();
    if (!javaLangThrowable.matches(catchType, state)) {
      // TODO(user): Error could be supported
      return false;
    }
View Full Code Here

    for (int x = 0; x < method.params.size(); x++) {
      Type methodParamType = method.params.get(x).type;
      Type supermethodParamType = supermethod.params.get(x).type;
      if (methodParamType.tsym.name.contentEquals(supermethodParamType.tsym.name)
          && !state.getTypes().isSameType(methodParamType, supermethodParamType)) {
        VariableTree param = tree.getParameters().get(x);

        // TODO(user): Name is most likely more qualified than necessary.
        Name replacement = supermethodParamType.tsym.getQualifiedName();
        if (builder == null) {
          builder = SuggestedFix.builder();
        }
        builder.replace(param, replacement + " " + param.getName());
      }
    }

    return (builder != null) ? describeMatch(tree, builder.build()) : describeMatch(tree);
  }
View Full Code Here

       * mismatch between the number of parameters declared and the number supplied.
       *
       * (Use MethodSymbol.isVarArgs.)
       */
      for (int i = 0; i < paramTypes.size() && i < invocation.getArguments().size(); i++) {
        VariableTree formalParam = paramTypes.get(i);
        String formalParamName = formalParam.getName().toString();
        Type formalParamType = getType(formalParam.getType());

        Type availableParamType = availableParams.get(formalParamName);

        ExpressionTree actualParam = invocation.getArguments().get(i);

View Full Code Here

        List<? extends VariableTree> args = node.getParameters();
        List<? extends TypeParameterTree> argTypes = node.getTypeParameters();
        int n = args.size();
        arguments = new MethodArgument[n];
        for (int i = 0; i < n; i++) {
            VariableTree var = args.get(i);
            long startOffset = positions.getStartPosition(tree, var);
            long endOffset = positions.getEndPosition(tree, var);
            arguments[i] = new MethodArgument(var.getName().toString(),
                                              var.getType().toString(),
                                              positionDelegate.createPosition(
                                                (int) startOffset,
                                                (int) lineMap.getLineNumber(startOffset),
                                                (int) lineMap.getColumnNumber(startOffset)),
                                              positionDelegate.createPosition(
View Full Code Here

                getInstanceFound = true;
            }
        }

        if (instanceFound) {
            VariableTree tree = (VariableTree) trees.getTree(instanceElement);
            ExpressionTree initializer = tree.getInitializer();
            if (initializer == null) {
                lazy = true;
            } else {
                lazy = false; //default
            }
View Full Code Here

        }

        final Singleton singletonAnn = singleton.getAnnotation(Singleton.class);
        if (singletonAnn == null) {
            if (singletonAnn.lazy()) {
                VariableTree tree = (VariableTree) trees.getTree(e);
                ExpressionTree initializer = tree.getInitializer();
                if (initializer != null) {
                    msgr.printMessage(Kind.ERROR, "For lazy Singleton initialization you must not inline initialize " + e.getSimpleName(), e);
                }
            }
            new SingletonProcessor().processElement(singleton, ann, true);
View Full Code Here

        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, Arrays.asList("-bootclasspath", bootPath, "-Xjcov"), null, Arrays.asList(new MyFileObject(code)));
        CompilationUnitTree cut = ct.parse().iterator().next();
        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
        MethodTree method = (MethodTree) clazz.getMembers().get(0);
        VariableTree condSt = (VariableTree) method.getBody().getStatements().get(1);
        BinaryTree cond = (BinaryTree) condSt.getInitializer();
        JCTree condJC = (JCTree) cond;

        if (condJC.pos != 93)
            throw new IllegalStateException("Unexpected position=" + condJC.pos);
    }
View Full Code Here

      current.addInterface(iface.toString());
    if (root.getExtendsClause() != null)
      current.setParent(root.getExtendsClause().toString());
    for (Tree member : root.getMembers())
      if (member.getKind() == Tree.Kind.VARIABLE) {
        VariableTree vtree = (VariableTree)member;
        Set<Modifier> mods = vtree.getModifiers().getFlags();
        FieldNode fn = getField(vtree);
        int index = exclusions.indexOf(current);
        if (index >= 0 && exclusions.get(index).fields.contains(fn))
          continue;
        if (mods.contains(Modifier.PUBLIC) || mods.contains(Modifier.PROTECTED))
View Full Code Here

    return ret;
  }

  private VariableTree variableTree() {
     // Checked implicitly in CompilationTestUtils by Tree.Kind parameter
    @SuppressWarnings("unchecked")
    VariableTree ret =
        (VariableTree) MoreTrees.findSubtree(baseTree(), Tree.Kind.VARIABLE, "variable");
    return ret;
  }
View Full Code Here

TOP

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

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.