Expand description
Java enricher for Model: HTTP endpoints and GWT RPC calls.
Run it on a ModelBuilder after model-treesitter (and the SCIP link)
extracted the Java files: it re-reads the sources, finds the entities the
extraction made by the position of their name, and adds facts a query
cannot express. The only kind added is http.endpoint, shared with the
Python and TypeScript enrichers; no language name enters model-core.
§What it adds
| Fact | Where | Shape |
|---|---|---|
HTTP_ENDPOINT entity (http.endpoint, props http.verb, http.path) | child of the handler method, named VERB /path, relation http.endpoints from the method | ANY for any verb, ? for a path that is not a literal |
PROP_ENDPOINTS (http.endpoints) | handler method | list of "VERB /path", as TypeScript’s |
PROP_RPC_SERVICE (rpc.service) | RemoteService interface | true |
PROP_RPC_CALLS (rpc.calls) | method or constructor calling a service | list of "a.b.Service#method/arity" (call arity, callback included) |
RPC_RELATION (gwt-rpc, RelationKind::Other) | caller → implementing method | Provenance::Frontend, one site per call |
Endpoints: Spring @RequestMapping and @Get/Post/Put/Delete/PatchMapping
(verbs, path arrays, path =/value =), JAX-RS @Path with @GET…;
the class-level prefix comes from the type, else from the nearest
supertype that has one. A method without a mapping inherits the one of the
method it overrides (same name and arity) on a supertype, also one of the
build-generated sources (target/generated-sources, build/generated,
read for that purpose only, never given entities). Feign and
@HttpExchange clients serve nothing.
GWT RPC: a call is RPC-shaped when its receiver is an XAsync field,
local or parameter, X.Util.getInstance() or GWT.create(X.class), and
X is a project RemoteService (or an unresolved XAsync, resolved by
the name of the implementing classes’ supertypes). The relation goes to
the method of each implementing class (transitively), matched by name and
arity with the callback dropped, then kept.
§Moose / Famix
Famix has no class for these facts. The http.endpoint entities have no
FM3 class (the exporter skips them), the other facts are extension
properties of existing entities, kept by the JSON model and ignored by
model-moose’s export: an http.endpoints prop is not written, and the gwt-rpc relation is reported by the exporter as
gwt-rpc (no Famix association); the entities themselves export as
before (tests/moose.rs checks it).
§Scope
Files under src/test/ are not read. Entities are found by file and
name position, so the model must come from the same sources
(tree-sitter, with or without SCIP: lifted entities keep their ranges).
Structs§
- Java
Stats - What an enrichment found.
- Prepared
- The Java sources of a project, read and parsed, ready to enrich a model.
Parsing needs no builder: a caller can prepare while the model is being
built (extraction, SCIP linking), then
apply.
Constants§
- HTTP_
ENDPOINT - Fine kind of the entity made for each endpoint: shared with the Python and TypeScript enrichers.
- PROP_
ENDPOINTS - Property of a handler method: its endpoints,
"GET /articles/{slug}". - PROP_
RPC_ CALLS - Property of a caller: the RPC calls it makes,
"a.b.Service#method/arity". - PROP_
RPC_ SERVICE - Property of a
RemoteServiceinterface:true. - RPC_
RELATION - Name of the relation (
RelationKind::Other) from a GWT RPC caller to the implementing method.
Functions§
- declare_
kinds - Defines the kinds this enricher adds (normally defined when first met),
see
model_treesitter::declare_kinds. - enrich
- Enriches
bfrom the Java files underroot(the root the model was extracted from). Reads the same filesmodel-treesitterdoes, minussrc/test/, plus the build-generated sources for endpoint inheritance. - enrich_
files enrichoverfiles, the source files underrootasmodel_treesitter::source_fileslists them (paths relative toroot; those that are not Java are skipped): a caller that has the list saves walking the tree again.- enrich_
sources enrichover in-memory sources(relative path, text).generatedare build-generated sources, read for endpoint inheritance only. Files that are not Java or undersrc/test/are skipped.- generated_
files .javafiles undertarget/generated-sources/**andbuild/generated/**, as sorted/-separated paths relative toroot.- prepare_
files - Reads and parses what
enrich_filesdoes, without a builder. - prepare_
sources - Parses what
enrich_sourcesdoes, without a builder. - rpc_
relation - The GWT RPC relation kind.