Repository navigation
feat(avi-1765): make PHP, Kotlin, Perl, C# and Java produce real graphs - #256
Conversation
Apply the avi-1765 openspec change. The four grammars were already registered
(AVI-1716), but checking each task against the spec deltas and against a run
over a mixed-language fixture corpus showed the languages did not yet produce
usable graphs.
Extraction
- Register .pl/.pm/.psgi in fecCode. They were registered as tree-sitter
extensions but absent from the file-category defaults, so Perl files were
never detected and the grammar was unreachable.
- Whitelist PHP's import forms (namespace_use_declaration and the
include/require expressions, which nest inside an expression_statement) and
C#'s compilation_unit file root, so .cs files get a module node and their
using edges get a source.
- Correct three dead Perl node names against the vendored ABI 11 parser.c:
`use Foo;` is use_no_statement, a named `sub f { }` is function_definition,
and a quoted `require 'x.pl'` does not parse at all. Verified names are
recorded in vendor/README.md.
Import edges
- Read unquoted specifiers (Convert.bareSpecifier), including the C# alias
directive `using A = B.C;`. Without it PHP/Perl/C#/Kotlin Import nodes
carried an empty label and no imports edge, which the import-resolution
delta forbids.
- Java: consult each ancestor's src/main/java and src/test/java, so a class
under src/test/java can resolve an import of one under src/main/java;
resolve `import static a.b.C.m` to the enclosing type; never target the
importing file.
- Kotlin: resolve imports against src/main/kotlin and src/test/kotlin first,
then the Java roots for interop, then fall back to an external node.
Node identity
- Perl `package`, PHP/C# `namespace` and C#/Java field declarations resolved
to no identifier, so each got the node id "" and every such node in a
corpus collided on it, leaving one survivor for the whole graph.
Verification
- graphos-test: 1663 examples, 1 failure, 4 pending (84 s). The failure is
pre-existing and belongs to the unapplied
avi-1440-ts-declaration-only-type-nodes change. The run skips
BoundedDeltaCommunitySpec's "small random graphs" property, which does not
terminate on main either (verified at 362c1fc with these changes stashed).
- A graphos run over a PHP/Perl/C#/Kotlin/Java fixture corpus: every language
produces symbols, 14 imports edges, 0 empty-id nodes.
|
Independent confirmation of pre-existing issue 2 in the description: the So This PR's own Worth a separate issue; this PR does not touch community-detection code. |
Applies the
avi-1765-add-tree-sitter-grammars-php-kotlin-perl-csharp-java-importsopenspec change.The four grammars were already registered (AVI-1716). Checking each task against the spec deltas, and running
graphosover a mixed-language fixture corpus, showed the languages still did not produce usable graphs.What was broken
.pl/.pm/.psgiabsent fromfecCodeapiSurfaceTypesuse Foo\Bar;andinclude/requireemitted nothingcompilation_unitunregistered.csfiles had no module node, so theirusingedges had no sourceextractSpecifieronly read quoted literalsImportnodes had an empty label and noimportsedge — forbidden by theimport-resolutiondeltause Foo;isuse_no_statement,sub f {}isfunction_definition, quotedrequire 'x.pl'does not parse at ABI 11src/test/javaclass could never resolve an import of asrc/main/javaclassImportnodes — same spec violationpackage, PHP/C#namespace, C#/Java fields all got node id""and collided into one node per graphWhat changed
fecCode; PHP import forms and C#'scompilation_unitwhitelisted; Perl node names corrected against the vendoredparser.cand documented invendor/README.md.Convert.bareSpecifierreads unquoted specifiers, including the C# alias directiveusing A = B.C;. Java consults each ancestor'ssrc/main/javaandsrc/test/java, resolvesimport static a.b.C.mto the enclosing type, and never targets the importing file. Kotlin (LangKotlin) resolves againstsrc/main/kotlin, then the Java roots for interop, then an external node.Core.extractIdentifierlearnspackage_name/namespace_name, plus two fallbacks keyed on the declaration type so aqualified_nameor a nestedidentifieris never mistaken for a name where it is really a reference.Verification
graphos-test: 1663 examples, 1 failure, 4 pending (84 s).graphosover a PHP/Perl/C#/Kotlin/Java fixture corpus: every language produces symbols, 14importsedges, 0 empty-id nodes. Asrc/test/javaclass resolves to both itssrc/main/javaimports; a Kotlin file resolves to a.ktsibling and to a.javaclass via interop.Two pre-existing issues, both unrelated to this change
type_identifiercase. It belongs to the separate, unappliedavi-1440-ts-declaration-only-type-nodeschange: that change's regression test is committed but its task 1.1 (removetype_identifierfromapiSurfaceTypes) is not done. Left alone deliberately.cabal test graphos-testdoes not terminate onmain.BoundedDeltaCommunitySpec.hs:224, "delta update equals full rebuild on small random graphs (property)", spins indefinitely. Verified at362c1fcwith this branch's changes stashed — identical hang — so CI'scabal test allis blocked independently of this work. The figures above come from a run with--skip "small random graphs". This likely needs its own issue.