public final class FileContents extends Object implements CommentListener
Constructor and Description |
---|
FileContents(FileText text)
Creates a new
FileContents instance. |
FileContents(String filename,
String... lines)
Deprecated.
Use
FileContents(FileText) instead
in order to preserve the original line breaks where possible. |
Modifier and Type | Method and Description |
---|---|
Map<Integer,List<TextBlock>> |
getBlockComments()
Returns a map of all block comments.
|
Map<Integer,List<TextBlock>> |
getCComments()
Deprecated.
Use
getBlockComments() instead. |
Map<Integer,TextBlock> |
getCppComments()
Deprecated.
Use
getSingleLineComments() instead. |
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(String type,
int startLineNo,
int startColNo,
int endLineNo,
int endColNo)
Report the location of a block comment that can span multiple lines.
|
void |
reportCComment(int startLineNo,
int startColNo,
int endLineNo,
int endColNo)
Deprecated.
Use
reportBlockComment(int, int, int, int) instead. |
void |
reportCppComment(int startLineNo,
int startColNo)
Deprecated.
Use
reportSingleLineComment(int, int) instead. |
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.
|
@Deprecated public FileContents(String filename, String... lines)
FileContents(FileText)
instead
in order to preserve the original line breaks where possible.FileContents
instance.filename
- name of the filelines
- the contents of the filepublic FileContents(FileText text)
FileContents
instance.text
- the contents of the filepublic void reportSingleLineComment(String type, int startLineNo, int startColNo)
CommentListener
reportSingleLineComment
in interface CommentListener
type
- 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)
CommentListener
reportBlockComment
in interface CommentListener
type
- 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 number@Deprecated public void reportCppComment(int startLineNo, int startColNo)
reportSingleLineComment(int, int)
instead.startLineNo
- the starting line numberstartColNo
- the starting column number@Deprecated public Map<Integer,TextBlock> getCppComments()
getSingleLineComments()
instead.TextBlock
at the line.public Map<Integer,TextBlock> getSingleLineComments()
TextBlock
at the line.@Deprecated public void reportCComment(int startLineNo, int startColNo, int endLineNo, int endColNo)
reportBlockComment(int, int, int, int)
instead.startLineNo
- the starting line numberstartColNo
- the starting column numberendLineNo
- the ending line numberendColNo
- the ending column number@Deprecated public Map<Integer,List<TextBlock>> getCComments()
getBlockComments()
instead.List
of C style comment TextBlock
s
that start at that line.public Map<Integer,List<TextBlock>> getBlockComments()
List
of block comment TextBlock
s
that start at that line.public TextBlock getJavadocBefore(int lineNoBefore)
null
means there is no such comment.lineNoBefore
- the line number to check beforenull
if nonepublic FileText getText()
public String getLine(int index)
index
- index of the linepublic String getFileName()
public 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 boolean inPackageInfo()
Copyright © 2001–2018. All rights reserved.