module Noir::TreeSitterJaxRsExtractor

Overview

Tree-sitter-backed JAX-RS / Jakarta REST extractor.

Walks @Path resource classes and emits one Endpoint-shaped Route per HTTP-method-annotated method. Recognises:

Out of scope for this first cut: meta-annotations, @MatrixParam, @Context (always skipped — framework injection, not user input).

Extended Modules

Defined in:

miniparsers/jaxrs_extractor_ts.cr

Constant Summary

HTTP_VERB_ANNOTATIONS = {"GET" => "GET", "POST" => "POST", "PUT" => "PUT", "DELETE" => "DELETE", "PATCH" => "PATCH", "HEAD" => "HEAD", "OPTIONS" => "OPTIONS"}

JAX-RS HTTP-method annotations. Simple names are matched; the walker normalises any package-qualified prefix to the trailing segment.

PARAM_ANNOTATION_FORMAT = {"QueryParam" => "query", "HeaderParam" => "header", "CookieParam" => "cookie", "FormParam" => "form", "RestQuery" => "query", "RestHeader" => "header", "RestCookie" => "cookie", "RestForm" => "form"}

Both standard JAX-RS names and Quarkus's @Rest* aliases map to the same param formats. Listing both here keeps the Quarkus analyzer a thin detector layer on top of this extractor.

PATH_PARAM_ANNOTATIONS = Set {"PathParam", "RestPath"}

@PathParam skip-list — Quarkus's @RestPath is a drop-in alias for the same role. Both are URL-carried and never emitted as request parameters.

PRIMITIVE_TYPES = Set {"boolean", "byte", "char", "short", "int", "long", "float", "double", "void", "string", "object", "integer", "character"}

Java primitive type names (lowercased). Anything else with no parameter annotation gets treated as a request-body DTO.

Instance Method Summary

Instance Method Detail

def extract_application_path(source : String) : String | Nil #

[View source]
def extract_application_path_from(root : LibTreeSitter::TSNode, source : String) : String | Nil #

[View source]
def extract_bean_fields(source : String) : Hash(String, Array(Param)) #

Read JAX-RS-annotated fields (@QueryParam, @HeaderParam, ...) from every class in the file as {class_name => Params}. Used to power @BeanParam expansion across files.


[View source]
def extract_class_names(source : String) : Array(String) #

[View source]
def extract_routes(source : String, dto_index : Hash(String, Array(TreeSitterJavaParameterExtractor::FieldInfo)) = {} of String => Array(TreeSitterJavaParameterExtractor::FieldInfo), bean_index : Hash(String, Array(Param)) = {} of String => Array(Param), subresource_sources : Hash(String, SourceEntry) = {} of String => SourceEntry, *, include_callees : Bool = false) : Array(Route) #

Public entry point — walks source and returns one Route per JAX-RS endpoint defined in path's file. dto_index maps class_name → fields for cross-file body / @BeanParam expansion (typically built via TreeSitterJavaDtoIndex).


[View source]
def extract_routes_from(root : LibTreeSitter::TSNode, source : String, dto_index : Hash(String, Array(TreeSitterJavaParameterExtractor::FieldInfo)) = {} of String => Array(TreeSitterJavaParameterExtractor::FieldInfo), bean_index : Hash(String, Array(Param)) = {} of String => Array(Param), subresource_sources : Hash(String, SourceEntry) = {} of String => SourceEntry, *, include_callees : Bool = false) : Array(Route) #

Same as #extract_routes, but reuses a Java tree-sitter root the caller already parsed. Analyzer adapters use this when they also need to attach method-body callees without reparsing the file.


[View source]