ASTNode clone0(AST target) { LineComment result = new LineComment(target); result.setSourceRange(getStartPosition(), getLength()); return result; }
@Override int treeSize() { return memSize(); } }
@Override final List internalStructuralPropertiesForType(int apiLevel) { return propertyDescriptors(apiLevel); }
public boolean visit(LineComment node) { int start = node.getStartPosition(); int end = start + node.getLength(); // source is a string representing your source code String comment = source.substring(start, end); System.out.println(comment); return true; }
private String getSpaceAtStart(String source, final LineComment lineComment) { final char firstChar = source.charAt(lineComment.getStartPosition() + "//".length()); return !Character.isWhitespace(firstChar) ? " " : ""; }
/** * Creates and returns a new line comment placeholder node. * <p> * Note that this node type is used to recording the source * range where a comment was found in the source string. * These comment nodes are normally found (only) in * {@linkplain CompilationUnit#getCommentList() * the comment table} for parsed compilation units. * </p> * * @return a new unparented line comment node * @since 3.0 */ public LineComment newLineComment() { LineComment result = new LineComment(this); return result; }
comment.setSourceRange(currentExtendedEnd + 1, 0); int index = Collections.binarySearch(commentList, comment, new Comparator() { public int compare(Object o1, Object o2) {
@Override public boolean visit(LineComment node) { if (node.subtreeMatch(fMatcher, fNodeToMatch)) return matches(node); return super.visit(node); }
private int[] getOffsets() { if (this.offsets == null) { if (this.commentList != null) { int nComments= this.commentList.size(); // count the number of line comments int count= 0; for (int i= 0; i < nComments; i++) { Object curr= this.commentList.get(i); if (curr instanceof LineComment) { count++; } } // fill the offset table this.offsets= new int[count]; for (int i= 0, k= 0; i < nComments; i++) { Object curr= this.commentList.get(i); if (curr instanceof LineComment) { LineComment comment= (LineComment) curr; this.offsets[k++]= comment.getStartPosition() + comment.getLength(); } } } else { this.offsets= Util.EMPTY_INT_ARRAY; } } return this.offsets; }
private void replaceEndsOfBlockCommentFromCommentText( List<TextEdit> commentEdits, LineComment lineComment, String source) { final Matcher matcher = endsOfBlockCommentMatcher(lineComment, source, lineComment.getStartPosition()); while (matcher.find()) { commentEdits.add(new ReplaceEdit(matcher.start(), matcher.end() - matcher.start(), "* /")); } }
/** * Creates and returns a new line comment placeholder node. * <p> * Note that this node type is used to recording the source * range where a comment was found in the source string. * These comment nodes are normally found (only) in * {@linkplain CompilationUnit#getCommentList() * the comment table} for parsed compilation units. * </p> * * @return a new unparented line comment node * @since 3.0 */ public LineComment newLineComment() { LineComment result = new LineComment(this); return result; }
comment.setSourceRange(currentExtendedEnd + 1, 0); int index = Collections.binarySearch(commentList, comment, new Comparator() { public int compare(Object o1, Object o2) {
public boolean visit(LineComment node) { if (node.subtreeMatch(fMatcher, fNodeToMatch)) return matches(node); return super.visit(node); }
ASTNode clone0(AST target) { LineComment result = new LineComment(target); result.setSourceRange(getStartPosition(), getLength()); return result; }
@Override public boolean visit(LineComment node) { _compilationUnit.addComment(new CSLineComment(node.getStartPosition(), getText(node.getStartPosition(), node .getLength()))); return false; }
private void appendCommentTextReplaceEndsOfBlockComment(StringBuilder sb, LineComment lineComment, String source) { final int commentStart = lineComment.getStartPosition(); int nextStart = commentStart + "//".length(); final Matcher matcher = endsOfBlockCommentMatcher(lineComment, source, nextStart); while (matcher.find()) { sb.append(source, nextStart, matcher.start()); sb.append("* /"); nextStart = matcher.end(); } if (source.charAt(nextStart) == '/') { sb.append(' '); } sb.append(source, nextStart, getEndPosition(lineComment)); }
/** * Creates and returns a new line comment placeholder node. * <p> * Note that this node type is used to recording the source * range where a comment was found in the source string. * These comment nodes are normally found (only) in * {@linkplain CompilationUnit#getCommentList() * the comment table} for parsed compilation units. * </p> * * @return a new unparented line comment node * @since 3.0 */ public LineComment newLineComment() { LineComment result = new LineComment(this); return result; }
int treeSize() { return memSize(); } }
final List internalStructuralPropertiesForType(int apiLevel) { return propertyDescriptors(apiLevel); }
node.setSourceRange(startChar, endChar - startChar + 1); commentNodes.put(node, parent, tokens);