Skip to content

Use native file type mappings for TypeScript-side classification - #14711

Open
Colen Garoutte-Carson (Colengms) wants to merge 5 commits into
mainfrom
dev/coleng/file_mappings
Open

Use native file type mappings for TypeScript-side classification#14711
Colen Garoutte-Carson (Colengms) wants to merge 5 commits into
mainfrom
dev/coleng/file_mappings

Conversation

@Colengms

@Colengms Colen Garoutte-Carson (Colengms) commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Use the effective mappings published by the native language server as the primary source of truth for TypeScript file classification.

This prevents hardcoded extension lists from drifting from native behavior and avoids forwarding changes for non-C/C++ files to the browse database.

package.json only augments VS Code’s language-association registry. VS Code’s built-in C++ language contribution already registers the standard extensions, so this package need only add associations that are missing or that cpptools wants to guarantee independently.

Changes

  • Add an atomic file type registry for extension and exact-filename mappings.
  • Retain bootstrap defaults for startup and compatibility with older native binaries.
  • Prefer exact filename mappings over extension mappings.
  • Support native extensionless headers and newly recognized extensions such as .cppm.
  • Preserve the existing uppercase .C compatibility behavior.
  • Use the active document language for otherwise unregistered paths.
  • Route common source/header predicates, build/debug checks, and file-watcher filtering through the registry.
  • Refresh active-file state and invalidate cached build tasks when mappings change.
  • Add focused tests for bootstrap behavior, native replacement, exact mappings, extensionless headers, watcher classification, and language fallback.

Validation

  • yarn compile
  • 3 focused Mocha tests
  • Focused ESLint
  • git diff --check

Depends on the corresponding native protocol PR. The extension remains compatible with older native binaries through its bootstrap mappings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

Review tier: Balanced
Findings: 2 Medium severity

New issues introduced by this change (2)
Severity Finding
Medium severity Extension/​src/​LanguageServer/​client.ts — The legacy-binary fallback compares the original-case suffix with a lowercase built-in set.…
Medium severity Extension/​src/​LanguageServer/​client.ts — In a multi-root workspace, this may be an inactive folder client when its asynchronous…
What changed in this PR

Introduces native-driven file classification to keep TypeScript behavior aligned with the language server.

Changes:

  • Adds an atomic file-type registry with bootstrap defaults and language fallback.
  • Routes build, debug, and watcher classification through native mappings.
  • Adds language associations and focused classification tests.
File Description
Extension/​src/​fileType.ts Implements the file-type registry.
Extension/​src/​common.ts Uses registry-backed predicates.
Extension/​src/​LanguageServer/​client.ts Receives mappings and updates watcher behavior.
Extension/​src/​LanguageServer/​cppBuildTaskProvider.ts Uses language-aware classification.
Extension/​src/​Debugger/​configurationProvider.ts Updates build/debug eligibility checks.
Extension/​package.json Registers additional C++ extensions.
Extension/​test/​unit/​fileType.test.ts Tests mapping and fallback behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Extension/src/LanguageServer/client.ts Outdated
Comment thread Extension/src/LanguageServer/client.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

Review tier: Balanced
Findings: 2 Medium severity

New issues introduced by this change (2)
Severity Finding
Medium severity Extension/​src/​Debugger/​configurationProvider.ts — This extension check prevents the registry from enabling detected build/debug tasks for an…
Medium severity Extension/​src/​LanguageServer/​cppBuildTaskProvider.ts — The new classifier can identify an extensionless exact filename (or an otherwise unregistered…
Issues resolved since last review (2)
Severity Finding
Medium severity Extension/​src/​LanguageServer/​client.ts — In a multi-root workspace, this may be an inactive folder client when its asynchronous… View resolved comment
Medium severity Extension/​src/​LanguageServer/​client.ts — The legacy-binary fallback compares the original-case suffix with a lowercase built-in set.… View resolved comment

Comment thread Extension/src/Debugger/configurationProvider.ts
Comment thread Extension/src/LanguageServer/cppBuildTaskProvider.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

Review tier: Balanced
Findings: None

Issues resolved since last review (2)
Severity Finding
Medium severity Extension/​src/​LanguageServer/​cppBuildTaskProvider.ts — The new classifier can identify an extensionless exact filename (or an otherwise unregistered… View resolved comment
Medium severity Extension/​src/​Debugger/​configurationProvider.ts — This extension check prevents the registry from enabling detected build/debug tasks for an… View resolved comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed together with the corresponding native protocol change.

Comment thread Extension/src/fileType.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pull Request

Development

Successfully merging this pull request may close these issues.

3 participants