Skip to content

Commit

Permalink
SLLS-284 accept path to eslint bridge server bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
sophio-japharidze-sonarsource committed Dec 6, 2024
1 parent c78da87 commit c155a86
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,9 @@ public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
setNotebookSyncOptions(c);
}

var eslintBridgeServerPath = (String) additionalAttributes.get("eslintBridgeServerPath");
var info = new ServerInfo("SonarLint Language Server", getServerVersion("slls-version.txt"));
provideBackendInitData(productKey, userAgent, clientNodePath);
provideBackendInitData(productKey, userAgent, clientNodePath, eslintBridgeServerPath);
return new InitializeResult(c, info);
});
}
Expand Down Expand Up @@ -763,7 +764,7 @@ private void addPluginPathOrWarn(String pluginName, Language language, Map<Strin
() -> lsLogOutput.warn(format("Embedded plugin not found: %s", SonarLanguage.valueOf(language.name()).getSonarLanguageKey())));
}

void provideBackendInitData(String productKey, String userAgent, String clientNodePath) {
void provideBackendInitData(String productKey, String userAgent, String clientNodePath, String eslintBridgeServerPath) {
BackendInitParams params = backendServiceFacade.getInitParams();
params.setTelemetryProductKey(productKey);
var actualSonarLintUserHome = Optional.ofNullable(SettingsManager.getSonarLintUserHomeOverride()).orElse(SonarLintUserHome.get());
Expand All @@ -780,6 +781,7 @@ void provideBackendInitData(String productKey, String userAgent, String clientNo
.map(l -> Language.valueOf(l.name())).collect(Collectors.toSet()));
params.setUserAgent(userAgent);
params.setClientNodePath(clientNodePath);
params.setEslintBridgeServerPath(eslintBridgeServerPath);
}

public CompletableFuture<Void> showHotspotLocations(ShowHotspotLocationsParams showHotspotLocationsParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.sonarsource.sonarlint.core.rpc.protocol.common.Language;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.connection.config.SonarCloudConnectionConfigurationDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.connection.config.SonarQubeConnectionConfigurationDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.rules.StandaloneRuleConfigDto;
import org.sonarsource.sonarlint.core.rpc.protocol.common.Language;

public class BackendInitParams {

Expand All @@ -44,6 +44,7 @@ public class BackendInitParams {
private String userAgent;
private boolean isFocusOnNewCode;
private String clientNodePath;
private String eslintBridgeServerPath;

public String getTelemetryProductKey() {
return telemetryProductKey;
Expand Down Expand Up @@ -156,4 +157,12 @@ public void setClientNodePath(String clientNodePath) {
public String getClientNodePath() {
return clientNodePath;
}

public void setEslintBridgeServerPath(String eslintBridgeServerPath) {
this.eslintBridgeServerPath = eslintBridgeServerPath;
}

public String getEslintBridgeServerPath() {
return eslintBridgeServerPath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.FeatureFlagsDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.HttpConfigurationDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.InitializeParams;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.JsTsRequirementsDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.LanguageSpecificRequirements;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.OmnisharpRequirementsDto;
import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.SonarCloudAlternativeEnvironmentDto;
Expand Down Expand Up @@ -155,7 +156,8 @@ private void initOnce(Map<String, ServerConnectionSettings> connections) {
private InitializeParams toInitParams(BackendInitParams initParams) {
var telemetryEnabled = telemetry != null && telemetry.enabled();
var clientNodeJsPath = StringUtils.isEmpty(initParams.getClientNodePath()) ? null : Path.of(initParams.getClientNodePath());
var languageSpecificRequirements = getLanguageSpecificRequirements(clientNodeJsPath);
var eslintBridgeServerBundlePath = StringUtils.isEmpty(initParams.getEslintBridgeServerPath()) ? null : Path.of(initParams.getEslintBridgeServerPath());
var languageSpecificRequirements = getLanguageSpecificRequirements(clientNodeJsPath, eslintBridgeServerBundlePath);
return new InitializeParams(
new ClientConstantInfoDto("Visual Studio Code", initParams.getUserAgent()),
new TelemetryClientConstantAttributesDto(initParams.getTelemetryProductKey(),
Expand Down Expand Up @@ -186,9 +188,9 @@ private InitializeParams toInitParams(BackendInitParams initParams) {
}

@NotNull
private LanguageSpecificRequirements getLanguageSpecificRequirements(@Nullable Path clientNodeJsPath) {
private LanguageSpecificRequirements getLanguageSpecificRequirements(@Nullable Path clientNodeJsPath, @Nullable Path eslintBridgeSeverPath) {
return new LanguageSpecificRequirements(
clientNodeJsPath,
new JsTsRequirementsDto(clientNodeJsPath, eslintBridgeSeverPath),
getOmnisharpRequirements()
);
}
Expand Down

0 comments on commit c155a86

Please sign in to comment.