Package org.sonar.php.tree.visitors
Class PHPCheckContext
- java.lang.Object
-
- org.sonar.php.tree.visitors.PHPCheckContext
-
- All Implemented Interfaces:
CheckContext
public class PHPCheckContext extends Object implements CheckContext
-
-
Constructor Summary
Constructors Constructor Description PHPCheckContext(PhpFile file, CompilationUnitTree tree, File workingDirectory)PHPCheckContext(PhpFile file, CompilationUnitTree tree, File workingDirectory, SymbolTable symbolTable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<PhpIssue>getIssues()PhpFilegetPhpFile()FilegetWorkingDirectory()FileIssuenewFileIssue(PHPCheck check, String message)To add cost useFileIssue.cost(double).LegacyIssuenewIssue(PHPCheck check, String message)To set line and cost useIssue.line(int)andIssue.cost(double).PreciseIssuenewIssue(PHPCheck check, Tree tree, String message)To add secondary locations and cost usePreciseIssue.secondary(Tree, String)andPreciseIssue.cost(double).PreciseIssuenewIssue(PHPCheck check, Tree startTree, Tree endTree, String message)To add secondary locations and cost usePreciseIssue.secondary(Tree, String)andPreciseIssue.cost(double).LineIssuenewLineIssue(PHPCheck check, int line, String message)To add cost useLineIssue.cost(double).SymbolTablesymbolTable()CompilationUnitTreetree()
-
-
-
Constructor Detail
-
PHPCheckContext
public PHPCheckContext(PhpFile file, CompilationUnitTree tree, @Nullable File workingDirectory)
-
PHPCheckContext
public PHPCheckContext(PhpFile file, CompilationUnitTree tree, @Nullable File workingDirectory, SymbolTable symbolTable)
-
-
Method Detail
-
tree
public CompilationUnitTree tree()
- Specified by:
treein interfaceCheckContext- Returns:
- the top tree node of the current file AST representation.
-
newIssue
public LegacyIssue newIssue(PHPCheck check, String message)
Description copied from interface:CheckContextTo set line and cost use
Issue.line(int)andIssue.cost(double). Note, that these calls could be chained.newIssue(myCheck, "Some message") .line(105) .cost(3);- Specified by:
newIssuein interfaceCheckContext- Parameters:
check- the instance of the rule for which issue should be createdmessage- message of the issue- Returns:
- instance of Issue
-
newIssue
public PreciseIssue newIssue(PHPCheck check, Tree tree, String message)
Description copied from interface:CheckContextTo add secondary locations and cost use
PreciseIssue.secondary(Tree, String)andPreciseIssue.cost(double). Note, that these calls could be chained.newIssue(myCheck, primaryTree, "Primary message") .secondary(secondaryTree1, "Secondary message") .secondary(secondaryTree2, null) .cost(3);- Specified by:
newIssuein interfaceCheckContext- Parameters:
check- the instance of the rule for which issue should be createdtree- primary location for issuemessage- primary message of the issue- Returns:
- issue with precise location
-
newIssue
public PreciseIssue newIssue(PHPCheck check, Tree startTree, Tree endTree, String message)
Description copied from interface:CheckContextTo add secondary locations and cost use
PreciseIssue.secondary(Tree, String)andPreciseIssue.cost(double). Note, that these calls could be chained.newIssue(myCheck, primaryLocationStartTree, primaryLocationEndTree, "Primary message") .secondary(secondaryTree1, "Secondary message") .secondary(secondaryTree2, null) .cost(3);- Specified by:
newIssuein interfaceCheckContext- Parameters:
check- the instance of the rule for which issue should be createdstartTree- start of this tree will be the start of primary location of the issueendTree- end of this tree will be the end of primary location of the issuemessage- primary message of the issue- Returns:
- issue with precise location
-
newLineIssue
public LineIssue newLineIssue(PHPCheck check, int line, String message)
Description copied from interface:CheckContextTo add cost use
LineIssue.cost(double).newLineIssue(myCheck, 42, "Message") .cost(3);- Specified by:
newLineIssuein interfaceCheckContext- Parameters:
check- the instance of the rule for which issue should be createdline- position of the issue in the filemessage- message of the issue- Returns:
- issue with line location
-
newFileIssue
public FileIssue newFileIssue(PHPCheck check, String message)
Description copied from interface:CheckContextTo add cost use
FileIssue.cost(double).newFileIssue(myCheck, "Message") .cost(3);- Specified by:
newFileIssuein interfaceCheckContext- Parameters:
check- the instance of the rule for which issue should be createdmessage- message of the issue- Returns:
- issue at file level
-
getPhpFile
public PhpFile getPhpFile()
- Specified by:
getPhpFilein interfaceCheckContext- Returns:
- the current file
-
getIssues
public List<PhpIssue> getIssues()
- Specified by:
getIssuesin interfaceCheckContext
-
symbolTable
public SymbolTable symbolTable()
- Specified by:
symbolTablein interfaceCheckContext
-
getWorkingDirectory
public File getWorkingDirectory()
- Specified by:
getWorkingDirectoryin interfaceCheckContext
-
-