Skip to content

Add C_Cpp.intelliSenseModuleSearchPath for module import IntelliSense - #14894

Open
soroshsabz wants to merge 2 commits into
microsoft:mainfrom
soroshsabz:feature/modules-e2e
Open

soroshsabz wants to merge 2 commits into
microsoft:mainfrom
soroshsabz:feature/modules-e2e

Conversation

@soroshsabz

@soroshsabz soroshsabz commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Follow-up to #14837 (the CppModulesProject test scenario) and the extension-side part of #6302 (IntelliSense for C++20 modules importing in gcc/clang projects).

Module IntelliSense for gcc/clang-mode projects has been blocked by two things:

  1. Module interface file resolution. The IntelliSense engine (EDG-based, now open source at edgcpp/compiler) understands import directives in every mode, but GCC/Clang toolchains produce their own binary module formats (.gcm, .pcm) which the engine cannot read, and the MSVC-style search-dir compiler arguments are not processed in gcc/clang modes. The engine can, however, read its own .eifc module interface files in every mode, and it searches the directory named by the EDG_MODULES_PATH environment variable (inherited from the extension host by the language server process).
  2. Module interface file production. No compiler or build system emits .eifc files, so even with a search path there was nothing for the engine to find.

This PR adds the extension-side workflow that resolves both, in every IntelliSense mode.

What this PR adds

1. New setting C_Cpp.intelliSenseModuleSearchPath (string, ${workspaceFolder} supported): the directory searched for module interface files when resolving import directives. It is passed to the language server through EDG_MODULES_PATH at server startup (composited with the existing sanitizer-env mechanism; inherited unchanged when unset).

2. New setting C_Cpp.intelliSenseModuleCompilerPath: a C/C++ front end command that compiles the workspace's module interface units (.cppm/.ixx/.ccm) into .eifc module interface files, so import resolution works without any manual per-module setup. Build the command from the open-source EDG front end (edgcpp/compiler; gnu emulation mode interfaces are supported since edgcpp/compiler#315). The extension:

  • finds the module interface units of the workspace,
  • (re)compiles the ones whose .eifc file is missing or older than the source (sequentially, per-file timeout, output logged to the C/C++ output channel),
  • writes the generated files into the module search path directory (C_Cpp.intelliSenseModuleSearchPath when set, otherwise a per-workspace cache directory under the extension's default cache root),
  • points the engine's EDG_MODULES_PATH at that directory.

This replaces the closed-source-only workflow with an open one: the module interface files that IntelliSense consumes are produced by the same open-source front end that anyone can build and audit.

3. Tests:

  • Unit tests for the settings→environment resolution and the target directory selection (7 tests), and for the module interface compilation orchestration — interface file detection, module name parsing (including partitions), standard mapping, and regeneration staleness (19 tests).
  • An end-to-end scenario test in CppModulesProject (running first, before the language server starts): with a module interface compiler configured (a test fake that produces the checked-in .eifc files) and the search path set, the test asserts that the generated files appear in the target directory and that import math; / import geometry; resolve in gcc mode — hovering over an imported function and over a variable exported from inside a namespace works, and the "could not find module file" diagnostics are gone. The .eifc fixtures were produced with the open-source EDG front end. The test dynamically skips its semantic assertions (with a console warning) if a future language server build can no longer read the checked-in fixtures, so module file format churn cannot turn CI red.

Validation

  • 7/7 CppModulesProject scenario tests pass against the shipped 1.36.0 binaries, including the new end-to-end test with semantic assertions on both function and variable imports.
  • 182/182 unit tests pass; TypeScript and ESLint clean.
  • The exported-variable import used by the test's namespace assertion required an engine fix: exported variables were silently dropped from module interface files (edgcpp/compiler#58). That fix is proposed in C++20 modules: write exported variables to IFC files [GH #58] edgcpp/compiler#631; the checked-in fixtures are generated with that fix.

Notes

Related: #6302, #14837, edgcpp/compiler#315, edgcpp/compiler#631

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.

1 participant