Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions gitnexus/src/core/group/extractors/http-patterns/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const METHOD_ANNOTATION_TO_HTTP: Record<string, string> = {
};

// ─── Provider: Spring class-level @RequestMapping prefix ──────────────
// Two patterns are needed because the AST shape differs depending on
// whether the annotation uses a positional argument or a named one:
// @RequestMapping("/api") → (annotation_argument_list (string_literal))
// @RequestMapping(path = "/api") → (annotation_argument_list (element_value_pair value: (string_literal)))
// @RequestMapping(value = "/api") → same as above
const SPRING_CLASS_PREFIX_PATTERNS = compilePatterns({
name: 'java-spring-class-prefix',
language: Java,
Expand All @@ -44,10 +49,23 @@ const SPRING_CLASS_PREFIX_PATTERNS = compilePatterns({
arguments: (annotation_argument_list (string_literal) @prefix)))) @class
`,
},
{
meta: {},
query: `
(class_declaration
(modifiers
(annotation
name: (identifier) @ann (#eq? @ann "RequestMapping")
arguments: (annotation_argument_list
(element_value_pair
value: (string_literal) @prefix))))) @class
`,
},
],
} satisfies LanguagePatterns<Record<string, never>>);

// ─── Provider: Spring @(Get|Post|...)Mapping method annotations ───────
// Same dual-pattern approach: positional vs named argument.
const SPRING_METHOD_ROUTE_PATTERNS = compilePatterns({
name: 'java-spring-method-route',
language: Java,
Expand All @@ -63,6 +81,19 @@ const SPRING_METHOD_ROUTE_PATTERNS = compilePatterns({
name: (identifier) @method_name) @method
`,
},
{
meta: {},
query: `
(method_declaration
(modifiers
(annotation
name: (identifier) @ann (#match? @ann "^(Get|Post|Put|Delete|Patch)Mapping$")
arguments: (annotation_argument_list
(element_value_pair
value: (string_literal) @path))))
name: (identifier) @method_name) @method
`,
},
],
} satisfies LanguagePatterns<Record<string, never>>);

Expand Down