Skip to content

Commit

Permalink
Fix LSP fetching bug and Emit getServer after each step of LSP fetchi…
Browse files Browse the repository at this point in the history
…ng (#260)
  • Loading branch information
nborges-aws authored Nov 21, 2024
1 parent bb3a474 commit 53c340f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static Builder builder() {
}

@Override
public LspInstallResult getLspInstallation() {
public synchronized LspInstallResult getLspInstallation() {
if (installResult != null) {
return installResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public LspFetchResult fetch(final PluginPlatform platform, final PluginArchitect

// delete invalid local cache
ArtifactUtils.deleteDirectory(downloadDirectory);
emitGetServer(Result.FAILED, serverVersion, LanguageServerLocation.CACHE, null, start);

// if all lsp target contents are successfully downloaded from remote location,
// return the download location
Expand All @@ -118,6 +119,7 @@ public LspFetchResult fetch(final PluginPlatform platform, final PluginArchitect
Activator.getLogger().info(String.format(
"Unable to download Amazon Q language server version v%s. Attempting to fetch from fallback location",
serverVersion));
emitGetServer(Result.FAILED, serverVersion, LanguageServerLocation.REMOTE, null, start);

// use the most compatible fallback cached lsp version
var fallbackDir = getFallback(serverVersion, platform, architecture, destination);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import software.aws.toolkits.eclipse.amazonq.lsp.manager.fetcher.RecordLspSetupArgs;
import software.aws.toolkits.eclipse.amazonq.plugin.Activator;
import software.aws.toolkits.telemetry.LanguageserverTelemetry;
import software.aws.toolkits.telemetry.TelemetryDefinitions.LanguageServerLocation;
import software.aws.toolkits.telemetry.TelemetryDefinitions.LanguageServerSetupStage;
import software.aws.toolkits.telemetry.TelemetryDefinitions.Result;

Expand Down Expand Up @@ -36,14 +37,14 @@ public static void emitSetupGetManifest(final Result result, final RecordLspSetu

public static void emitSetupGetServer(final Result result, final RecordLspSetupArgs args) {
emitSetupMetric(result, args, LanguageServerSetupStage.GET_SERVER);
if (result == Result.FAILED) {
if (result == Result.FAILED && args.getLocation() == LanguageServerLocation.UNKNOWN) {
emitSetupAll(Result.FAILED, args);
}
}

public static void emitSetupValidate(final Result result, final RecordLspSetupArgs args) {
emitSetupMetric(result, args, LanguageServerSetupStage.VALIDATE);
if (result == Result.FAILED) {
if (result == Result.FAILED && args.getLocation() != LanguageServerLocation.OVERRIDE) {
emitSetupAll(Result.FAILED, args);
}
}
Expand Down

0 comments on commit 53c340f

Please sign in to comment.