Package com.puppycrawl.tools.checkstyle
Class XpathFileGeneratorAstFilter
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.api.AutomaticBean
-
- com.puppycrawl.tools.checkstyle.XpathFileGeneratorAstFilter
-
- All Implemented Interfaces:
Configurable,Contextualizable,TreeWalkerFilter
public class XpathFileGeneratorAstFilter extends AutomaticBean implements TreeWalkerFilter
CatchesTreeWalkerAuditEventand generates corresponding xpath query. Stores violations and xpath queries map inside static variable forXpathFileGeneratorAuditListener. See issue #102 https://github.com/checkstyle/checkstyle/issues/102
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
AutomaticBean.OutputStreamOptions
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringDELIMITERThe delimiter between xpath queries.private static java.util.Map<Violation,java.lang.String>MESSAGE_QUERY_MAPMap fromViolationobjects to xpath queries.private inttabWidthThe distance between tab stop position.
-
Constructor Summary
Constructors Constructor Description XpathFileGeneratorAstFilter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(TreeWalkerAuditEvent event)Determines whether or not a filteredTreeWalkerAuditEventis accepted.static java.lang.StringfindCorrespondingXpathQuery(AuditEvent event)Returns xpath query corresponding to violation of theTreeWalkerAuditEventobject which points to the same AST element as specifiedAuditEventobject.protected voidfinishLocalSetup()Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.voidsetTabWidth(int tabWidth)Sets tab width.-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, getConfiguration, setupChild
-
-
-
-
Field Detail
-
DELIMITER
private static final java.lang.String DELIMITER
The delimiter between xpath queries.- See Also:
- Constant Field Values
-
MESSAGE_QUERY_MAP
private static final java.util.Map<Violation,java.lang.String> MESSAGE_QUERY_MAP
Map fromViolationobjects to xpath queries.
-
tabWidth
private int tabWidth
The distance between tab stop position.
-
-
Constructor Detail
-
XpathFileGeneratorAstFilter
public XpathFileGeneratorAstFilter()
-
-
Method Detail
-
setTabWidth
public void setTabWidth(int tabWidth)
Sets tab width.- Parameters:
tabWidth- the distance between tab stops
-
findCorrespondingXpathQuery
public static java.lang.String findCorrespondingXpathQuery(AuditEvent event)
Returns xpath query corresponding to violation of theTreeWalkerAuditEventobject which points to the same AST element as specifiedAuditEventobject.- Parameters:
event- theAuditEventobject.- Returns:
- returns corresponding xpath query
-
finishLocalSetup
protected void finishLocalSetup()
Description copied from class:AutomaticBeanProvides a hook to finish the part of this component's setup that was not handled by the bean introspection.The default implementation does nothing.
- Specified by:
finishLocalSetupin classAutomaticBean
-
accept
public boolean accept(TreeWalkerAuditEvent event)
Description copied from interface:TreeWalkerFilterDetermines whether or not a filteredTreeWalkerAuditEventis accepted.- Specified by:
acceptin interfaceTreeWalkerFilter- Parameters:
event- the TreeWalkerAuditEvent to filter.- Returns:
- true if the event is accepted.
-
-