Skip to content

Commit

Permalink
SLI-1313 Avoid slow operations when opening project settings (#977)
Browse files Browse the repository at this point in the history
  • Loading branch information
nquinquenel authored Mar 6, 2024
1 parent 97a906f commit 8823c9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import static java.awt.GridBagConstraints.NONE;
import static java.awt.GridBagConstraints.WEST;
import static java.util.Optional.ofNullable;
import static org.sonarlint.intellij.util.ThreadUtilsKt.computeOnPooledThread;

public class SonarLintProjectBindPanel {
private static final String CONNECTION_EMPTY_TEXT = "<No connections configured>";
Expand Down Expand Up @@ -289,7 +290,8 @@ public void actionPerformed(ActionEvent e) {
private void actionConfigureConnections() {
var allSettings = Settings.KEY.getData(DataManager.getInstance().getDataContext(rootPanel));
if (allSettings != null) {
final var globalConfigurable = allSettings.find(SonarLintGlobalConfigurable.class);
final var globalConfigurable = computeOnPooledThread("Find Global Configurable Task",
() -> allSettings.find(SonarLintGlobalConfigurable.class));
if (globalConfigurable != null) {
allSettings.select(globalConfigurable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import javax.swing.JComponent;
import org.jetbrains.annotations.Nls;
import org.jetbrains.concurrency.Promise;
import org.jetbrains.concurrency.Promises;
import org.sonarlint.intellij.analysis.AnalysisSubmitter;
import org.sonarlint.intellij.config.global.ServerConnection;
import org.sonarlint.intellij.config.global.SonarLintGlobalConfigurable;
Expand All @@ -43,6 +44,7 @@
import static org.sonarlint.intellij.common.util.SonarLintUtils.getService;
import static org.sonarlint.intellij.config.Settings.getGlobalSettings;
import static org.sonarlint.intellij.config.Settings.getSettingsFor;
import static org.sonarlint.intellij.util.ThreadUtilsKt.computeOnPooledThread;

/**
* Coordinates creation of models and visual components from persisted settings.
Expand Down Expand Up @@ -119,15 +121,16 @@ public void reset() {

private static Promise<List<ServerConnection>> getServersFromApplicationConfigurable() {
return DataManager.getInstance().getDataContextFromFocusAsync()
.then(dataContext -> {
.thenAsync(dataContext -> {
var allSettings = Settings.KEY.getData(dataContext);
if (allSettings != null) {
final var globalConfigurable = allSettings.find(SonarLintGlobalConfigurable.class);
final var globalConfigurable = computeOnPooledThread("Find Global Configurable Task",
() -> allSettings.find(SonarLintGlobalConfigurable.class));
if (globalConfigurable != null) {
return globalConfigurable.getCurrentConnections();
return Promises.resolvedPromise(globalConfigurable.getCurrentConnections());
}
}
return null;
return Promises.resolvedPromise(null);
});
}

Expand Down

0 comments on commit 8823c9e

Please sign in to comment.