Skip to content

Add C and C++ extraction coverage#34

Open
sameer2191 wants to merge 2 commits into
mainfrom
feature/c-cpp-extraction
Open

Add C and C++ extraction coverage#34
sameer2191 wants to merge 2 commits into
mainfrom
feature/c-cpp-extraction

Conversation

@sameer2191

Copy link
Copy Markdown
Owner

Summary

  • Add C and C++ language detection for common source/header extensions.
  • Extract C/C++ #include imports, C macros, structs, enums, functions, C++ namespaces/classes, and C++ colon inheritance edges.
  • Add focused tests for detection, include edges, symbols, and graph inheritance.
  • Update README supported extraction coverage.

Validation

  • npm run verify
  • npm run test:skip-gate
  • npm run package:check
  • npm run audit:prod -> 0 vulnerabilities
  • npm pack --dry-run

Comment thread src/core/extractor.ts Fixed
Comment thread src/core/extractor.ts Fixed
Comment thread src/core/extractor.ts Fixed
Comment thread src/core/extractor.ts Fixed
Comment thread src/core/extractor.ts Fixed
Comment thread src/core/extractor.ts Fixed
Comment thread src/core/extractor.ts Fixed
Comment thread src/core/extractor.ts Fixed
Comment thread src/core/extractor.ts Fixed
Comment thread src/core/extractor.ts Fixed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f062e739f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/core/extractor.ts
Comment on lines +646 to +647
c: [/^\s*#\s*include\s+[<"]([^>"]+)[>"]/gm],
cpp: [/^\s*#\s*include\s+[<"]([^>"]+)[>"]/gm, /^\s*import\s+([A-Za-z_][\w.:]*)\s*;/gm]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve quoted includes for local resolution

When a local C/C++ header is included with the normal quoted form (#include "orders.h"), this regex returns only orders.h and loses that it was quoted. buildResolvedImportEdges then passes the bare specifier to resolveImportFile, which only performs same-directory relative resolution for specifiers starting with ., so common local headers in the same folder are left as external-only imports and never produce IMPORTS_FILE edges. This breaks the new include graph for the typical non-./ quoted include case.

Useful? React with 👍 / 👎.

Comment thread src/core/extractor.ts
Comment on lines +2197 to +2200
if (["swift", "kotlin", "cpp"].includes(symbol.language) || ["struct", "enum", "protocol", "actor"].includes(symbol.kind)) {
const colonConformance = /\b(?:class|struct|enum|actor|protocol)\s+[A-Za-z_]\w*(?:<[^>{}]+>)?\s*:\s*([^{}]+)/.exec(compact);
if (colonConformance?.[1]) {
relations.push({ targets: typeNamesFromList(colonConformance[1]), reason: "colon inheritance or conformance" });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle C++ qualified base classes

For C++ inheritance like class Derived : public ns::Base, this new path feeds ns::Base into typeNamesFromList, but that helper only understands dotted qualifiers and captures ns instead of Base; resolveTypeSymbol then cannot find the extracted Base class, so no INHERITS edge is emitted. Namespaced base classes are common in C++, so the newly advertised colon-inheritance extraction silently misses those relationships.

Useful? React with 👍 / 👎.

Signed-off-by: Mir Sameer <mirsameer0304@gmail.com>
@sameer2191

Copy link
Copy Markdown
Owner Author

CodeQL follow-up pushed in b02a874:

  • Replaced the C/C++ function regex qualifier groups with bounded, line-local token patterns to avoid the inefficient backtracking shape flagged by CodeQL.
  • Added a focused qualifier stress assertion for C++ function extraction.

Validation after the fix:

  • npm run build
  • git diff --check
  • node --test --experimental-sqlite dist/tests/indexer.test.js: 25 passed
  • npm run verify: 65 passed, 1 known sandbox dashboard skip
  • npm run package:check: 89 files inspected
  • npm pack --dry-run: 89 files
  • npm run audit:prod: 0 vulnerabilities
  • Remote PR checks now pass: verify, Analyze, CodeQL, GitGuardian.

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