diff --git a/graphify/cache.py b/graphify/cache.py index 3b52d33c35..c64d8d6de1 100644 --- a/graphify/cache.py +++ b/graphify/cache.py @@ -38,7 +38,7 @@ _EXTRACTOR_VERSION = "unknown" # Bump when AST cache-key semantics change independently of the package version. -_AST_CACHE_SCHEMA = 48 # A Go same-package member call types its receiver by a bare name scoped to the caller's own package instead of matching that name against every package in the corpus, so two packages each declaring a type with the same name (e.g. `alpha.Service` and `beta.Service`) keep their own same-file member calls instead of both losing them to a corpus-wide ambiguity bail (#5242); each Java overload gets its own node keyed by arity and erased signature (with generic bounds erased per scope), and the `affected` override-matching is made arity-aware so a split `run(int)` is not tied to a supertype `run()` by label alone (#5251); a JS `this.x = function(params){}` member's own params and enclosing-bound names shadow outer names, so an argument-position param no longer fabricates a false `indirect_call` to a same-named corpus function (#5241); a C/C++ directory-qualified angle include `` resolves to the local file and standard-library headers are kept off the alias index (#5218); and a SQL table named with non-ASCII letters that the grammar collapses no longer mints an empty-id node or an edge to an empty id (#5250); a Pascal unit the tree-sitter grammar cannot parse end to end is recovered through a byte-length-preserving masked retry (escaped string literals and compiler directives) instead of yielding no nodes (#5264), and the Pascal extractor now records unit-level global variables and a qualifier on unresolved qualified raw_calls so a call through a global object variable (`DM.Open`, the Delphi data-module idiom) resolves to the variable's type member (#3101); so cached Go, Java, JS/TS, C/C++, SQL and Pascal extractions re-run; prior (47): A JS/TS name bound in an enclosing scope and captured into a tracked nested closure no longer fabricates a false `indirect_call` to a same-named corpus function (#5217); a T-SQL procedure that parses structurally (not via ERROR recovery) keeps its INSERT/UPDATE/DELETE/SELECT INTO writes (#5146); and an Oracle `CREATE PACKAGE [BODY]`'s member procedures and functions, and their table reads/writes, are recovered instead of yielding only a file node (#5168); and nested types get owner-qualified ids so same-named nested types under different owners no longer collide into one node, with qualified calls (`Outer.Inner.m()`, `Outer::Inner::m()`) resolving through the owner chain (#5185); so cached JS/TS, SQL and nested-type (C#, Java, Scala, C++, TS) extractions re-run; prior (46): A non-UTF-8 C# file with any preprocessor directive is decoded (Windows-1252/UTF-16, #4145) before the directive blanking of #5003 instead of being parsed as raw bytes, so its non-ASCII identifiers are no longer cut short and later members are no longer dropped (#5194); a C# explicit interface implementation (`void IFoo.Bar()`) is kept out of overload binding and gets a distinct node id so it no longer collapses with a public `Bar` overload and calls dispatch to the right member (#5193); and members whose names differ only by a leading/trailing `_` (or `~`, or by case) get distinct node ids in Kotlin (#5206), Swift (#5204), Dart (#5200) and C++ (including constructor `Foo` vs destructor `~Foo`, #5202), as already done for Python/C#/Java/PHP; a variadic parameter (`xs ...T`, `T... xs`, `params T[]`, `T*`, `...$xs`) references its element type in Go, Java, C#, Scala and PHP (#4638); and a Dart legacy typedef that returns a function type (`typedef int Function(int) Make();`) is named by its own declared name instead of `Function` (#4641); so cached C#, Kotlin, Swift, Dart, C++, Go, Java, Scala and PHP extractions re-run; prior (45): A C# field or primary-constructor parameter whose type name does not start with a capital (`_Pair`, `pair`, `bool`) is recorded in the receiver table, and a member call on a receiver that no local, parameter, field or property declares carries `receiver_undeclared`, so `_Pair.Make()`/`pair.Create()` bind as static calls (#5174); a Java call through a class-qualified static field (`Service.INSTANCE.get()`) resolves via the field's declared type, recorded in a static-field type table (#5149); and a SQL routine body preserves comma joins and keeps a `@dblink` suffix distinct, an unparsed derived table's alias is no longer read as a table, and Oracle `[NON]EDITIONABLE` PROCEDURE/FUNCTION/TRIGGER DDL is recovered instead of yielding only a file node (#5169, #5147, #5167); so cached C#, Java and SQL extractions re-run; prior (44): A folded C++ parameterless member records its `definition_file` anchored to the source root instead of a cache-root-relative `../`-walk; a PHP route closure takes its path only from the arguments before it, so a string argument after the closure no longer becomes the route's path or leaks into an enclosing group's prefix (#5135); two module-level declarations in one file differing only by a leading/trailing `_` keep distinct ids (the first keeps the plain id, the rest are salted) across JS, TS, C, C++, PHP, Ruby, Kotlin, Swift and Lua (#2810); PHP methods of one class/trait/interface/enum differing only by a `_` keep distinct ids (#5137); and Java members differing only by a `_` or only by case keep distinct ids (#5151); so cached C++, PHP, Java and module-level-id extractions re-run; prior (43): A dotted Python subscript annotation (`mod.MyBox[Foo]`) walks its value once as the type, not again as its own generic argument, so the false `generic_arg` reference no longer replaces the real `parameter_type`/`return_type` edge, a C++ plain class/struct forward folds into its unique exactly-qualified definition when one file reaches the other through unconditional exact quoted includes, and a parameterless member declaration folds into its proven out-of-line definition by matching return type/qualifiers, with per-node `_cpp_member_records`/`_cpp_class_kind` facts persisted (#5117); a C++ member receiver resolves through a scoped type alias (`using Alias = ns::Type;`) and through inherited fields/methods, with forward-declared pointee types completed at the use site via a lexical-scope lookup, fail-closed on ambiguous/virtual/diamond bases (#5118); and a C++ out-of-line template member keeps its proven primary-template owner while calls in a `#if`-guarded initializer or argument list are recovered from byte-preserving branch views, with dependent receivers left unresolved (#5115); so cached Python and C++ extractions re-run; prior (42): A bare, unqualified free-function mention in a Markdown document (`token` in prose, no `()` and no namespace) binds to a same-named function only when the defining file, or another symbol from it, is cited within the heading's section chain, instead of matching any same-named callable anywhere in the corpus; reference-style links (`[text][label]`) resolve at the use site (#4804, #4806); and a C# classic extension-method call (`x.Foo()` where `Foo` is a `static ... Foo(this X x, ...)`) binds to the extension's declaration through a post-nominal additive pass, gated to a visible namespace, a matching `this` type and a unique applicable method, with a BCL deny-list and fail-closed on ambiguity or an instance-method shadow (#4828); so cached Markdown and C# extractions re-run; prior (41): A C++ member-call chain routed through class fields declared in other headers (`client.actions->Execute()`, with value `.`, raw-pointer `->` and single-arg `unique_ptr`/`shared_ptr` receivers) resolves to the field type's member across the include set, gated to a unique type and member and fail-closed otherwise, and class fields are persisted on the node (#5098); and a Markdown code span naming an uppercase `\`-namespace class (`\Foo\Bar`, `App\API`) or a type-qualified method call (`Type::member()`) is kept as a symbol mention instead of being dropped, while a non-call `Type::CONST`/`Type::class` stays dropped (#5093); so cached C++ and Markdown extractions re-run; prior (40): Solidity members, free functions and types whose names differ only by a leading `_` (or by case) in one scope (`_grantRole(bytes32,address)` / `grantRole(bytes32,address)`) get separate node ids: the one public name keeps its id and the others are salted, as in Python and C# (#3302, #4415), so the `_` function no longer vanishes and its calls stop landing on its twin (#5027); a Solidity call on a receiver of a contract or interface type (`IERC20 token; token.transfer()`, `IERC20(a).transfer()`, `token().balanceOf()`) binds by name and arity through that type's linearization to the type's own member instead of producing no edge, gated to a single visible contract/interface and fail-closed on an unknown or ambiguous type (#5060); a Solidity call attached by a `using A for T` directive (`using SafeCast for uint256; x.toUint48()`) binds to the library or free function it attaches, matched by the receiver's type and an arity one greater than the call (the receiver), fail-closed when the type is unknown or two functions fit (#5062); a C# constructor (instance, static or primary) is its own node owned by its type through a `method` edge, its body and `: base(...)`/`: this(...)` calls credited to it, and `new X(...)`/`: base`/`: this` additively link the arity-correct overload (#5054); and a C# call inside a property/indexer accessor, expression body, operator or conversion is credited to that member (an indexer is a `this[]` node, an operator a `.operator +()` node) instead of being lost (#5056), so cached Solidity and C# extractions re-run; prior (39): A Markdown code span written as a backslash namespace (`\Foo\Bar`) or a type-qualified member (`Type::member`) is recognised as a symbol mention and emits a `ns_qualified` raw_call (#4610, #4695), so cached Markdown extractions re-run; prior (38): C# preprocessor directives and `#if` branches that would derail tree-sitter-c-sharp are blanked before parsing (byte-length preserving, so lines and columns do not move), so a directive no longer closes the enclosing class early and drops later members or calls (#5003); a Solidity library call (`Lib.f()`, including an aliased import), and an `emit`/`revert`/`require` naming a declared event or error, link to the member they name instead of producing no edge, resolved only when a single visible type and a unique name/arity member match (#5001, #5005); and a YAML `<<` merge sequence gives the earlier anchor precedence for a duplicated key, matching the merge spec and PyYAML, so the winning key carries its correct source line (#4995); so cached C#, Solidity and YAML extractions re-run; prior (37): Solidity `import "../x/Y.sol"` resolves the `..` to the real file instead of a dangling stub that kept the importer's own folder (#4985); a Python module-level singleton (`g = Service()` then `g.method()`) resolves its member calls through the instance's type, gated by an exact-spelling and lexical-shadow guard (#4972); Kotlin resolves a call to an overloaded method and attributes calls inside an `init {}` block to the class, and a bare call no longer binds to a class the caller cannot reach (#4935, #4956); a Go same-file member call resolves through the receiver's type instead of a declaration-order-dependent same-named method (#4962, #4966); a Go member call on a receiver typed from another package (`pkg.T`) binds only to the `T` declared at the path the file imports `pkg` from (#3368, #4853); and a Go interface method call additively dispatches to the interface's implicit implementers (#4934), so cached Solidity, Python, Kotlin and Go extractions re-run; prior (36): C++ extraction changes: a type-alias reference (`using Foo = Bar;` then `Foo x;`) binds by exact spelling so it no longer loses to a same-normalized function, and a salted alias keeps its own `contains` edge (#4951); a member call `x.m()` binds by the receiver's type, now typed from parameters and class fields and not just locals, with untyped receivers kept bound in-file (#3215, #4946); an out-of-line/split-header definition attaches to the unique owner whose class file is in its include set via a `_cpp_qualified` identity marker, instead of file-containing or cross-binding to an unrelated same-named function (#4916, #4920); and a local callable value (a lambda or `std::function` local) is kept out of global call resolution by byte-range binding lifetimes so it no longer mints a spurious INFERRED call to a same-named global (#4917, #4921), so cached C++ extractions re-run; prior (35): A Rust module-qualified call like `crate::b::helper()` resolves to the function it names via qualifier-verified cross-file resolution, kept inside the caller's crate and out of local names (#2135, #4944); a Rust call written inside an expression macro's arguments (`println!`, `vec!`, ...) is linked, with a parsed call winning the dedupe (#4945); and cache keys keep their written case (file I/O through os_long_path, cache identity via normpath not normcase, and the digest salt no longer lowercased) so README.md and readme.md stop sharing one digest on a case-sensitive filesystem, which also changes the salt digest for any relative path carrying an uppercase char (#4925, #4937), so cached Rust extractions and any uppercase-path cache entries re-run; prior (34): A bare call inside a Python method no longer self-binds to a same-named method, so it resolves to the imported/module function instead (#4933); a Go method value reached through a receiver field is linked as an indirect_call (#4931); and a Go package-level `var` initialiser references the types it names (#4932), so cached Python and Go extractions re-run; prior (33): A Scala `extension (x: T)` method is scoped to its receiver type T (#2044, #4856); and a Terraform node carries its original scope so ids stay portable when the cached project is moved to a new directory (#4858, #4861), so cached Scala and Terraform extractions re-run; prior (32): A type and a function whose names differ only in case get separate node ids (#4904, #4908); and a PHP `Scope::MEMBER` access in a class-level initializer (const value, property/parameter default) emits a references_constant edge (#4648, #4895); R `setClass`/`setRefClass` `contains=` superclasses get inherits edges (#4902); an Elixir bare call resolves to the caller's own module first (#4900); a Dart mixin `on A, B` clause resolves every constraint (#4899); and a Fortran derived-type `extends` emits an inherits edge (#4897), so cached extractions for those languages re-run (#4904); Go credits a call in a package-level `var` initialiser (and its closures) to the file node (#4867); a Go method value passed as an argument is linked as an `indirect_call` (#4868); a Go receiver's field whose struct is declared in a sibling file of the same package is typed so its member calls resolve (#4866); and a Python dispatch table's `module.func` values resolve to the referenced functions as `indirect_call`s (#4773), so cached Go and Python extractions re-run; prior (30): File and per-declaration ids are kept distinct so a top-level declaration sharing the file's name is not dropped (#4854); a SystemVerilog `function new(...)` constructor gets its own node, `method` edge and parameter refs (#4848); a Go `var x = T{}`/`var x = &T{}` types `x` as `T` for receiver resolution like `x := T{}` (#4843); a PowerShell `using module`/`using assembly` name drops its file extension (#4847); a Solidity free-function `using {a, b} for T` set emits `uses` edges (#4846); a CommonLisp forward-referenced superclass binds to its local node instead of a sourceless stub (#4845); and Pascal `inherited`/`inline` form component blocks are recognised so later `object` blocks keep their parent (#4844), so cached extractions across those languages re-run; prior (29): OCaml `and`-chained module/class bindings are all walked (only the first was, so later bindings were silently dropped, #4822), and a SystemVerilog class `task` method is modeled like a `function` one with its own node and parameter refs while its task-locals no longer leak as class fields (#4774), so cached OCaml and Verilog/SystemVerilog extractions re-run; prior (28): Markdown ATX headings parse per CommonMark (closing `#` runs dropped, 0-3 space indent, hash-only lines mint no node, #4790) and fenced code blocks are tracked by CommonMark rules so headings inside fences stop leaking (#4787); YAML keys carry their written spelling and real line and `on`/`off`/`yes`/`no` keys no longer fold to booleans (#4784); rationale labels redact more credential shapes before caching (#4647); Razor `@implements` interface edges are extracted (#4820); aliased Terraform providers get their own node and `provider =` refs resolve (#4819); COBOL paragraphs after a nested `END PROGRAM` reattach to the enclosing program (#4824); Blade `wire:click` binds the bare method name (#4823); a Pascal record is a type with its own methods (#4825); VB.NET operator declarations are extracted as members with their bodies walked (#4821); and a Fortran call resolves to the subroutine it names (#4795), so cached Markdown/YAML/rationale/Razor/Terraform/COBOL/Blade/Pascal/VB.NET/Fortran extractions re-run; prior (27): VB.NET external namespace/type stubs now carry a `source_file` sentinel (#4725); Python member calls resolve through injected fields and method-result types (#4726); a Rust `use` is scoped to the crate it names (#4699), so cached VB.NET/Python/Rust extractions re-run; prior (26): Zig no longer crosses a call between a method and a same-named free function (#4755), and a Dart unnamed `extension on T` is detected (#4741), so cached Zig and Dart extractions re-run; prior (25): Python/Go/C++/Rust explicit type aliases (and Rust `union` items) are extracted as type nodes so references resolve instead of minting sourceless stubs (#4578/#4579/#4580/#4581); each C# method overload gets its own node bound by arity (#4584); a package.json dependency's manifest entry links to its ref node (#4569), so cached extractions re-run; prior (24): Objective-C `NS_CLOSED_ENUM` declarations are extracted as enums like `NS_ENUM` (#4705), and a `CREATE TABLE` whose column default the SQL grammar rejects (MySQL `DEFAULT current_timestamp()`) is recovered from its ERROR node (#4613), so cached ObjC and SQL extractions re-run; prior (23): `.yaml`/`.yml` files are structurally extracted (keys as nodes, config-vs-data gated) and reclassified from document to code (#2214), so cached YAML re-extracts; prior (22): SQL labels drop T-SQL brackets and routine bodies emit `reads_from`/`writes_to` (#4635), and a `GO` batch separator ends a statement (#4651), so cached `.sql` extractions re-run; prior (21): a CommonJS `const X = require('./m')` binding no longer mints a module-scope node that shadows the class the required file exports, so `new X()` resolves to the required declaration (#4621); prior (20): Obsidian `[[wikilink]]` targets that start with the scan root's own folder names now resolve to the real page (#4559), so cached markdown extractions re-run; prior (19): Dart `typedef` declarations are extracted as aliases (not variables of type `typedef`); C++ Metal/CUDA GPU qualifiers no longer mint sourceless god nodes (#4550); a `.h` header containing `extern "C"` routes to the C++ extractor; prior (18): Kotlin `typealias` (#4553), C# `delegate` (#4552), and Swift `macro` declarations (#4551) are now extracted so references stop minting sourceless stubs; Rust `use` rooted at a `mod` declared in the same scope carries `_rust_use_name` (#4564); prior (17): Python pytest-fixture markers (`_py_fixture`/`_python_fixture_param`, #4332) and module-level class-id collision salting (#2810); TS `this.field` typed from any method incl. static (#4473); Solidity callables carry `metadata.arity` + inherited-call/`super`/modifier raw calls (#4379); Go type-decl and Rust file-item case-distinct node ids (#4444); prior (16): Rust `use` edges carry the imported name as written (`_rust_use_name`, #4439); (15): Go generic receiver types normalized (`Box[T]` -> `Box`) so methods attach to the type node; prior (14): C# receiver resolution for nameless/`new X()`/`foreach` receivers (defer + receiver-chain markers) and `_`/case-distinct node ids (underscore-salted); prior (13): Kotlin/Scala/C++/Swift generic & template type params no longer mint sourceless stubs; Objective-C NS_ENUM/NS_OPTIONS extraction and `_callable`/`_callable_class` markers; Go and PHP receiver-typed member calls park cross-repo (`go_type_table`/`php_type_table`, receiver fields); prior (12): Java inherited-supertype (`receiver_unbound`) and chained/new/cast receiver typing (`java_receiver_chain`, `_java_ret`); C/C++ quoted cross-directory include provenance (`include_kind`); JS external imports anchored to the package, not the path leaf; prior (11): Python property-accessor decorators / `Self`, Swift `Self`, Go generic type params, Python forward type-hint file node, PowerShell dot-source, C# verbatim-interpolated string recovery; (10): C# partial types carry `type_path`; (9): Python property-read raw calls and `_py_property` nodes; (8): Rust `use`-group per-binding edges; (7): Python opaque-base/super(args) markers + nested-class enclosing ids. +_AST_CACHE_SCHEMA = 49 # A Java field or class annotated with Lombok `@Getter` gets a node for each getter Lombok writes (`getX()`/`isX()`, static for a static field), carrying the field's type as its return type, so a chain such as `Model.getInstance().work()` resolves (#5148); so cached Java extractions re-run; prior (48): A Go same-package member call types its receiver by a bare name scoped to the caller's own package instead of matching that name against every package in the corpus, so two packages each declaring a type with the same name (e.g. `alpha.Service` and `beta.Service`) keep their own same-file member calls instead of both losing them to a corpus-wide ambiguity bail (#5242); each Java overload gets its own node keyed by arity and erased signature (with generic bounds erased per scope), and the `affected` override-matching is made arity-aware so a split `run(int)` is not tied to a supertype `run()` by label alone (#5251); a JS `this.x = function(params){}` member's own params and enclosing-bound names shadow outer names, so an argument-position param no longer fabricates a false `indirect_call` to a same-named corpus function (#5241); a C/C++ directory-qualified angle include `` resolves to the local file and standard-library headers are kept off the alias index (#5218); and a SQL table named with non-ASCII letters that the grammar collapses no longer mints an empty-id node or an edge to an empty id (#5250); a Pascal unit the tree-sitter grammar cannot parse end to end is recovered through a byte-length-preserving masked retry (escaped string literals and compiler directives) instead of yielding no nodes (#5264), and the Pascal extractor now records unit-level global variables and a qualifier on unresolved qualified raw_calls so a call through a global object variable (`DM.Open`, the Delphi data-module idiom) resolves to the variable's type member (#3101); so cached Go, Java, JS/TS, C/C++, SQL and Pascal extractions re-run; prior (47): A JS/TS name bound in an enclosing scope and captured into a tracked nested closure no longer fabricates a false `indirect_call` to a same-named corpus function (#5217); a T-SQL procedure that parses structurally (not via ERROR recovery) keeps its INSERT/UPDATE/DELETE/SELECT INTO writes (#5146); and an Oracle `CREATE PACKAGE [BODY]`'s member procedures and functions, and their table reads/writes, are recovered instead of yielding only a file node (#5168); and nested types get owner-qualified ids so same-named nested types under different owners no longer collide into one node, with qualified calls (`Outer.Inner.m()`, `Outer::Inner::m()`) resolving through the owner chain (#5185); so cached JS/TS, SQL and nested-type (C#, Java, Scala, C++, TS) extractions re-run; prior (46): A non-UTF-8 C# file with any preprocessor directive is decoded (Windows-1252/UTF-16, #4145) before the directive blanking of #5003 instead of being parsed as raw bytes, so its non-ASCII identifiers are no longer cut short and later members are no longer dropped (#5194); a C# explicit interface implementation (`void IFoo.Bar()`) is kept out of overload binding and gets a distinct node id so it no longer collapses with a public `Bar` overload and calls dispatch to the right member (#5193); and members whose names differ only by a leading/trailing `_` (or `~`, or by case) get distinct node ids in Kotlin (#5206), Swift (#5204), Dart (#5200) and C++ (including constructor `Foo` vs destructor `~Foo`, #5202), as already done for Python/C#/Java/PHP; a variadic parameter (`xs ...T`, `T... xs`, `params T[]`, `T*`, `...$xs`) references its element type in Go, Java, C#, Scala and PHP (#4638); and a Dart legacy typedef that returns a function type (`typedef int Function(int) Make();`) is named by its own declared name instead of `Function` (#4641); so cached C#, Kotlin, Swift, Dart, C++, Go, Java, Scala and PHP extractions re-run; prior (45): A C# field or primary-constructor parameter whose type name does not start with a capital (`_Pair`, `pair`, `bool`) is recorded in the receiver table, and a member call on a receiver that no local, parameter, field or property declares carries `receiver_undeclared`, so `_Pair.Make()`/`pair.Create()` bind as static calls (#5174); a Java call through a class-qualified static field (`Service.INSTANCE.get()`) resolves via the field's declared type, recorded in a static-field type table (#5149); and a SQL routine body preserves comma joins and keeps a `@dblink` suffix distinct, an unparsed derived table's alias is no longer read as a table, and Oracle `[NON]EDITIONABLE` PROCEDURE/FUNCTION/TRIGGER DDL is recovered instead of yielding only a file node (#5169, #5147, #5167); so cached C#, Java and SQL extractions re-run; prior (44): A folded C++ parameterless member records its `definition_file` anchored to the source root instead of a cache-root-relative `../`-walk; a PHP route closure takes its path only from the arguments before it, so a string argument after the closure no longer becomes the route's path or leaks into an enclosing group's prefix (#5135); two module-level declarations in one file differing only by a leading/trailing `_` keep distinct ids (the first keeps the plain id, the rest are salted) across JS, TS, C, C++, PHP, Ruby, Kotlin, Swift and Lua (#2810); PHP methods of one class/trait/interface/enum differing only by a `_` keep distinct ids (#5137); and Java members differing only by a `_` or only by case keep distinct ids (#5151); so cached C++, PHP, Java and module-level-id extractions re-run; prior (43): A dotted Python subscript annotation (`mod.MyBox[Foo]`) walks its value once as the type, not again as its own generic argument, so the false `generic_arg` reference no longer replaces the real `parameter_type`/`return_type` edge, a C++ plain class/struct forward folds into its unique exactly-qualified definition when one file reaches the other through unconditional exact quoted includes, and a parameterless member declaration folds into its proven out-of-line definition by matching return type/qualifiers, with per-node `_cpp_member_records`/`_cpp_class_kind` facts persisted (#5117); a C++ member receiver resolves through a scoped type alias (`using Alias = ns::Type;`) and through inherited fields/methods, with forward-declared pointee types completed at the use site via a lexical-scope lookup, fail-closed on ambiguous/virtual/diamond bases (#5118); and a C++ out-of-line template member keeps its proven primary-template owner while calls in a `#if`-guarded initializer or argument list are recovered from byte-preserving branch views, with dependent receivers left unresolved (#5115); so cached Python and C++ extractions re-run; prior (42): A bare, unqualified free-function mention in a Markdown document (`token` in prose, no `()` and no namespace) binds to a same-named function only when the defining file, or another symbol from it, is cited within the heading's section chain, instead of matching any same-named callable anywhere in the corpus; reference-style links (`[text][label]`) resolve at the use site (#4804, #4806); and a C# classic extension-method call (`x.Foo()` where `Foo` is a `static ... Foo(this X x, ...)`) binds to the extension's declaration through a post-nominal additive pass, gated to a visible namespace, a matching `this` type and a unique applicable method, with a BCL deny-list and fail-closed on ambiguity or an instance-method shadow (#4828); so cached Markdown and C# extractions re-run; prior (41): A C++ member-call chain routed through class fields declared in other headers (`client.actions->Execute()`, with value `.`, raw-pointer `->` and single-arg `unique_ptr`/`shared_ptr` receivers) resolves to the field type's member across the include set, gated to a unique type and member and fail-closed otherwise, and class fields are persisted on the node (#5098); and a Markdown code span naming an uppercase `\`-namespace class (`\Foo\Bar`, `App\API`) or a type-qualified method call (`Type::member()`) is kept as a symbol mention instead of being dropped, while a non-call `Type::CONST`/`Type::class` stays dropped (#5093); so cached C++ and Markdown extractions re-run; prior (40): Solidity members, free functions and types whose names differ only by a leading `_` (or by case) in one scope (`_grantRole(bytes32,address)` / `grantRole(bytes32,address)`) get separate node ids: the one public name keeps its id and the others are salted, as in Python and C# (#3302, #4415), so the `_` function no longer vanishes and its calls stop landing on its twin (#5027); a Solidity call on a receiver of a contract or interface type (`IERC20 token; token.transfer()`, `IERC20(a).transfer()`, `token().balanceOf()`) binds by name and arity through that type's linearization to the type's own member instead of producing no edge, gated to a single visible contract/interface and fail-closed on an unknown or ambiguous type (#5060); a Solidity call attached by a `using A for T` directive (`using SafeCast for uint256; x.toUint48()`) binds to the library or free function it attaches, matched by the receiver's type and an arity one greater than the call (the receiver), fail-closed when the type is unknown or two functions fit (#5062); a C# constructor (instance, static or primary) is its own node owned by its type through a `method` edge, its body and `: base(...)`/`: this(...)` calls credited to it, and `new X(...)`/`: base`/`: this` additively link the arity-correct overload (#5054); and a C# call inside a property/indexer accessor, expression body, operator or conversion is credited to that member (an indexer is a `this[]` node, an operator a `.operator +()` node) instead of being lost (#5056), so cached Solidity and C# extractions re-run; prior (39): A Markdown code span written as a backslash namespace (`\Foo\Bar`) or a type-qualified member (`Type::member`) is recognised as a symbol mention and emits a `ns_qualified` raw_call (#4610, #4695), so cached Markdown extractions re-run; prior (38): C# preprocessor directives and `#if` branches that would derail tree-sitter-c-sharp are blanked before parsing (byte-length preserving, so lines and columns do not move), so a directive no longer closes the enclosing class early and drops later members or calls (#5003); a Solidity library call (`Lib.f()`, including an aliased import), and an `emit`/`revert`/`require` naming a declared event or error, link to the member they name instead of producing no edge, resolved only when a single visible type and a unique name/arity member match (#5001, #5005); and a YAML `<<` merge sequence gives the earlier anchor precedence for a duplicated key, matching the merge spec and PyYAML, so the winning key carries its correct source line (#4995); so cached C#, Solidity and YAML extractions re-run; prior (37): Solidity `import "../x/Y.sol"` resolves the `..` to the real file instead of a dangling stub that kept the importer's own folder (#4985); a Python module-level singleton (`g = Service()` then `g.method()`) resolves its member calls through the instance's type, gated by an exact-spelling and lexical-shadow guard (#4972); Kotlin resolves a call to an overloaded method and attributes calls inside an `init {}` block to the class, and a bare call no longer binds to a class the caller cannot reach (#4935, #4956); a Go same-file member call resolves through the receiver's type instead of a declaration-order-dependent same-named method (#4962, #4966); a Go member call on a receiver typed from another package (`pkg.T`) binds only to the `T` declared at the path the file imports `pkg` from (#3368, #4853); and a Go interface method call additively dispatches to the interface's implicit implementers (#4934), so cached Solidity, Python, Kotlin and Go extractions re-run; prior (36): C++ extraction changes: a type-alias reference (`using Foo = Bar;` then `Foo x;`) binds by exact spelling so it no longer loses to a same-normalized function, and a salted alias keeps its own `contains` edge (#4951); a member call `x.m()` binds by the receiver's type, now typed from parameters and class fields and not just locals, with untyped receivers kept bound in-file (#3215, #4946); an out-of-line/split-header definition attaches to the unique owner whose class file is in its include set via a `_cpp_qualified` identity marker, instead of file-containing or cross-binding to an unrelated same-named function (#4916, #4920); and a local callable value (a lambda or `std::function` local) is kept out of global call resolution by byte-range binding lifetimes so it no longer mints a spurious INFERRED call to a same-named global (#4917, #4921), so cached C++ extractions re-run; prior (35): A Rust module-qualified call like `crate::b::helper()` resolves to the function it names via qualifier-verified cross-file resolution, kept inside the caller's crate and out of local names (#2135, #4944); a Rust call written inside an expression macro's arguments (`println!`, `vec!`, ...) is linked, with a parsed call winning the dedupe (#4945); and cache keys keep their written case (file I/O through os_long_path, cache identity via normpath not normcase, and the digest salt no longer lowercased) so README.md and readme.md stop sharing one digest on a case-sensitive filesystem, which also changes the salt digest for any relative path carrying an uppercase char (#4925, #4937), so cached Rust extractions and any uppercase-path cache entries re-run; prior (34): A bare call inside a Python method no longer self-binds to a same-named method, so it resolves to the imported/module function instead (#4933); a Go method value reached through a receiver field is linked as an indirect_call (#4931); and a Go package-level `var` initialiser references the types it names (#4932), so cached Python and Go extractions re-run; prior (33): A Scala `extension (x: T)` method is scoped to its receiver type T (#2044, #4856); and a Terraform node carries its original scope so ids stay portable when the cached project is moved to a new directory (#4858, #4861), so cached Scala and Terraform extractions re-run; prior (32): A type and a function whose names differ only in case get separate node ids (#4904, #4908); and a PHP `Scope::MEMBER` access in a class-level initializer (const value, property/parameter default) emits a references_constant edge (#4648, #4895); R `setClass`/`setRefClass` `contains=` superclasses get inherits edges (#4902); an Elixir bare call resolves to the caller's own module first (#4900); a Dart mixin `on A, B` clause resolves every constraint (#4899); and a Fortran derived-type `extends` emits an inherits edge (#4897), so cached extractions for those languages re-run (#4904); Go credits a call in a package-level `var` initialiser (and its closures) to the file node (#4867); a Go method value passed as an argument is linked as an `indirect_call` (#4868); a Go receiver's field whose struct is declared in a sibling file of the same package is typed so its member calls resolve (#4866); and a Python dispatch table's `module.func` values resolve to the referenced functions as `indirect_call`s (#4773), so cached Go and Python extractions re-run; prior (30): File and per-declaration ids are kept distinct so a top-level declaration sharing the file's name is not dropped (#4854); a SystemVerilog `function new(...)` constructor gets its own node, `method` edge and parameter refs (#4848); a Go `var x = T{}`/`var x = &T{}` types `x` as `T` for receiver resolution like `x := T{}` (#4843); a PowerShell `using module`/`using assembly` name drops its file extension (#4847); a Solidity free-function `using {a, b} for T` set emits `uses` edges (#4846); a CommonLisp forward-referenced superclass binds to its local node instead of a sourceless stub (#4845); and Pascal `inherited`/`inline` form component blocks are recognised so later `object` blocks keep their parent (#4844), so cached extractions across those languages re-run; prior (29): OCaml `and`-chained module/class bindings are all walked (only the first was, so later bindings were silently dropped, #4822), and a SystemVerilog class `task` method is modeled like a `function` one with its own node and parameter refs while its task-locals no longer leak as class fields (#4774), so cached OCaml and Verilog/SystemVerilog extractions re-run; prior (28): Markdown ATX headings parse per CommonMark (closing `#` runs dropped, 0-3 space indent, hash-only lines mint no node, #4790) and fenced code blocks are tracked by CommonMark rules so headings inside fences stop leaking (#4787); YAML keys carry their written spelling and real line and `on`/`off`/`yes`/`no` keys no longer fold to booleans (#4784); rationale labels redact more credential shapes before caching (#4647); Razor `@implements` interface edges are extracted (#4820); aliased Terraform providers get their own node and `provider =` refs resolve (#4819); COBOL paragraphs after a nested `END PROGRAM` reattach to the enclosing program (#4824); Blade `wire:click` binds the bare method name (#4823); a Pascal record is a type with its own methods (#4825); VB.NET operator declarations are extracted as members with their bodies walked (#4821); and a Fortran call resolves to the subroutine it names (#4795), so cached Markdown/YAML/rationale/Razor/Terraform/COBOL/Blade/Pascal/VB.NET/Fortran extractions re-run; prior (27): VB.NET external namespace/type stubs now carry a `source_file` sentinel (#4725); Python member calls resolve through injected fields and method-result types (#4726); a Rust `use` is scoped to the crate it names (#4699), so cached VB.NET/Python/Rust extractions re-run; prior (26): Zig no longer crosses a call between a method and a same-named free function (#4755), and a Dart unnamed `extension on T` is detected (#4741), so cached Zig and Dart extractions re-run; prior (25): Python/Go/C++/Rust explicit type aliases (and Rust `union` items) are extracted as type nodes so references resolve instead of minting sourceless stubs (#4578/#4579/#4580/#4581); each C# method overload gets its own node bound by arity (#4584); a package.json dependency's manifest entry links to its ref node (#4569), so cached extractions re-run; prior (24): Objective-C `NS_CLOSED_ENUM` declarations are extracted as enums like `NS_ENUM` (#4705), and a `CREATE TABLE` whose column default the SQL grammar rejects (MySQL `DEFAULT current_timestamp()`) is recovered from its ERROR node (#4613), so cached ObjC and SQL extractions re-run; prior (23): `.yaml`/`.yml` files are structurally extracted (keys as nodes, config-vs-data gated) and reclassified from document to code (#2214), so cached YAML re-extracts; prior (22): SQL labels drop T-SQL brackets and routine bodies emit `reads_from`/`writes_to` (#4635), and a `GO` batch separator ends a statement (#4651), so cached `.sql` extractions re-run; prior (21): a CommonJS `const X = require('./m')` binding no longer mints a module-scope node that shadows the class the required file exports, so `new X()` resolves to the required declaration (#4621); prior (20): Obsidian `[[wikilink]]` targets that start with the scan root's own folder names now resolve to the real page (#4559), so cached markdown extractions re-run; prior (19): Dart `typedef` declarations are extracted as aliases (not variables of type `typedef`); C++ Metal/CUDA GPU qualifiers no longer mint sourceless god nodes (#4550); a `.h` header containing `extern "C"` routes to the C++ extractor; prior (18): Kotlin `typealias` (#4553), C# `delegate` (#4552), and Swift `macro` declarations (#4551) are now extracted so references stop minting sourceless stubs; Rust `use` rooted at a `mod` declared in the same scope carries `_rust_use_name` (#4564); prior (17): Python pytest-fixture markers (`_py_fixture`/`_python_fixture_param`, #4332) and module-level class-id collision salting (#2810); TS `this.field` typed from any method incl. static (#4473); Solidity callables carry `metadata.arity` + inherited-call/`super`/modifier raw calls (#4379); Go type-decl and Rust file-item case-distinct node ids (#4444); prior (16): Rust `use` edges carry the imported name as written (`_rust_use_name`, #4439); (15): Go generic receiver types normalized (`Box[T]` -> `Box`) so methods attach to the type node; prior (14): C# receiver resolution for nameless/`new X()`/`foreach` receivers (defer + receiver-chain markers) and `_`/case-distinct node ids (underscore-salted); prior (13): Kotlin/Scala/C++/Swift generic & template type params no longer mint sourceless stubs; Objective-C NS_ENUM/NS_OPTIONS extraction and `_callable`/`_callable_class` markers; Go and PHP receiver-typed member calls park cross-repo (`go_type_table`/`php_type_table`, receiver fields); prior (12): Java inherited-supertype (`receiver_unbound`) and chained/new/cast receiver typing (`java_receiver_chain`, `_java_ret`); C/C++ quoted cross-directory include provenance (`include_kind`); JS external imports anchored to the package, not the path leaf; prior (11): Python property-accessor decorators / `Self`, Swift `Self`, Go generic type params, Python forward type-hint file node, PowerShell dot-source, C# verbatim-interpolated string recovery; (10): C# partial types carry `type_path`; (9): Python property-read raw calls and `_py_property` nodes; (8): Rust `use`-group per-binding edges; (7): Python opaque-base/super(args) markers + nested-class enclosing ids. # Per-process memo: distributions() scans site-packages metadata, which is diff --git a/graphify/extractors/engine.py b/graphify/extractors/engine.py index a202550daa..1bbf76de3a 100644 --- a/graphify/extractors/engine.py +++ b/graphify/extractors/engine.py @@ -1687,6 +1687,79 @@ def _php_member_nid(class_nid: str, member_node, name: str, source: bytes, _JAVA_MEMBER_CALLABLE_TYPES = ("method_declaration", "constructor_declaration") +_JAVA_LOMBOK_IMPORT_RE = re.compile( + rb"^\s*import\s+lombok\s*\.\s*(?:Getter|\*)\s*;", re.MULTILINE +) + + +def _java_lombok_getter_annotation(declaration_node, source: bytes): + """The ``@Getter`` annotation on a declaration when it is Lombok's. + + ``@lombok.Getter`` always is; a bare ``@Getter`` only when the file + imports ``lombok.Getter`` or ``lombok.*``. ``@Getter(AccessLevel.NONE)`` + asks for no getter, so it returns None. + """ + for anno in _java_annotation_nodes(declaration_node): + name_node = anno.child_by_field_name("name") + raw = _read_text(name_node, source) if name_node is not None else "" + if raw == "Getter" and not _JAVA_LOMBOK_IMPORT_RE.search(source): + continue + if raw not in ("Getter", "lombok.Getter"): + continue + args = anno.child_by_field_name("arguments") + if args is not None and re.search(r"\bNONE\b", _read_text(args, source)): + return None + return anno + return None + + +def _java_lombok_getters(field_node, source: bytes) -> list[str]: + """Names of the getters Lombok ``@Getter`` writes for a field (#5148). + + A field annotation covers static and instance fields; a class annotation + covers instance fields only. The name is ``get`` + the capitalised field + name, or ``is`` for a primitive ``boolean`` (a ``boolean isX`` keeps its + own name). Lombok skips a getter when the class already declares a + zero-argument method of that name, ignoring case. + """ + body = field_node.parent + owner = body.parent if body is not None else None + if owner is None: + return [] + own = _java_lombok_getter_annotation(field_node, source) + if own is None: + if any( + a.child_by_field_name("name") is not None + and _read_text(a.child_by_field_name("name"), source) in ("Getter", "lombok.Getter") + for a in _java_annotation_nodes(field_node) + ): + return [] # @Getter(AccessLevel.NONE) on the field wins over the class + if (_java_has_modifier(field_node, "static") + or _java_lombok_getter_annotation(owner, source) is None): + return [] + type_node = field_node.child_by_field_name("type") + is_boolean = type_node is not None and _read_text(type_node, source) == "boolean" + declared = set() + for c in body.children: + if c.type != "method_declaration": + continue + params = c.child_by_field_name("parameters") + name_node = c.child_by_field_name("name") + if name_node is not None and params is not None and not any( + p.type in ("formal_parameter", "spread_parameter") for p in params.children + ): + declared.add(_read_text(name_node, source).lower()) + names = [] + for field in _java_declarator_names(field_node, source): + if is_boolean and field.startswith("is") and field[2:3].isupper(): + getter = field + else: + getter = ("is" if is_boolean else "get") + field[:1].upper() + field[1:] + if getter.lower() not in declared: + names.append(getter) + return names + + def _java_member_nid(class_nid: str, member_node, name: str, source: bytes, groups_cache: dict) -> str: """Node id for a Java method or constructor, salted when a sibling collides. @@ -9179,6 +9252,18 @@ def scala_base_name(type_node) -> str | None: static_fields = java_static_field_types.setdefault(parent_class_nid, {}) for field_name in field_names: static_fields[field_name] = receiver_type + # Lombok @Getter (#5148): the getter is real at compile time, + # so it gets the node a hand-written one would, and its return + # type types a chain such as `Model.getInstance().work()`. + for getter in _java_lombok_getters(node, source): + getter_nid = _make_id(parent_class_nid, getter) + if any(n["id"] == getter_nid for n in nodes): + continue + getter_line = node.start_point[0] + 1 + add_node(getter_nid, f".{getter}()", getter_line, + metadata={"arity": 0, "signature": "", "lombok": "Getter"}) + add_edge(parent_class_nid, getter_nid, "method", getter_line) + java_return_types[getter_nid] = receiver_type line = node.start_point[0] + 1 refs: list[tuple[str, str]] = [] _java_collect_type_refs(type_node, source, False, refs) diff --git a/tests/test_java_lombok_getter.py b/tests/test_java_lombok_getter.py new file mode 100644 index 0000000000..a0ff2a10e9 --- /dev/null +++ b/tests/test_java_lombok_getter.py @@ -0,0 +1,90 @@ +"""Lombok ``@Getter`` getters are callable members (#5148). + +Lombok writes ``getX()``/``isX()`` at compile time, so the source has no +declaration for them. A chain such as ``Model.getInstance().work()`` was typed +step by step from declared return types and stopped at the missing getter. +""" +from __future__ import annotations + +from pathlib import Path + +import pytest + +from graphify.extract import extract + + +def _graph(tmp_path: Path, files: dict[str, str]): + paths = [] + for name, body in files.items(): + p = tmp_path / name + p.parent.mkdir(parents=True, exist_ok=True) + p.write_text(body, encoding="utf-8") + paths.append(p) + r = extract(paths, cache_root=tmp_path / "graphify-out") + label = {n["id"]: n["label"] for n in r["nodes"]} + calls = { + (label.get(e["source"]), label.get(e["target"])) + for e in r["edges"] + if e["relation"] == "calls" + } + return r, calls + + +MODEL = ( + "import lombok.Getter;\n" + "public class Model {\n" + " @Getter\n" + " private static final Model Instance = new Model();\n" + " public void work() {}\n" + "}\n" +) +CALLER = "public class Caller { void run() { Model.getInstance().work(); } }\n" + + +def test_static_getter_chain_reaches_the_member(tmp_path: Path): + _, calls = _graph(tmp_path, {"src/Model.java": MODEL, "src/Caller.java": CALLER}) + assert {(".run()", ".work()"), (".run()", ".getInstance()")} <= calls + + +def test_generated_getter_looks_like_a_hand_written_one(tmp_path: Path): + r, _ = _graph(tmp_path, {"Model.java": MODEL}) + g = next(n for n in r["nodes"] if n["label"] == ".getInstance()") + assert g["_java_ret"] == "Model" + assert g["metadata"]["arity"] == 0 + assert g["metadata"]["lombok"] == "Getter" + assert any(e["relation"] == "method" and e["target"] == g["id"] for e in r["edges"]) + + +@pytest.mark.parametrize("decl, getters", [ + ("boolean active;", {".isActive()"}), + ("boolean isReady;", {".isReady()"}), + ("Boolean flag;", {".getFlag()"}), + ("String uRL;", {".getURL()"}), + ("int a, b;", {".getA()", ".getB()"}), +]) +def test_getter_name_follows_lombok(tmp_path: Path, decl: str, getters: set[str]): + src = f"import lombok.Getter;\nclass T {{ @Getter private {decl} }}\n" + r, _ = _graph(tmp_path, {"T.java": src}) + assert getters <= {n["label"] for n in r["nodes"]} + + +def test_class_level_getter_skips_static_fields(tmp_path: Path): + src = ( + "import lombok.Getter;\n@Getter\nclass W {\n" + " private static int sCount;\n private int count;\n}\n" + ) + r, _ = _graph(tmp_path, {"W.java": src}) + labels = {n["label"] for n in r["nodes"]} + assert ".getCount()" in labels + assert ".getSCount()" not in labels + + +@pytest.mark.parametrize("src", [ + "import lombok.*;\nclass T { @Getter(AccessLevel.NONE) private int x; }\n", + "@interface Getter {}\nclass T { @Getter private int x; }\n", + "import lombok.Getter;\nclass T { @Getter private int x; int getX() { return 1; } }\n", +], ids=["access-none", "not-lombok", "hand-written"]) +def test_no_extra_getter_node(tmp_path: Path, src: str): + r, _ = _graph(tmp_path, {"T.java": src}) + assert [n["label"] for n in r["nodes"]].count(".getX()") <= 1 + assert not any((n.get("metadata") or {}).get("lombok") for n in r["nodes"])