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 |
---|---|
com.google.common.collect.ImmutableMap<Integer,List<TextBlock>> |
getCComments()
Returns a map of all C style comments.
|
com.google.common.collect.ImmutableMap<Integer,TextBlock> |
getCppComments()
Returns a map of all the C++ style comments.
|
String |
getFilename() |
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() |
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)
Report the location of a C-style comment.
|
void |
reportCppComment(int startLineNo,
int startColNo)
Report the location of a C++ style 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)
reportSingleLineComment
in interface CommentListener
type
- an identifier for what type of comment it is.startLineNo
- the starting line numberstartColNo
- the starting column numberpublic void reportBlockComment(String type, int startLineNo, int startColNo, int endLineNo, int endColNo)
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 numberpublic void reportCppComment(int startLineNo, int startColNo)
startLineNo
- the starting line numberstartColNo
- the starting column numberpublic com.google.common.collect.ImmutableMap<Integer,TextBlock> getCppComments()
TextBlock
at the line.public void reportCComment(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 com.google.common.collect.ImmutableMap<Integer,List<TextBlock>> getCComments()
List
of C style 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–2015. All rights reserved.