Class ParseTreeTablePresentation
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.gui.ParseTreeTablePresentation
-
public class ParseTreeTablePresentation extends Object
The model that backs the parse tree in the GUI.
-
-
Field Summary
Fields Modifier and Type Field Description private Map<DetailAST,DetailNode>
blockCommentToJavadocTree
Cache to store already parsed Javadoc comments.private static String[]
COLUMN_NAMES
Column names.private MainFrameModel.ParseMode
parseMode
Parsing mode.private DetailAST
root
The root node of the tree table model.private static String
UNKNOWN_COLUMN_MSG
Exception message.
-
Constructor Summary
Constructors Constructor Description ParseTreeTablePresentation(DetailAST parseTree)
Constructor initialise root node.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getChild(Object parent, int index)
Returns the child of parent at index.private Object
getChildAtDetailAst(DetailAST parent, int index)
Gets child of DetailAST node at specified index.int
getChildCount(Object parent)
Returns the number of children of parent.Class<?>
getColumnClass(int column)
Returns type of specified column number.int
getColumnCount()
Returns number of available columns.String
getColumnName(int column)
Returns name for specified column number.int
getIndexOfChild(Object parent, Object child)
Return the index of child in parent.private DetailNode
getJavadocTree(DetailAST blockComment)
Gets Javadoc (DetailNode) tree of specified block comments.Object
getRoot()
Returns value of root.Object
getValueAt(Object node, int column)
Returns the value to be displayed for node at column number.private static Object
getValueAtDetailAST(DetailAST ast, int column)
Gets a value for DetailAST object.private static Object
getValueAtDetailNode(DetailNode node, int column)
Gets a value for DetailNode object.boolean
isCellEditable(int column)
Indicates whether the value for nodenode
, at column numbercolumn
is editable.boolean
isLeaf(Object node)
Whether the node is a leaf.private static DetailNode
parseJavadocTree(DetailAST blockComment)
Parses Javadoc (DetailNode) tree of specified block comments.protected void
setParseMode(MainFrameModel.ParseMode mode)
Set parse mode.protected void
setRoot(DetailAST parseTree)
Set parse tree.
-
-
-
Field Detail
-
UNKNOWN_COLUMN_MSG
private static final String UNKNOWN_COLUMN_MSG
Exception message.- See Also:
- Constant Field Values
-
COLUMN_NAMES
private static final String[] COLUMN_NAMES
Column names.
-
blockCommentToJavadocTree
private final Map<DetailAST,DetailNode> blockCommentToJavadocTree
Cache to store already parsed Javadoc comments. Used for optimisation purposes.
-
parseMode
private MainFrameModel.ParseMode parseMode
Parsing mode.
-
-
Constructor Detail
-
ParseTreeTablePresentation
public ParseTreeTablePresentation(DetailAST parseTree)
Constructor initialise root node.- Parameters:
parseTree
- DetailAST parse tree.
-
-
Method Detail
-
setRoot
protected final void setRoot(DetailAST parseTree)
Set parse tree.- Parameters:
parseTree
- DetailAST parse tree.
-
setParseMode
protected void setParseMode(MainFrameModel.ParseMode mode)
Set parse mode.- Parameters:
mode
- ParseMode enum
-
getColumnCount
public int getColumnCount()
Returns number of available columns.- Returns:
- the number of available columns.
-
getColumnName
public String getColumnName(int column)
Returns name for specified column number.- Parameters:
column
- the column number- Returns:
- the name for column number
column
.
-
getColumnClass
public Class<?> getColumnClass(int column)
Returns type of specified column number.- Parameters:
column
- the column number- Returns:
- the type for column number
column
. - Throws:
IllegalStateException
- if an unknown column index was specified.
-
getValueAt
public Object getValueAt(Object node, int column)
Returns the value to be displayed for node at column number.- Parameters:
node
- the nodecolumn
- the column number- Returns:
- the value to be displayed for node
node
, at column numbercolumn
.
-
getChild
public Object getChild(Object parent, int index)
Returns the child of parent at index.- Parameters:
parent
- the node to get a child from.index
- the index of a child.- Returns:
- the child of parent at index.
-
getChildCount
public int getChildCount(Object parent)
Returns the number of children of parent.- Parameters:
parent
- the node to count children for.- Returns:
- the number of children of the node parent.
-
isLeaf
public boolean isLeaf(Object node)
Whether the node is a leaf.- Parameters:
node
- the node to check.- Returns:
- true if the node is a leaf.
-
getIndexOfChild
public int getIndexOfChild(Object parent, Object child)
Return the index of child in parent. If eitherparent
orchild
isnull
, returns -1. If eitherparent
orchild
don't belong to this tree model, returns -1.- Parameters:
parent
- a node in the tree, obtained from this data source.child
- the node we are interested in.- Returns:
- the index of the child in the parent, or -1 if either
child
orparent
arenull
or don't belong to this tree model.
-
isCellEditable
public boolean isCellEditable(int column)
Indicates whether the value for nodenode
, at column numbercolumn
is editable.- Parameters:
column
- the column number- Returns:
- true if editable
-
getChildAtDetailAst
private Object getChildAtDetailAst(DetailAST parent, int index)
Gets child of DetailAST node at specified index.- Parameters:
parent
- DetailAST nodeindex
- child index- Returns:
- child DetailsAST or DetailNode if child is Javadoc node and parseMode is JAVA_WITH_JAVADOC_AND_COMMENTS.
-
getValueAtDetailNode
private static Object getValueAtDetailNode(DetailNode node, int column)
Gets a value for DetailNode object.- Parameters:
node
- DetailNode(Javadoc) node.column
- column index.- Returns:
- value at specified column.
- Throws:
IllegalStateException
- if an unknown column index was specified.
-
getValueAtDetailAST
private static Object getValueAtDetailAST(DetailAST ast, int column)
Gets a value for DetailAST object.- Parameters:
ast
- DetailAST node.column
- column index.- Returns:
- value at specified column.
- Throws:
IllegalStateException
- if an unknown column index was specified.
-
getJavadocTree
private DetailNode getJavadocTree(DetailAST blockComment)
Gets Javadoc (DetailNode) tree of specified block comments.- Parameters:
blockComment
- Javadoc comment as a block comment- Returns:
- root of DetailNode tree
-
parseJavadocTree
private static DetailNode parseJavadocTree(DetailAST blockComment)
Parses Javadoc (DetailNode) tree of specified block comments.- Parameters:
blockComment
- Javadoc comment as a block comment- Returns:
- root of DetailNode tree
-
-