Skip to content

Commit

Permalink
chore: update rest-related annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
mingxuanzhangsfdx committed Dec 17, 2024
1 parent d84d771 commit 8a79000
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
6 changes: 4 additions & 2 deletions packages/salesforcedx-vscode-apex/src/languageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
retrieveAAMethodAccessModifiers,
retrieveAAPropDefModifiers,
retrieveAAPropAccessModifiers,
retrieveAAClassAnnotations,
retrieveAAClassRestAnnotations,
retrieveAAMethodRestAnnotations,
retrieveAAMethodAnnotations,
retrieveGeneralClassAccessModifiers,
retrieveGeneralMethodAccessModifiers,
Expand Down Expand Up @@ -171,7 +172,8 @@ export const buildClientOptions = (): LanguageClientOptions => {
apexActionMethodAccessModifiers: retrieveAAMethodAccessModifiers().join(','),
apexActionPropDefModifiers: retrieveAAPropDefModifiers().join(','),
apexActionPropAccessModifiers: retrieveAAPropAccessModifiers().join(','),
apexActionClassAnnotations: retrieveAAClassAnnotations().join(','),
apexActionClassRestAnnotations: retrieveAAClassRestAnnotations().join(','),
apexActionMethodRestAnnotations: retrieveAAMethodRestAnnotations().join(','),
apexActionMethodAnnotations: retrieveAAMethodAnnotations().join(','),
apexOASClassAccessModifiers: retrieveGeneralClassAccessModifiers().join(','),
apexOASMethodAccessModifiers: retrieveGeneralMethodAccessModifiers().join(','),
Expand Down
21 changes: 12 additions & 9 deletions packages/salesforcedx-vscode-apex/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ const APEX_ACTION_METHOD_DEF_MODIFIERS = ['static'];
const APEX_ACTION_METHOD_ACCESS_MODIFIERS = ['global', 'public'];
const APEX_ACTION_PROP_DEF_MODIFIERS = ['static'];
const APEX_ACTION_PROP_ACCESS_MODIFIERS = ['global', 'public'];
const APEX_ACTION_CLASS_ANNOTATION = ['AuraEnabled', 'RestResource'];
const APEX_ACTION_METHOD_ANNOTATION = ['AuraEnabled', 'HttpDelete', 'HttpGet', 'HttpPatch', 'HttpPost', 'HttpPut'];
const APEX_ACTION_CLASS_REST_ANNOTATION = ['RestResource'];
const APEX_ACTION_METHOD_REST_ANNOTATION = ['HttpDelete', 'HttpGet', 'HttpPatch', 'HttpPost', 'HttpPut'];
const APEX_ACTION_METHOD_ANNOTATION = ['AuraEnabled'];

// Default eligibility for general OAS generation. Users can changed the setting through VSCode configurations
const DEFAULT_CLASS_ACCESS_MODIFIERS = ['global', 'public'];
Expand Down Expand Up @@ -79,20 +80,22 @@ export const retrieveAAPropAccessModifiers = (): string[] => {
return [...new Set([...APEX_ACTION_PROP_ACCESS_MODIFIERS, ...userDefinedModifiers])];
};

export const retrieveAAClassAnnotations = (): string[] => {
const userDefinedModifiers = vscode.workspace
.getConfiguration()
.get<string[]>('salesforcedx-vscode-apex.apexoas.aa.class.annotations', []);
return [...new Set([...APEX_ACTION_CLASS_ANNOTATION, ...userDefinedModifiers])];
};

export const retrieveAAMethodAnnotations = (): string[] => {
const userDefinedModifiers = vscode.workspace
.getConfiguration()
.get<string[]>('salesforcedx-vscode-apex.apexoas.aa.method.annotations', []);
return [...new Set([...APEX_ACTION_METHOD_ANNOTATION, ...userDefinedModifiers])];
};

// The REST-related annotations should not be edited by users
export const retrieveAAClassRestAnnotations = (): string[] => {
return [...new Set([...APEX_ACTION_CLASS_REST_ANNOTATION])];
};

export const retrieveAAMethodRestAnnotations = (): string[] => {
return [...new Set([...APEX_ACTION_METHOD_REST_ANNOTATION])];
};

export const retrieveGeneralClassAccessModifiers = (): string[] =>
vscode.workspace
.getConfiguration()
Expand Down

0 comments on commit 8a79000

Please sign in to comment.