fix(cpp): six parser bugs dropping or corrupting graph data-Issue:1538 - #1628
Open
VasudhaM04 wants to merge 2 commits into
Open
fix(cpp): six parser bugs dropping or corrupting graph data-Issue:1538#1628VasudhaM04 wants to merge 2 commits into
VasudhaM04 wants to merge 2 commits into
Conversation
…notes Relocate the six-bug regression tests to tests/unit/parsers/ so they are picked up by test discovery and run in CI, per CONTRIBUTING.md. Use the shared temp_test_dir fixture instead of a local sys.path shim. Remove the cpp_parser_fix/ spec working notes, which were scratch material rather than project documentation.
|
@VasudhaM04 is attempting to deploy a commit to the shashankss1205's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes six independent bugs in the C++ tree-sitter parser that produce incorrect graph data or silently dropped code elements. Each is isolated to
CppTreeSitterParserorCPP_QUERIES, so they're fixed independently with no shared surface.Fixes #1538
Bugs fixed
All in
src/codegraphcontext/tools/languages/cpp.py.#include "local.h"→ name"local.h"with quotes_find_importsstripped only<>"<>, matching the C parserint x = 5;→type: None, alwaystypeoffinit_declarator, which has no such fielddeclarationint count;never captured at allinit_declaratorshapesidentifierdeclarator patternclass_context::-qualified names set itclass_specifier#define SQUARE(x) ...missed entirelypreproc_defpreproc_function_defalternativeend_lineone past the real endend_point[0] + 1double-counts the trailing newlineend_point[0]when end column is 0Bug 4 previously meant the indexer's C++ post-pass could not create
Class-[:CONTAINS]->Functionedges for inline methods. Bug 1 also brought C++in line with the C parser, which already used
.strip('"<>').Notes on the implementation
Bug 2's fix is guarded on
assignment_node.type == 'init_declarator'. Afield_declarationcarriestypeon the node itself, so walking upunconditionally returns
Noneand regresses class fields — caught duringverification.
Bug 3 dedupes on
(name, row)so declarations matching both the initializedand plain patterns aren't emitted twice.
Bug 4 is gated on
if not class_context, so::splitting still takesprecedence and file-scope functions still get no context.
Testing
New:
tests/unit/parsers/test_cpp_parser_fixes.py— 15 tests. Each bug gets atest pinning the fixed behaviour plus preservation tests for the neighbouring
behaviour the fix must not disturb (system includes, field declarations,
qualified methods, file-scope functions, object-like macros, multi-line macros,
lambda assignments), and one integration test combining all six scenarios to
catch cross-interference.