Search in sources :

Example 1 with LoggedErrorHandler

use of org.sonarsource.sonarlint.core.util.LoggedErrorHandler in project sonarlint-core by SonarSource.

the class ConnectedSonarLintEngineImpl method analyze.

@Override
public AnalysisResults analyze(ConnectedAnalysisConfiguration configuration, IssueListener issueListener, @Nullable LogOutput logOutput, @Nullable ProgressMonitor monitor) {
    checkNotNull(configuration);
    checkNotNull(issueListener);
    setLogging(logOutput);
    LoggedErrorHandler errorHandler = new LoggedErrorHandler(configuration.inputFiles());
    SonarLintLogging.setErrorHandler(errorHandler);
    return withReadLock(() -> {
        try {
            AnalysisResults results = getHandler().analyze(storageContainer.getGlobalExtensionContainer(), configuration, issueListener, new ProgressWrapper(monitor));
            errorHandler.getErrorFiles().forEach(results.failedAnalysisFiles()::add);
            return results;
        } catch (RuntimeException e) {
            throw SonarLintWrappedException.wrap(e);
        }
    });
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) LoggedErrorHandler(org.sonarsource.sonarlint.core.util.LoggedErrorHandler) AnalysisResults(org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults)

Example 2 with LoggedErrorHandler

use of org.sonarsource.sonarlint.core.util.LoggedErrorHandler in project sonarlint-core by SonarSource.

the class StandaloneSonarLintEngineImpl method analyze.

@Override
public AnalysisResults analyze(StandaloneAnalysisConfiguration configuration, IssueListener issueListener, @Nullable LogOutput logOutput, @Nullable ProgressMonitor monitor) {
    checkNotNull(configuration);
    checkNotNull(issueListener);
    setLogging(logOutput);
    LoggedErrorHandler errorHandler = new LoggedErrorHandler(configuration.inputFiles());
    SonarLintLogging.setErrorHandler(errorHandler);
    rwl.readLock().lock();
    try {
        AnalysisResults results = globalContainer.analyze(configuration, issueListener, new ProgressWrapper(monitor));
        errorHandler.getErrorFiles().forEach(results.failedAnalysisFiles()::add);
        return results;
    } catch (RuntimeException e) {
        throw SonarLintWrappedException.wrap(e);
    } finally {
        rwl.readLock().unlock();
    }
}
Also used : ProgressWrapper(org.sonarsource.sonarlint.core.util.ProgressWrapper) LoggedErrorHandler(org.sonarsource.sonarlint.core.util.LoggedErrorHandler) AnalysisResults(org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults)

Aggregations

AnalysisResults (org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults)2 LoggedErrorHandler (org.sonarsource.sonarlint.core.util.LoggedErrorHandler)2 ProgressWrapper (org.sonarsource.sonarlint.core.util.ProgressWrapper)2