Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(graph): register .hh as C++ and reassign .inc from Pascal (#1693)

Raghav Chamadiyaf8350db1385a
diff --git a/packages/core/src/repowise/core/ingestion/dynamic_hints/cpp.py b/packages/core/src/repowise/core/ingestion/dynamic_hints/cpp.py
index 9f3361f00..0c481df4b 100644
--- a/packages/core/src/repowise/core/ingestion/dynamic_hints/cpp.py
+++ b/packages/core/src/repowise/core/ingestion/dynamic_hints/cpp.py
@@ -1,8 +1,8 @@
"""Dynamic-hint extractor for C++ function pointers, dlopen/dlsym, and Qt
``QObject::connect`` signal/slot wiring.
-Mirrors :mod:`.c` but on C++ extensions (``.cc``/``.cpp``/``.cxx``/``.hpp``/
-``.hxx``) and adds the Qt connect-string idiom — ``QObject::connect(s,
+Mirrors :mod:`.c` but on the C++ extensions in ``_CPP_EXTS`` below, and adds
+the Qt connect-string idiom — ``QObject::connect(s,
SIGNAL(sig()), r, SLOT(slot()))`` — which wires a method into a runtime
dispatch table that the static call graph never sees.
"""
@@ -24,7 +24,7 @@ _SKIP_DIRS = {
# .inl is exactly where function-pointer and designated-initialiser wiring
# tends to live, which is the wiring this extractor exists to find.
_CPP_EXTS: tuple[str, ...] = (
- ".cc", ".cpp", ".cxx", ".c++", ".hpp", ".hxx", ".h",
+ ".cc", ".cpp", ".cxx", ".c++", ".hh", ".hpp", ".hxx", ".h",
*sorted(INCLUDE_FRAGMENT_EXTENSIONS),
)
diff --git a/packages/core/src/repowise/core/ingestion/languages/specs/cpp.py b/packages/core/src/repowise/core/ingestion/languages/specs/cpp.py
index 8992fe39a..4ca1e1cef 100644
--- a/packages/core/src/repowise/core/ingestion/languages/specs/cpp.py
+++ b/packages/core/src/repowise/core/ingestion/languages/specs/cpp.py
@@ -11,7 +11,16 @@ from .c import BUILTIN_TYPES as _C_BUILTIN_TYPES
#: each keep their own list: which extensions are C++ at all, which behave like
#: a header for include resolution and reachability, and which are a fragment
#: rather than a module. See ``traverser`` for the last of those.
-INCLUDE_FRAGMENT_EXTENSIONS: frozenset[str] = frozenset({".inl", ".ipp", ".tpp"})
+#:
+#: ``.inc`` was claimed exclusively by the Pascal spec, which routed abseil's
+#: 24 template-implementation fragments to a grammar that cannot parse them —
+#: no symbols, no edges, no error. Reassigned here on the corpus count: 24 of
+#: the 25 code-bearing ``.inc`` files are C++ and none are Pascal, on a corpus
+#: that does contain Pascal. The one PHP ``.inc`` (a Drush plugin) is the known
+#: cost; ``.inc`` is shared by C++, PHP and Pascal in the wild, and a
+#: content- or sibling-aware router is the real answer if a second language's
+#: usage ever shows up in the corpus.
+INCLUDE_FRAGMENT_EXTENSIONS: frozenset[str] = frozenset({".inl", ".ipp", ".tpp", ".inc"})
SPEC = LanguageSpec(
tag="cpp",
@@ -24,7 +33,7 @@ SPEC = LanguageSpec(
# its API surface (fmt, leveldb, boost layouts). Root-anchored: a
# vendored include/ deep in another tree must not mint the layer.
layer_dir_hints=(("/include", "API"),),
- extensions=frozenset({".cpp", ".cc", ".cxx", ".h", ".hpp", ".hxx"})
+ extensions=frozenset({".cpp", ".cc", ".cxx", ".h", ".hh", ".hpp", ".hxx"})
| INCLUDE_FRAGMENT_EXTENSIONS,
grammar_package="tree_sitter_cpp",
scm_file="cpp.scm",
diff --git a/packages/core/src/repowise/core/ingestion/languages/specs/pascal.py b/packages/core/src/repowise/core/ingestion/languages/specs/pascal.py
index f9b148a78..77c709973 100644
--- a/packages/core/src/repowise/core/ingestion/languages/specs/pascal.py
+++ b/packages/core/src/repowise/core/ingestion/languages/specs/pascal.py
@@ -22,7 +22,13 @@ from ..spec import LanguageSpec
SPEC = LanguageSpec(
tag="pascal",
display_name="Object Pascal",
- extensions=frozenset({".pas", ".pp", ".dpr", ".dpk", ".lpr", ".inc"}),
+ # ``.inc`` is a Delphi include convention, but it is also C++'s and PHP's,
+ # and this spec held it exclusively. The corpus has 24 C++ ``.inc`` files
+ # and zero Pascal ones, so it now belongs to cpp — see the note on
+ # ``specs/cpp.INCLUDE_FRAGMENT_EXTENSIONS``. Dropped rather than left to
+ # first-spec-wins ordering so the routing survives a reordering of
+ # ``ALL_SPECS``.
+ extensions=frozenset({".pas", ".pp", ".dpr", ".dpk", ".lpr"}),
grammar_package="tree_sitter_pascal",
scm_file="pascal.scm",
heritage_node_types=frozenset({"declType"}),