public String getValue() { return node.getValue(); } }
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(getLength() + 10); sb.append(makeIndent(depth)); sb.append(value); return sb.toString(); }
private void recordComment(int lineno, String comment) { if (scannedComments == null) { scannedComments = new ArrayList<Comment>(); } Comment commentNode = new Comment(ts.tokenBeg, ts.getTokenLength(), ts.commentType, comment); if (ts.commentType == Token.CommentType.JSDOC && compilerEnv.isRecordingLocalJsDocComments()) { currentJsDocComment = commentNode; } commentNode.setLineno(lineno); scannedComments.add(commentNode); }
/** * Add a comment to the comment set. * @param comment the comment node. * @throws IllegalArgumentException if comment is {@code null} */ public void addComment(Comment comment) { assertNotNull(comment); if (comments == null) { comments = new TreeSet<Comment>(new AstNode.PositionComparator()); } comments.add(comment); comment.setParent(this); }
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(getLength() + 10); sb.append(makeIndent(depth)); sb.append(value); return sb.toString(); }
private void recordComment(int lineno, String comment) { if (scannedComments == null) { scannedComments = new ArrayList<Comment>(); } Comment commentNode = new Comment(ts.tokenBeg, ts.getTokenLength(), ts.commentType, comment); if (ts.commentType == Token.CommentType.JSDOC && compilerEnv.isRecordingLocalJsDocComments()) { currentJsDocComment = commentNode; } commentNode.setLineno(lineno); scannedComments.add(commentNode); }
/** * Add a comment to the comment set. * @param comment the comment node. * @throws IllegalArgumentException if comment is {@code null} */ public void addComment(Comment comment) { assertNotNull(comment); if (comments == null) { comments = new TreeSet<Comment>(new AstNode.PositionComparator()); } comments.add(comment); comment.setParent(this); }
public EcmascriptNode<AstRoot> parse(final Reader reader) { try { final List<ParseProblem> parseProblems = new ArrayList<>(); final String sourceCode = IOUtils.toString(reader); final AstRoot astRoot = parseEcmascript(sourceCode, parseProblems); final EcmascriptTreeBuilder treeBuilder = new EcmascriptTreeBuilder(sourceCode, parseProblems); EcmascriptNode<AstRoot> tree = treeBuilder.build(astRoot); suppressMap = new HashMap<>(); if (astRoot.getComments() != null) { for (Comment comment : astRoot.getComments()) { int nopmd = comment.getValue().indexOf(suppressMarker); if (nopmd > -1) { String suppression = comment.getValue().substring(nopmd + suppressMarker.length()); EcmascriptNode<Comment> node = treeBuilder.build(comment); suppressMap.put(node.getBeginLine(), suppression); } } } return tree; } catch (IOException e) { throw new ParseException(e); } }
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(getLength() + 10); sb.append(makeIndent(depth)); sb.append(value); return sb.toString(); }
private void recordComment(int lineno, String comment) { if (scannedComments == null) { scannedComments = new ArrayList<Comment>(); } Comment commentNode = new Comment(ts.tokenBeg, ts.getTokenLength(), ts.commentType, comment); if (ts.commentType == Token.CommentType.JSDOC && compilerEnv.isRecordingLocalJsDocComments()) { currentJsDocComment = commentNode; } commentNode.setLineno(lineno); scannedComments.add(commentNode); }
/** * Add a comment to the comment set. * @param comment the comment node. * @throws IllegalArgumentException if comment is {@code null} */ public void addComment(Comment comment) { assertNotNull(comment); if (comments == null) { comments = new TreeSet<Comment>(new AstNode.PositionComparator()); } comments.add(comment); comment.setParent(this); }
/** * Gets the JsDoc comment string attached to this node. * @return the comment string or {@code null} if no JsDoc is attached to * this node */ public String getJsDoc() { Comment comment = getJsDocNode(); if (comment != null) { return comment.getValue(); } return null; }
@Override public String toSource(int depth) { StringBuilder sb = new StringBuilder(getLength() + 10); sb.append(makeIndent(depth)); sb.append(value); return sb.toString(); }
private void recordComment(int lineno, String comment) { if (scannedComments == null) { scannedComments = new ArrayList<Comment>(); } Comment commentNode = new Comment(ts.tokenBeg, ts.getTokenLength(), ts.commentType, comment); if (ts.commentType == Token.CommentType.JSDOC && compilerEnv.isRecordingLocalJsDocComments()) { currentJsDocComment = commentNode; } commentNode.setLineno(lineno); scannedComments.add(commentNode); }
/** * Add a comment to the comment set. * @param comment the comment node. * @throws IllegalArgumentException if comment is {@code null} */ public void addComment(Comment comment) { assertNotNull(comment); if (comments == null) { comments = new TreeSet<Comment>(new AstNode.PositionComparator()); } comments.add(comment); comment.setParent(this); }
/** * Gets the JsDoc comment string attached to this node. * @return the comment string or {@code null} if no JsDoc is attached to * this node */ public String getJsDoc() { Comment comment = getJsDocNode(); if (comment != null) { return comment.getValue(); } return null; }
/** * Gets the JsDoc comment string attached to this node. * @return the comment string or {@code null} if no JsDoc is attached to * this node */ public String getJsDoc() { Comment comment = getJsDocNode(); if (comment != null) { return comment.getValue(); } return null; }
/** * Gets the JsDoc comment string attached to this node. * @return the comment string or {@code null} if no JsDoc is attached to * this node */ public String getJsDoc() { Comment comment = getJsDocNode(); if (comment != null) { return comment.getValue(); } return null; }
if (root.getComments() != null && !root.getComments().isEmpty()) final String rawHeaderDocs = root.getComments().first().getValue(); jsDoc.set(JsDocParser.parse(getId(), rawHeaderDocs));
@Override public boolean visit(AstNode node) { if (node instanceof AstRoot) return true; else { ITree t = buildTree(node); ITree p = trees.get(node.getParent()); p.addChild(t); if (node instanceof Name) { Name name = (Name) node; t.setLabel(name.getIdentifier()); } else if ( node instanceof StringLiteral) { StringLiteral literal = (StringLiteral) node; t.setLabel(literal.getValue()); } else if ( node instanceof NumberLiteral) { NumberLiteral l = (NumberLiteral) node; t.setLabel(l.getValue()); } else if ( node instanceof Comment) { Comment c = (Comment) node; t.setLabel(c.getValue()); } return true; } }