Package org.sonar.java
Class SonarComponents
- java.lang.Object
-
- org.sonar.java.SonarComponents
-
@ScannerSide @SonarLintSide public class SonarComponents extends Object
-
-
Field Summary
Fields Modifier and Type Field Description List<AnalysisError>
analysisErrors
static String
COLLECT_ANALYSIS_ERRORS_KEY
static String
FAIL_ON_EXCEPTION_KEY
static org.sonar.api.measures.Metric<String>
FEEDBACK_METRIC
Metric to collect
-
Constructor Summary
Constructors Constructor Description SonarComponents(org.sonar.api.measures.FileLinesContextFactory fileLinesContextFactory, org.sonar.api.batch.fs.FileSystem fs, JavaClasspath javaClasspath, JavaTestClasspath javaTestClasspath, org.sonar.api.batch.rule.CheckFactory checkFactory)
SonarComponents(org.sonar.api.measures.FileLinesContextFactory fileLinesContextFactory, org.sonar.api.batch.fs.FileSystem fs, JavaClasspath javaClasspath, JavaTestClasspath javaTestClasspath, org.sonar.api.batch.rule.CheckFactory checkFactory, org.sonar.api.batch.bootstrap.ProjectDefinition projectDefinition)
Will be called in SonarScanner context when no custom rules is presentSonarComponents(org.sonar.api.measures.FileLinesContextFactory fileLinesContextFactory, org.sonar.api.batch.fs.FileSystem fs, JavaClasspath javaClasspath, JavaTestClasspath javaTestClasspath, org.sonar.api.batch.rule.CheckFactory checkFactory, CheckRegistrar[] checkRegistrars)
Will be called in SonarLint context when custom rules are presentSonarComponents(org.sonar.api.measures.FileLinesContextFactory fileLinesContextFactory, org.sonar.api.batch.fs.FileSystem fs, JavaClasspath javaClasspath, JavaTestClasspath javaTestClasspath, org.sonar.api.batch.rule.CheckFactory checkFactory, CheckRegistrar[] checkRegistrars, org.sonar.api.batch.bootstrap.ProjectDefinition projectDefinition)
ProjectDefinition class is not available in SonarLint context, so this constructor will never be called when using SonarLint
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAnalysisError(AnalysisError analysisError)
void
addIssue(File file, JavaCheck check, int line, String message, Integer cost)
boolean
analysisCancelled()
JavaCheck[]
checkClasses()
Iterable<org.sonar.api.batch.rule.Checks<JavaCheck>>
checks()
String
fileContent(File file)
int
fileLength(File file)
List<String>
fileLines(File file)
org.sonar.api.measures.FileLinesContext
fileLinesContextFor(File file)
org.sonar.api.batch.fs.FileSystem
getFileSystem()
List<File>
getJavaClasspath()
List<File>
getJavaTestClasspath()
org.sonar.api.rule.RuleKey
getRuleKey(JavaCheck check)
org.sonar.api.batch.sensor.highlighting.NewHighlighting
highlightableFor(File file)
org.sonar.api.batch.fs.InputFile
inputFromIOFile(File file)
boolean
isSonarLintContext()
void
registerCheckClasses(String repositoryKey, Iterable<Class<? extends JavaCheck>> checkClasses)
void
registerTestCheckClasses(String repositoryKey, Iterable<Class<? extends JavaCheck>> checkClasses)
boolean
reportAnalysisError(com.sonar.sslr.api.RecognitionException re, File file)
void
reportAnalysisError(File file, String message)
void
reportIssue(AnalyzerMessage analyzerMessage)
void
saveAnalysisErrors()
void
setSensorContext(org.sonar.api.batch.sensor.SensorContext context)
boolean
shouldFailAnalysisOnException()
org.sonar.api.batch.sensor.symbol.NewSymbolTable
symbolizableFor(File file)
Collection<JavaCheck>
testCheckClasses()
File
workDir()
-
-
-
Field Detail
-
FEEDBACK_METRIC
public static final org.sonar.api.measures.Metric<String> FEEDBACK_METRIC
Metric to collect
-
COLLECT_ANALYSIS_ERRORS_KEY
public static final String COLLECT_ANALYSIS_ERRORS_KEY
- See Also:
- Constant Field Values
-
FAIL_ON_EXCEPTION_KEY
public static final String FAIL_ON_EXCEPTION_KEY
- See Also:
- Constant Field Values
-
analysisErrors
public List<AnalysisError> analysisErrors
-
-
Constructor Detail
-
SonarComponents
public SonarComponents(org.sonar.api.measures.FileLinesContextFactory fileLinesContextFactory, org.sonar.api.batch.fs.FileSystem fs, JavaClasspath javaClasspath, JavaTestClasspath javaTestClasspath, org.sonar.api.batch.rule.CheckFactory checkFactory)
-
SonarComponents
public SonarComponents(org.sonar.api.measures.FileLinesContextFactory fileLinesContextFactory, org.sonar.api.batch.fs.FileSystem fs, JavaClasspath javaClasspath, JavaTestClasspath javaTestClasspath, org.sonar.api.batch.rule.CheckFactory checkFactory, @Nullable CheckRegistrar[] checkRegistrars)
Will be called in SonarLint context when custom rules are present
-
SonarComponents
public SonarComponents(org.sonar.api.measures.FileLinesContextFactory fileLinesContextFactory, org.sonar.api.batch.fs.FileSystem fs, JavaClasspath javaClasspath, JavaTestClasspath javaTestClasspath, org.sonar.api.batch.rule.CheckFactory checkFactory, @Nullable org.sonar.api.batch.bootstrap.ProjectDefinition projectDefinition)
Will be called in SonarScanner context when no custom rules is present
-
SonarComponents
public SonarComponents(org.sonar.api.measures.FileLinesContextFactory fileLinesContextFactory, org.sonar.api.batch.fs.FileSystem fs, JavaClasspath javaClasspath, JavaTestClasspath javaTestClasspath, org.sonar.api.batch.rule.CheckFactory checkFactory, @Nullable CheckRegistrar[] checkRegistrars, @Nullable org.sonar.api.batch.bootstrap.ProjectDefinition projectDefinition)
ProjectDefinition class is not available in SonarLint context, so this constructor will never be called when using SonarLint
-
-
Method Detail
-
setSensorContext
public void setSensorContext(org.sonar.api.batch.sensor.SensorContext context)
-
inputFromIOFile
public org.sonar.api.batch.fs.InputFile inputFromIOFile(File file)
-
fileLength
public int fileLength(File file)
-
fileLinesContextFor
public org.sonar.api.measures.FileLinesContext fileLinesContextFor(File file)
-
symbolizableFor
public org.sonar.api.batch.sensor.symbol.NewSymbolTable symbolizableFor(File file)
-
highlightableFor
public org.sonar.api.batch.sensor.highlighting.NewHighlighting highlightableFor(File file)
-
registerCheckClasses
public void registerCheckClasses(String repositoryKey, Iterable<Class<? extends JavaCheck>> checkClasses)
-
checkClasses
public JavaCheck[] checkClasses()
-
registerTestCheckClasses
public void registerTestCheckClasses(String repositoryKey, Iterable<Class<? extends JavaCheck>> checkClasses)
-
testCheckClasses
public Collection<JavaCheck> testCheckClasses()
-
getFileSystem
public org.sonar.api.batch.fs.FileSystem getFileSystem()
-
getRuleKey
public org.sonar.api.rule.RuleKey getRuleKey(JavaCheck check)
-
addIssue
public void addIssue(File file, JavaCheck check, int line, String message, @Nullable Integer cost)
-
reportIssue
public void reportIssue(AnalyzerMessage analyzerMessage)
-
reportAnalysisError
public boolean reportAnalysisError(com.sonar.sslr.api.RecognitionException re, File file)
-
isSonarLintContext
public boolean isSonarLintContext()
-
analysisCancelled
public boolean analysisCancelled()
-
addAnalysisError
public void addAnalysisError(AnalysisError analysisError)
-
saveAnalysisErrors
public void saveAnalysisErrors()
-
shouldFailAnalysisOnException
public boolean shouldFailAnalysisOnException()
-
workDir
public File workDir()
-
-