public final class FileContents extends Object implements CommentListener
| Constructor and Description |
|---|
FileContents(FileText text)
Creates a new
FileContents instance. |
| Modifier and Type | Method and Description |
|---|---|
Map<Integer,List<TextBlock>> |
getBlockComments()
Returns a map of all block comments.
|
String |
getFileName()
Gets the name of the file.
|
TextBlock |
getJavadocBefore(int lineNoBefore)
Returns the Javadoc comment before the specified line.
|
String |
getLine(int index)
Get the line from text of the file.
|
String[] |
getLines()
Gets the lines in the file.
|
Map<Integer,TextBlock> |
getSingleLineComments()
Returns a map of all the single line comments.
|
FileText |
getText()
Get the full text of the file.
|
boolean |
hasIntersectionWithComment(int startLineNo,
int startColNo,
int endLineNo,
int endColNo)
Checks if the specified position intersects with a comment.
|
boolean |
inPackageInfo()
Checks if the current file is a package-info.java file.
|
boolean |
lineIsBlank(int lineNo)
Checks if the specified line is blank.
|
boolean |
lineIsComment(int lineNo)
Checks if the specified line is a single-line comment without code.
|
void |
reportBlockComment(int startLineNo,
int startColNo,
int endLineNo,
int endColNo)
Report the location of a block comment.
|
void |
reportBlockComment(String type,
int startLineNo,
int startColNo,
int endLineNo,
int endColNo)
Report the location of a block comment that can span multiple lines.
|
void |
reportSingleLineComment(int startLineNo,
int startColNo)
Report the location of a single line comment.
|
void |
reportSingleLineComment(String type,
int startLineNo,
int startColNo)
Report the location of a single line comment that extends from the
given point to the end of the line.
|
public FileContents(FileText text)
FileContents instance.text - the contents of the filepublic FileText getText()
public String getLine(int index)
index - index of the linepublic String getFileName()
public void reportSingleLineComment(String type, int startLineNo, int startColNo)
CommentListenerreportSingleLineComment in interface CommentListenertype - an identifier for what type of comment it is.startLineNo - the starting line numberstartColNo - the starting column numberpublic void reportSingleLineComment(int startLineNo, int startColNo)
startLineNo - the starting line numberstartColNo - the starting column numberpublic void reportBlockComment(String type, int startLineNo, int startColNo, int endLineNo, int endColNo)
CommentListenerreportBlockComment in interface CommentListenertype - an identifier for what type of comment it is.startLineNo - the starting line numberstartColNo - the starting column numberendLineNo - the ending line numberendColNo - the ending column numberpublic void reportBlockComment(int startLineNo, int startColNo, int endLineNo, int endColNo)
startLineNo - the starting line numberstartColNo - the starting column numberendLineNo - the ending line numberendColNo - the ending column numberpublic TextBlock getJavadocBefore(int lineNoBefore)
null means there is no such comment.lineNoBefore - the line number to check beforenull if nonepublic boolean lineIsBlank(int lineNo)
lineNo - the line number to checkpublic boolean lineIsComment(int lineNo)
lineNo - the line number to checkpublic boolean hasIntersectionWithComment(int startLineNo, int startColNo, int endLineNo, int endColNo)
startLineNo - the starting line numberstartColNo - the starting column numberendLineNo - the ending line numberendColNo - the ending column numberpublic Map<Integer,TextBlock> getSingleLineComments()
TextBlock at the line.public Map<Integer,List<TextBlock>> getBlockComments()
List of block comment TextBlocks
that start at that line.public boolean inPackageInfo()
Copyright © 2001–2020. All rights reserved.