com.puppycrawl.tools.checkstyle.api
Class FileContents
java.lang.Object
com.puppycrawl.tools.checkstyle.api.FileContents
- CommentListener
public final class FileContents
extends java.lang.Object
Represents the contents of a file.
Version:
- Oliver Burn
FileContents(String aFilename, String[] aLines) - Creates a new
FileContents instance.
|
Map | getCComments() - Returns a map of all C style comments.
|
Map | getCppComments() - Returns a map of all the C++ style comments.
|
String | getFilename()
|
TextBlock | getJavadocBefore(int aLineNo) - Returns the Javadoc comment before the specified line.
|
String[] | getLines()
|
boolean | hasIntersectionWithComment(int aStartLineNo, int aStartColNo, int aEndLineNo, int aEndColNo) - Checks if the specified position intersects with a comment.
|
boolean | lineIsBlank(int aLineNo) - Checks if the specified line is blank.
|
boolean | lineIsComment(int aLineNo) - Checks if the specified line is a single-line comment without code.
|
void | reportBlockComment(String aType, int aStartLineNo, int aStartColNo, int aEndLineNo, int aEndColNo) -
|
void | reportCComment(int aStartLineNo, int aStartColNo, int aEndLineNo, int aEndColNo) - Report the location of a C-style comment.
|
void | reportCppComment(int aStartLineNo, int aStartColNo) - Report the location of a C++ style comment.
|
void | reportSingleLineComment(String aType, int aStartLineNo, int aStartColNo) -
|
FileContents
public FileContents(String aFilename,
String[] aLines)
Creates a new FileContents
instance.
aFilename
- name of the fileaLines
- the contents of the file
getCComments
public Map getCComments()
Returns a map of all C style comments. The key is the line number, the
value is a list of C style comments at the line.
- the map of comments
getCppComments
public Map getCppComments()
Returns a map of all the C++ style comments. The key is a line number,
the value is the comment at the line.
- the Map of comments
getFilename
public String getFilename()
- the name of the file
getJavadocBefore
public TextBlock getJavadocBefore(int aLineNo)
Returns the Javadoc comment before the specified line.
A return value of null
means there is no such comment.
aLineNo
- the line number to check before
- the Javadoc comment, or
null
if none
getLines
public String[] getLines()
- the lines in the file
hasIntersectionWithComment
public boolean hasIntersectionWithComment(int aStartLineNo,
int aStartColNo,
int aEndLineNo,
int aEndColNo)
Checks if the specified position intersects with a comment.
aStartLineNo
- the starting line numberaStartColNo
- the starting column numberaEndLineNo
- the ending line numberaEndColNo
- the ending column number
- true if the positions intersects with a comment.
lineIsBlank
public boolean lineIsBlank(int aLineNo)
Checks if the specified line is blank.
aLineNo
- the line number to check
- if the specified line consists only of tabs and spaces.
lineIsComment
public boolean lineIsComment(int aLineNo)
Checks if the specified line is a single-line comment without code.
aLineNo
- the line number to check
- if the specified line consists of only a single line comment
without code.
reportBlockComment
public void reportBlockComment(String aType,
int aStartLineNo,
int aStartColNo,
int aEndLineNo,
int aEndColNo)
- reportBlockComment in interface CommentListener
reportCComment
public void reportCComment(int aStartLineNo,
int aStartColNo,
int aEndLineNo,
int aEndColNo)
Report the location of a C-style comment.
aStartLineNo
- the starting line numberaStartColNo
- the starting column numberaEndLineNo
- the ending line numberaEndColNo
- the ending column number
reportCppComment
public void reportCppComment(int aStartLineNo,
int aStartColNo)
Report the location of a C++ style comment.
aStartLineNo
- the starting line numberaStartColNo
- the starting column number