/** * Adapt the any comments to the roo interface * * @param parserNode The antlr-java-parser node from which the comments will * be read * @param commentStructure The roo structure from which to retrieve comments * @return List of comments from the antlr-java-parser package */ public static void updateCommentsToRoo(final CommentStructure commentStructure, final Node parserNode) { // Nothing to do here if (parserNode == null || commentStructure == null) { return; } commentStructure.setBeginComments(adaptToRooComments(parserNode.getBeginComments())); commentStructure.setInternalComments(adaptToRooComments(parserNode.getInternalComments())); commentStructure.setEndComments(adaptToRooComments(parserNode.getEndComments())); }
/** * Adapt the any comments to the antlr-java-parser interface * * @param parserNode The antlr-java-parser node to where the comments will * be set * @param commentStructure The roo structure from which to retrieve comments * @return List of comments from the antlr-java-parser package */ public static void updateCommentsToJavaParser(final Node parserNode, final CommentStructure commentStructure) { // Nothing to do here if (parserNode == null || commentStructure == null) { return; } parserNode.setBeginComments(adaptComments(commentStructure.getBeginComments())); parserNode.setInternalComments(adaptComments(commentStructure.getInternalComments())); parserNode.setEndComments(adaptComments(commentStructure.getEndComments())); }
if (node.getBeginComments() != null) { node.getBeginComments().addAll(beginCommentList); } else { node.setBeginComments(beginCommentList); if (node.getEndComments() != null) { node.getEndComments().addAll(endCommentList); } else { node.setEndComments(endCommentList);
public static void setPosition(Node node, ParserRuleContext ctx) { int beginLine = ctx.getStart().getLine(); int beginColumn = ctx.getStart().getCharPositionInLine(); int endLine = ctx.getStop().getLine(); int endTokenLength = ctx.getStop().getStopIndex() - ctx.getStop().getStartIndex(); int endColumn = ctx.getStop().getCharPositionInLine() + endTokenLength; node.setBeginLine(beginLine); node.setBeginColumn(beginColumn); node.setEndLine(endLine); node.setEndColumn(endColumn); node.setBeginIndex(ctx.getStart().getStartIndex()); node.setEndIndex(ctx.getStop().getStopIndex()); }
if (node.getInternalComments() != null) { node.getInternalComments().addAll(internalCommentList); } else { node.setInternalComments(internalCommentList);
private <T extends Node> boolean nodeEquals(T n1, T n2) { if (n1 == n2) { return true; } if (n1 == null) { if (n2 == null) { return true; } return false; } else if (n2 == null) { return false; } if (n1.getClass() != n2.getClass()) { return false; } return n1.accept(this, n2).booleanValue(); }
if (node.getBeginComments() != null) { node.getBeginComments().addAll(beginCommentList); } else { node.setBeginComments(beginCommentList); if (node.getEndComments() != null) { node.getEndComments().addAll(endCommentList); } else { node.setEndComments(endCommentList);
public static void setPosition(Node node, ParserRuleContext ctx) { int beginLine = ctx.getStart().getLine(); int beginColumn = ctx.getStart().getCharPositionInLine(); int endLine = ctx.getStop().getLine(); int endTokenLength = ctx.getStop().getStopIndex() - ctx.getStop().getStartIndex(); int endColumn = ctx.getStop().getCharPositionInLine() + endTokenLength; node.setBeginLine(beginLine); node.setBeginColumn(beginColumn); node.setEndLine(endLine); node.setEndColumn(endColumn); node.setBeginIndex(ctx.getStart().getStartIndex()); node.setEndIndex(ctx.getStop().getStopIndex()); }
if (node.getInternalComments() != null) { node.getInternalComments().addAll(internalCommentList); } else { node.setInternalComments(internalCommentList);
private <T extends Node> boolean nodeEquals(T n1, T n2) { if (n1 == n2) { return true; } if (n1 == null) { if (n2 == null) { return true; } return false; } else if (n2 == null) { return false; } if (n1.getClass() != n2.getClass()) { return false; } return n1.accept(this, n2).booleanValue(); }
/** * Return the String representation of this node. * * @return the String representation of this node */ @Override public final String toString() { DumpVisitor visitor = new DumpVisitor(); accept(visitor, null); return visitor.getSource(); }
/** * Return the String representation of this node. * * @return the String representation of this node */ @Override public final String toString() { DumpVisitor visitor = new DumpVisitor(); accept(visitor, null); return visitor.getSource(); }