-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deserialization support for AWS LSP extended InitializeResult (#49)
- Loading branch information
Showing
9 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/QLspTypeAdapterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.lsp; | ||
|
||
import java.io.IOException; | ||
|
||
import org.eclipse.lsp4j.InitializeResult; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.TypeAdapterFactory; | ||
import com.google.gson.reflect.TypeToken; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonWriter; | ||
|
||
import software.aws.toolkits.eclipse.amazonq.lsp.model.AwsExtendedInitializeResult; | ||
|
||
public class QLspTypeAdapterFactory implements TypeAdapterFactory { | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public final <T> TypeAdapter<T> create(final Gson gson, final TypeToken<T> type) { | ||
if (type.getRawType() == InitializeResult.class) { | ||
final TypeAdapter<InitializeResult> delegate = (TypeAdapter<InitializeResult>) gson.getDelegateAdapter(this, type); | ||
|
||
return (TypeAdapter<T>) new TypeAdapter<InitializeResult>() { | ||
@Override | ||
public void write(final JsonWriter out, final InitializeResult value) throws IOException { | ||
delegate.write(out, value); | ||
} | ||
|
||
@Override | ||
public InitializeResult read(final JsonReader in) throws IOException { | ||
return gson.fromJson(in, AwsExtendedInitializeResult.class); | ||
} | ||
}; | ||
} | ||
return null; | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/model/AwsExtendedInitializeResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.lsp.model; | ||
|
||
import org.eclipse.lsp4j.InitializeResult; | ||
|
||
public class AwsExtendedInitializeResult extends InitializeResult { | ||
private AwsServerCapabilities awsServerCapabilities; | ||
|
||
public final AwsServerCapabilities getAwsServerCapabilities() { | ||
return awsServerCapabilities; | ||
} | ||
|
||
public final void setAwsServerCapabilities(final AwsServerCapabilities awsServerCapabilities) { | ||
this.awsServerCapabilities = awsServerCapabilities; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/model/AwsServerCapabilities.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.lsp.model; | ||
|
||
public record AwsServerCapabilities(ChatOptions chatOptions) { } |
6 changes: 6 additions & 0 deletions
6
plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/model/ChatOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.lsp.model; | ||
|
||
public record ChatOptions(QuickActions quickActions) { } |
6 changes: 6 additions & 0 deletions
6
plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/model/Command.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.lsp.model; | ||
|
||
public record Command(String command, String description) { } |
8 changes: 8 additions & 0 deletions
8
plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/model/QuickActions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.lsp.model; | ||
|
||
import java.util.List; | ||
|
||
public record QuickActions(List<QuickActionsCommandGroup> quickActionsCommandGroups) { } |
8 changes: 8 additions & 0 deletions
8
plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/model/QuickActionsCommandGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.lsp.model; | ||
|
||
import java.util.List; | ||
|
||
public record QuickActionsCommandGroup(List<Command> commands) { } |