Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: eligibility criteria for class and method annotations #5981

Draft
wants to merge 2 commits into
base: feat/apex-oas
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 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,9 @@ import {
retrieveAAMethodAccessModifiers,
retrieveAAPropDefModifiers,
retrieveAAPropAccessModifiers,
retrieveAAAnnotations,
retrieveAAClassRestAnnotations,
retrieveAAMethodRestAnnotations,
retrieveAAMethodAnnotations,
retrieveGeneralClassAccessModifiers,
retrieveGeneralMethodAccessModifiers,
retrieveGeneralPropAccessModifiers
Expand Down Expand Up @@ -170,7 +172,9 @@ export const buildClientOptions = (): LanguageClientOptions => {
apexActionMethodAccessModifiers: retrieveAAMethodAccessModifiers().join(','),
apexActionPropDefModifiers: retrieveAAPropDefModifiers().join(','),
apexActionPropAccessModifiers: retrieveAAPropAccessModifiers().join(','),
apexActionAnnotations: retrieveAAAnnotations().join(','),
apexActionClassRestAnnotations: retrieveAAClassRestAnnotations().join(','),
apexActionMethodRestAnnotations: retrieveAAMethodRestAnnotations().join(','),
apexActionMethodAnnotations: retrieveAAMethodAnnotations().join(','),
apexOASClassAccessModifiers: retrieveGeneralClassAccessModifiers().join(','),
apexOASMethodAccessModifiers: retrieveGeneralMethodAccessModifiers().join(','),
apexOASPropAccessModifiers: retrieveGeneralPropAccessModifiers().join(',')
Expand Down
19 changes: 15 additions & 4 deletions packages/salesforcedx-vscode-apex/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +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_ANNOTATIONS = ['AuraEnabled', 'RestResource'];
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 @@ -78,11 +80,20 @@ export const retrieveAAPropAccessModifiers = (): string[] => {
return [...new Set([...APEX_ACTION_PROP_ACCESS_MODIFIERS, ...userDefinedModifiers])];
};

export const retrieveAAAnnotations = (): string[] => {
export const retrieveAAMethodAnnotations = (): string[] => {
const userDefinedModifiers = vscode.workspace
.getConfiguration()
.get<string[]>('salesforcedx-vscode-apex.apexoas.aa.annotations', []);
return [...new Set([...APEX_ACTION_ANNOTATIONS, ...userDefinedModifiers])];
.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[] =>
Expand Down
Loading