feat(code-graph): add preliminary C++ language support
What does this MR do and why?
Part of #337 (closed). Adds C++ to the code-graph pipeline. C++ joins the CFamily language family (!1210 (merged)), sharing a CodeGraph with C so that #include-based cross-language resolution works out of the box.
What C++ can parse
Namespaces namespace math { ... }
Classes/Structs class Vec3 { ... }; struct Point { ... };
Enums/Unions enum Color { RED, GREEN }; union Data { ... };
Typedefs typedef struct { ... } Name;
Templates template<typename T> class Container { ... };
Functions int add(int a, int b) { ... }
Member calls obj.method() obj->method()
Qualified calls Ns::func() Class::static_method()
Includes #include "header.h" #include <iostream>
Bindings int x = foo(); parameters; assignment
Control flow if/switch branches, for/while/do/for-range loopsHow resolution works
main.cpp ──#include──► math/vec.hpp ──paired──► math/vec.cpp
│ │ │
│ declarations definitions
│ (Vec3, cross) (Vec3::length, cross)
│ │ │
▼ ▼ ▼
┌──────────────────────────────────────────────────────┐
│ Shared CFamily CodeGraph │
│ │
│ main.cpp calls cross() ──resolves──► math/vec.cpp │
└──────────────────────────────────────────────────────┘The IncludeGraph import strategy does BFS through transitive #include chains. For each reachable header (.h, .hpp, .hh, .hxx), it also searches the paired source file (.c, .cc, .cpp, .cxx). This means main.cpp including vec.hpp can resolve symbols defined in vec.cpp.
file_scope uses the filename (without extension) as the root scope for all top-level definitions, since C/C++ have no module/package system. A function add in math.cpp gets FQN math::add.
Integration tests
cpp/resolution.yaml -- namespaces, classes, includes, cross-file FQNs, enum constants, file discovery
cpp/hardcore.yaml -- negative assertions (no edges to static functions from other files, no edges to unincluded files), exact definition counts, templates, static function visibility, nested namespace scoping (outer::inner::Widget), duplicate edge checks, file containment assertions
Changelog
langs/generic/cpp.rs-- C++ DSL handler (scopes, refs, imports, chains, bindings, branches, loops)linker/imports.rs--IncludeGraphBFS strategy with header-to-source pairinglinker/rules.rs--IncludeGraphenum variantdsl/types.rs+engine.rs--file_scopetrait methodconfig/lang.rs--Cppvariant mapped toCFamily, extensionscpp/cc/cxx/hpp/hh/hxxtreesitter-visit/-- tree-sitter-cpp 0.23.4,SupportLang::Cpp