Class VisitorComments
java.lang.Object
org.eclipse.jdt.core.dom.ASTVisitor
fr.inria.verveine.extractor.java.visitors.GetVisitedEntityAbstractVisitor
fr.inria.verveine.extractor.java.visitors.defvisitors.VisitorComments
A class to collect all comments.
Some important details on comments in JDT:
- only JavaDoc comment are associated to any entity node in the AST (the entity immediately after the javadoc)
- The
startPositionof a node with a JavaDoc is actually thestartPositionof the JavaDoc (ie. the JavaDoc is considered to be part of the entity declaration) - line and block comment are recorded in a list, but we have to decide to what entity they will be associated. We put them in the method containing them or in the method or attribute immediately after them if they are outside a method
- content (text) of block or line comments is not stored, only their position and length. We have to recover them from the source file
- if it is a JavaDoc, gets its associated node
- if not javadoc, finds out if it is in a method or not
- if not, it find the class, method, or attribute that comes immediately after the comment
- if in a method, it associates the comment to this method
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<org.eclipse.jdt.core.dom.Comment> list of all comments in the compilation unitprotected booleanWhether we are defining a class member or not
Used to differentiate attribute declarations from other variable declarationsprotected Stringprotected intprotected intIndice inallCommentsof next comment to deal with (ie.protected BufferedReaderFields inherited from class GetVisitedEntityAbstractVisitor
anonymousSuperTypeName, context, dico, options -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassignCommentsBefore(org.eclipse.jdt.core.dom.ASTNode node, org.eclipse.jdt.core.dom.Javadoc optionalJavadoc, TWithComments fmx) Assigns all "pending" comments to the Famix entity.
Pending comments are those not treated that appear before thenodeassociated with the Famix entity.
optionalJavadocis an optional Javadoc comment (!) that could be associated to thenode.protected voidassignCommentsInInterval(int start, int end, TWithComments fmx) Assigns to the Famix entity all "pending" comments that appear within the interval [start ; stop]protected voidassignCommentsInside(org.eclipse.jdt.core.dom.ASTNode node, TWithComments fmx) Assigns all "pending" comments that appear with the Famix entity (actually within thenodeassociated to it)protected voidprotected booleancommentIsInside(org.eclipse.jdt.core.dom.Comment cmt, int start, int end) whethercmtappears inside interval [ start ; end ]voidendVisit(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration node) voidendVisit(org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration node) voidendVisit(org.eclipse.jdt.core.dom.AnonymousClassDeclaration node) voidendVisit(org.eclipse.jdt.core.dom.CompilationUnit node) voidendVisit(org.eclipse.jdt.core.dom.EnumDeclaration node) voidendVisit(org.eclipse.jdt.core.dom.ImplicitTypeDeclaration node) voidendVisit(org.eclipse.jdt.core.dom.Initializer node) voidendVisit(org.eclipse.jdt.core.dom.MethodDeclaration node) voidendVisit(org.eclipse.jdt.core.dom.RecordDeclaration node) voidendVisit(org.eclipse.jdt.core.dom.TypeDeclaration node) protected StringgetFileContent(int start, int lenghtToRead) protected voidinitializeCommentsReader(org.eclipse.jdt.core.dom.CompilationUnit node) protected booleanWhether there is still some "pending" commentsbooleanvisit(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration node) booleanvisit(org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration node) booleanvisit(org.eclipse.jdt.core.dom.AnonymousClassDeclaration node) AnonymousClassDeclaration appear within a method, we deal first with all "pending" comments that appear before the AnonymousClassDeclaration and should be associated with the method and not anonymous classbooleanvisit(org.eclipse.jdt.core.dom.CompilationUnit node) booleanvisit(org.eclipse.jdt.core.dom.EnumDeclaration node) booleanvisit(org.eclipse.jdt.core.dom.ImplicitTypeDeclaration node) booleanvisit(org.eclipse.jdt.core.dom.Initializer node) booleanvisit(org.eclipse.jdt.core.dom.MethodDeclaration node) booleanvisit(org.eclipse.jdt.core.dom.RecordDeclaration node) booleanvisit(org.eclipse.jdt.core.dom.TypeDeclaration node) booleanvisit(org.eclipse.jdt.core.dom.VariableDeclarationFragment node) Methods inherited from class GetVisitedEntityAbstractVisitor
addAssociationSourceAnchor, ctxtPushInitializerMethod, endVisitAbstractTypeDeclaration, endVisitAnnotationTypeDeclaration, endVisitAnonymousClassDeclaration, endVisitCompilationUnit, endVisitEnumConstantDeclaration, endVisitEnumDeclaration, endVisitFieldDeclaration, endVisitInitializer, endVisitMethodDeclaration, endVisitTypeDeclaration, endVisitTypeDeclaration, endVisitTypeDeclaration, endVisitTypeDeclaration, endVisitTypeDeclaration, getAnonymousSuperTypeName, hasInitBlock, possiblyAnonymousClassDeclaration, typeName, visit, visit, visitAnnotationTypeDeclaration, visitAnnotationTypeMemberDeclaration, visitAnonymousClassDeclaration, visitCompilationUnit, visitEnumConstantDeclaration, visitEnumDeclaration, visitInitializer, visitMethodDeclaration, visitNodeList, visitTypeDeclarationMethods inherited from class org.eclipse.jdt.core.dom.ASTVisitor
endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, postVisit, preVisit, preVisit2, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
-
Field Details
-
allComments
list of all comments in the compilation unit -
nextComment
protected int nextCommentIndice inallCommentsof next comment to deal with (ie. associate with a Famix entity). -
classMemberDeclarations
protected boolean classMemberDeclarationsWhether we are defining a class member or not
Used to differentiate attribute declarations from other variable declarations -
currentFilename
-
openedFile
-
lastPositionRead
protected int lastPositionRead
-
-
Constructor Details
-
VisitorComments
-
-
Method Details
-
visit
public boolean visit(org.eclipse.jdt.core.dom.CompilationUnit node) - Overrides:
visitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
endVisit
public void endVisit(org.eclipse.jdt.core.dom.CompilationUnit node) - Overrides:
endVisitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
visit
public boolean visit(org.eclipse.jdt.core.dom.TypeDeclaration node) - Overrides:
visitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
endVisit
public void endVisit(org.eclipse.jdt.core.dom.TypeDeclaration node) - Overrides:
endVisitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
visit
public boolean visit(org.eclipse.jdt.core.dom.ImplicitTypeDeclaration node) - Overrides:
visitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
endVisit
public void endVisit(org.eclipse.jdt.core.dom.ImplicitTypeDeclaration node) - Overrides:
endVisitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
visit
public boolean visit(org.eclipse.jdt.core.dom.RecordDeclaration node) - Overrides:
visitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
endVisit
public void endVisit(org.eclipse.jdt.core.dom.RecordDeclaration node) - Overrides:
endVisitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
visit
public boolean visit(org.eclipse.jdt.core.dom.AnonymousClassDeclaration node) AnonymousClassDeclaration appear within a method, we deal first with all "pending" comments that appear before the AnonymousClassDeclaration and should be associated with the method and not anonymous class- Overrides:
visitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
endVisit
public void endVisit(org.eclipse.jdt.core.dom.AnonymousClassDeclaration node) - Overrides:
endVisitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
visit
public boolean visit(org.eclipse.jdt.core.dom.EnumDeclaration node) - Overrides:
visitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
endVisit
public void endVisit(org.eclipse.jdt.core.dom.EnumDeclaration node) - Overrides:
endVisitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
visit
public boolean visit(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration node) - Overrides:
visitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
endVisit
public void endVisit(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration node) - Overrides:
endVisitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
visit
public boolean visit(org.eclipse.jdt.core.dom.MethodDeclaration node) - Overrides:
visitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
endVisit
public void endVisit(org.eclipse.jdt.core.dom.MethodDeclaration node) - Overrides:
endVisitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
visit
public boolean visit(org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration node) - Overrides:
visitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
endVisit
public void endVisit(org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration node) - Overrides:
endVisitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
visit
public boolean visit(org.eclipse.jdt.core.dom.Initializer node) - Overrides:
visitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
endVisit
public void endVisit(org.eclipse.jdt.core.dom.Initializer node) - Overrides:
endVisitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
visit
public boolean visit(org.eclipse.jdt.core.dom.VariableDeclarationFragment node) - Overrides:
visitin classorg.eclipse.jdt.core.dom.ASTVisitor
-
assignCommentsBefore
protected void assignCommentsBefore(org.eclipse.jdt.core.dom.ASTNode node, org.eclipse.jdt.core.dom.Javadoc optionalJavadoc, TWithComments fmx) Assigns all "pending" comments to the Famix entity.
Pending comments are those not treated that appear before thenodeassociated with the Famix entity.
optionalJavadocis an optional Javadoc comment (!) that could be associated to thenode. If this is the case, the realstartPositionof thenodemust be incremented of the length of the javadoc because this one is considered part of thenode. -
assignCommentsInside
Assigns all "pending" comments that appear with the Famix entity (actually within thenodeassociated to it) -
assignCommentsInInterval
Assigns to the Famix entity all "pending" comments that appear within the interval [start ; stop] -
pendingComments
protected boolean pendingComments()Whether there is still some "pending" comments -
commentIsInside
protected boolean commentIsInside(org.eclipse.jdt.core.dom.Comment cmt, int start, int end) whethercmtappears inside interval [ start ; end ] -
initializeCommentsReader
protected void initializeCommentsReader(org.eclipse.jdt.core.dom.CompilationUnit node) -
getFileContent
-
closeFile
protected void closeFile()
-