private void addToMap(Node positionNode, Node linked) { if (positionNode == null) return; int start = positionNode.getPosition().getStart(); if (start == -1) return; if (linked instanceof JavadocContainer || !nodePositions.containsKey(start)) { nodePositions.put(start, linked); } }
private void addToMap(Node positionNode, Node linked) { if (positionNode == null) return; int start = positionNode.getPosition().getStart(); if (start == -1) return; if (linked instanceof JavadocContainer || !nodePositions.containsKey(start)) { nodePositions.put(start, linked); } }
private static <T extends ASTNode> T posParen(T in, lombok.ast.Node node) { if (in == null) return null; if (node instanceof lombok.ast.Expression) { List<Position> parensPositions = ((lombok.ast.Expression)node).astParensPositions(); if (!parensPositions.isEmpty()) { in.sourceStart = parensPositions.get(parensPositions.size() - 1).getStart(); in.sourceEnd = parensPositions.get(parensPositions.size() - 1).getEnd() - 1; } } return in; }
@Override public boolean visitNode(Node node) { if (node.isGenerated()) return false; int startPos = node.getPosition().getStart(); Node current = startPosMap.get(startPos); if (current == null || !(current instanceof JavadocContainer)) { startPosMap.put(startPos, node); } return false; } });
private boolean isUndocumented(lombok.ast.Node block) { if (block == null) return false; if (rawInput == null) return false; lombok.ast.Position pos = block.getPosition(); if (pos.isUnplaced() || pos.size() < 3) return true; String content = rawInput.substring(pos.getStart() + 1, pos.getEnd() - 1); return content.trim().isEmpty(); } };
private void posParen(Node node, int iteration, java.util.List<Position> parenPositions, JCTree jcTree) { Position p = null; if (parenPositions.size() > iteration) p = parenPositions.get(iteration); int start = (p == null || p.isUnplaced() || p.getStart() < 0) ? node.getPosition().getStart() - 1 - iteration : p.getStart(); int end = (p == null || p.isUnplaced() || p.getEnd() < 0) ? node.getPosition().getEnd() + 1 + iteration : p.getEnd(); setPos(start, end, jcTree); }
private void posParen(Node node, int iteration, java.util.List<Position> parenPositions, JCTree jcTree) { Position p = null; if (parenPositions.size() > iteration) p = parenPositions.get(iteration); int start = (p == null || p.isUnplaced() || p.getStart() < 0) ? node.getPosition().getStart() - 1 - iteration : p.getStart(); int end = (p == null || p.isUnplaced() || p.getEnd() < 0) ? node.getPosition().getEnd() + 1 + iteration : p.getEnd(); setPos(start, end, jcTree); }
@Override public boolean visitComment(Comment node) { String contents = node.astContent(); checkComment(mContext, contents, node.getPosition().getStart(), 0, contents.length()); return super.visitComment(node); } }
@NonNull @Override public Location resolve() { lombok.ast.Position pos = mNode.getPosition(); return Location.create(mFile, null /*contents*/, pos.getStart(), pos.getEnd()); }
private List<JCCase> addCase(List<JCCase> cases, JCExpression currentPat, Node currentNode, List<JCStatement> stats) { JCStatement last = stats.last(); int start = currentNode.getPosition().getStart(); int end = last == null ? currentNode.getPosition().getEnd() : endPosTable.get(last); cases = cases.append(setPos(start, end, treeMaker.Case(currentPat, stats))); return cases; }
private List<JCCase> addCase(List<JCCase> cases, JCExpression currentPat, Node currentNode, List<JCStatement> stats) { JCStatement last = stats.last(); int start = currentNode.getPosition().getStart(); int end = last == null ? currentNode.getPosition().getEnd() : endPosTable.get(last); cases = cases.append(setPos(start, end, treeMaker.Case(currentPat, stats))); return cases; }
@Override public boolean visitAnnotation(Annotation node) { int start = node.getPosition().getStart(); int end = node.getPosition().getEnd(); // Newer javacs //int end = node.astAnnotationTypeReference().getPosition().getEnd(); // Older javacs return set(node, setPos(start, end, treeMaker.Annotation(toTree(node.astAnnotationTypeReference()), toList(JCExpression.class, node.astElements())))); }
@Override public boolean visitAnnotation(Annotation node) { int start = node.getPosition().getStart(); int end = node.getPosition().getEnd(); // Newer javacs //int end = node.astAnnotationTypeReference().getPosition().getEnd(); // Older javacs return set(node, setPos(start, end, treeMaker.Annotation(toTree(node.astAnnotationTypeReference()), toList(JCExpression.class, node.astElements())))); }
@Override public boolean visitImportDeclaration(ImportDeclaration node) { JCExpression name = chain(node.astParts()); if (node.astStarImport()) { int start, end; Position jcDotStarPos = getConversionPositionInfo(node, ".*"); start = jcDotStarPos == null ? posOfStructure(node, ".", true) : jcDotStarPos.getStart(); end = jcDotStarPos == null ? posOfStructure(node, "*", false) : jcDotStarPos.getEnd(); name = setPos(start, end, treeMaker.Select(name, table.asterisk)); } return posSet(node, treeMaker.Import(name, node.astStaticImport())); }
@Override public String process(Source source, Node in) throws ConversionProblem { SourceFormatter formatter = new TextFormatter(); in.accept(new SourcePrinter(formatter)); for (ParseProblem x : source.getProblems()) { formatter.addError(x.getPosition().getStart(), x.getPosition().getEnd(), x.getMessage()); } return formatter.finish(); } };
@Override public String process(Source source, Node in) throws ConversionProblem { SourceFormatter formatter = new HtmlFormatter(source.getRawInput()); in.accept(new SourcePrinter(formatter)); for (ParseProblem x : source.getProblems()) { formatter.addError(x.getPosition().getStart(), x.getPosition().getEnd(), x.getMessage()); } return formatter.finish(); } };
@Override public String process(Source source, Node in) throws ConversionProblem { SourceFormatter formatter = new HtmlFormatter(source.getRawInput()); in.accept(new SourcePrinter(formatter)); for (ParseProblem x : source.getProblems()) { formatter.addError(x.getPosition().getStart(), x.getPosition().getEnd(), x.getMessage()); } return formatter.finish(); } };
public Node createEnhancedFor( org.parboiled.Node<Node> modifiers, Node type, org.parboiled.Node<Node> varDefEntry, Node iterable, Node statement) { VariableDefinition decl = new VariableDefinition().rawTypeReference(type).rawVariables() .addToEnd(varDefEntry.getValue()); positionSpan(decl, modifiers, varDefEntry); decl.astModifiers(createModifiersIfNeeded(modifiers.getValue(), decl.getPosition().getStart())); return posify(new ForEach().rawVariable(decl).rawIterable(iterable).rawStatement(statement)); }
public Node createEnhancedFor( org.parboiled.Node<Node> modifiers, Node type, org.parboiled.Node<Node> varDefEntry, Node iterable, Node statement) { VariableDefinition decl = new VariableDefinition().rawTypeReference(type).rawVariables() .addToEnd(varDefEntry.getValue()); positionSpan(decl, modifiers, varDefEntry); decl.astModifiers(createModifiersIfNeeded(modifiers.getValue(), decl.getPosition().getStart())); return posify(new ForEach().rawVariable(decl).rawIterable(iterable).rawStatement(statement)); }
public Node createCatch(Node modifiers, Node type, Node varName, Node body) { VariableDefinitionEntry varNameEntry = new VariableDefinitionEntry().astName(createIdentifierIfNeeded(varName, currentPos())); if (varName != null) varNameEntry.setPosition(varName.getPosition()); VariableDefinition decl = new VariableDefinition().rawTypeReference(type).rawVariables().addToEnd( varNameEntry); if (type != null && varName != null) decl.setPosition(new Position(type.getPosition().getStart(), varName.getPosition().getEnd())); if (modifiers != null) decl.astModifiers(createModifiersIfNeeded(modifiers, currentPos())); return posify(new Catch().rawExceptionDeclaration(decl).rawBody(body)); }