fix: fix when goto extension's .d.ts/.d.ets files using to internal arkts language server#288
fix: fix when goto extension's .d.ts/.d.ets files using to internal arkts language server#288Groupguanfang merged 2 commits intonextfrom
Conversation
…rkts language server
🦋 Changeset detectedLatest commit: eaa26c5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…ing to internal arkts language server
There was a problem hiding this comment.
Pull request overview
This PR updates the VS Code extension’s document-open language auto-detection so that certain bundled declaration files (.d.ts / .d.ets) are opened in ets language mode, improving “Go to definition”/language-server behavior for internal extension artifacts.
Changes:
- Pass
ExtensionContextintoautoSetLanguageso it can detect extension-bundled files. - Add a new rule to treat declaration files under the extension’s
dist/libfolder asets. - Extend the file-type check to include
.d.ets(for the new bundled-files rule).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| vscode.languages.setTextDocumentLanguage(document, 'ets') | ||
| return | ||
| } | ||
| const clientOptions = await languageServer?.getClientOptions() | ||
| if (typeof clientOptions?.initializationOptions?.ets?.sdkPath !== 'string' || !clientOptions?.initializationOptions?.ets?.sdkPath) return | ||
| if (document.fileName.endsWith('.d.ts') && document.fileName.startsWith(clientOptions?.initializationOptions?.ets?.sdkPath)) vscode.languages.setTextDocumentLanguage(document, 'ets') |
There was a problem hiding this comment.
vscode.languages.setTextDocumentLanguage(...) returns a Thenable, but this branch neither returns nor awaits it. Please return the Thenable (as done for the .json5 case) or explicitly ignore it (e.g., void ...) to avoid a floating/unhandled promise and keep the method’s behavior consistent.
| vscode.languages.setTextDocumentLanguage(document, 'ets') | |
| return | |
| } | |
| const clientOptions = await languageServer?.getClientOptions() | |
| if (typeof clientOptions?.initializationOptions?.ets?.sdkPath !== 'string' || !clientOptions?.initializationOptions?.ets?.sdkPath) return | |
| if (document.fileName.endsWith('.d.ts') && document.fileName.startsWith(clientOptions?.initializationOptions?.ets?.sdkPath)) vscode.languages.setTextDocumentLanguage(document, 'ets') | |
| return vscode.languages.setTextDocumentLanguage(document, 'ets') | |
| } | |
| const clientOptions = await languageServer?.getClientOptions() | |
| if (typeof clientOptions?.initializationOptions?.ets?.sdkPath !== 'string' || !clientOptions?.initializationOptions?.ets?.sdkPath) return | |
| if (document.fileName.endsWith('.d.ts') && document.fileName.startsWith(clientOptions?.initializationOptions?.ets?.sdkPath)) return vscode.languages.setTextDocumentLanguage(document, 'ets') |
| } | ||
| const clientOptions = await languageServer?.getClientOptions() | ||
| if (typeof clientOptions?.initializationOptions?.ets?.sdkPath !== 'string' || !clientOptions?.initializationOptions?.ets?.sdkPath) return | ||
| if (document.fileName.endsWith('.d.ts') && document.fileName.startsWith(clientOptions?.initializationOptions?.ets?.sdkPath)) vscode.languages.setTextDocumentLanguage(document, 'ets') |
There was a problem hiding this comment.
This adds .d.ets handling for the extension-bundled dist/lib folder, but the SDK-path branch below still only matches .d.ts. Since the language server codebase treats both .d.ts and .d.ets as declaration inputs, consider extending the sdkPath check to include .d.ets as well so SDK .d.ets files also get ets language mode.
| if (document.fileName.endsWith('.d.ts') && document.fileName.startsWith(clientOptions?.initializationOptions?.ets?.sdkPath)) vscode.languages.setTextDocumentLanguage(document, 'ets') | |
| if ((document.fileName.endsWith('.d.ts') || document.fileName.endsWith('.d.ets')) && document.fileName.startsWith(clientOptions?.initializationOptions?.ets?.sdkPath)) vscode.languages.setTextDocumentLanguage(document, 'ets') |
| private async autoSetLanguage(document: vscode.TextDocument, languageServer?: EtsLanguageServer | null): Promise<vscode.TextDocument | void> { | ||
| private async autoSetLanguage(document: vscode.TextDocument, context: ExtensionContext, languageServer?: EtsLanguageServer | null): Promise<vscode.TextDocument | void> { | ||
| if (document.fileName.endsWith('.json5')) return vscode.languages.setTextDocumentLanguage(document, 'jsonc') | ||
| // For SDK files, set the language to ets |
There was a problem hiding this comment.
The comment says "For SDK files" but the condition is checking for files under the extension’s bundled dist/lib directory. Please update the comment to reflect what’s actually being detected (extension-bundled declaration files), to avoid confusion with the later sdkPath-based SDK check.
| // For SDK files, set the language to ets | |
| // For extension-bundled declaration files under dist/lib, set the language to ets |
No description provided.