Skip to content

Commit

Permalink
SLLS-281 try deduplicating
Browse files Browse the repository at this point in the history
  • Loading branch information
sophio-japharidze-sonarsource committed Nov 28, 2024
1 parent 6755162 commit d84e2ea
Showing 1 changed file with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,12 @@ private void notifyBackend(List<FileEvent> changes) {
if (event.getType() == FileChangeType.Deleted) {
deletedFileUris.add(fileUri);
} else {
workspaceFoldersManager.findFolderForFile(fileUri)
.ifPresent(folder -> {
var settings = folder.getSettings();
var baseDir = folder.getRootPath();
var fsPath = Paths.get(fileUri);
var relativePath = baseDir.relativize(fsPath);
var folderUri = folder.getUri().toString();
var isTest = isTestFile(fileUri, settings);
if (event.getType() == FileChangeType.Created) {
addedFiles.add(new ClientFileDto(fileUri, relativePath, folderUri, isTest, StandardCharsets.UTF_8.name(), fsPath, null, null, true));
} else {
changedFiles.add(new ClientFileDto(fileUri, relativePath, folderUri, isTest, StandardCharsets.UTF_8.name(), fsPath, null, null, true));
}
});
var clientFileDto = getClientFileDto(new VersionedOpenFile(fileUri, "", 0, ""));
if (event.getType() == FileChangeType.Created) {
addedFiles.add(clientFileDto);
} else {
changedFiles.add(clientFileDto);
}
}
});
backendServiceFacade.getBackendService().updateFileSystem(addedFiles, changedFiles, deletedFileUris);
Expand Down Expand Up @@ -133,10 +125,6 @@ ClientFileDto getClientFileDto(VersionedOpenFile file) {
return clientFileDto.get();
}

private boolean isTestFile(URI fileUri, WorkspaceFolderSettings settings) {
return fileTypeClassifier.isTest(settings, fileUri, false, () -> javaConfigCache.getOrFetch(fileUri));
}

private boolean isTestFile(VersionedOpenFile file, WorkspaceFolderSettings settings) {
return fileTypeClassifier.isTest(settings, file.getUri(), file.isJava(), () -> javaConfigCache.getOrFetch(file.getUri()));
}
Expand Down

0 comments on commit d84e2ea

Please sign in to comment.