Skip to content

Commit

Permalink
feat: gather context
Browse files Browse the repository at this point in the history
  • Loading branch information
CristiCanizales committed Dec 31, 2024
1 parent 24c366b commit 8569463
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
Binary file modified packages/salesforcedx-vscode-apex/out/apex-jorje-lsp.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,26 @@ export class MetadataOrchestrator {
return response;
};

public gatherContext = async (
sourceUri: vscode.Uri | vscode.Uri[]
): Promise<ApexClassOASEligibleResponses | undefined> => {
const telemetryService = await getTelemetryService();
let response;
const languageClient = languageClientUtils.getClientInstance();
if (languageClient) {
try {
response = (await languageClient?.sendRequest(
'apexoas/gatherContext',
sourceUri?.toString() ?? vscode.window.activeTextEditor?.document.uri.toString()
)) as ApexClassOASEligibleResponses;
} catch (error) {
// fallback TBD after we understand it better
throw new Error(nls.localize('cannot_gather_context'));
}
}
return response;
};

public validateEligibility = async (
sourceUri: vscode.Uri | vscode.Uri[],
isMethodSelected: boolean = false
Expand Down Expand Up @@ -140,6 +160,7 @@ export class MetadataOrchestrator {
requests.push(request);
}

const response = this.gatherContext(sourceUri);
const responses = await this.eligibilityDelegate({ payload: requests });
return responses;
};
Expand Down
1 change: 1 addition & 0 deletions packages/salesforcedx-vscode-apex/src/messages/i18n.ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const messages = {
'Method %s is not eligible for Apex Action creation. It is not annotated with @AuraEnabled or has wrong access modifiers.',
unknown: 'Unknown',
invalid_active_text_editor: 'The active text editor is missing or is an invalid file.',
cannot_gather_context: 'An error occurred while gathering context for the Apex class.',
sobjects_no_refresh_if_already_active_error_text:
'sObject 定義の更新が既に実行中です。プロセスを再起動する必要がある場合は、実行中のタスクをキャンセルしてください。',
test_view_loading_message: 'Apex テストを読み込んでいます...',
Expand Down
3 changes: 2 additions & 1 deletion packages/salesforcedx-vscode-apex/src/messages/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,6 @@ export const messages = {
orphan_process_advice:
"The list of processes below are Apex Language Server instances that didn't properly shutdown. These\nprocesses can be stopped from the warning message that brought you here, or you can handle this\ntask yourself. If you choose to terminate these processes yourself, refer to relevant documentation\nto stop these processes.",
unknown: 'Unknown',
invalid_active_text_editor: 'The active text editor is missing or is an invalid file.'
invalid_active_text_editor: 'The active text editor is missing or is an invalid file.',
cannot_gather_context: 'An error occurred while gathering context for the Apex class.'
};

0 comments on commit 8569463

Please sign in to comment.