/** * Builds a NavigableMap containing all of the given compilation unit's top-level nodes * (package declaration, import declarations, type declarations, and non-doc comments), * keyed by start position. */ private static NavigableMap<Integer, ASTNode> mapTopLevelNodes(CompilationUnit compilationUnit) { NavigableMap<Integer, ASTNode> map = new TreeMap<Integer, ASTNode>(); Collection<ASTNode> nodes = new ArrayList<ASTNode>(); if (compilationUnit.getPackage() != null) { nodes.add(compilationUnit.getPackage()); } nodes.addAll(compilationUnit.imports()); nodes.addAll(compilationUnit.types()); for (Comment comment : ((List<Comment>) compilationUnit.getCommentList())) { // Include only top-level (non-doc) comments; // doc comments are contained within their parent nodes' ranges. if (comment.getParent() == null) { nodes.add(comment); } } for (ASTNode node : nodes) { map.put(node.getStartPosition(), node); } return map; }
private Iterable<Comment> unAssignedComments(final CompilationUnit cu) { final Function1<Comment, Boolean> _function = (Comment c) -> { return Boolean.valueOf(((!(c.isDocComment() && (c.getParent() != null))) && this.notAssigned(c))); }; return IterableExtensions.<Comment>filter(cu.getCommentList(), _function); }
/** * Builds a NavigableMap containing all of the given compilation unit's top-level nodes * (package declaration, import declarations, type declarations, and non-doc comments), * keyed by start position. */ private static NavigableMap<Integer, ASTNode> mapTopLevelNodes(CompilationUnit compilationUnit) { NavigableMap<Integer, ASTNode> map = new TreeMap<Integer, ASTNode>(); Collection<ASTNode> nodes = new ArrayList<ASTNode>(); if (compilationUnit.getPackage() != null) { nodes.add(compilationUnit.getPackage()); } nodes.addAll(compilationUnit.imports()); nodes.addAll(compilationUnit.types()); for (Comment comment : ((List<Comment>) compilationUnit.getCommentList())) { // Include only top-level (non-doc) comments; // doc comments are contained within their parent nodes' ranges. if (comment.getParent() == null) { nodes.add(comment); } } for (ASTNode node : nodes) { map.put(node.getStartPosition(), node); } return map; }
/** * Builds a NavigableMap containing all of the given compilation unit's top-level nodes * (package declaration, import declarations, type declarations, and non-doc comments), * keyed by start position. */ private static NavigableMap<Integer, ASTNode> mapTopLevelNodes(CompilationUnit compilationUnit) { NavigableMap<Integer, ASTNode> map = new TreeMap<Integer, ASTNode>(); Collection<ASTNode> nodes = new ArrayList<ASTNode>(); if (compilationUnit.getPackage() != null) { nodes.add(compilationUnit.getPackage()); } nodes.addAll(compilationUnit.imports()); nodes.addAll(compilationUnit.types()); for (Comment comment : ((List<Comment>) compilationUnit.getCommentList())) { // Include only top-level (non-doc) comments; // doc comments are contained within their parent nodes' ranges. if (comment.getParent() == null) { nodes.add(comment); } } for (ASTNode node : nodes) { map.put(node.getStartPosition(), node); } return map; }
int treeSize() { int size = memSize(); if (this.optionalPackageDeclaration != null) { size += getPackage().treeSize(); } size += this.imports.listSize(); size += this.types.listSize(); // include disconnected comments if (this.optionalCommentList != null) { for (int i = 0; i < this.optionalCommentList.size(); i++) { Comment comment = (Comment) this.optionalCommentList.get(i); if (comment != null && comment.getParent() == null) { size += comment.treeSize(); } } } return size; }
int treeSize() { int size = memSize(); if (this.optionalPackageDeclaration != null) { size += getPackage().treeSize(); } size += this.imports.listSize(); size += this.types.listSize(); // include disconnected comments if (this.optionalCommentList != null) { for (int i = 0; i < this.optionalCommentList.size(); i++) { Comment comment = (Comment) this.optionalCommentList.get(i); if (comment != null && comment.getParent() == null) { size += comment.treeSize(); } } } return size; }
private Javadoc convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc) { Javadoc docComment = null; if (javadoc != null) { if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) { this.commentMapper = new DefaultCommentMapper(this.commentsTable); } Comment comment = this.commentMapper.getComment(javadoc.sourceStart); if (comment != null && comment.isDocComment() && comment.getParent() == null) { docComment = (Javadoc) comment; if (this.resolveBindings) { recordNodes(docComment, javadoc); // resolve member and method references binding Iterator tags = docComment.tags().listIterator(); while (tags.hasNext()) { recordNodes(javadoc, (TagElement) tags.next()); } } } } return docComment; } public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, BodyDeclaration bodyDeclaration) {
int treeSize() { int size = memSize(); if (this.optionalPackageDeclaration != null) { size += getPackage().treeSize(); } size += this.imports.listSize(); size += this.types.listSize(); // include disconnected comments if (this.optionalCommentList != null) { for (int i = 0; i < this.optionalCommentList.size(); i++) { Comment comment = (Comment) this.optionalCommentList.get(i); if (comment != null && comment.getParent() == null) { size += comment.treeSize(); } } } return size; }
int treeSize() { int size = memSize(); if (this.optionalPackageDeclaration != null) { size += getPackage().treeSize(); } size += this.imports.listSize(); size += this.types.listSize(); // include disconnected comments if (this.optionalCommentList != null) { for (int i = 0; i < this.optionalCommentList.size(); i++) { Comment comment = (Comment) this.optionalCommentList.get(i); if (comment != null && comment.getParent() == null) { size += comment.treeSize(); } } } return size; }
private Javadoc convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc) { Javadoc docComment = null; if (javadoc != null) { if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) { this.commentMapper = new DefaultCommentMapper(this.commentsTable); } Comment comment = this.commentMapper.getComment(javadoc.sourceStart); if (comment != null && comment.isDocComment() && comment.getParent() == null) { docComment = (Javadoc) comment; if (this.resolveBindings) { recordNodes(docComment, javadoc); // resolve member and method references binding Iterator tags = docComment.tags().listIterator(); while (tags.hasNext()) { recordNodes(javadoc, (TagElement) tags.next()); } } } } return docComment; } public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, BodyDeclaration bodyDeclaration) {
protected IValue convertToM3(LimitedTypeStore store, Map<String, ISourceLocation> cache, ISourceLocation loc, CompilationUnit cu) { SourceConverter converter = new SourceConverter(store, cache); converter.convert(cu, cu, loc); for (Object cm: cu.getCommentList()) { Comment comment = (Comment)cm; // Issue 720: changed condition to only visit comments without a parent (includes line, block and misplaced javadoc comments). if (comment.getParent() != null) continue; converter.convert(cu, comment, loc); } return converter.getModel(true); }
public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, BodyDeclaration bodyDeclaration) { if (bodyDeclaration.getJavadoc() == null) { if (javadoc != null) { if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) { this.commentMapper = new DefaultCommentMapper(this.commentsTable); } Comment comment = this.commentMapper.getComment(javadoc.sourceStart); if (comment != null && comment.isDocComment() && comment.getParent() == null) { Javadoc docComment = (Javadoc) comment; if (this.resolveBindings) { recordNodes(docComment, javadoc); // resolve member and method references binding Iterator tags = docComment.tags().listIterator(); while (tags.hasNext()) { recordNodes(javadoc, (TagElement) tags.next()); } } bodyDeclaration.setJavadoc(docComment); } } } }
public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, PackageDeclaration packageDeclaration) { if (this.ast.apiLevel == AST.JLS3 && packageDeclaration.getJavadoc() == null) { if (javadoc != null) { if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) { this.commentMapper = new DefaultCommentMapper(this.commentsTable); } Comment comment = this.commentMapper.getComment(javadoc.sourceStart); if (comment != null && comment.isDocComment() && comment.getParent() == null) { Javadoc docComment = (Javadoc) comment; if (this.resolveBindings) { recordNodes(docComment, javadoc); // resolve member and method references binding Iterator tags = docComment.tags().listIterator(); while (tags.hasNext()) { recordNodes(javadoc, (TagElement) tags.next()); } } packageDeclaration.setJavadoc(docComment); } } } }
public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, BodyDeclaration bodyDeclaration) { if (bodyDeclaration.getJavadoc() == null) { if (javadoc != null) { if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) { this.commentMapper = new DefaultCommentMapper(this.commentsTable); } Comment comment = this.commentMapper.getComment(javadoc.sourceStart); if (comment != null && comment.isDocComment() && comment.getParent() == null) { Javadoc docComment = (Javadoc) comment; if (this.resolveBindings) { recordNodes(docComment, javadoc); // resolve member and method references binding Iterator tags = docComment.tags().listIterator(); while (tags.hasNext()) { recordNodes(javadoc, (TagElement) tags.next()); } } bodyDeclaration.setJavadoc(docComment); } } } }
public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, BodyDeclaration bodyDeclaration) { if (bodyDeclaration.getJavadoc() == null) { if (javadoc != null) { if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) { this.commentMapper = new DefaultCommentMapper(this.commentsTable); } Comment comment = this.commentMapper.getComment(javadoc.sourceStart); if (comment != null && comment.isDocComment() && comment.getParent() == null) { Javadoc docComment = (Javadoc) comment; if (this.resolveBindings) { recordNodes(docComment, javadoc); // resolve member and method references binding Iterator tags = docComment.tags().listIterator(); while (tags.hasNext()) { recordNodes(javadoc, (TagElement) tags.next()); } } bodyDeclaration.setJavadoc(docComment); } } } }
int treeSize() { int size = memSize(); if (this.module != null) { size += getModule().treeSize(); } if (this.optionalPackageDeclaration != null) { size += getPackage().treeSize(); } size += this.imports.listSize(); size += this.types.listSize(); // include disconnected comments if (this.optionalCommentList != null) { for (int i = 0; i < this.optionalCommentList.size(); i++) { Comment comment = (Comment) this.optionalCommentList.get(i); if (comment != null && comment.getParent() == null) { size += comment.treeSize(); } } } return size; }
public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, BodyDeclaration bodyDeclaration) { if (bodyDeclaration.getJavadoc() == null) { if (javadoc != null) { if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) { this.commentMapper = new DefaultCommentMapper(this.commentsTable); } Comment comment = this.commentMapper.getComment(javadoc.sourceStart); if (comment != null && comment.isDocComment() && comment.getParent() == null) { Javadoc docComment = (Javadoc) comment; if (this.resolveBindings) { recordNodes(docComment, javadoc); // resolve member and method references binding Iterator tags = docComment.tags().listIterator(); while (tags.hasNext()) { recordNodes(javadoc, (TagElement) tags.next()); } } bodyDeclaration.setJavadoc(docComment); } } } }
public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, PackageDeclaration packageDeclaration) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : return; } if (packageDeclaration.getJavadoc() == null) { if (javadoc != null) { if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) { this.commentMapper = new DefaultCommentMapper(this.commentsTable); } Comment comment = this.commentMapper.getComment(javadoc.sourceStart); if (comment != null && comment.isDocComment() && comment.getParent() == null) { Javadoc docComment = (Javadoc) comment; if (this.resolveBindings) { recordNodes(docComment, javadoc); // resolve member and method references binding Iterator tags = docComment.tags().listIterator(); while (tags.hasNext()) { recordNodes(javadoc, (TagElement) tags.next()); } } packageDeclaration.setJavadoc(docComment); } } } }
public void convert(org.eclipse.jdt.internal.compiler.ast.Javadoc javadoc, PackageDeclaration packageDeclaration) { switch(this.ast.apiLevel) { case AST.JLS2_INTERNAL : return; } if (packageDeclaration.getJavadoc() == null) { if (javadoc != null) { if (this.commentMapper == null || !this.commentMapper.hasSameTable(this.commentsTable)) { this.commentMapper = new DefaultCommentMapper(this.commentsTable); } Comment comment = this.commentMapper.getComment(javadoc.sourceStart); if (comment != null && comment.isDocComment() && comment.getParent() == null) { Javadoc docComment = (Javadoc) comment; if (this.resolveBindings) { recordNodes(docComment, javadoc); // resolve member and method references binding Iterator tags = docComment.tags().listIterator(); while (tags.hasNext()) { recordNodes(javadoc, (TagElement) tags.next()); } } packageDeclaration.setJavadoc(docComment); } } } }
@Override int treeSize() { int size = memSize(); if (this.module != null) { size += getModule().treeSize(); } if (this.optionalPackageDeclaration != null) { size += getPackage().treeSize(); } size += this.imports.listSize(); size += this.types.listSize(); // include disconnected comments if (this.optionalCommentList != null) { for (int i = 0; i < this.optionalCommentList.size(); i++) { Comment comment = (Comment) this.optionalCommentList.get(i); if (comment != null && comment.getParent() == null) { size += comment.treeSize(); } } } return size; }