Search in sources :

Example 1 with DefaultClientInputFile

use of org.sonarlint.daemon.model.DefaultClientInputFile in project sonarlint-core by SonarSource.

the class StandaloneSonarLintImpl method analyze.

@Override
public void analyze(AnalysisReq requestConfig, StreamObserver<Issue> response) {
    if (engine == null) {
        response.onError(new IllegalStateException("Not registered"));
        return;
    }
    try {
        List<ClientInputFile> files = new LinkedList<>();
        List<InputFile> requestFiles = requestConfig.getFileList();
        Path baseDir = Paths.get(requestConfig.getBaseDir());
        for (InputFile f : requestFiles) {
            files.add(new DefaultClientInputFile(baseDir, Paths.get(f.getPath()), f.getIsTest(), Charset.forName(f.getCharset()), f.getUserObject(), trimToNull(f.getLanguage())));
        }
        StandaloneAnalysisConfiguration config = new StandaloneAnalysisConfiguration(baseDir, Paths.get(requestConfig.getWorkDir()), files, requestConfig.getPropertiesMap());
        logOutput.log("Analysis configuration:\n" + config.toString(), Level.DEBUG);
        engine.analyze(config, new ProxyIssueListener(response), logOutput, null);
        response.onCompleted();
    } catch (Exception e) {
        LOGGER.error("Error analyzing", e);
        response.onError(e);
    }
}
Also used : Path(java.nio.file.Path) DefaultClientInputFile(org.sonarlint.daemon.model.DefaultClientInputFile) ProxyIssueListener(org.sonarlint.daemon.model.ProxyIssueListener) StandaloneAnalysisConfiguration(org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration) DefaultClientInputFile(org.sonarlint.daemon.model.DefaultClientInputFile) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) LinkedList(java.util.LinkedList) DefaultClientInputFile(org.sonarlint.daemon.model.DefaultClientInputFile) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) InputFile(org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.InputFile)

Example 2 with DefaultClientInputFile

use of org.sonarlint.daemon.model.DefaultClientInputFile in project sonarlint-core by SonarSource.

the class ConnectedSonarLintImpl method analyze.

@Override
public void analyze(ConnectedAnalysisReq requestConfig, StreamObserver<org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.Issue> response) {
    try {
        List<ClientInputFile> files = new LinkedList<>();
        List<InputFile> requestFiles = requestConfig.getFileList();
        Path baseDir = Paths.get(requestConfig.getBaseDir());
        for (InputFile f : requestFiles) {
            files.add(new DefaultClientInputFile(baseDir, Paths.get(f.getPath()), f.getIsTest(), Charset.forName(f.getCharset()), f.getUserObject(), trimToNull(f.getLanguage())));
        }
        ConnectedAnalysisConfiguration config = new ConnectedAnalysisConfiguration(requestConfig.getModuleKey(), baseDir, Paths.get(requestConfig.getWorkDir()), files, requestConfig.getPropertiesMap());
        engine.analyze(config, new ProxyIssueListener(response), logOutput, null);
        response.onCompleted();
    } catch (Exception e) {
        LOGGER.error("Error analyzing", e);
        response.onError(e);
    }
}
Also used : Path(java.nio.file.Path) DefaultClientInputFile(org.sonarlint.daemon.model.DefaultClientInputFile) ConnectedAnalysisConfiguration(org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration) ProxyIssueListener(org.sonarlint.daemon.model.ProxyIssueListener) DefaultClientInputFile(org.sonarlint.daemon.model.DefaultClientInputFile) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) LinkedList(java.util.LinkedList) DefaultClientInputFile(org.sonarlint.daemon.model.DefaultClientInputFile) ClientInputFile(org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile) InputFile(org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.InputFile)

Aggregations

Path (java.nio.file.Path)2 LinkedList (java.util.LinkedList)2 DefaultClientInputFile (org.sonarlint.daemon.model.DefaultClientInputFile)2 ProxyIssueListener (org.sonarlint.daemon.model.ProxyIssueListener)2 ClientInputFile (org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile)2 InputFile (org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.InputFile)2 ConnectedAnalysisConfiguration (org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration)1 StandaloneAnalysisConfiguration (org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration)1