Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLLS-207 do not notify backend after assistCreatingConnection #401

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -113,7 +112,6 @@
import org.sonarsource.sonarlint.ls.folders.WorkspaceFoldersManager;
import org.sonarsource.sonarlint.ls.log.LanguageClientLogger;
import org.sonarsource.sonarlint.ls.progress.LSProgressMonitor;
import org.sonarsource.sonarlint.ls.settings.ServerConnectionSettings;
import org.sonarsource.sonarlint.ls.settings.SettingsManager;
import org.sonarsource.sonarlint.ls.standalone.notifications.PromotionalNotifications;
import org.sonarsource.sonarlint.ls.util.Utils;
Expand All @@ -122,7 +120,6 @@
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList;
import static org.sonarsource.sonarlint.ls.backend.BackendServiceFacade.ROOT_CONFIGURATION_SCOPE;
import static org.sonarsource.sonarlint.ls.settings.ServerConnectionSettings.SONARCLOUD_URL;
import static org.sonarsource.sonarlint.ls.util.URIUtils.getFullFileUriFromFragments;
import static org.sonarsource.sonarlint.ls.util.Utils.convertMessageType;

Expand Down Expand Up @@ -272,33 +269,17 @@ public AssistCreatingConnectionResponse assistCreatingConnection(AssistCreatingC
isSonarCloud ? params.getConnectionParams().getRight().getOrganizationKey() : params.getConnectionParams().getLeft().getServerUrl(),
tokenValue));
return workspaceFoldersFuture.thenCombine(assistCreatingConnectionFuture, (workspaceFolders, assistCreatingConnectionResponse) -> {
var currentConnections = getCurrentConnections(params, assistCreatingConnectionResponse);
var newConnectionId = assistCreatingConnectionResponse.getNewConnectionId();
if (newConnectionId != null) {
var serverProductName = isSonarCloud ? "SonarCloud" : "SonarQube";
client.showMessage(new MessageParams(MessageType.Info, format("Connection to %s was successfully created.", serverProductName)));
backendServiceFacade.getBackendService().didChangeConnections(currentConnections);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call was in fact making things worse, as it was "faking" to notifying SLCORE that a connection was added BEFORE it had actually reached SLLS settings storage. SLCORE already has a mechanism that waits for the actual connection creation for 5 seconds.

return new AssistCreatingConnectionResponse(newConnectionId);
} else {
throw new CancellationException("Automatic connection setup was cancelled");
}
}).join();
}

@NotNull
private HashMap<String, ServerConnectionSettings> getCurrentConnections(AssistCreatingConnectionParams params,
@Nullable SonarLintExtendedLanguageClient.AssistCreatingConnectionResponse assistCreatingConnectionResponse) {
if (assistCreatingConnectionResponse == null) {
throw new CancellationException("Automatic connection setup was cancelled");
}
var serverUrl = params.getConnectionParams().isLeft() ? params.getConnectionParams().getLeft().getServerUrl() : SONARCLOUD_URL;
var organisationKey = params.getConnectionParams().isRight() ? params.getConnectionParams().getRight().getOrganizationKey() : null;
var newConnection = new ServerConnectionSettings(assistCreatingConnectionResponse.getNewConnectionId(), serverUrl, params.getTokenValue(), organisationKey, false);
var currentConnections = new HashMap<>(settingsManager.getCurrentSettings().getServerConnections());
currentConnections.put(assistCreatingConnectionResponse.getNewConnectionId(), newConnection);
return currentConnections;
}

@Override
public AssistBindingResponse assistBinding(AssistBindingParams params, SonarLintCancelChecker cancelChecker) {
workspaceFoldersManager.updateAnalysisReadiness(Set.of(params.getConfigScopeId()), false);
Expand Down
Loading