Class DefaultModuleScannerContext
java.lang.Object
org.sonar.java.model.DefaultModuleScannerContext
- All Implemented Interfaces:
ModuleScannerContext
- Direct Known Subclasses:
DefaultInputFileScannerContext
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CacheContextprotected final booleanprotected final JavaVersionprotected final SonarComponents -
Constructor Summary
ConstructorsConstructorDescriptionDefaultModuleScannerContext(SonarComponents sonarComponents, JavaVersion javaVersion, boolean inAndroidContext, CacheContext cacheContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIssueOnProject(JavaCheck check, String message) Report an issue at the project level.org.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.voidreportIssue(AnalyzerMessage message) org.sonar.api.SonarProduct
-
Field Details
-
sonarComponents
-
javaVersion
-
inAndroidContext
protected final boolean inAndroidContext -
cacheContext
-
-
Constructor Details
-
DefaultModuleScannerContext
public DefaultModuleScannerContext(@Nullable SonarComponents sonarComponents, JavaVersion javaVersion, boolean inAndroidContext, @Nullable CacheContext cacheContext)
-
-
Method Details
-
addIssueOnProject
Description copied from interface:ModuleScannerContextReport an issue at the project level.- Specified by:
addIssueOnProjectin interfaceModuleScannerContext- Parameters:
check- The check raising the issue.message- Message to display to the user
-
getJavaVersion
Description copied from interface:ModuleScannerContextJava version defined for the analysis usingsonar.java.versionparameter.- Specified by:
getJavaVersionin interfaceModuleScannerContext- Returns:
- JavaVersion object with API to act on it.
-
inAndroidContext
public boolean inAndroidContext()Description copied from interface:ModuleScannerContextTo be used to know if the current file is in an android context or not. This value is determined thanks to the presence of android classes in the classpath.- Specified by:
inAndroidContextin interfaceModuleScannerContext- Returns:
- true if the current file is in an android context.
-
getProject
public org.sonar.api.batch.fs.InputComponent getProject()Description copied from interface:ModuleScannerContextInputComponentrepresenting the project being analyzed- Specified by:
getProjectin interfaceModuleScannerContext- Returns:
- the project component
-
getWorkingDirectory
Description copied from interface:ModuleScannerContextThe working directory used by the analysis.- Specified by:
getWorkingDirectoryin interfaceModuleScannerContext- Returns:
- the current working directory.
-
getCacheContext
- Specified by:
getCacheContextin interfaceModuleScannerContext- Returns:
- the
CacheContextapplicable to this scan.
-
reportIssue
-
getRootProjectWorkingDirectory
- Specified by:
getRootProjectWorkingDirectoryin interfaceModuleScannerContext- Returns:
- The working directory used by the analysis on project-level. Even if the project contains multiple modules, this method will always return the same value.
-
getModuleKey
- Specified by:
getModuleKeyin interfaceModuleScannerContext- Returns:
- A key that uniquely identifies the current module, provided that this project consists of multiple modules.
-
sonarProduct
@CheckForNull public org.sonar.api.SonarProduct sonarProduct()- Specified by:
sonarProductin interfaceModuleScannerContext- Returns:
- The Sonar product (SONARQUBE/SONARLINT) which forms the current execution context of the scan.
See also
SonarRuntime.getProduct(). In a production environment, this method never returns null but in testing contexts, it may happen.
-
getConfiguration
public org.sonar.api.config.Configuration getConfiguration()- Specified by:
getConfigurationin interfaceModuleScannerContext- Returns:
- The configuration used for the analysis.
-