use of org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.InputFile in project sonarlint-core by SonarSource.
the class StandaloneDaemonTest method createAnalysisConfig.
private AnalysisReq createAnalysisConfig(String projectName) throws IOException {
Path projectPath = clientTools.deployProject(projectName);
List<Path> sourceFiles = clientTools.collectAllFiles(projectPath.resolve("src"));
Builder builder = AnalysisReq.newBuilder();
for (Path p : sourceFiles) {
InputFile file = InputFile.newBuilder().setCharset(StandardCharsets.UTF_8.name()).setPath(p.toAbsolutePath().toString()).setIsTest(false).build();
builder.addFile(file);
}
return builder.setBaseDir(projectPath.toAbsolutePath().toString()).setWorkDir(temp.newFolder().getAbsolutePath()).putAllProperties(Collections.singletonMap("key", "value")).build();
}
use of org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.InputFile 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);
}
}
use of org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.InputFile 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);
}
}
use of org.sonarsource.sonarlint.daemon.proto.SonarlintDaemon.InputFile in project sonarlint-core by SonarSource.
the class ConnectedDaemonTest method createAnalysisConfig.
private ConnectedAnalysisReq createAnalysisConfig(String projectName) throws IOException {
Path projectPath = clientTools.deployProject(projectName);
List<Path> sourceFiles = clientTools.collectAllFiles(projectPath);
Builder builder = ConnectedAnalysisReq.newBuilder();
for (Path p : sourceFiles) {
InputFile file = InputFile.newBuilder().setCharset(StandardCharsets.UTF_8.name()).setPath(p.toAbsolutePath().toString()).setIsTest(false).build();
builder.addFile(file);
}
return builder.setBaseDir(projectPath.toAbsolutePath().toString()).setWorkDir(temp.newFolder().getAbsolutePath()).setModuleKey(PROJECT_KEY_JAVA).putAllProperties(Collections.singletonMap("sonar.java.binaries", new File("projects/sample-java/target/classes").getAbsolutePath())).build();
}
Aggregations