driftdetect-core 0.1.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boundaries/boundary-store.d.ts +92 -0
- package/dist/boundaries/boundary-store.d.ts.map +1 -0
- package/dist/boundaries/boundary-store.js +458 -0
- package/dist/boundaries/boundary-store.js.map +1 -0
- package/dist/boundaries/index.d.ts +8 -0
- package/dist/boundaries/index.d.ts.map +1 -0
- package/dist/boundaries/index.js +8 -0
- package/dist/boundaries/index.js.map +1 -0
- package/dist/boundaries/types.d.ts +237 -0
- package/dist/boundaries/types.d.ts.map +1 -0
- package/dist/boundaries/types.js +8 -0
- package/dist/boundaries/types.js.map +1 -0
- package/dist/dna/ai-context.d.ts +10 -0
- package/dist/dna/ai-context.d.ts.map +1 -0
- package/dist/dna/ai-context.js +46 -0
- package/dist/dna/ai-context.js.map +1 -0
- package/dist/dna/dna-analyzer.d.ts +34 -0
- package/dist/dna/dna-analyzer.d.ts.map +1 -0
- package/dist/dna/dna-analyzer.js +110 -0
- package/dist/dna/dna-analyzer.js.map +1 -0
- package/dist/dna/dna-store.d.ts +13 -0
- package/dist/dna/dna-store.d.ts.map +1 -0
- package/dist/dna/dna-store.js +43 -0
- package/dist/dna/dna-store.js.map +1 -0
- package/dist/dna/gene-extractors/animation-approach.d.ts +15 -0
- package/dist/dna/gene-extractors/animation-approach.d.ts.map +1 -0
- package/dist/dna/gene-extractors/animation-approach.js +97 -0
- package/dist/dna/gene-extractors/animation-approach.js.map +1 -0
- package/dist/dna/gene-extractors/base-extractor.d.ts +53 -0
- package/dist/dna/gene-extractors/base-extractor.d.ts.map +1 -0
- package/dist/dna/gene-extractors/base-extractor.js +76 -0
- package/dist/dna/gene-extractors/base-extractor.js.map +1 -0
- package/dist/dna/gene-extractors/index.d.ts +16 -0
- package/dist/dna/gene-extractors/index.d.ts.map +1 -0
- package/dist/dna/gene-extractors/index.js +38 -0
- package/dist/dna/gene-extractors/index.js.map +1 -0
- package/dist/dna/gene-extractors/responsive-approach.d.ts +10 -0
- package/dist/dna/gene-extractors/responsive-approach.d.ts.map +1 -0
- package/dist/dna/gene-extractors/responsive-approach.js +30 -0
- package/dist/dna/gene-extractors/responsive-approach.js.map +1 -0
- package/dist/dna/gene-extractors/spacing-philosophy.d.ts +10 -0
- package/dist/dna/gene-extractors/spacing-philosophy.d.ts.map +1 -0
- package/dist/dna/gene-extractors/spacing-philosophy.js +30 -0
- package/dist/dna/gene-extractors/spacing-philosophy.js.map +1 -0
- package/dist/dna/gene-extractors/state-styling.d.ts +10 -0
- package/dist/dna/gene-extractors/state-styling.d.ts.map +1 -0
- package/dist/dna/gene-extractors/state-styling.js +29 -0
- package/dist/dna/gene-extractors/state-styling.js.map +1 -0
- package/dist/dna/gene-extractors/theming.d.ts +10 -0
- package/dist/dna/gene-extractors/theming.d.ts.map +1 -0
- package/dist/dna/gene-extractors/theming.js +30 -0
- package/dist/dna/gene-extractors/theming.js.map +1 -0
- package/dist/dna/gene-extractors/variant-handling.d.ts +13 -0
- package/dist/dna/gene-extractors/variant-handling.d.ts.map +1 -0
- package/dist/dna/gene-extractors/variant-handling.js +38 -0
- package/dist/dna/gene-extractors/variant-handling.js.map +1 -0
- package/dist/dna/health-calculator.d.ts +21 -0
- package/dist/dna/health-calculator.d.ts.map +1 -0
- package/dist/dna/health-calculator.js +113 -0
- package/dist/dna/health-calculator.js.map +1 -0
- package/dist/dna/index.d.ts +21 -0
- package/dist/dna/index.d.ts.map +1 -0
- package/dist/dna/index.js +19 -0
- package/dist/dna/index.js.map +1 -0
- package/dist/dna/mutation-detector.d.ts +10 -0
- package/dist/dna/mutation-detector.d.ts.map +1 -0
- package/dist/dna/mutation-detector.js +39 -0
- package/dist/dna/mutation-detector.js.map +1 -0
- package/dist/dna/playbook-generator.d.ts +6 -0
- package/dist/dna/playbook-generator.d.ts.map +1 -0
- package/dist/dna/playbook-generator.js +53 -0
- package/dist/dna/playbook-generator.js.map +1 -0
- package/dist/dna/types.d.ts +95 -0
- package/dist/dna/types.d.ts.map +1 -0
- package/dist/dna/types.js +8 -0
- package/dist/dna/types.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/parsers/parser-manager.d.ts.map +1 -1
- package/dist/parsers/parser-manager.js +2 -0
- package/dist/parsers/parser-manager.js.map +1 -1
- package/dist/parsers/tree-sitter/config.d.ts +82 -0
- package/dist/parsers/tree-sitter/config.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/config.js +200 -0
- package/dist/parsers/tree-sitter/config.js.map +1 -0
- package/dist/parsers/tree-sitter/csharp-ast-converter.d.ts +64 -0
- package/dist/parsers/tree-sitter/csharp-ast-converter.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/csharp-ast-converter.js +271 -0
- package/dist/parsers/tree-sitter/csharp-ast-converter.js.map +1 -0
- package/dist/parsers/tree-sitter/csharp-loader.d.ts +43 -0
- package/dist/parsers/tree-sitter/csharp-loader.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/csharp-loader.js +146 -0
- package/dist/parsers/tree-sitter/csharp-loader.js.map +1 -0
- package/dist/parsers/tree-sitter/index.d.ts +26 -0
- package/dist/parsers/tree-sitter/index.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/index.js +47 -0
- package/dist/parsers/tree-sitter/index.js.map +1 -0
- package/dist/parsers/tree-sitter/java/annotation-extractor.d.ts +79 -0
- package/dist/parsers/tree-sitter/java/annotation-extractor.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/java/annotation-extractor.js +540 -0
- package/dist/parsers/tree-sitter/java/annotation-extractor.js.map +1 -0
- package/dist/parsers/tree-sitter/java/class-extractor.d.ts +40 -0
- package/dist/parsers/tree-sitter/java/class-extractor.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/java/class-extractor.js +770 -0
- package/dist/parsers/tree-sitter/java/class-extractor.js.map +1 -0
- package/dist/parsers/tree-sitter/java/index.d.ts +14 -0
- package/dist/parsers/tree-sitter/java/index.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/java/index.js +25 -0
- package/dist/parsers/tree-sitter/java/index.js.map +1 -0
- package/dist/parsers/tree-sitter/java/method-extractor.d.ts +88 -0
- package/dist/parsers/tree-sitter/java/method-extractor.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/java/method-extractor.js +551 -0
- package/dist/parsers/tree-sitter/java/method-extractor.js.map +1 -0
- package/dist/parsers/tree-sitter/java/types.d.ts +545 -0
- package/dist/parsers/tree-sitter/java/types.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/java/types.js +81 -0
- package/dist/parsers/tree-sitter/java/types.js.map +1 -0
- package/dist/parsers/tree-sitter/loader.d.ts +50 -0
- package/dist/parsers/tree-sitter/loader.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/loader.js +156 -0
- package/dist/parsers/tree-sitter/loader.js.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/config-extractor.d.ts +78 -0
- package/dist/parsers/tree-sitter/pydantic/config-extractor.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/config-extractor.js +278 -0
- package/dist/parsers/tree-sitter/pydantic/config-extractor.js.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/constraint-parser.d.ts +84 -0
- package/dist/parsers/tree-sitter/pydantic/constraint-parser.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/constraint-parser.js +321 -0
- package/dist/parsers/tree-sitter/pydantic/constraint-parser.js.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/field-extractor.d.ts +74 -0
- package/dist/parsers/tree-sitter/pydantic/field-extractor.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/field-extractor.js +285 -0
- package/dist/parsers/tree-sitter/pydantic/field-extractor.js.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/index.d.ts +18 -0
- package/dist/parsers/tree-sitter/pydantic/index.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/index.js +23 -0
- package/dist/parsers/tree-sitter/pydantic/index.js.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/inheritance-resolver.d.ts +70 -0
- package/dist/parsers/tree-sitter/pydantic/inheritance-resolver.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/inheritance-resolver.js +251 -0
- package/dist/parsers/tree-sitter/pydantic/inheritance-resolver.js.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/pydantic-extractor.d.ts +102 -0
- package/dist/parsers/tree-sitter/pydantic/pydantic-extractor.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/pydantic-extractor.js +399 -0
- package/dist/parsers/tree-sitter/pydantic/pydantic-extractor.js.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/type-resolver.d.ts +89 -0
- package/dist/parsers/tree-sitter/pydantic/type-resolver.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/type-resolver.js +426 -0
- package/dist/parsers/tree-sitter/pydantic/type-resolver.js.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/types.d.ts +177 -0
- package/dist/parsers/tree-sitter/pydantic/types.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/types.js +139 -0
- package/dist/parsers/tree-sitter/pydantic/types.js.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/validator-extractor.d.ts +88 -0
- package/dist/parsers/tree-sitter/pydantic/validator-extractor.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/pydantic/validator-extractor.js +315 -0
- package/dist/parsers/tree-sitter/pydantic/validator-extractor.js.map +1 -0
- package/dist/parsers/tree-sitter/python-ast-converter.d.ts +140 -0
- package/dist/parsers/tree-sitter/python-ast-converter.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/python-ast-converter.js +360 -0
- package/dist/parsers/tree-sitter/python-ast-converter.js.map +1 -0
- package/dist/parsers/tree-sitter/tree-sitter-csharp-parser.d.ts +465 -0
- package/dist/parsers/tree-sitter/tree-sitter-csharp-parser.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/tree-sitter-csharp-parser.js +1146 -0
- package/dist/parsers/tree-sitter/tree-sitter-csharp-parser.js.map +1 -0
- package/dist/parsers/tree-sitter/tree-sitter-python-parser.d.ts +86 -0
- package/dist/parsers/tree-sitter/tree-sitter-python-parser.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/tree-sitter-python-parser.js +177 -0
- package/dist/parsers/tree-sitter/tree-sitter-python-parser.js.map +1 -0
- package/dist/parsers/tree-sitter/types.d.ts +399 -0
- package/dist/parsers/tree-sitter/types.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/types.js +20 -0
- package/dist/parsers/tree-sitter/types.js.map +1 -0
- package/dist/parsers/types.d.ts +1 -1
- package/dist/parsers/types.d.ts.map +1 -1
- package/dist/scanner/file-walker.d.ts.map +1 -1
- package/dist/scanner/file-walker.js +5 -0
- package/dist/scanner/file-walker.js.map +1 -1
- package/dist/store/history-store.d.ts +85 -269
- package/dist/store/history-store.d.ts.map +1 -1
- package/dist/store/history-store.js +272 -624
- package/dist/store/history-store.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/java-type-mapping.d.ts +79 -0
- package/dist/types/java-type-mapping.d.ts.map +1 -0
- package/dist/types/java-type-mapping.js +290 -0
- package/dist/types/java-type-mapping.js.map +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java Annotation Extractor
|
|
3
|
+
*
|
|
4
|
+
* Extracts annotation information from Java AST nodes.
|
|
5
|
+
* Annotations are FIRST-CLASS CITIZENS in Spring - they drive
|
|
6
|
+
* DI, security, web, data, and virtually everything else.
|
|
7
|
+
*
|
|
8
|
+
* Handles:
|
|
9
|
+
* - Marker annotations: @Service
|
|
10
|
+
* - Single-value annotations: @RequestMapping("/api")
|
|
11
|
+
* - Named argument annotations: @Transactional(readOnly = true)
|
|
12
|
+
* - Array value annotations: @Secured({"ADMIN", "USER"})
|
|
13
|
+
* - Nested annotations: @Caching(@Cacheable(...), @CacheEvict(...))
|
|
14
|
+
*
|
|
15
|
+
* @requirements Java/Spring Boot Language Support
|
|
16
|
+
*/
|
|
17
|
+
import { DEFAULT_ANNOTATION_OPTIONS, COMMON_SPRING_ANNOTATIONS } from './types.js';
|
|
18
|
+
// ============================================
|
|
19
|
+
// Position Helpers
|
|
20
|
+
// ============================================
|
|
21
|
+
/**
|
|
22
|
+
* Convert tree-sitter position to drift Position.
|
|
23
|
+
*/
|
|
24
|
+
function toPosition(point) {
|
|
25
|
+
return {
|
|
26
|
+
row: point.row,
|
|
27
|
+
column: point.column,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// ============================================
|
|
31
|
+
// Annotation Extraction
|
|
32
|
+
// ============================================
|
|
33
|
+
/**
|
|
34
|
+
* Extract all annotations from a node and its preceding siblings.
|
|
35
|
+
*
|
|
36
|
+
* In Java, annotations appear before the element they annotate,
|
|
37
|
+
* either as siblings or as children of the parent node.
|
|
38
|
+
*
|
|
39
|
+
* @param node - The AST node to extract annotations from
|
|
40
|
+
* @param target - What type of element these annotations are on
|
|
41
|
+
* @param imports - Import statements for resolving full names
|
|
42
|
+
* @param options - Extraction options
|
|
43
|
+
* @returns Array of extracted annotations
|
|
44
|
+
*/
|
|
45
|
+
export function extractAnnotations(node, target, imports = [], options = DEFAULT_ANNOTATION_OPTIONS) {
|
|
46
|
+
const annotations = [];
|
|
47
|
+
// Look for annotations in different places depending on node type
|
|
48
|
+
// 1. Direct children named 'modifiers' that contain annotations
|
|
49
|
+
// 2. Sibling nodes that are annotations
|
|
50
|
+
// 3. Children that are annotation nodes
|
|
51
|
+
// Check for modifiers node (common pattern in tree-sitter-java)
|
|
52
|
+
const modifiersNode = findChildByType(node, 'modifiers');
|
|
53
|
+
if (modifiersNode) {
|
|
54
|
+
for (const child of modifiersNode.children) {
|
|
55
|
+
if (isAnnotationNode(child)) {
|
|
56
|
+
const annotation = parseAnnotationNode(child, target, imports, options);
|
|
57
|
+
if (annotation) {
|
|
58
|
+
annotations.push(annotation);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Check direct children for annotations
|
|
64
|
+
for (const child of node.children) {
|
|
65
|
+
if (isAnnotationNode(child)) {
|
|
66
|
+
const annotation = parseAnnotationNode(child, target, imports, options);
|
|
67
|
+
if (annotation) {
|
|
68
|
+
annotations.push(annotation);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Check preceding siblings for annotations
|
|
73
|
+
let sibling = node.previousNamedSibling;
|
|
74
|
+
while (sibling && isAnnotationNode(sibling)) {
|
|
75
|
+
const annotation = parseAnnotationNode(sibling, target, imports, options);
|
|
76
|
+
if (annotation) {
|
|
77
|
+
// Prepend since we're going backwards
|
|
78
|
+
annotations.unshift(annotation);
|
|
79
|
+
}
|
|
80
|
+
sibling = sibling.previousNamedSibling;
|
|
81
|
+
}
|
|
82
|
+
return annotations;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Extract annotations specifically for a parameter node.
|
|
86
|
+
* Parameters have a different structure in the AST.
|
|
87
|
+
*/
|
|
88
|
+
export function extractParameterAnnotations(paramNode, imports = [], options = DEFAULT_ANNOTATION_OPTIONS) {
|
|
89
|
+
const annotations = [];
|
|
90
|
+
// In tree-sitter-java, parameter annotations are direct children
|
|
91
|
+
for (const child of paramNode.children) {
|
|
92
|
+
if (isAnnotationNode(child)) {
|
|
93
|
+
const annotation = parseAnnotationNode(child, 'parameter', imports, options);
|
|
94
|
+
if (annotation) {
|
|
95
|
+
annotations.push(annotation);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return annotations;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Check if a node is an annotation node.
|
|
103
|
+
*/
|
|
104
|
+
function isAnnotationNode(node) {
|
|
105
|
+
return (node.type === 'annotation' ||
|
|
106
|
+
node.type === 'marker_annotation' ||
|
|
107
|
+
node.type === 'single_element_annotation' ||
|
|
108
|
+
node.type === 'normal_annotation');
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Parse a single annotation node into AnnotationUsage.
|
|
112
|
+
*/
|
|
113
|
+
function parseAnnotationNode(node, target, imports, options) {
|
|
114
|
+
// Get annotation name
|
|
115
|
+
const nameNode = findAnnotationName(node);
|
|
116
|
+
if (!nameNode) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const name = extractAnnotationName(nameNode);
|
|
120
|
+
if (!name) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
// Parse arguments
|
|
124
|
+
const args = parseAnnotationArguments(node, options);
|
|
125
|
+
// Resolve full name
|
|
126
|
+
const fullName = options.resolveFullNames
|
|
127
|
+
? resolveAnnotationFullName(name, imports)
|
|
128
|
+
: null;
|
|
129
|
+
return {
|
|
130
|
+
name,
|
|
131
|
+
fullName,
|
|
132
|
+
arguments: args,
|
|
133
|
+
target,
|
|
134
|
+
startPosition: toPosition(node.startPosition),
|
|
135
|
+
endPosition: toPosition(node.endPosition),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Find the name node within an annotation.
|
|
140
|
+
*/
|
|
141
|
+
function findAnnotationName(node) {
|
|
142
|
+
// The name can be an identifier or a scoped_identifier (qualified name)
|
|
143
|
+
for (const child of node.children) {
|
|
144
|
+
if (child.type === 'identifier' || child.type === 'scoped_identifier') {
|
|
145
|
+
return child;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// Also check childForFieldName if available
|
|
149
|
+
const nameField = node.childForFieldName?.('name');
|
|
150
|
+
if (nameField) {
|
|
151
|
+
return nameField;
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Extract the annotation name from a name node.
|
|
157
|
+
* Handles both simple names and qualified names.
|
|
158
|
+
*/
|
|
159
|
+
function extractAnnotationName(nameNode) {
|
|
160
|
+
if (nameNode.type === 'identifier') {
|
|
161
|
+
return nameNode.text;
|
|
162
|
+
}
|
|
163
|
+
if (nameNode.type === 'scoped_identifier') {
|
|
164
|
+
// For qualified names like org.springframework.Service,
|
|
165
|
+
// we want just the simple name (Service)
|
|
166
|
+
const parts = nameNode.text.split('.');
|
|
167
|
+
return parts[parts.length - 1] ?? nameNode.text;
|
|
168
|
+
}
|
|
169
|
+
return nameNode.text;
|
|
170
|
+
}
|
|
171
|
+
// ============================================
|
|
172
|
+
// Argument Parsing
|
|
173
|
+
// ============================================
|
|
174
|
+
/**
|
|
175
|
+
* Parse annotation arguments from an annotation node.
|
|
176
|
+
*/
|
|
177
|
+
function parseAnnotationArguments(node, options) {
|
|
178
|
+
const args = [];
|
|
179
|
+
// Find the argument list node
|
|
180
|
+
const argListNode = findChildByType(node, 'annotation_argument_list');
|
|
181
|
+
if (!argListNode) {
|
|
182
|
+
// Check for single element annotation value
|
|
183
|
+
// @GetMapping("/api") - the "/api" is a direct child
|
|
184
|
+
for (const child of node.children) {
|
|
185
|
+
if (isValueNode(child)) {
|
|
186
|
+
args.push(parseArgumentValue(null, child, options));
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return args;
|
|
191
|
+
}
|
|
192
|
+
// Parse each argument in the list
|
|
193
|
+
for (const child of argListNode.children) {
|
|
194
|
+
if (child.type === 'element_value_pair') {
|
|
195
|
+
// Named argument: name = value
|
|
196
|
+
const arg = parseElementValuePair(child, options);
|
|
197
|
+
if (arg) {
|
|
198
|
+
args.push(arg);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else if (isValueNode(child)) {
|
|
202
|
+
// Single value argument (no name)
|
|
203
|
+
args.push(parseArgumentValue(null, child, options));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return args;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Parse a named element-value pair.
|
|
210
|
+
* @example readOnly = true, value = "/api"
|
|
211
|
+
*/
|
|
212
|
+
function parseElementValuePair(node, options) {
|
|
213
|
+
let name = null;
|
|
214
|
+
let valueNode = null;
|
|
215
|
+
for (const child of node.children) {
|
|
216
|
+
if (child.type === 'identifier') {
|
|
217
|
+
name = child.text;
|
|
218
|
+
}
|
|
219
|
+
else if (isValueNode(child)) {
|
|
220
|
+
valueNode = child;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (!valueNode) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
return parseArgumentValue(name, valueNode, options);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Parse an argument value node into AnnotationArgument.
|
|
230
|
+
*/
|
|
231
|
+
function parseArgumentValue(name, valueNode, options) {
|
|
232
|
+
const { value, valueType, arrayElements } = extractValue(valueNode, options);
|
|
233
|
+
const arg = {
|
|
234
|
+
name,
|
|
235
|
+
value,
|
|
236
|
+
valueType,
|
|
237
|
+
};
|
|
238
|
+
if (arrayElements && arrayElements.length > 0) {
|
|
239
|
+
arg.arrayElements = arrayElements;
|
|
240
|
+
}
|
|
241
|
+
return arg;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Extract the value and type from a value node.
|
|
245
|
+
*/
|
|
246
|
+
function extractValue(node, options) {
|
|
247
|
+
const text = node.text;
|
|
248
|
+
switch (node.type) {
|
|
249
|
+
case 'string_literal':
|
|
250
|
+
case 'string':
|
|
251
|
+
// Remove quotes from string literals
|
|
252
|
+
return {
|
|
253
|
+
value: text.replace(/^["']|["']$/g, ''),
|
|
254
|
+
valueType: 'string',
|
|
255
|
+
};
|
|
256
|
+
case 'decimal_integer_literal':
|
|
257
|
+
case 'hex_integer_literal':
|
|
258
|
+
case 'octal_integer_literal':
|
|
259
|
+
case 'binary_integer_literal':
|
|
260
|
+
case 'decimal_floating_point_literal':
|
|
261
|
+
case 'hex_floating_point_literal':
|
|
262
|
+
case 'integer_literal':
|
|
263
|
+
case 'floating_point_literal':
|
|
264
|
+
case 'number':
|
|
265
|
+
return {
|
|
266
|
+
value: text,
|
|
267
|
+
valueType: 'number',
|
|
268
|
+
};
|
|
269
|
+
case 'true':
|
|
270
|
+
case 'false':
|
|
271
|
+
case 'boolean':
|
|
272
|
+
return {
|
|
273
|
+
value: text,
|
|
274
|
+
valueType: 'boolean',
|
|
275
|
+
};
|
|
276
|
+
case 'class_literal':
|
|
277
|
+
// SomeClass.class
|
|
278
|
+
return {
|
|
279
|
+
value: text.replace(/\.class$/, ''),
|
|
280
|
+
valueType: 'class',
|
|
281
|
+
};
|
|
282
|
+
case 'array_initializer':
|
|
283
|
+
case 'element_value_array_initializer':
|
|
284
|
+
// { "value1", "value2" }
|
|
285
|
+
const elements = options.parseArrayElements
|
|
286
|
+
? extractArrayElements(node)
|
|
287
|
+
: [];
|
|
288
|
+
return {
|
|
289
|
+
value: text,
|
|
290
|
+
valueType: 'array',
|
|
291
|
+
arrayElements: elements,
|
|
292
|
+
};
|
|
293
|
+
case 'annotation':
|
|
294
|
+
case 'marker_annotation':
|
|
295
|
+
case 'single_element_annotation':
|
|
296
|
+
case 'normal_annotation':
|
|
297
|
+
// Nested annotation
|
|
298
|
+
return {
|
|
299
|
+
value: text,
|
|
300
|
+
valueType: 'annotation',
|
|
301
|
+
};
|
|
302
|
+
case 'field_access':
|
|
303
|
+
case 'scoped_identifier':
|
|
304
|
+
// Enum value like RequestMethod.GET or Propagation.REQUIRED
|
|
305
|
+
return {
|
|
306
|
+
value: text,
|
|
307
|
+
valueType: 'enum',
|
|
308
|
+
};
|
|
309
|
+
case 'identifier':
|
|
310
|
+
// Could be an enum constant or a reference
|
|
311
|
+
// If it's all caps, likely an enum
|
|
312
|
+
if (text === text.toUpperCase() && text.length > 1) {
|
|
313
|
+
return {
|
|
314
|
+
value: text,
|
|
315
|
+
valueType: 'enum',
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
return {
|
|
319
|
+
value: text,
|
|
320
|
+
valueType: 'string',
|
|
321
|
+
};
|
|
322
|
+
default:
|
|
323
|
+
// Default to string for unknown types
|
|
324
|
+
return {
|
|
325
|
+
value: text,
|
|
326
|
+
valueType: 'string',
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Extract individual elements from an array initializer.
|
|
332
|
+
*/
|
|
333
|
+
function extractArrayElements(node) {
|
|
334
|
+
const elements = [];
|
|
335
|
+
for (const child of node.children) {
|
|
336
|
+
if (isValueNode(child)) {
|
|
337
|
+
const { value } = extractValue(child, { resolveFullNames: false, parseArrayElements: false });
|
|
338
|
+
elements.push(value);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return elements;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Check if a node is a value node (can be an annotation argument value).
|
|
345
|
+
*/
|
|
346
|
+
function isValueNode(node) {
|
|
347
|
+
const valueTypes = [
|
|
348
|
+
'string_literal',
|
|
349
|
+
'string',
|
|
350
|
+
'decimal_integer_literal',
|
|
351
|
+
'hex_integer_literal',
|
|
352
|
+
'octal_integer_literal',
|
|
353
|
+
'binary_integer_literal',
|
|
354
|
+
'decimal_floating_point_literal',
|
|
355
|
+
'hex_floating_point_literal',
|
|
356
|
+
'integer_literal',
|
|
357
|
+
'floating_point_literal',
|
|
358
|
+
'number',
|
|
359
|
+
'true',
|
|
360
|
+
'false',
|
|
361
|
+
'boolean',
|
|
362
|
+
'class_literal',
|
|
363
|
+
'array_initializer',
|
|
364
|
+
'element_value_array_initializer',
|
|
365
|
+
'annotation',
|
|
366
|
+
'marker_annotation',
|
|
367
|
+
'single_element_annotation',
|
|
368
|
+
'normal_annotation',
|
|
369
|
+
'field_access',
|
|
370
|
+
'scoped_identifier',
|
|
371
|
+
'identifier',
|
|
372
|
+
];
|
|
373
|
+
return valueTypes.includes(node.type);
|
|
374
|
+
}
|
|
375
|
+
// ============================================
|
|
376
|
+
// Name Resolution
|
|
377
|
+
// ============================================
|
|
378
|
+
/**
|
|
379
|
+
* Resolve the fully qualified name of an annotation.
|
|
380
|
+
*
|
|
381
|
+
* @param simpleName - The simple annotation name (e.g., "GetMapping")
|
|
382
|
+
* @param imports - Import statements from the file
|
|
383
|
+
* @returns The fully qualified name or null if not resolvable
|
|
384
|
+
*/
|
|
385
|
+
export function resolveAnnotationFullName(simpleName, imports) {
|
|
386
|
+
// First, check explicit imports
|
|
387
|
+
for (const imp of imports) {
|
|
388
|
+
if (imp.isWildcard) {
|
|
389
|
+
// Can't resolve from wildcard imports without more context
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
// Check if this import matches the annotation name
|
|
393
|
+
const importedName = imp.path.split('.').pop();
|
|
394
|
+
if (importedName === simpleName) {
|
|
395
|
+
return imp.path;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
// Check common Spring annotations
|
|
399
|
+
if (simpleName in COMMON_SPRING_ANNOTATIONS) {
|
|
400
|
+
return COMMON_SPRING_ANNOTATIONS[simpleName] ?? null;
|
|
401
|
+
}
|
|
402
|
+
// Check if any wildcard import could match
|
|
403
|
+
// We can't be certain, but we can make educated guesses
|
|
404
|
+
for (const imp of imports) {
|
|
405
|
+
if (imp.isWildcard) {
|
|
406
|
+
const packagePath = imp.path.replace('.*', '');
|
|
407
|
+
// Common Spring packages
|
|
408
|
+
if (packagePath.includes('springframework')) {
|
|
409
|
+
// Check if this is a known Spring annotation
|
|
410
|
+
// const possibleFullName = `${packagePath}.${simpleName}`;
|
|
411
|
+
// We could validate this against a known list
|
|
412
|
+
// For now, return null for wildcards
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Build an import map for faster lookups.
|
|
420
|
+
*/
|
|
421
|
+
export function buildImportMap(imports) {
|
|
422
|
+
const map = new Map();
|
|
423
|
+
for (const imp of imports) {
|
|
424
|
+
if (!imp.isWildcard) {
|
|
425
|
+
const simpleName = imp.path.split('.').pop();
|
|
426
|
+
if (simpleName) {
|
|
427
|
+
map.set(simpleName, imp.path);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return map;
|
|
432
|
+
}
|
|
433
|
+
// ============================================
|
|
434
|
+
// Utility Functions
|
|
435
|
+
// ============================================
|
|
436
|
+
/**
|
|
437
|
+
* Find a child node by type.
|
|
438
|
+
*/
|
|
439
|
+
function findChildByType(node, type) {
|
|
440
|
+
for (const child of node.children) {
|
|
441
|
+
if (child.type === type) {
|
|
442
|
+
return child;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Find all children of a specific type.
|
|
449
|
+
*/
|
|
450
|
+
export function findChildrenByType(node, type) {
|
|
451
|
+
const results = [];
|
|
452
|
+
for (const child of node.children) {
|
|
453
|
+
if (child.type === type) {
|
|
454
|
+
results.push(child);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return results;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Check if an annotation has a specific argument.
|
|
461
|
+
*/
|
|
462
|
+
export function hasAnnotationArgument(annotation, argumentName) {
|
|
463
|
+
return annotation.arguments.some(arg => arg.name === argumentName);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Get an annotation argument value by name.
|
|
467
|
+
*/
|
|
468
|
+
export function getAnnotationArgument(annotation, argumentName) {
|
|
469
|
+
return annotation.arguments.find(arg => arg.name === argumentName);
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Get the single/default value of an annotation.
|
|
473
|
+
* This is the value when no argument name is specified.
|
|
474
|
+
* @example @GetMapping("/api") -> "/api"
|
|
475
|
+
*/
|
|
476
|
+
export function getAnnotationValue(annotation) {
|
|
477
|
+
// Look for argument with null name (single value)
|
|
478
|
+
const singleValue = annotation.arguments.find(arg => arg.name === null);
|
|
479
|
+
if (singleValue) {
|
|
480
|
+
return singleValue.value;
|
|
481
|
+
}
|
|
482
|
+
// Also check for "value" named argument
|
|
483
|
+
const valueArg = annotation.arguments.find(arg => arg.name === 'value');
|
|
484
|
+
return valueArg?.value;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Check if an annotation is a Spring web mapping annotation.
|
|
488
|
+
*/
|
|
489
|
+
export function isWebMappingAnnotation(annotation) {
|
|
490
|
+
const webMappings = [
|
|
491
|
+
'RequestMapping',
|
|
492
|
+
'GetMapping',
|
|
493
|
+
'PostMapping',
|
|
494
|
+
'PutMapping',
|
|
495
|
+
'DeleteMapping',
|
|
496
|
+
'PatchMapping',
|
|
497
|
+
];
|
|
498
|
+
return webMappings.includes(annotation.name);
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Check if an annotation is a Spring stereotype annotation.
|
|
502
|
+
*/
|
|
503
|
+
export function isStereotypeAnnotation(annotation) {
|
|
504
|
+
const stereotypes = [
|
|
505
|
+
'Component',
|
|
506
|
+
'Service',
|
|
507
|
+
'Repository',
|
|
508
|
+
'Controller',
|
|
509
|
+
'RestController',
|
|
510
|
+
'Configuration',
|
|
511
|
+
];
|
|
512
|
+
return stereotypes.includes(annotation.name);
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Check if an annotation is a validation annotation.
|
|
516
|
+
*/
|
|
517
|
+
export function isValidationAnnotation(annotation) {
|
|
518
|
+
const validations = [
|
|
519
|
+
'Valid',
|
|
520
|
+
'Validated',
|
|
521
|
+
'NotNull',
|
|
522
|
+
'NotBlank',
|
|
523
|
+
'NotEmpty',
|
|
524
|
+
'Size',
|
|
525
|
+
'Min',
|
|
526
|
+
'Max',
|
|
527
|
+
'Email',
|
|
528
|
+
'Pattern',
|
|
529
|
+
'Positive',
|
|
530
|
+
'PositiveOrZero',
|
|
531
|
+
'Negative',
|
|
532
|
+
'NegativeOrZero',
|
|
533
|
+
'Past',
|
|
534
|
+
'PastOrPresent',
|
|
535
|
+
'Future',
|
|
536
|
+
'FutureOrPresent',
|
|
537
|
+
];
|
|
538
|
+
return validations.includes(annotation.name);
|
|
539
|
+
}
|
|
540
|
+
//# sourceMappingURL=annotation-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-extractor.js","sourceRoot":"","sources":["../../../../src/parsers/tree-sitter/java/annotation-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAYH,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEnF,+CAA+C;AAC/C,mBAAmB;AACnB,+CAA+C;AAE/C;;GAEG;AACH,SAAS,UAAU,CAAC,KAAsC;IACxD,OAAO;QACL,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC;AACJ,CAAC;AAED,+CAA+C;AAC/C,wBAAwB;AACxB,+CAA+C;AAE/C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAoB,EACpB,MAAwB,EACxB,UAA4B,EAAE,EAC9B,UAAuC,0BAA0B;IAEjE,MAAM,WAAW,GAAsB,EAAE,CAAC;IAE1C,kEAAkE;IAClE,gEAAgE;IAChE,wCAAwC;IACxC,wCAAwC;IAExC,gEAAgE;IAChE,MAAM,aAAa,GAAG,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACzD,IAAI,aAAa,EAAE,CAAC;QAClB,KAAK,MAAM,KAAK,IAAI,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3C,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,MAAM,UAAU,GAAG,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;gBACxE,IAAI,UAAU,EAAE,CAAC;oBAC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AC,CAAC;IACxE,OAAO,QAAQ,EAAE,KAAK,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAA2B;IAChE,MAAM,WAAW,GAAG;QAClB,gBAAgB;QAChB,YAAY;QACZ,aAAa;QACb,YAAY;QACZ,eAAe;QACf,cAAc;KACf,CAAC;IACF,OAAO,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAA2B;IAChE,MAAM,WAAW,GAAG;QAClB,WAAW;QACX,SAAS;QACT,YAAY;QACZ,YAAY;QACZ,gBAAgB;QAChB,eAAe;KAChB,CAAC;IACF,OAAO,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAA2B;IAChE,MAAM,WAAW,GAAG;QAClB,OAAO;QACP,WAAW;QACX,SAAS;QACT,UAAU;QACV,UAAU;QACV,MAAM;QACN,KAAK;QACL,KAAK;QACL,OAAO;QACP,SAAS;QACT,UAAU;QACV,gBAAgB;QAChB,UAAU;QACV,gBAAgB;QAChB,MAAM;QACN,eAAe;QACf,QAAQ;QACR,iBAAiB;KAClB,CAAC;IACF,OAAO,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java Class Extractor
|
|
3
|
+
*
|
|
4
|
+
* Extracts class, interface, enum, and record declarations from Java AST.
|
|
5
|
+
* Handles all Java type declarations with their annotations, modifiers,
|
|
6
|
+
* inheritance, and members.
|
|
7
|
+
*
|
|
8
|
+
* @requirements Java/Spring Boot Language Support
|
|
9
|
+
*/
|
|
10
|
+
import type { TreeSitterNode } from '../types.js';
|
|
11
|
+
import type { JavaClassInfo, JavaInterfaceInfo, JavaEnumInfo, JavaRecordInfo, JavaModifier, JavaAccessibility, JavaImportInfo, AnnotationDefinition } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Extract modifiers from a node.
|
|
14
|
+
*/
|
|
15
|
+
export declare function extractModifiers(node: TreeSitterNode): JavaModifier[];
|
|
16
|
+
/**
|
|
17
|
+
* Derive accessibility from modifiers.
|
|
18
|
+
*/
|
|
19
|
+
export declare function deriveAccessibility(modifiers: JavaModifier[]): JavaAccessibility;
|
|
20
|
+
/**
|
|
21
|
+
* Extract all class declarations from the AST.
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractClasses(root: TreeSitterNode, packageName: string | null, imports: JavaImportInfo[]): JavaClassInfo[];
|
|
24
|
+
/**
|
|
25
|
+
* Extract all interface declarations from the AST.
|
|
26
|
+
*/
|
|
27
|
+
export declare function extractInterfaces(root: TreeSitterNode, packageName: string | null, imports: JavaImportInfo[]): JavaInterfaceInfo[];
|
|
28
|
+
/**
|
|
29
|
+
* Extract all enum declarations from the AST.
|
|
30
|
+
*/
|
|
31
|
+
export declare function extractEnums(root: TreeSitterNode, packageName: string | null, imports: JavaImportInfo[]): JavaEnumInfo[];
|
|
32
|
+
/**
|
|
33
|
+
* Extract all record declarations from the AST.
|
|
34
|
+
*/
|
|
35
|
+
export declare function extractRecords(root: TreeSitterNode, packageName: string | null, imports: JavaImportInfo[]): JavaRecordInfo[];
|
|
36
|
+
/**
|
|
37
|
+
* Extract all annotation type definitions from the AST.
|
|
38
|
+
*/
|
|
39
|
+
export declare function extractAnnotationDefinitions(root: TreeSitterNode, packageName: string | null, imports: JavaImportInfo[]): AnnotationDefinition[];
|
|
40
|
+
//# sourceMappingURL=class-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-extractor.d.ts","sourceRoot":"","sources":["../../../../src/parsers/tree-sitter/java/class-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE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