Package org.sonar.java.model
Class DefaultModuleScannerContext
java.lang.Object
org.sonar.java.model.DefaultModuleScannerContext
- All Implemented Interfaces:
ModuleScannerContext
- Direct Known Subclasses:
DefaultInputFileScannerContext
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CacheContext
protected final boolean
protected final JavaVersion
protected final SonarComponents
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultModuleScannerContext
(SonarComponents sonarComponents, JavaVersion javaVersion, boolean inAndroidContext, CacheContext cacheContext) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addIssueOnProject
(JavaCheck check, String message) Report an issue at the project level.Java version defined for the analysis usingsonar.java.version
parameter.org.sonar.api.batch.fs.InputComponent
InputComponent
representing the project being analyzedThe working directory used by the analysis.boolean
To be used to know if the current file is in an android context or not.void
reportIssue
(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:ModuleScannerContext
Report an issue at the project level.- Specified by:
addIssueOnProject
in interfaceModuleScannerContext
- Parameters:
check
- The check raising the issue.message
- Message to display to the user
-
getJavaVersion
Description copied from interface:ModuleScannerContext
Java version defined for the analysis usingsonar.java.version
parameter.- Specified by:
getJavaVersion
in interfaceModuleScannerContext
- Returns:
- JavaVersion object with API to act on it.
-
inAndroidContext
public boolean inAndroidContext()Description copied from interface:ModuleScannerContext
To 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:
inAndroidContext
in 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:ModuleScannerContext
InputComponent
representing the project being analyzed- Specified by:
getProject
in interfaceModuleScannerContext
- Returns:
- the project component
-
getWorkingDirectory
Description copied from interface:ModuleScannerContext
The working directory used by the analysis.- Specified by:
getWorkingDirectory
in interfaceModuleScannerContext
- Returns:
- the current working directory.
-
getCacheContext
- Specified by:
getCacheContext
in interfaceModuleScannerContext
- Returns:
- the
CacheContext
applicable to this scan.
-
reportIssue
-
getRootProjectWorkingDirectory
- Specified by:
getRootProjectWorkingDirectory
in 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:
getModuleKey
in 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:
sonarProduct
in 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.
-