Skip to content

fix: fix when goto extension's .d.ts/.d.ets files using to internal arkts language server#288

Merged
Groupguanfang merged 2 commits intonextfrom
next-dev
Mar 9, 2026
Merged

fix: fix when goto extension's .d.ts/.d.ets files using to internal arkts language server#288
Groupguanfang merged 2 commits intonextfrom
next-dev

Conversation

@Groupguanfang
Copy link
Collaborator

@Groupguanfang Groupguanfang commented Mar 9, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 9, 2026 06:37
@github-project-automation github-project-automation bot moved this to Todo in ArkTS Mar 9, 2026
@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

🦋 Changeset detected

Latest commit: eaa26c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vscode-naily-ets Patch

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

@Groupguanfang Groupguanfang changed the title fix: fix when goto extension's .d.ts/.d.ets files using to internal a… fix: fix when goto extension's .d.ts/.d.ets files using to internal arkts language server Mar 9, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ExtensionContext into autoSetLanguage so it can detect extension-bundled files.
  • Add a new rule to treat declaration files under the extension’s dist/lib folder as ets.
  • 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.

Comment on lines +46 to 51
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')
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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')

Copilot uses AI. Check for mistakes.
}
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')
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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')

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// For SDK files, set the language to ets
// For extension-bundled declaration files under dist/lib, set the language to ets

Copilot uses AI. Check for mistakes.
@Groupguanfang Groupguanfang merged commit 29850de into next Mar 9, 2026
@github-project-automation github-project-automation bot moved this from Todo to Done in ArkTS Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants