/** Tokenizes as little of the {@code tree} as possible to ensure we grab all the annotations. */ private static ImmutableList<ErrorProneToken> annotationTokens( Tree tree, VisitorState state, int annotationEnd) { int endPos; if (tree instanceof JCMethodDecl) { JCMethodDecl methodTree = (JCMethodDecl) tree; endPos = methodTree.getBody() == null ? state.getEndPosition(methodTree) : methodTree.getBody().getStartPosition(); } else if (tree instanceof JCVariableDecl) { endPos = ((JCVariableDecl) tree).getType().getStartPosition(); } else if (tree instanceof JCClassDecl) { JCClassDecl classTree = (JCClassDecl) tree; endPos = classTree.getMembers().isEmpty() ? state.getEndPosition(classTree) : classTree.getMembers().get(0).getStartPosition(); } else { throw new AssertionError(); } return ErrorProneTokens.getTokens( state.getSourceCode().subSequence(annotationEnd, endPos).toString(), state.context); }
if (catchTree.getParameter().getType().getKind() == Kind.UNION_TYPE) { String.format( "assertThrows(%s.class, () -> ", state.getSourceForNode(catchTree.getParameter().getType()))) .replace(endPosition, state.getEndPosition(catchTree), (expression ? "" : "}") + ");\n"); } else { String.format( " = assertThrows(%s.class, () -> ", state.getSourceForNode(catchTree.getParameter().getType()))) .replace(
if (var.sym.getModifiers() != null && var.sym.getModifiers().contains(Modifier.PUBLIC) && var.sym.getModifiers().contains(Modifier.STATIC)) { commentLines.add("@property {" + getMappedDocType(context, var.getType(), var.getType().type) + "} " + var.getName().toString()); Comment varComment = compilationUnit.docComments.getComment(var);
&& newT.hasTag(Tag.VARDEF) && ((JCVariableDecl)newT).getType() != null; if (handleImplicitLambda) { tokenSequence.move(getOldPos(parent));
JCTree.JCExpression initializer = vd.getInitializer(); JCTree.JCExpression nameExpression = vd.getNameExpression(); JCTree typeTree = vd.getType(); JCTree.JCModifiers modifiers = vd.getModifiers(); final String fieldModifier = parseModifiers(context, modifiers);
if (catchTree.getParameter().getType().getKind() == Kind.UNION_TYPE) { String.format( "assertThrows(%s.class, () -> ", state.getSourceForNode(catchTree.getParameter().getType()))) .replace(endPosition, state.getEndPosition(catchTree), (expression ? "" : "}") + ");\n"); } else { String.format( " = assertThrows(%s.class, () -> ", state.getSourceForNode(catchTree.getParameter().getType()))) .replace(
/** Tokenizes as little of the {@code tree} as possible to ensure we grab all the annotations. */ private static ImmutableList<ErrorProneToken> annotationTokens( Tree tree, VisitorState state, int annotationEnd) { int endPos; if (tree instanceof JCMethodDecl) { JCMethodDecl methodTree = (JCMethodDecl) tree; endPos = methodTree.getBody() == null ? state.getEndPosition(methodTree) : methodTree.getBody().getStartPosition(); } else if (tree instanceof JCVariableDecl) { endPos = ((JCVariableDecl) tree).getType().getStartPosition(); } else if (tree instanceof JCClassDecl) { JCClassDecl classTree = (JCClassDecl) tree; endPos = classTree.getMembers().isEmpty() ? state.getEndPosition(classTree) : classTree.getMembers().get(0).getStartPosition(); } else { throw new AssertionError(); } return ErrorProneTokens.getTokens( state.getSourceCode().subSequence(annotationEnd, endPos).toString(), state.context); }
@Override public void visitVarDef(JCTree.JCVariableDecl jcVariableDecl) { if ("int".equals(jcVariableDecl.getType().toString())) { int id = Integer.valueOf(jcVariableDecl.getInitializer().toString()); String resourceName = jcVariableDecl.getName().toString(); QualifiedId qualifiedId = new QualifiedId( this.respectivePackageName, this.className.toString(), jcVariableDecl.getName().toString(), id ); this.ids.put(qualifiedId, new Id(id, this.className, resourceName)); } }
@Override public void visitVarDef(JCTree.JCVariableDecl jcVariableDecl) { if ("int".equals(jcVariableDecl.getType().toString())) { int id = Integer.valueOf(jcVariableDecl.getInitializer().toString()); String resourceName = jcVariableDecl.getName().toString(); QualifiedId qualifiedId = new QualifiedId(respectivePackageName, id); ids.put(qualifiedId, new Id(id, className, resourceName)); } } }
substituteAndPrintType(catcher.param.getType()); print(">__e;").println();