Class JavaFileScannerContextForTests
java.lang.Object
org.sonar.java.model.DefaultModuleScannerContext
org.sonar.java.model.DefaultInputFileScannerContext
org.sonar.java.model.DefaultJavaFileScannerContext
org.sonar.java.testing.JavaFileScannerContextForTests
- All Implemented Interfaces:
MetricsScannerContext, RegexScannerContext, FluentReporting, InputFileScannerContext, JavaFileScannerContext, ModuleScannerContext
-
Nested Class Summary
Nested classes/interfaces inherited from interface FluentReporting
FluentReporting.JavaIssueBuilderNested classes/interfaces inherited from interface JavaFileScannerContext
JavaFileScannerContext.LocationModifier and TypeInterfaceDescriptionstatic classMessage and syntaxNode for a secondary location. -
Field Summary
Fields inherited from class DefaultInputFileScannerContext
inputFileFields inherited from class DefaultModuleScannerContext
cacheContext, inAndroidContext, javaVersion, sonarComponentsModifier and TypeFieldDescriptionprotected final CacheContextprotected final booleanprotected final JavaVersionprotected final SonarComponents -
Constructor Summary
ConstructorsConstructorDescriptionJavaFileScannerContextForTests(CompilationUnitTree tree, org.sonar.api.batch.fs.InputFile inputFile, Sema semanticModel, SonarComponents sonarComponents, JavaVersion javaVersion, boolean failedParsing, boolean inAndroidContext, CacheContext cacheContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidReport an issue on a specific line.voidaddIssueOnProject(JavaCheck javaCheck, String message) Report an issue at the project level.createAnalyzerMessage(JavaCheck javaCheck, Tree startTree, String message) newIssue()voidreportIssue(AnalyzerMessage message) voidreportIssue(JavaCheck javaCheck, Tree tree, String message) Report an issue.voidreportIssue(JavaCheck javaCheck, Tree syntaxNode, String message, List<JavaFileScannerContext.Location> secondary, Integer cost) Report an issue.voidreportIssue(JavaCheck javaCheck, Tree startTree, Tree endTree, String message) Report an issue.voidreportIssue(JavaCheck javaCheck, Tree startTree, Tree endTree, String message, List<JavaFileScannerContext.Location> secondary, Integer cost) Report an issue.voidreportIssueWithFlow(JavaCheck javaCheck, Tree syntaxNode, String message, Iterable<List<JavaFileScannerContext.Location>> flows, Integer cost) Report an issue.Methods inherited from class DefaultJavaFileScannerContext
createAnalyzerMessage, fileParsed, getComplexityNodes, getFileContent, getFileLines, getMetricsComputer, getSemanticModel, getTree, regexForLiterals, reportIssue, reportIssue, sourceMap, throwIfEndOfAnalysisCheckModifier and TypeMethodDescriptionprotected static AnalyzerMessagecreateAnalyzerMessage(org.sonar.api.batch.fs.InputFile inputFile, JavaCheck javaCheck, Tree startTree, Tree endTree, String message, Iterable<List<JavaFileScannerContext.Location>> flows, Integer cost) booleanChecks if file has been parsed correctly.getComplexityNodes(Tree tree) Computes the list of syntax nodes which are contributing to increase the complexity for the given methodTree.Content of the currently analyzed file.Lines of the currently analyzed file.Get semantic analysis.getTree()Parsed tree of the current file.org.sonarsource.analyzer.commons.regex.RegexParseResultregexForLiterals(org.sonarsource.analyzer.commons.regex.ast.FlagSet initialFlags, LiteralTree... stringLiterals) voidreportIssue(RegexCheck regexCheck, Tree javaSyntaxElement, String message, Integer cost, List<RegexCheck.RegexIssueLocation> secondaries) voidreportIssue(RegexCheck regexCheck, org.sonarsource.analyzer.commons.regex.ast.RegexSyntaxElement regexTree, String message, Integer cost, List<RegexCheck.RegexIssueLocation> secondaries) Return JSR 45 source map for current input fileprotected static voidthrowIfEndOfAnalysisCheck(JavaCheck javaCheck) Methods inherited from class DefaultInputFileScannerContext
addIssue, addIssueOnFile, getInputFileModifier and TypeMethodDescriptionvoidReport an issue on a specific line.voidaddIssueOnFile(JavaCheck javaCheck, String message) Report an issue at file level.org.sonar.api.batch.fs.InputFileInputFile under analysis.Methods inherited from class DefaultModuleScannerContext
getCacheContext, getConfiguration, getFullyQualifiedModuleKey, getJavaVersion, getModuleKey, getProject, getRootProjectWorkingDirectory, getWorkingDirectory, inAndroidContext, sonarProductModifier and TypeMethodDescriptionorg.sonar.api.config.ConfigurationJava version defined for the analysis usingsonar.java.versionparameter.org.sonar.api.batch.fs.InputComponentInputComponentrepresenting the project being analyzedThe working directory used by the analysis.booleanTo be used to know if the current file is in an android context or not.org.sonar.api.SonarProduct
-
Constructor Details
-
JavaFileScannerContextForTests
public JavaFileScannerContextForTests(CompilationUnitTree tree, org.sonar.api.batch.fs.InputFile inputFile, Sema semanticModel, @Nullable SonarComponents sonarComponents, JavaVersion javaVersion, boolean failedParsing, boolean inAndroidContext, @Nullable CacheContext cacheContext)
-
-
Method Details
-
getIssues
-
getQuickFixes
-
addIssueOnProject
Description copied from interface:ModuleScannerContextReport an issue at the project level.- Specified by:
addIssueOnProjectin interfaceModuleScannerContext- Overrides:
addIssueOnProjectin classDefaultModuleScannerContext- Parameters:
javaCheck- The check raising the issue.message- Message to display to the user
-
addIssue
Description copied from interface:InputFileScannerContextReport an issue on a specific line. PreferJavaFileScannerContext.reportIssue(JavaCheck, Tree, String, List, Integer)for more precise reporting.- Specified by:
addIssuein interfaceInputFileScannerContext- Overrides:
addIssuein classDefaultInputFileScannerContext- Parameters:
line- line on which to report the issuejavaCheck- The check raising the issue.message- Message to display to the usercost- computed remediation cost if applicable, null if not.
-
reportIssue
Description copied from interface:JavaFileScannerContextReport an issue.- Specified by:
reportIssuein interfaceJavaFileScannerContext- Overrides:
reportIssuein classDefaultJavaFileScannerContext- Parameters:
javaCheck- check raising the issuetree- syntax node on which to raise the issue.message- Message to display to the user.
-
reportIssue
public void reportIssue(JavaCheck javaCheck, Tree syntaxNode, String message, List<JavaFileScannerContext.Location> secondary, @Nullable Integer cost) Description copied from interface:JavaFileScannerContextReport an issue.- Specified by:
reportIssuein interfaceJavaFileScannerContext- Overrides:
reportIssuein classDefaultJavaFileScannerContext- Parameters:
javaCheck- check raising the issuesyntaxNode- syntax node on which to raise the issue.message- Message to display to the user.secondary- List ofJavaFileScannerContext.Locationto display secondary location for the issue.cost- computed remediation cost if applicable, null if not.
-
reportIssue
Description copied from interface:JavaFileScannerContextReport an issue.- Specified by:
reportIssuein interfaceJavaFileScannerContext- Overrides:
reportIssuein classDefaultJavaFileScannerContext- Parameters:
javaCheck- check raising the issuestartTree- syntax node on which to start the highlighting of the issue.endTree- syntax node on which to end the highlighting of the issue.message- Message to display to the user.
-
reportIssue
public void reportIssue(JavaCheck javaCheck, Tree startTree, Tree endTree, String message, List<JavaFileScannerContext.Location> secondary, @Nullable Integer cost) Description copied from interface:JavaFileScannerContextReport an issue.- Specified by:
reportIssuein interfaceJavaFileScannerContext- Overrides:
reportIssuein classDefaultJavaFileScannerContext- Parameters:
javaCheck- check raising the issuestartTree- syntax node on which to start the highlighting of the issue.endTree- syntax node on which to end the highlighting of the issue.message- Message to display to the user.secondary- List ofJavaFileScannerContext.Locationto display secondary location for the issue.cost- computed remediation cost if applicable, null if not.
-
reportIssueWithFlow
public void reportIssueWithFlow(JavaCheck javaCheck, Tree syntaxNode, String message, Iterable<List<JavaFileScannerContext.Location>> flows, @Nullable Integer cost) Description copied from interface:JavaFileScannerContextReport an issue.- Specified by:
reportIssueWithFlowin interfaceJavaFileScannerContext- Overrides:
reportIssueWithFlowin classDefaultJavaFileScannerContext- Parameters:
javaCheck- check raising the issuesyntaxNode- syntax node on which to raise the issue.message- Message to display to the user.flows- List of list ofJavaFileScannerContext.Locationto display flows for the issue.cost- computed remediation cost if applicable, null if not.
-
reportIssue
- Overrides:
reportIssuein classDefaultModuleScannerContext
-
createAnalyzerMessage
- Overrides:
createAnalyzerMessagein classDefaultJavaFileScannerContext
-
newIssue
- Specified by:
newIssuein interfaceFluentReporting- Overrides:
newIssuein classDefaultJavaFileScannerContext
-