Begin adding typescript frontend for CLDK#158
Closed
rahlk wants to merge 6 commits into
Closed
Conversation
Signed-off-by: Rahul Krishna <rkrsn@ibm.com>
…analyzer-ts graph) Add TSNeo4jBackend, a drop-in alternative to the in-memory TSCodeanalyzer that answers the exact same get_* query surface (call graph, callers/callees, class hierarchy, call sites, decorators, symbol/method/field lookups, imports/exports/ variables, ...) by running Cypher over a live Neo4j graph instead of walking the pydantic / NetworkX structures. The graph is the one codeanalyzer-typescript emits with `--emit neo4j` (schema schema.neo4j.json). The backend can populate the database for you over Bolt (running the analyzer with --emit neo4j --neo4j-uri), or query a DB that is already loaded (build_db=False). Results are re-hydrated into the same cldk.models.typescript pydantic objects the in-memory backend returns; lossy fields inherent to the projection (collapsed comments/type-params, aggregated import edges, the three round-tripped CALLS tag keys) are reconstructed best-effort and documented inline. - cldk/analysis/typescript/neo4j/: backend, model reconstruction, Neo4jConnectionConfig. - TypeScriptAnalysis / CLDK.analysis: optional neo4j_config selects the backend; default behavior unchanged. - pyproject: optional `neo4j` extra for the driver. - tests: live-DB integration tests (skipped when no Neo4j reachable) mirroring the in-memory backend's sample-app expectations, plus no-DB backend-selection unit tests.
Extract TSAnalysisBackend (cldk/analysis/typescript/backend.py), an abstract base declaring the full 40-method query surface the TypeScriptAnalysis facade delegates to. Both backends now implement it: - TSCodeanalyzer (in-memory pydantic / NetworkX) - TSNeo4jBackend (Cypher over Neo4j) The facade<->backend relationship is now enforced by the type system and at instantiation time, instead of matching only by convention. Facade `backend` is typed against the ABC. Added a contract test asserting both backends subclass it, fully implement it, and preserve every method signature.
Mirror the TypeScript TSAnalysisBackend pattern for Java and Python, in
anticipation of Neo4j/Cypher backends for those languages too:
- cldk/analysis/java/backend.py: JavaAnalysisBackend (36-method surface);
JCodeanalyzer now subclasses it.
- cldk/analysis/python/backend.py: PythonAnalysisBackend (21-method surface);
PyCodeanalyzer now subclasses it.
Both facades type their `backend` attribute against the ABC, so a future
alternative backend can be selected without touching the facade. Added contract
tests for each (subclass, abstract/not-instantiable, fully-implemented, and that
the ABC covers every method the facade delegates to).
use_ray is already lifted all the way up (CLDK.analysis → PythonAnalysis → PyCodeanalyzer → AnalysisOptions.using_ray), but unlike use_codeql and cache_dir it had no regression test. Add test_use_ray_forwarded_through_facade mirroring the existing use_codeql guard, so the facade can't silently drop the flag.
f0188ad to
0a4f6da
Compare
Collaborator
Author
|
Closing in favor of #159, which tracks the same changes from the Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Rahul Krishna rkrsn@ibm.com