Skip to content

Commit

Permalink
SLVSCODE-955 pass null content for modified files
Browse files Browse the repository at this point in the history
  • Loading branch information
sophio-japharidze-sonarsource committed Dec 4, 2024
1 parent cbbc5ac commit 1008302
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.sonarsource.sonarlint.ls.file;

import java.net.URI;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import org.apache.commons.lang3.builder.ToStringBuilder;

Expand All @@ -33,7 +34,7 @@ public class VersionedOpenFile {
private final int version;
private final String content;

public VersionedOpenFile(URI uri, String languageId, int version, String content) {
public VersionedOpenFile(URI uri, @Nullable String languageId, int version, @Nullable String content) {
this.uri = uri;
this.languageId = languageId;
this.version = version;
Expand All @@ -44,6 +45,7 @@ public URI getUri() {
return uri;
}

@Nullable
public String getLanguageId() {
return languageId;
}
Expand All @@ -52,6 +54,7 @@ public int getVersion() {
return version;
}

@Nullable
public String getContent() {
return content;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void notifyBackend(List<FileEvent> changes) {
if (event.getType() == FileChangeType.Deleted) {
deletedFileUris.add(fileUri);
} else {
var clientFileDto = getClientFileDto(new VersionedOpenFile(fileUri, "", 0, ""));
var clientFileDto = getClientFileDto(new VersionedOpenFile(fileUri, null, 0, null));
if (event.getType() == FileChangeType.Created) {
addedFiles.add(clientFileDto);
} else {
Expand Down Expand Up @@ -107,7 +107,8 @@ ClientFileDto getClientFileDto(VersionedOpenFile file) {
AtomicReference<ClientFileDto> clientFileDto = new AtomicReference<>();
var fileUri = file.getUri();
var fsPath = Paths.get(fileUri);
SonarLanguage sqLanguage = AnalysisClientInputFile.toSqLanguage(file.getLanguageId().toLowerCase(Locale.ROOT));
SonarLanguage sqLanguage = file.getLanguageId() != null ?
AnalysisClientInputFile.toSqLanguage(file.getLanguageId().toLowerCase(Locale.ROOT)) : null;
workspaceFoldersManager.findFolderForFile(fileUri)
.ifPresentOrElse(folder -> {
var settings = folder.getSettings();
Expand Down

0 comments on commit 1008302

Please sign in to comment.