public abstract class CheckImplementationBase extends java.lang.Object
CheckInfo
Objects. It is destroyed, when the executing processor has
finished execution.Modifier and Type | Field and Description |
---|---|
protected ICheckContext |
context
The check context that is used to access custom check specific functionality.
|
Constructor and Description |
---|
CheckImplementationBase() |
Modifier and Type | Method and Description |
---|---|
protected void |
createFinding(java.lang.String message)
Creates a finding with the given message for the whole analyzed token
element.
|
protected void |
createFinding(java.lang.String message,
int line)
Creates a finding with the given message at the given line.
|
protected void |
createFinding(java.lang.String message,
int startLine,
int endLine)
Creates a finding with the given message from the given start line
(inclusive) to the given end line (inclusive).
|
protected void |
createFinding(java.lang.String message,
IToken token)
Creates a finding with the given message at the given token.
|
protected void |
createFinding(java.lang.String message,
IToken startToken,
IToken endToken)
Creates a finding with the given message beginning from startToken to
endToken.
|
protected void |
createFinding(java.lang.String message,
java.util.List<IToken> tokens)
Creates a finding with the given message beginning from first token to last
token.
|
protected void |
createFinding(java.lang.String message,
ShallowEntity entity)
Creates a finding with the given message for the given entity.
|
protected void |
createFindingForSiblingEntities(java.lang.String message,
java.util.List<ShallowEntity> associatedEntities)
Creates findings for entities which are associated in some way.
|
protected void |
createFindingForSiblings(java.lang.String message,
PairList<IToken,IToken> startAndEndTokens)
Creates findings with the given message for the given pair lists of start-
and end tokens.
|
protected void |
createFindingOnFirstLine(java.lang.String message,
ShallowEntity entity)
Creates a finding with the given message on the first line of the given
entity.
|
protected void |
createFindingOnUnfilteredCode(java.lang.String message,
IToken token)
Creates a finding with the given message at the given token.
|
protected void |
createFindingOnUnfilteredCode(java.lang.String message,
IToken startToken,
IToken endToken)
Creates a finding with the given message beginning from startToken to
endToken.
|
protected void |
createFindingOnUnfilteredCode(java.lang.String message,
ShallowEntity entity)
Creates a finding with the given message for the given entity.
|
static CheckImplementationBase |
createInstance(java.lang.Class<?> checkClass)
Creates an instance of the given check class.
|
protected static java.lang.String |
createSelectionPattern(EShallowEntityType entityType,
java.lang.String... subtypeAlternatives)
Creates a xpath-expression to select entities with the given type and the
optional subtype alternatives eg.
|
abstract void |
execute()
Executes the custom check with the given context.
|
protected ECodeViewOption |
getCodeViewOption()
Can be used to specifiy the code representation.
|
void |
initialize()
Initializes the custom check.
|
boolean |
isCpp()
Determines if the the check is currently processing source code that is
written in C++ based on the file extension and the C++ specific tokens.
|
static java.util.List<ShallowEntity> |
select(ShallowEntity entity,
java.lang.String xPathExpression)
Selects all shallow entities starting from the given entity, that match the
given xpath-expression.
|
protected java.util.List<ShallowEntity> |
select(java.lang.String xPathExpression)
Selects all shallow entities from the abstract syntax tree, that match the
given xpath-expression.
|
protected java.util.List<ShallowEntity> |
selectUnfilteredPreProcessed(java.lang.String xPathExpression)
Selects all shallow entities from the abstract syntax tree, that match the
given xpath-expression.
|
void |
setContext(ICheckContext context)
Sets the context.
|
protected ICheckContext context
public CheckImplementationBase()
public void setContext(ICheckContext context)
public void initialize() throws CheckException
CheckException
- can be thrown by subclassespublic abstract void execute() throws CheckException
CheckException
protected ECodeViewOption getCodeViewOption()
ECodeViewOption
for details, the default is ECodeViewOption.FILTERED
. See the
Teamscale Code Processing Pipelineprotected java.util.List<ShallowEntity> select(java.lang.String xPathExpression) throws CheckException
getCodeViewOption()
. This method can be used, if the executing check
requests the ECheckParameter.ABSTRACT_SYNTAX_TREE
parameter.CheckException
protected java.util.List<ShallowEntity> selectUnfilteredPreProcessed(java.lang.String xPathExpression) throws CheckException
ECodeViewOption.UNFILTERED_PREPROCESSED
.CheckException
protected static java.lang.String createSelectionPattern(EShallowEntityType entityType, java.lang.String... subtypeAlternatives)
public static java.util.List<ShallowEntity> select(ShallowEntity entity, java.lang.String xPathExpression) throws CheckException
CheckException
protected void createFinding(java.lang.String message) throws CheckException
CheckException
protected void createFinding(java.lang.String message, IToken token) throws CheckException
ICheckContext#getTextContent()
or another method that is based on
filtered content.CheckException
protected void createFinding(java.lang.String message, IToken startToken, IToken endToken) throws CheckException
ICheckContext#getTextContent()
or another method that is based on
filtered content.CheckException
protected void createFinding(java.lang.String message, java.util.List<IToken> tokens) throws CheckException
ICheckContext#getTextContent()
or another method that is based on
filtered content.CheckException
protected void createFindingOnUnfilteredCode(java.lang.String message, IToken startToken, IToken endToken) throws CheckException
ICheckContext#getUnfilteredTextContent()
or another method that is
based on unfiltered content.CheckException
protected void createFinding(java.lang.String message, ShallowEntity entity) throws CheckException
ICheckContext#getTextContent()
or another method that is based on
filtered content.CheckException
protected void createFindingOnFirstLine(java.lang.String message, ShallowEntity entity) throws CheckException
ICheckContext#getTextContent()
or another method that is based on
filtered content.CheckException
protected void createFindingOnUnfilteredCode(java.lang.String message, IToken token) throws CheckException
ICheckContext#getUnfilteredTextContent()
or another method that is
based on unfiltered content.CheckException
protected void createFindingOnUnfilteredCode(java.lang.String message, ShallowEntity entity) throws CheckException
ICheckContext#getUnfilteredTextContent()
or another method that is
based on unfiltered content.CheckException
protected void createFinding(java.lang.String message, int line) throws CheckException
ICheckContext#getTextContent()
or
another method that is based on filtered content.CheckException
protected void createFindingForSiblings(java.lang.String message, PairList<IToken,IToken> startAndEndTokens) throws CheckException
message
- the message describing the findingsstartAndEndTokens
- A list of corresponding pairs of start and end tokens.CheckException
protected void createFindingForSiblingEntities(java.lang.String message, java.util.List<ShallowEntity> associatedEntities) throws CheckException
CheckException
protected void createFinding(java.lang.String message, int startLine, int endLine) throws CheckException
ICheckContext#getTextContent()
or another method
that is based on filtered content.CheckException
public static CheckImplementationBase createInstance(java.lang.Class<?> checkClass) throws CheckException
CheckException
public boolean isCpp() throws CheckException
CheckException