Skip to content

Support language-specific compiler macros in clangd configuration - #387

Merged
brondani merged 5 commits into
mainfrom
support-language-specific-compiler
Jul 22, 2026
Merged

Support language-specific compiler macros in clangd configuration#387
brondani merged 5 commits into
mainfrom
support-language-specific-compiler

Conversation

@brondani

@brondani brondani commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Fixes

Aligns

Changes

  • Detect separate compile_macros_c.h and compile_macros_cxx.h files and add language-specific .clangd sections for available headers. Legacy compile_macros.h output is no longer supported.
  • Simplify .clangd content regeneration to avoid outdated fragments.
  • Keep the compilation database configuration in the generated .clangd file without relying on setContext.
  • Avoid applying generated macro headers to CLANG contexts.
  • Update unit tests to parse the generated YAML and verify language-specific macros and compilation database settings.

This supports build output that provides separate C and C++ compiler macro headers, ensuring clangd applies the appropriate macros for each language.

Path matching remains file extension-based according to Filename Extensions.

Screenshots

N/A — no UI changes.

Checklist

  • 🤖 This change is covered by unit tests (if applicable).
  • 🤹 Manual testing has been performed (if necessary).
  • 🛡️ Security impacts have been considered (if relevant).
  • 📖 Documentation updates are complete (not required).
  • 🧠 Third-party dependencies and TPIP updated (not required).

Use separate C and C++ compile macro headers when available.
Skip macro headers for the CLANG toolchain.
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@qltysh

qltysh Bot commented Jul 21, 2026

Copy link
Copy Markdown

Qlty


Coverage Impact

⬆️ Merging this pull request will increase total coverage on main by 0.06%.

Modified Files with Diff Coverage (1)

RatingFile% DiffUncovered Line #s
Coverage rating: B Coverage rating: B
src/solutions/clangd-manager.ts92.3%367-373
Total92.3%
🤖 Increase coverage with AI coding...
In the `support-language-specific-compiler` branch, add test coverage for this new code:

- `src/solutions/clangd-manager.ts` -- Line 367-373

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

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.

Pull request overview

This PR updates the extension’s clangd configuration generation to support language-specific compiler macro headers (compile_macros_c.h / compile_macros_cxx.h) and to persist compilation database settings directly in generated project .clangd files rather than relying on setContext.

Changes:

  • Detect C vs C++ macro header outputs and generate language-specific .clangd fragments guarded by If: PathMatch.
  • Keep CompileFlags.CompilationDatabase set in generated .clangd fragments (and avoid applying macro headers for CLANG compiler contexts).
  • Update unit tests to parse the generated YAML and validate fragment structure/content.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/solutions/clangd-manager.ts Generates project .clangd fragments with language-specific -include headers and sets CompilationDatabase directly.
src/solutions/clangd-manager.test.ts Updates tests to assert YAML fragment structure and validate C/C++ macro fragment generation behavior.

Comment thread src/solutions/clangd-manager.ts
@brondani
brondani marked this pull request as ready for review July 22, 2026 08:40
@brondani
brondani requested a review from edriouk July 22, 2026 08:41

@edriouk edriouk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@brondani
brondani merged commit 626659d into main Jul 22, 2026
13 checks passed
@brondani
brondani deleted the support-language-specific-compiler branch July 22, 2026 13:07
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.

3 participants