From 4239e79879bfe9f7b7f7e0ef657ec41fbc8a913e Mon Sep 17 00:00:00 2001 From: sunerpy Date: Tue, 14 Jul 2026 18:22:44 +0800 Subject: [PATCH] feat(cpp): namespace-qualified names, template-arg calls, UE class recovery, .h detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ports the C++ subset of upstream colby 1.2.0..1.4.1 plus a Lua fix. - C++ symbols defined inside `namespace` blocks now carry the namespace in their qualified name (`ns::compute`, C++17 `namespace a::b {` included), and namespace-qualified calls (`ns::fn(...)`) resolve to their definitions — previously such calls never linked, hiding much of the call graph in namespace-heavy C++. A namespace-prefix stack contributes the prefix only, so no namespace node is emitted. (e1a8d88, namespace hunks only.) - C++ calls that spell out template arguments (`fn(args)`) now link to the function they instantiate, reusing the same `<>`-stripping normalization templated base classes already had. (e1a8d88.) - Heavily-reflected Unreal Engine C++ classes are recovered instead of dropped: an offset-preserving pre-parse blanks line-leading reflection macros (GENERATED_BODY/UPROPERTY/UFUNCTION/UE_DEPRECATED/DECLARE_DELEGATE), member `*_API`/`*_EXPORT`/`*_ABI` export macros, and mid-line UMETA/UPARAM, so the class and its base clause survive tree-sitter. The passes are contains-gated and byte-identical on non-UE C++. (#1158.) - A `.h` file whose only C++ signal is an export-macro-annotated class (`class ENGINE_API UFoo : public UObject` with GENERATED_BODY) is reclassified from C to C++ during extraction by content, so its class is no longer dropped. Path-only `detect_language` and its callers are unchanged. (#1159, #1133.) - Lua/Luau: a capitalized `obj:Method()` (Roblox convention) is no longer misread as a `:Type` annotation and dropped when two classes share a method name. The annotation pattern is gated code-side (the regex crate has no lookahead) so a real `local x: Type` annotation still resolves. (#1124.) The cpp golden fixture is deliberately extended (namespaced call, templated call, UE `.h` class) and regenerated: the only pre-existing-record changes are the `Tpl`->`ns::Tpl` qualified names and the `Q : ns::Tpl` base resolving from unresolved to a real Extends edge. godot/ruby/mini goldens byte-identical. --- .../fixtures/cpp/namespaced.cpp | 9 + .../fixtures/cpp/templated_call.cpp | 6 + .../codegraph-bench/fixtures/cpp/ue_actor.h | 11 + crates/codegraph-extract/src/engine.rs | 90 +++++- crates/codegraph-extract/src/lang/cpp.rs | 276 ++++++++++++++++++ crates/codegraph-extract/src/walker.rs | 126 +++++++- crates/codegraph-resolve/src/name_matcher.rs | 129 +++++++- docs/equivalence.md | 28 +- reference/golden/cpp/colby.db | Bin 151552 -> 151552 bytes reference/golden/cpp/edges.json | 102 +++++++ reference/golden/cpp/files.json | 24 ++ reference/golden/cpp/nodes.json | 202 ++++++++++++- reference/golden/cpp/refs.json | 10 +- 13 files changed, 992 insertions(+), 21 deletions(-) create mode 100644 crates/codegraph-bench/fixtures/cpp/namespaced.cpp create mode 100644 crates/codegraph-bench/fixtures/cpp/templated_call.cpp create mode 100644 crates/codegraph-bench/fixtures/cpp/ue_actor.h diff --git a/crates/codegraph-bench/fixtures/cpp/namespaced.cpp b/crates/codegraph-bench/fixtures/cpp/namespaced.cpp new file mode 100644 index 00000000..b481f222 --- /dev/null +++ b/crates/codegraph-bench/fixtures/cpp/namespaced.cpp @@ -0,0 +1,9 @@ +#include "base.hpp" + +namespace ns { +void compute() {} +} + +void run_namespaced() { + ns::compute(); +} diff --git a/crates/codegraph-bench/fixtures/cpp/templated_call.cpp b/crates/codegraph-bench/fixtures/cpp/templated_call.cpp new file mode 100644 index 00000000..45b6f5c6 --- /dev/null +++ b/crates/codegraph-bench/fixtures/cpp/templated_call.cpp @@ -0,0 +1,6 @@ +template +void process(T value) {} + +void run_templated() { + process(0); +} diff --git a/crates/codegraph-bench/fixtures/cpp/ue_actor.h b/crates/codegraph-bench/fixtures/cpp/ue_actor.h new file mode 100644 index 00000000..0b679356 --- /dev/null +++ b/crates/codegraph-bench/fixtures/cpp/ue_actor.h @@ -0,0 +1,11 @@ +#pragma once + +class ENGINE_API UFoo : public UObject +{ + GENERATED_BODY() + UPROPERTY(EditAnywhere) + int Health; + ENGINE_API virtual void Tick(); + UFUNCTION() + void Bar(); +}; diff --git a/crates/codegraph-extract/src/engine.rs b/crates/codegraph-extract/src/engine.rs index eefafd17..01fa73b9 100644 --- a/crates/codegraph-extract/src/engine.rs +++ b/crates/codegraph-extract/src/engine.rs @@ -9,9 +9,11 @@ use codegraph_core::config::IndexingConfig; use codegraph_core::node_id::hash_content; use codegraph_core::types::{ExtractionResult, Language}; use rayon::prelude::*; +use regex::Regex; use std::collections::HashSet; use std::fs; use std::path::{Path, PathBuf}; +use std::sync::OnceLock; use std::time::Instant; use tree_sitter::Parser; @@ -110,13 +112,58 @@ pub fn detect_language(file_path: impl AsRef) -> Language { Language::Unknown } +/// A `.h` file maps to `Language::C` by extension, but may hold C++ or +/// Objective-C. Match the upstream 8 KB-prefix content sniff (`grammars.ts` +/// `looksLikeCpp`). The `class MACRO Name : Base` alternative recognizes an +/// export-macro-annotated class whose only C++ signal is the macro — the +/// two-token ` ` shape never occurs in valid C, so genuine C +/// headers stay C. Lookahead-free (the `regex` crate has none). +fn looks_like_cpp(source: &str) -> bool { + static RE: OnceLock = OnceLock::new(); + let re = RE.get_or_init(|| { + Regex::new( + r"\bnamespace\b|\bclass\s+\w+\s*[:{]|\b(?:class|struct)\s+[A-Z][A-Z0-9_]+\s+\w+\s*(?:final\s*)?[:{]|\btemplate\s*<|\b(?:public|private|protected)\s*:|\bvirtual\b|\busing\s+(?:namespace\b|\w+\s*=)", + ) + .expect("looks-like-cpp regex") + }); + re.is_match(prefix_8k(source)) +} + +fn looks_like_objc(source: &str) -> bool { + static RE: OnceLock = OnceLock::new(); + let re = RE.get_or_init(|| { + Regex::new(r"@(?:interface|implementation|protocol|synthesize)\b") + .expect("looks-like-objc regex") + }); + re.is_match(prefix_8k(source)) +} + +fn prefix_8k(source: &str) -> &str { + match source.char_indices().nth(8192) { + Some((idx, _)) => &source[..idx], + None => source, + } +} + pub fn extract_source( file_path: &str, source: &str, language: Option, ) -> ExtractionResult { let start = Instant::now(); - let language = language.unwrap_or_else(|| detect_language(file_path)); + let mut language = language.unwrap_or_else(|| detect_language(file_path)); + if language == Language::C + && Path::new(file_path) + .extension() + .and_then(|ext| ext.to_str()) + .is_some_and(|ext| ext.eq_ignore_ascii_case("h")) + { + if looks_like_cpp(source) { + language = Language::Cpp; + } else if looks_like_objc(source) { + language = Language::ObjC; + } + } if let Some(result) = crate::embedded::extract_embedded(file_path, source, language) { return result; } @@ -974,4 +1021,45 @@ mod tests { merged.nodes.iter().map(|n| &n.name).collect::>() ); } + + #[test] + fn looks_like_cpp_export_macro_class() { + assert!(looks_like_cpp( + "class ENGINE_API UFoo : public UObject { };" + )); + } + + #[test] + fn looks_like_cpp_plain_c_false() { + assert!(!looks_like_cpp("struct Foo { int x; };\nvoid f(void);\n")); + } + + #[test] + fn looks_like_objc_interface() { + assert!(looks_like_objc("@interface Foo\n@end\n")); + } + + #[test] + fn dot_h_reclassified_to_cpp_by_content() { + let result = extract_source( + "F.h", + "class ENGINE_API UFoo : public UObject { GENERATED_BODY() };", + None, + ); + assert!( + result.nodes.iter().any(|n| n.name == "UFoo"), + "a UE .h should be reclassified to C++ and yield a UFoo class node, got: {:?}", + result + .nodes + .iter() + .map(|n| (n.kind, n.name.as_str())) + .collect::>() + ); + } + + #[test] + fn dot_h_plain_c_stays_c() { + let result = extract_source("plain.h", "int add(int a, int b);\n", None); + assert!(result.errors.is_empty(), "errors: {:?}", result.errors); + } } diff --git a/crates/codegraph-extract/src/lang/cpp.rs b/crates/codegraph-extract/src/lang/cpp.rs index d9e48579..fdb339e1 100644 --- a/crates/codegraph-extract/src/lang/cpp.rs +++ b/crates/codegraph-extract/src/lang/cpp.rs @@ -1,6 +1,9 @@ //! C++ `LanguageSpec`, ported from `upstream extraction/languages/c-cpp.ts:144-213`. +use std::sync::OnceLock; + use codegraph_core::types::{Language, NodeKind}; +use regex::Regex; use tree_sitter::{Language as TsLanguage, Node}; use crate::lang::c::{include_import, normalize_c_return_type}; @@ -113,6 +116,189 @@ impl LanguageSpec for CppSpec { fn extract_import(&self, node: Node<'_>, source: &str) -> Option { include_import(node, source) } + fn pre_parse(&self, source: &str) -> String { + pre_parse_cpp_source(source) + } +} + +/// Offset-preserving C++ pre-parse: blank heavily-reflected Unreal-Engine markup +/// (member-level `*_API` prefixes, line-leading no-semicolon annotation macros, +/// mid-line `UMETA`/`UPARAM`/`UE_DEPRECATED`) so the enclosing class parses +/// instead of collapsing into an ERROR node (#1158). Blanking replaces bytes with +/// ASCII spaces — tree-sitter consumes byte offsets, and every blanked span lies +/// on char boundaries, so byte length (and thus line/column) is preserved. Each +/// pass is `contains`-gated, so macro-free C++ is returned byte-identical. +fn pre_parse_cpp_source(source: &str) -> String { + let bytes = blank_cpp_annotation_macro_calls(blank_cpp_inline_annotation_macros( + blank_cpp_api_prefix_macros(source.as_bytes().to_vec()), + )); + String::from_utf8(bytes).unwrap_or_else(|_| source.to_string()) +} + +fn blank_span(bytes: &mut [u8], start: usize, end: usize) { + for b in bytes.iter_mut().take(end).skip(start) { + if *b != b'\n' && *b != b'\r' { + *b = b' '; + } + } +} + +/// Scan a balanced `(...)` from `open` (the index of the `(`), skipping string +/// and char literals so an embedded `)` cannot mis-close. All delimiters are +/// ASCII and UTF-8 continuation bytes never match them, so a byte scan is safe. +/// Returns the index just past the closing `)`, or `None` if unbalanced. +fn balanced_paren_end(bytes: &[u8], open: usize) -> Option { + let mut depth = 0i32; + let mut i = open; + while i < bytes.len() { + let c = bytes[i]; + if c == b'"' || c == b'\'' { + let quote = c; + i += 1; + while i < bytes.len() && bytes[i] != quote { + if bytes[i] == b'\\' { + i += 1; + } + i += 1; + } + } else if c == b'(' { + depth += 1; + } else if c == b')' { + depth -= 1; + if depth == 0 { + return Some(i + 1); + } + } + i += 1; + } + None +} + +/// Blank an export/visibility macro (`ENGINE_API`, `*_EXPORT`, `*_ABI`) in front +/// of a member/method declaration (`ENGINE_API virtual void Tick()`). The upstream +/// `(?=\s+[A-Za-z_])` look-ahead is reproduced in code (the `regex` crate has no +/// look-ahead): a match is blanked only when followed by whitespace then a +/// declaration token, so a value use (`x = FOO_API;`) survives. +fn blank_cpp_api_prefix_macros(bytes: Vec) -> Vec { + let source = match std::str::from_utf8(&bytes) { + Ok(source) => source, + Err(_) => return bytes, + }; + if !(source.contains("_API") || source.contains("_EXPORT") || source.contains("_ABI")) { + return bytes; + } + static RE: OnceLock = OnceLock::new(); + let re = RE.get_or_init(|| { + Regex::new(r"\b[A-Z][A-Z0-9_]*(?:_API|_EXPORT|_ABI)\b").expect("api-prefix regex") + }); + let spans: Vec<(usize, usize)> = re + .find_iter(source) + .filter(|m| { + let mut saw_space = false; + for c in source[m.end()..].chars() { + if c.is_whitespace() { + saw_space = true; + } else { + return saw_space && (c.is_ascii_alphabetic() || c == '_'); + } + } + false + }) + .map(|m| (m.start(), m.end())) + .collect(); + let mut bytes = bytes; + for (start, end) in spans { + blank_span(&mut bytes, start, end); + } + bytes +} + +/// Blank a mid-line UE annotation macro (`UMETA(...)`, `UPARAM(...)`, +/// `UE_DEPRECATED*(...)`) — the forms `blank_cpp_annotation_macro_calls` can't see +/// because they are not line-leading. Keyed on an explicit UE-only name list (zero +/// risk to non-UE sources); the whole `MACRO(...)` becomes spaces. +fn blank_cpp_inline_annotation_macros(bytes: Vec) -> Vec { + let source = match std::str::from_utf8(&bytes) { + Ok(source) => source, + Err(_) => return bytes, + }; + if !(source.contains("UMETA") || source.contains("UPARAM") || source.contains("UE_DEPRECATED")) + { + return bytes; + } + static RE: OnceLock = OnceLock::new(); + let re = RE.get_or_init(|| { + Regex::new(r"\b(?:UMETA|UPARAM|UE_DEPRECATED\w*)\s*\(").expect("inline-annotation regex") + }); + let mut spans: Vec<(usize, usize)> = Vec::new(); + let mut search_from = 0usize; + while let Some(m) = re.find_at(source, search_from) { + match balanced_paren_end(&bytes, m.end() - 1) { + Some(end) => { + spans.push((m.start(), end)); + search_from = end; + } + None => break, + } + } + let mut bytes = bytes; + for (start, end) in spans { + blank_span(&mut bytes, start, end); + } + bytes +} + +/// Blank a line-leading no-semicolon annotation macro call (`UPROPERTY(...)`, +/// `UFUNCTION(...)`, `GENERATED_BODY()`, `DECLARE_DELEGATE_*(...)`) that decorates +/// the following declaration. Name-list-FREE / structural: the macro must be the +/// first non-whitespace token on its line, ALL-CAPS (`[A-Z][A-Z0-9_]{2,}`), and +/// the char after the balanced `(...)` must START A DECLARATION (`[A-Za-z_~#]`) — +/// so a statement call (`FOO(x);`) or expression fragment is never blanked. +fn blank_cpp_annotation_macro_calls(bytes: Vec) -> Vec { + let source = match std::str::from_utf8(&bytes) { + Ok(source) => source, + Err(_) => return bytes, + }; + static GATE: OnceLock = OnceLock::new(); + let gate = GATE.get_or_init(|| { + Regex::new(r"(?m)^[ \t]*[A-Z][A-Z0-9_]{2,}\s*\(").expect("annotation-gate regex") + }); + if !gate.is_match(source) { + return bytes; + } + static RE: OnceLock = OnceLock::new(); + let re = RE.get_or_init(|| { + Regex::new(r"(?m)^([ \t]*)([A-Z][A-Z0-9_]{2,})(\s*)\(").expect("annotation-call regex") + }); + let mut spans: Vec<(usize, usize)> = Vec::new(); + let mut search_from = 0usize; + while let Some(caps) = re.captures_at(source, search_from) { + let whole = caps.get(0).expect("match 0"); + let indent_len = caps.get(1).map_or(0, |g| g.as_str().len()); + let end = match balanced_paren_end(&bytes, whole.end() - 1) { + Some(end) => end, + None => { + search_from = whole.end(); + continue; + } + }; + let mut j = end; + while j < bytes.len() && bytes[j].is_ascii_whitespace() { + j += 1; + } + let starts_decl = bytes + .get(j) + .is_some_and(|b| b.is_ascii_alphabetic() || *b == b'_' || *b == b'~' || *b == b'#'); + if starts_decl { + spans.push((whole.start() + indent_len, end)); + } + search_from = end; + } + let mut bytes = bytes; + for (start, end) in spans { + blank_span(&mut bytes, start, end); + } + bytes } fn declarator_qualified_id<'tree>(declarator: Node<'tree>) -> Option> { @@ -328,3 +514,93 @@ pub(crate) fn detect_export_macro_class<'tree>( is_struct, }) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn blank_cpp_api_prefix_member() { + let src = "ENGINE_API virtual void Tick();"; + let out = pre_parse_cpp_source(src); + assert_eq!(out.len(), src.len()); + assert!(out.starts_with(" virtual void Tick();")); + } + + #[test] + fn blank_cpp_api_prefix_bare_value_untouched() { + let src = "int x = MY_API;"; + let out = pre_parse_cpp_source(src); + assert_eq!(out, src); + } + + #[test] + fn blank_cpp_annotation_macro_calls_ue() { + let src = "UPROPERTY(EditAnywhere)\nint X;"; + let out = pre_parse_cpp_source(src); + assert_eq!(out.len(), src.len()); + assert!(out.starts_with(" \nint X;")); + } + + #[test] + fn blank_cpp_annotation_statement_call_untouched() { + let src = "FOO(x);"; + let out = pre_parse_cpp_source(src); + assert_eq!(out, src); + } + + #[test] + fn blank_cpp_annotation_in_expression_untouched() { + let src = "if (CHECK(x)) {}"; + let out = pre_parse_cpp_source(src); + assert_eq!(out, src); + } + + #[test] + fn blank_cpp_inline_annotation_umeta() { + let src = "Foo UMETA(DisplayName=\"Foo\"),"; + let out = pre_parse_cpp_source(src); + assert_eq!(out.len(), src.len()); + assert!(out.starts_with("Foo ")); + assert!(out.ends_with(",")); + assert!(!out.contains("UMETA")); + } + + #[test] + fn blank_cpp_inline_annotation_lowercase_untouched() { + let src = "auto v = meta(1);"; + let out = pre_parse_cpp_source(src); + assert_eq!(out, src); + } + + #[test] + fn cpp_pre_parse_is_offset_preserving() { + let src = r#"class ENGINE_API UFoo : public UObject +{ + GENERATED_BODY() + UPROPERTY(EditAnywhere) + ENGINE_API int X; + UFUNCTION() + void Bar(); +}; +"#; + let out = pre_parse_cpp_source(src); + assert_eq!(out.len(), src.len()); + assert_eq!( + out.bytes().filter(|&b| b == b'\n').count(), + src.bytes().filter(|&b| b == b'\n').count() + ); + } + + #[test] + fn cpp_pre_parse_noop_on_plain_cpp() { + let src = r#"namespace ns { +class Widget { +public: + void render(); +}; +} +"#; + assert_eq!(pre_parse_cpp_source(src), src); + } +} diff --git a/crates/codegraph-extract/src/walker.rs b/crates/codegraph-extract/src/walker.rs index b2d39605..0ce993b2 100644 --- a/crates/codegraph-extract/src/walker.rs +++ b/crates/codegraph-extract/src/walker.rs @@ -40,6 +40,10 @@ pub struct TreeSitterWalker<'a, 'tree> { errors: Vec, node_stack: Vec, fn_ref_candidates: Vec<(crate::function_ref::FnRefCandidate, String)>, + /// C++ enclosing `namespace ns { … }` names, prefixed onto contained + /// symbols' `qualified_name`. Prefix-only (no namespace node) to avoid the + /// #1093 crowd-out; empty outside C++. + namespace_prefix: Vec, } impl<'a, 'tree> TreeSitterWalker<'a, 'tree> { @@ -60,6 +64,7 @@ impl<'a, 'tree> TreeSitterWalker<'a, 'tree> { errors: Vec::new(), node_stack: Vec::new(), fn_ref_candidates: Vec::new(), + namespace_prefix: Vec::new(), } } @@ -222,10 +227,27 @@ impl<'a, 'tree> TreeSitterWalker<'a, 'tree> { Language::Php => self.visit_php_node(node), Language::R => self.visit_r_node(node), Language::Gdscript => self.visit_gdscript_node(node), + Language::Cpp => self.visit_cpp_node(node), _ => false, } } + fn visit_cpp_node(&mut self, node: SyntaxNode<'tree>) -> bool { + if node.kind() != "namespace_definition" { + return false; + } + let ns_name = child_by_field(node, "name") + .map(|name| node_text(name, self.source)) + .unwrap_or_default(); + if ns_name.is_empty() { + return false; + } + self.namespace_prefix.push(ns_name); + self.visit_named_children(node); + self.namespace_prefix.pop(); + true + } + fn visit_ruby_node(&mut self, node: SyntaxNode<'tree>) -> bool { if node.kind() != "call" { return false; @@ -2107,11 +2129,23 @@ impl<'a, 'tree> TreeSitterWalker<'a, 'tree> { if let Some(converted) = normalize_parenthesized_go_conversion(&callee_name) { callee_name = converted; } + callee_name = self.maybe_strip_cpp_template_call(callee_name); if !callee_name.is_empty() { self.push_ref(&caller_id, &callee_name, EdgeKind::Calls, node); } } + fn maybe_strip_cpp_template_call(&self, callee_name: String) -> String { + if matches!(self.spec.language(), Language::C | Language::Cpp) + && callee_name.contains('<') + && !callee_name.contains("operator") + { + strip_cpp_template_args(&callee_name) + } else { + callee_name + } + } + /// Encode a Java/Kotlin/PHP `object`/`scope` + `name` call into a resolver /// reference (tree-sitter.ts:2578-2663). Handles the PHP `Cls::for()->m()` /// and Java `Foo.factory().m()` chain re-encodings (`().`), @@ -2610,7 +2644,7 @@ impl<'a, 'tree> TreeSitterWalker<'a, 'tree> { } fn build_qualified_name(&self, name: &str) -> String { - let mut parts = Vec::new(); + let mut parts: Vec<&str> = self.namespace_prefix.iter().map(String::as_str).collect(); for node_id in &self.node_stack { if let Some(node) = self.nodes.iter().find(|node| &node.id == node_id) { if node.kind != NodeKind::File { @@ -4702,6 +4736,96 @@ WINAPI HRESULT DoThing(int x) { return x; } assert_ne!(f.return_type.as_deref(), Some("WINAPI")); } + // ---- Release D: C++ namespace qualified names + template-arg calls (e1a8d88) ---- + + #[test] + fn cpp_namespace_prefixes_qualified_name() { + let src = "namespace ns { void fn() {} }"; + let (nodes, _) = run("ns.cpp", src, Language::Cpp); + let f = node(&nodes, NodeKind::Function, "fn"); + assert_eq!(f.qualified_name, "ns::fn"); + } + + #[test] + fn cpp_nested_namespace_and_class_qualified_name() { + let src = "namespace a { class C { public: void m() {} }; }"; + let (nodes, _) = run("nc.cpp", src, Language::Cpp); + let m = node(&nodes, NodeKind::Method, "m"); + assert_eq!(m.qualified_name, "a::C::m"); + } + + #[test] + fn cpp17_nested_namespace_qualified_name() { + let src = "namespace a::b { void f() {} }"; + let (nodes, _) = run("ab.cpp", src, Language::Cpp); + let f = node(&nodes, NodeKind::Function, "f"); + assert_eq!(f.qualified_name, "a::b::f"); + } + + #[test] + fn cpp_anonymous_namespace_leaves_bare_qualified_name() { + let src = "namespace { void f() {} }"; + let (nodes, _) = run("anon.cpp", src, Language::Cpp); + let f = node(&nodes, NodeKind::Function, "f"); + assert_eq!(f.qualified_name, "f"); + } + + #[test] + fn cpp_template_arg_call_strips_to_base() { + let src = r#" +void fn() {} +void caller() { fn(x); } +"#; + let (_, refs) = run("tc.cpp", src, Language::Cpp); + assert!( + has_ref(&refs, EdgeKind::Calls, "fn"), + "templated call `fn(x)` should emit a Calls ref to `fn`, got: {:?}", + refs.iter() + .filter(|r| r.reference_kind == EdgeKind::Calls) + .map(|r| r.reference_name.as_str()) + .collect::>() + ); + } + + #[test] + fn cpp_operator_lt_call_not_stripped() { + let src = r#" +void caller() { operator<<(a, b); } +"#; + let (_, refs) = run("op.cpp", src, Language::Cpp); + assert!( + !has_ref(&refs, EdgeKind::Calls, "operator"), + "operator<< callee must not be template-stripped to `operator`" + ); + } + + #[test] + fn cpp_ue_reflected_class_recovered() { + let src = r#" +class ENGINE_API UFoo : public UObject +{ + GENERATED_BODY() + UPROPERTY(EditAnywhere) + int X; + UFUNCTION() + void Bar(); +}; +"#; + let (nodes, refs) = run("ue.cpp", src, Language::Cpp); + assert!( + has_node(&nodes, NodeKind::Class, "UFoo"), + "heavily-reflected UE class UFoo should be recovered, got: {:?}", + nodes + .iter() + .map(|n| (n.kind, n.name.as_str())) + .collect::>() + ); + assert!( + has_ref(&refs, EdgeKind::Extends, "UObject"), + "recovered UFoo should Extends UObject" + ); + } + #[test] fn cpp_listed_macro_without_error_yields_no_return_type() { // Listed macro that tree-sitter parses cleanly as the sole `type` (no diff --git a/crates/codegraph-resolve/src/name_matcher.rs b/crates/codegraph-resolve/src/name_matcher.rs index 08ae7482..5d348ad2 100644 --- a/crates/codegraph-resolve/src/name_matcher.rs +++ b/crates/codegraph-resolve/src/name_matcher.rs @@ -769,7 +769,18 @@ fn normalize_inferred_type_name(raw: &str) -> Option { /// baked into the second pattern per language. Languages without a pattern set /// (the C++ path uses its own dedicated inferrer) return an empty vector. fn local_receiver_type_patterns(language: Language, r: &str) -> Vec { - let build = |src: String| Regex::new(&src).ok(); + local_receiver_type_patterns_tagged(language, r) + .into_iter() + .map(|(re, _)| re) + .collect() +} + +/// The bool tags the Lua/Luau `receiver: Type` ANNOTATION pattern, which needs a +/// code-side self-match gate (#1124): `lg:Log()` is byte-identical to the Luau +/// annotation `lg: Logger`, and the `regex` crate has no look-ahead to reject the +/// call form, so `infer_local_receiver_type` post-checks the tagged capture. +fn local_receiver_type_patterns_tagged(language: Language, r: &str) -> Vec<(Regex, bool)> { + let build = |src: String| Regex::new(&src).ok().map(|re| (re, false)); let pats: Vec = match language { Language::TypeScript | Language::Tsx | Language::JavaScript | Language::Jsx => vec![ format!(r"\b{r}\b\s*=\s*new\s+([A-Za-z_$][\w.$]*)"), @@ -817,11 +828,21 @@ fn local_receiver_type_patterns(language: Language, r: &str) -> Vec { format!(r"\$?{r}\b\s*=\s*new\s+([A-Za-z_\\][\w\\]*)"), format!(r"\b([A-Za-z_\\][\w\\]*)\s+&?\${r}\b"), ], - Language::Lua | Language::Luau => vec![ - format!(r"\b{r}\b\s*=\s*([A-Z]\w*)\.new\b"), - format!(r"\b{r}\b\s*=\s*([A-Z]\w*)\s*\("), - format!(r#"\b{r}\b\s*:\s*([A-Z][\w.]*)(?:[\w.]|\s*[({{"'\[])?"#), - ], + Language::Lua | Language::Luau => { + let mut out: Vec<(Regex, bool)> = Vec::new(); + for src in [ + format!(r"\b{r}\b\s*=\s*([A-Z]\w*)\.new\b"), + format!(r"\b{r}\b\s*=\s*([A-Z]\w*)\s*\("), + ] { + if let Some((re, _)) = build(src) { + out.push((re, false)); + } + } + if let Ok(re) = Regex::new(&format!(r"\b{r}\b\s*:\s*([A-Z][\w.]*)")) { + out.push((re, true)); + } + return out; + } Language::R => vec![format!(r"\b{r}\b\s*(?:<-|<<-|=)\s*([A-Z][\w.]*)\$new\b")], Language::Pascal => vec![ format!(r"\b{r}\b\s*:\s*([A-Z]\w*)"), @@ -867,7 +888,7 @@ fn infer_local_receiver_type( context: &dyn ResolutionContext, ) -> Option { let escaped = regex_escape(receiver_name); - let patterns = local_receiver_type_patterns(reference.language, &escaped); + let patterns = local_receiver_type_patterns_tagged(reference.language, &escaped); if patterns.is_empty() { return None; } @@ -889,9 +910,12 @@ fn infer_local_receiver_type( if line.len() > 10_000 { continue; } - for re in &patterns { + for (re, is_lua_annotation) in &patterns { if let Some(caps) = re.captures(line) { if let Some(m) = caps.get(1) { + if *is_lua_annotation && lua_annotation_is_method_call(line, m.end()) { + continue; + } if let Some(ty) = normalize_inferred_type_name(m.as_str()) { return Some(ty); } @@ -902,6 +926,26 @@ fn infer_local_receiver_type( None } +/// True when a Lua/Luau `receiver:Capitalized` annotation match is really a +/// method call (`lg:Log()`, `lg:Log"s"`, `lg:Log{t}`, or a longer `lg:Log.More` +/// token the annotation regex stopped short of), which must NOT be read as a type +/// annotation (#1124). Reproduces upstream's `(?![\w.]|\s*[({"'\[])` look-ahead in +/// code, since the `regex` crate has no look-ahead. `capture_end` is the byte +/// offset just past the captured type on `line`. +fn lua_annotation_is_method_call(line: &str, capture_end: usize) -> bool { + let rest = &line[capture_end..]; + if let Some(next) = rest.chars().next() { + if next.is_alphanumeric() || next == '_' || next == '.' { + return true; + } + } + let trimmed = rest.trim_start(); + trimmed + .chars() + .next() + .is_some_and(|c| matches!(c, '(' | '"' | '\'' | '[' | '{')) +} + /// The PHP `$this->prop->method()` receiver shape — encoded by the extractor as /// `this->prop.method` (a SINGLE property segment, no `()`). Matches the upstream /// `PHP_PROP_SHAPE = /^this->\w+\.\w+$/` (`index.ts:47`). Deeper chains @@ -5507,6 +5551,75 @@ mod tests { assert_eq!(res.target_node_id, "method:log"); } + #[test] + fn lua_capitalized_method_call_not_self_matched() { + // #1124: `lg:Log()` is byte-identical to a Luau annotation `lg: Log`; the + // call line must NOT self-match `type=Log`. The scan continues to the real + // `local lg = Logger.new()` declaration and resolves to Logger::Log. + let m = mk( + "method:Log", + NodeKind::Method, + "Log", + "Logger::Log", + "a.lua", + Language::Lua, + ); + let ctx = ctx_with_scope( + "a.lua", + "function run()\n local lg = Logger.new()\n lg:Log()\nend\n", + Language::Lua, + m, + "Log", + ); + let r = refv("lg:Log", EdgeKind::Calls, "a.lua", Language::Lua, 3); + let res = match_method_call(&r, &ctx).expect("lua PascalCase call resolves"); + assert_eq!(res.target_node_id, "method:Log"); + } + + #[test] + fn lua_annotation_still_resolves() { + let m = mk( + "method:Log", + NodeKind::Method, + "Log", + "Logger::Log", + "a.luau", + Language::Luau, + ); + let ctx = ctx_with_scope( + "a.luau", + "function run()\n local lg: Logger\n lg:Log()\nend\n", + Language::Luau, + m, + "Log", + ); + let r = refv("lg:Log", EdgeKind::Calls, "a.luau", Language::Luau, 3); + let res = match_method_call(&r, &ctx).expect("lua annotation resolves"); + assert_eq!(res.target_node_id, "method:Log"); + } + + #[test] + fn luau_typed_param_annotation_preserved() { + let m = mk( + "method:Log", + NodeKind::Method, + "Log", + "Logger::Log", + "a.luau", + Language::Luau, + ); + let ctx = ctx_with_scope( + "a.luau", + "function f(lg: Logger)\n lg:Log()\nend\n", + Language::Luau, + m, + "Log", + ); + let r = refv("lg:Log", EdgeKind::Calls, "a.luau", Language::Luau, 2); + let res = match_method_call(&r, &ctx).expect("luau typed param resolves"); + assert_eq!(res.target_node_id, "method:Log"); + } + #[test] fn separator_r_dollar() { // R: `lg <- Logger$new()\n lg$log()` — ref name is `lg$log`. diff --git a/docs/equivalence.md b/docs/equivalence.md index 8694572b..f1bd31d8 100644 --- a/docs/equivalence.md +++ b/docs/equivalence.md @@ -252,12 +252,32 @@ general C++ inheritance shapes plus templated-base stripping: - **struct base** — `struct S : Container` resolving to `Container` (struct inheritance goes through the same path as class inheritance). - **`::`-qualified templated base** — `class Q : public ns::Tpl` recording - an `Extends` ref to `ns::Tpl` (qualified head kept, template args stripped); - captured as an unresolved ref in `refs.json`. + an `Extends` ref to `ns::Tpl` (qualified head kept, template args stripped). + Since the C++ namespace-prefix work (Release D) stores `Tpl`'s qualified name as + `ns::Tpl`, this ref now RESOLVES to a real `Extends` edge (`Q` → `ns::Tpl`) in + `edges.json` instead of remaining an unresolved ref. + +Three further files exercise the Release D C++ extraction gains: + +- **namespace prefix + `ns::fn()` resolution** — `namespaced.cpp` defines + `namespace ns { void compute() {} }` (qualified name `ns::compute`) and calls + `ns::compute()` from `run_namespaced`; the call resolves to a `Calls` edge via + the existing qualified-name matcher (no resolver change). +- **template-argument call stripping** — `templated_call.cpp` defines + `template void process(T)` and calls `process(0)`; the + `` template args are stripped at extraction so the call links to `process`. +- **Unreal-Engine reflection-macro recovery + `.h` C++ detection** — `ue_actor.h` + is a lean UE header whose only C++ signal is `class ENGINE_API UFoo : public +UObject` plus line-leading `GENERATED_BODY()`/`UPROPERTY(...)`/`UFUNCTION()`, + a member-level `ENGINE_API`, and no explicit `public:`. Content sniffing + reclassifies the `.h` to C++, and the offset-preserving pre-parse blanking + recovers the `UFoo` class + its `Extends UObject` clause (both dropped before). The minimal source corpus lives at `crates/codegraph-bench/fixtures/cpp/` -(`base.hpp`, `derived.cpp`). The base classes live in a `.hpp` file (not `.h`, -which maps to `Language::C` where `class` is not valid syntax). +(`base.hpp`, `derived.cpp`, `namespaced.cpp`, `templated_call.cpp`, +`ue_actor.h`). The inheritance base classes live in a `.hpp` file (not `.h`, +which maps to `Language::C` by extension); `ue_actor.h` deliberately uses `.h` to +guard the content-based C++ reclassification. Regenerate the committed database + canonical JSON reproducibly from the corpus: diff --git a/reference/golden/cpp/colby.db b/reference/golden/cpp/colby.db index 5f1f220dc7bde46e29b1b362ec7bb3e2840c56f4..a509717a0fdc5b859ff84b3f65b99d30e5dbcbbe 100644 GIT binary patch delta 9258 zcmd5iYjhjcnR7KGOEaUn*N$VoC0lk9+c*!sCEE}J97qZ#2}wh25+WpxL=1l6M<5hd z2}?r=garhvcH0w@ZpxvDLb8}WX1CcUn^QO^SyIwHr5wW9knO^jO03kjSTq-N#g&+S!|bHlWsD7X4+*6i9Z$lg|CH!LXdx#zk}zE&lztt zoH0CTU~8VKaq180S8#7|+quTcf2@6vHTJsAeU^p>PxjbV=1g2pb@~%>xHAz?COZAz zq&JlG%07QU_QylMfHyf19~;|n!|*WuPo!e;dCVLPow6+Qd+DynlG8tJ50}M*N9{KNOH7 z{?1@D5$+6n!_lZujzmL=bXpxaIx!R*PYsR?#K%)|S)5 zP*9^vsKdTwA`*pP$QSmdL+Ml?oep)zBf-vOBrW?oHPj=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K&v#Y1vZxv^%n8 znsKq4V?twCgQ1{}#0!?J`m-AqW;PRH`mom{#{0mOw!Ot%-Pr-Jy4_1Qq;KSe+$WsTPW14|GW($~(c@zxC)Pe4p)u1_MC8&;B z0*Yh8AUkHh{ca`9r@f@Ymc!ue9iMW$VioLlMku^`C5NuS6g3jRy{DQ?w?in&8mBydS`dEr?=l$9*0kJf_j4S z2ICBW-Taxc(J11gaey|iR@1Nxwu3(-VQ$kCkdk(8e{&}+gh0yp z?Fo8v`4&oz)NOECiJjL4@?7s6sXP~)Jgu2^oTMc5W!vkXhDGsJ-SE0FFQ@}EZ}B7M zJo7ocpkKf?eX+5Q|64z*x9eaqUK+27!UctnST5L!8=%|28h{W4?ZiM*#u>->ZO6>W zuqO{giG6MeWboQO0}#x}UMw}`S)+BO@ikAwS+P1OpJ(c7W4GC&SkkAj^Lhb(mVWosp diff --git a/reference/golden/cpp/edges.json b/reference/golden/cpp/edges.json index 947828ae..8fcdbd63 100644 --- a/reference/golden/cpp/edges.json +++ b/reference/golden/cpp/edges.json @@ -11,6 +11,18 @@ "source": "file:derived.cpp", "target": "file:base.hpp" }, + { + "col": 0, + "kind": "imports", + "line": 1, + "metadata": { + "confidence": 0.92, + "resolvedBy": "import" + }, + "provenance": null, + "source": "file:namespaced.cpp", + "target": "file:base.hpp" + }, { "col": 11, "kind": "extends", @@ -23,6 +35,18 @@ "source": "struct:418731e230da99cc3237d0e7e35385f1", "target": "class:e436be77a00102552decf9de5d7cc052" }, + { + "col": 17, + "kind": "extends", + "line": 22, + "metadata": { + "confidence": 0.95, + "resolvedBy": "qualified-name" + }, + "provenance": null, + "source": "class:b28eae813de1699c6b7d7727db856721", + "target": "class:11306345dc1e400be056c1416040177a" + }, { "col": 17, "kind": "extends", @@ -59,6 +83,30 @@ "source": "class:1f9695d61900e851f6609231a60ccd9a", "target": "class:e436be77a00102552decf9de5d7cc052" }, + { + "col": 4, + "kind": "calls", + "line": 5, + "metadata": { + "confidence": 0.9, + "resolvedBy": "exact-match" + }, + "provenance": null, + "source": "function:906472bb253d72948b69406881d785bf", + "target": "function:61cb788885161f5fe3ff59a749c7fd19" + }, + { + "col": 4, + "kind": "calls", + "line": 8, + "metadata": { + "confidence": 0.9, + "resolvedBy": "exact-match" + }, + "provenance": null, + "source": "function:8118a321a3f16f7898de2768139b459d", + "target": "function:a83447ac43eae44cd787ebbed1f221b2" + }, { "col": 44, "kind": "extends", @@ -233,6 +281,60 @@ "source": "file:derived.cpp", "target": "struct:418731e230da99cc3237d0e7e35385f1" }, + { + "col": null, + "kind": "contains", + "line": null, + "metadata": null, + "provenance": null, + "source": "file:namespaced.cpp", + "target": "function:8118a321a3f16f7898de2768139b459d" + }, + { + "col": null, + "kind": "contains", + "line": null, + "metadata": null, + "provenance": null, + "source": "file:namespaced.cpp", + "target": "function:a83447ac43eae44cd787ebbed1f221b2" + }, + { + "col": null, + "kind": "contains", + "line": null, + "metadata": null, + "provenance": null, + "source": "file:namespaced.cpp", + "target": "import:d427e262bde770416cf520f12c124a85" + }, + { + "col": null, + "kind": "contains", + "line": null, + "metadata": null, + "provenance": null, + "source": "file:templated_call.cpp", + "target": "function:61cb788885161f5fe3ff59a749c7fd19" + }, + { + "col": null, + "kind": "contains", + "line": null, + "metadata": null, + "provenance": null, + "source": "file:templated_call.cpp", + "target": "function:906472bb253d72948b69406881d785bf" + }, + { + "col": null, + "kind": "contains", + "line": null, + "metadata": null, + "provenance": null, + "source": "file:ue_actor.h", + "target": "class:ade92bd69bacb920c05c0d123d2a5130" + }, { "col": null, "kind": "contains", diff --git a/reference/golden/cpp/files.json b/reference/golden/cpp/files.json index 8178b9be..8e0c3bcb 100644 --- a/reference/golden/cpp/files.json +++ b/reference/golden/cpp/files.json @@ -14,5 +14,29 @@ "node_count": 12, "path": "derived.cpp", "size": 363 + }, + { + "content_hash": "bfd6da256b748444e2bfdff365e7d56daa640afa638e50b294db94cca1f2a7f8", + "errors": null, + "language": "cpp", + "node_count": 4, + "path": "namespaced.cpp", + "size": 102 + }, + { + "content_hash": "e72bc5982add705d170ebd03d4a3db5286237e5b8ab662fc9ed35cd51da438c9", + "errors": null, + "language": "cpp", + "node_count": 3, + "path": "templated_call.cpp", + "size": 94 + }, + { + "content_hash": "5afecb82e36830d924845a28b9069f2fb7cc3d9b15d74f6bf6623fd737b3d265", + "errors": null, + "language": "c", + "node_count": 2, + "path": "ue_actor.h", + "size": 191 } ] diff --git a/reference/golden/cpp/nodes.json b/reference/golden/cpp/nodes.json index dcd03830..961e88a2 100644 --- a/reference/golden/cpp/nodes.json +++ b/reference/golden/cpp/nodes.json @@ -35,7 +35,7 @@ "kind": "class", "language": "cpp", "name": "Tpl", - "qualified_name": "Tpl", + "qualified_name": "ns::Tpl", "return_type": null, "signature": null, "start_column": 0, @@ -131,6 +131,28 @@ "type_parameters": null, "visibility": null }, + { + "decorators": null, + "docstring": null, + "end_column": 1, + "end_line": 11, + "file_path": "ue_actor.h", + "id": "class:ade92bd69bacb920c05c0d123d2a5130", + "is_abstract": 0, + "is_async": 0, + "is_exported": 0, + "is_static": 0, + "kind": "class", + "language": "cpp", + "name": "UFoo", + "qualified_name": "UFoo", + "return_type": null, + "signature": null, + "start_column": 0, + "start_line": 3, + "type_parameters": null, + "visibility": null + }, { "decorators": null, "docstring": null, @@ -219,6 +241,160 @@ "type_parameters": null, "visibility": null }, + { + "decorators": null, + "docstring": null, + "end_column": 0, + "end_line": 10, + "file_path": "namespaced.cpp", + "id": "file:namespaced.cpp", + "is_abstract": 0, + "is_async": 0, + "is_exported": 0, + "is_static": 0, + "kind": "file", + "language": "cpp", + "name": "namespaced.cpp", + "qualified_name": "namespaced.cpp", + "return_type": null, + "signature": null, + "start_column": 0, + "start_line": 1, + "type_parameters": null, + "visibility": null + }, + { + "decorators": null, + "docstring": null, + "end_column": 0, + "end_line": 7, + "file_path": "templated_call.cpp", + "id": "file:templated_call.cpp", + "is_abstract": 0, + "is_async": 0, + "is_exported": 0, + "is_static": 0, + "kind": "file", + "language": "cpp", + "name": "templated_call.cpp", + "qualified_name": "templated_call.cpp", + "return_type": null, + "signature": null, + "start_column": 0, + "start_line": 1, + "type_parameters": null, + "visibility": null + }, + { + "decorators": null, + "docstring": null, + "end_column": 0, + "end_line": 12, + "file_path": "ue_actor.h", + "id": "file:ue_actor.h", + "is_abstract": 0, + "is_async": 0, + "is_exported": 0, + "is_static": 0, + "kind": "file", + "language": "cpp", + "name": "ue_actor.h", + "qualified_name": "ue_actor.h", + "return_type": null, + "signature": null, + "start_column": 0, + "start_line": 1, + "type_parameters": null, + "visibility": null + }, + { + "decorators": null, + "docstring": null, + "end_column": 24, + "end_line": 2, + "file_path": "templated_call.cpp", + "id": "function:61cb788885161f5fe3ff59a749c7fd19", + "is_abstract": 0, + "is_async": 0, + "is_exported": 0, + "is_static": 0, + "kind": "function", + "language": "cpp", + "name": "process", + "qualified_name": "process", + "return_type": null, + "signature": null, + "start_column": 0, + "start_line": 2, + "type_parameters": null, + "visibility": null + }, + { + "decorators": null, + "docstring": null, + "end_column": 1, + "end_line": 9, + "file_path": "namespaced.cpp", + "id": "function:8118a321a3f16f7898de2768139b459d", + "is_abstract": 0, + "is_async": 0, + "is_exported": 0, + "is_static": 0, + "kind": "function", + "language": "cpp", + "name": "run_namespaced", + "qualified_name": "run_namespaced", + "return_type": null, + "signature": null, + "start_column": 0, + "start_line": 7, + "type_parameters": null, + "visibility": null + }, + { + "decorators": null, + "docstring": null, + "end_column": 1, + "end_line": 6, + "file_path": "templated_call.cpp", + "id": "function:906472bb253d72948b69406881d785bf", + "is_abstract": 0, + "is_async": 0, + "is_exported": 0, + "is_static": 0, + "kind": "function", + "language": "cpp", + "name": "run_templated", + "qualified_name": "run_templated", + "return_type": null, + "signature": null, + "start_column": 0, + "start_line": 4, + "type_parameters": null, + "visibility": null + }, + { + "decorators": null, + "docstring": null, + "end_column": 17, + "end_line": 4, + "file_path": "namespaced.cpp", + "id": "function:a83447ac43eae44cd787ebbed1f221b2", + "is_abstract": 0, + "is_async": 0, + "is_exported": 0, + "is_static": 0, + "kind": "function", + "language": "cpp", + "name": "compute", + "qualified_name": "ns::compute", + "return_type": null, + "signature": null, + "start_column": 0, + "start_line": 4, + "type_parameters": null, + "visibility": null + }, { "decorators": null, "docstring": null, @@ -241,6 +417,28 @@ "type_parameters": null, "visibility": null }, + { + "decorators": null, + "docstring": null, + "end_column": 0, + "end_line": 2, + "file_path": "namespaced.cpp", + "id": "import:d427e262bde770416cf520f12c124a85", + "is_abstract": 0, + "is_async": 0, + "is_exported": 0, + "is_static": 0, + "kind": "import", + "language": "cpp", + "name": "base.hpp", + "qualified_name": "base.hpp", + "return_type": null, + "signature": "#include \"base.hpp\"", + "start_column": 0, + "start_line": 1, + "type_parameters": null, + "visibility": null + }, { "decorators": null, "docstring": null, @@ -387,7 +585,7 @@ "kind": "method", "language": "cpp", "name": "wrap", - "qualified_name": "Tpl::wrap", + "qualified_name": "ns::Tpl::wrap", "return_type": null, "signature": null, "start_column": 4, diff --git a/reference/golden/cpp/refs.json b/reference/golden/cpp/refs.json index 120a707b..fed34718 100644 --- a/reference/golden/cpp/refs.json +++ b/reference/golden/cpp/refs.json @@ -1,12 +1,12 @@ [ { "candidates": null, - "col": 17, - "file_path": "derived.cpp", - "from_node_id": "class:b28eae813de1699c6b7d7727db856721", + "col": 31, + "file_path": "ue_actor.h", + "from_node_id": "class:ade92bd69bacb920c05c0d123d2a5130", "language": "cpp", - "line": 22, + "line": 3, "reference_kind": "extends", - "reference_name": "ns::Tpl" + "reference_name": "UObject" } ]