Skip to content

c++ functions after a large anonymous namespace are not indexed #1505

Description

@lewisl

codegraph indexes a C++ file but extracts zero function/method symbols from it
when the file begins with one or more large anonymous namespace { ... } blocks
containing raw-string-literal declarations, followed by top-level function definitions.

The underlying tree-sitter-cpp grammar parses the file correctly and finds the
functions — so this is in codegraph's symbol-extraction/tree-walk layer, not the grammar.

Environment

  • codegraph: colbymchenry/codegraph (Codex CLI integration)
  • Backend: node:sqlite (full WAL)
  • tree-sitter-cpp verified at: 0.23.4 (clean parse, hasError: false)

Repro

See repro.cpp. Structure:

  • two anonymous namespace { ... } blocks containing R"TAG(...)TAG" raw strings
  • two top-level functions (create_scaffold, helper_after) after the namespaces

Expected

codegraph query create_scaffold returns the function at its definition line.

Actual

codegraph query create_scaffold -> "No results found".
codegraph query <file> shows only the file node and #include imports for the
file — no function/method nodes at all.

Evidence the grammar is fine

Parsing repro.cpp with tree-sitter-cpp 0.23.4 directly:

  • tree.rootNode.hasError === false
  • function_definition nodes present at the expected lines
  • top-level children are: preproc_include* , namespace_alias_definition,
    namespace_definition (large), namespace_definition (large),
    function_definition (x N)

So the functions exist in the parse tree as siblings after the namespace_definition
nodes. codegraph appears to stop extracting symbols after walking the large
namespace_definition subtree(s) and never processes the following siblings.

Original file

In the real file (918 lines), nine raw strings live inside two anonymous namespaces
spanning lines ~23-801; the five real functions start at line 803. None of the five
were indexed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions