Skip to content

Commit 35f3078

Browse files
pras0131Paras
andauthored
chore: refactor common customization logic to a function and update corresponding CONTRIBUTION.md (#1281)
Co-authored-by: Paras <[email protected]>
1 parent 16162f6 commit 35f3078

File tree

2 files changed

+39
-30
lines changed

2 files changed

+39
-30
lines changed

CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,20 @@ npm link @aws/language-server-runtimes @aws/language-server-runtimes-types &&
431431
npm run compile -- --force
432432
```
433433

434+
### Customization
435+
#### Single Profile Customizations
436+
To request customization information for a selected developer profile, use the `aws/getConfigurationFromServer` LSP extension with the section field set to `aws.q.customizations`.
437+
438+
#### Multiple Profile Customizations
439+
To request customization information for all valid developer profiles, use the same `aws/getConfigurationFromServer` LSP extension. However, this requires setting the following initialization parameters in the client:
440+
1. `initializationOptions.aws.awsClientCapabilities.q.customizationsWithMetadata`
441+
2. `initializationOptions.aws.awsClientCapabilities.q.developerProfiles`
442+
443+
Both the above-mentioned fields must be set to true.
444+
445+
#### Testing Customizations
446+
When testing customizations with the minimal VSCode extension, set the `ENABLE_CUSTOMIZATIONS_WITH_METADATA` environment variable to `true` in your launch configuration.
447+
434448
### Endpoint and region override
435449
It is possible to override the default region and default endpoint utilized by the AWS SDK clients (e.g. for the Q developer backend api endpoint) when building the capabilities servers.
436450

server/aws-lsp-codewhisperer/src/language-server/configuration/qConfigurationServer.ts

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ export const QConfigurationServerToken =
5252
let serverConfigurationProvider: ServerConfigurationProvider
5353
let enableCustomizationsWithMetadata = false
5454

55+
const isCustomizationsWithDeveloperProfileEnabled = (): boolean => {
56+
return enableCustomizationsWithMetadata && amazonQServiceManager.getEnableDeveloperProfileSupport()
57+
}
58+
59+
const enhancedCustomizationsWithMetadata = async (
60+
token: CancellationToken
61+
): Promise<CustomizationWithMetadata[]> => {
62+
logging.debug('Using enhanced customizations with metadata')
63+
64+
// Fetch profiles first
65+
const developerProfiles = await serverConfigurationProvider.listAvailableProfiles(token)
66+
67+
// Then use those profiles to fetch customizations
68+
const customizations = await serverConfigurationProvider.listAllAvailableCustomizationsWithMetadata(
69+
developerProfiles,
70+
token
71+
)
72+
73+
return customizations
74+
}
75+
5576
lsp.addInitializer((params: InitializeParams) => {
5677
// Check for feature flag in client capabilities
5778
const qCapabilities = params.initializationOptions?.aws?.awsClientCapabilities?.q as
@@ -98,21 +119,8 @@ export const QConfigurationServerToken =
98119
try {
99120
switch (section) {
100121
case Q_CONFIGURATION_SECTION:
101-
if (
102-
enableCustomizationsWithMetadata &&
103-
amazonQServiceManager.getEnableDeveloperProfileSupport()
104-
) {
105-
logging.debug('Using enhanced customizations with metadata')
106-
107-
// Fetch profiles first
108-
developerProfiles = await serverConfigurationProvider.listAvailableProfiles(token)
109-
110-
// Then use those profiles to fetch customizations
111-
customizations =
112-
await serverConfigurationProvider.listAllAvailableCustomizationsWithMetadata(
113-
developerProfiles,
114-
token
115-
)
122+
if (isCustomizationsWithDeveloperProfileEnabled()) {
123+
customizations = await enhancedCustomizationsWithMetadata(token)
116124
} else {
117125
;[customizations, developerProfiles] = await Promise.all([
118126
serverConfigurationProvider.listAvailableCustomizations(),
@@ -126,21 +134,8 @@ export const QConfigurationServerToken =
126134
? { customizations, developerProfiles }
127135
: { customizations }
128136
case Q_CUSTOMIZATIONS_CONFIGURATION_SECTION:
129-
if (
130-
enableCustomizationsWithMetadata &&
131-
amazonQServiceManager.getEnableDeveloperProfileSupport()
132-
) {
133-
logging.debug('Using enhanced customizations with metadata')
134-
135-
// Fetch profiles first
136-
const profiles = await serverConfigurationProvider.listAvailableProfiles(token)
137-
138-
// Then use those profiles to fetch customizations
139-
customizations =
140-
await serverConfigurationProvider.listAllAvailableCustomizationsWithMetadata(
141-
profiles,
142-
token
143-
)
137+
if (isCustomizationsWithDeveloperProfileEnabled()) {
138+
customizations = await enhancedCustomizationsWithMetadata(token)
144139
} else {
145140
customizations = await serverConfigurationProvider.listAvailableCustomizations()
146141
}

0 commit comments

Comments
 (0)