Class DefaultModuleScannerContext

java.lang.Object
org.sonar.java.model.DefaultModuleScannerContext
All Implemented Interfaces:
ModuleScannerContext
Direct Known Subclasses:
DefaultInputFileScannerContext

public class DefaultModuleScannerContext extends Object implements ModuleScannerContext
  • Field Details

    • sonarComponents

      protected final SonarComponents sonarComponents
    • javaVersion

      protected final JavaVersion javaVersion
    • inAndroidContext

      protected final boolean inAndroidContext
    • cacheContext

      protected final CacheContext cacheContext
  • Constructor Details

    • DefaultModuleScannerContext

      public DefaultModuleScannerContext(@Nullable SonarComponents sonarComponents, JavaVersion javaVersion, boolean inAndroidContext, @Nullable CacheContext cacheContext)
  • Method Details

    • addIssueOnProject

      public void addIssueOnProject(JavaCheck check, String message)
      Description copied from interface: ModuleScannerContext
      Report an issue at the project level.
      Specified by:
      addIssueOnProject in interface ModuleScannerContext
      Parameters:
      check - The check raising the issue.
      message - Message to display to the user
    • getJavaVersion

      public JavaVersion getJavaVersion()
      Description copied from interface: ModuleScannerContext
      Java version defined for the analysis using sonar.java.version parameter.
      Specified by:
      getJavaVersion in interface ModuleScannerContext
      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 interface ModuleScannerContext
      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 interface ModuleScannerContext
      Returns:
      the project component
    • getWorkingDirectory

      public File getWorkingDirectory()
      Description copied from interface: ModuleScannerContext
      The working directory used by the analysis.
      Specified by:
      getWorkingDirectory in interface ModuleScannerContext
      Returns:
      the current working directory.
    • getCacheContext

      public CacheContext getCacheContext()
      Specified by:
      getCacheContext in interface ModuleScannerContext
      Returns:
      the CacheContext applicable to this scan.
    • reportIssue

      public void reportIssue(AnalyzerMessage message)
    • getRootProjectWorkingDirectory

      public File getRootProjectWorkingDirectory()
      Specified by:
      getRootProjectWorkingDirectory in interface ModuleScannerContext
      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

      public String getModuleKey()
      Specified by:
      getModuleKey in interface ModuleScannerContext
      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 interface ModuleScannerContext
      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.