Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit f8934ed

Browse files
authored
Merge pull request #39 from abeaumont/feature/improve-annotations
Add annotations/samples for all node types except comments
2 parents 3b9d93c + de9ee61 commit f8934ed

18 files changed

Lines changed: 3882 additions & 21 deletions

ANNOTATION.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@
151151
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='TryStatement'\]/\*\[@internalRole\]\[@internalRole='finally'\] | TryFinally |
152152
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='ThrowStatement'\] | Throw, Statement |
153153
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='AssertStatement'\] | Assert, Statement |
154+
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='MarkerAnnotation'\] | Incomplete |
155+
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='MemberRef'\] | Incomplete |
156+
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='MemberValuePair'\] | Incomplete |
157+
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='MethodRef'\] | Incomplete |
158+
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='MethodRefParameter'\] | Incomplete |
159+
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='NormalAnnotation'\] | Incomplete |
160+
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='SingleMemberAnnotation'\] | Incomplete |
161+
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='TagElement'\] | Incomplete |
162+
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='TextElement'\] | Incomplete |
154163
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='ArrayAccess'\] | Expression, Incomplete |
155164
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='ArrayCreation'\] | Expression, Incomplete |
156165
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='CastExpression'\] | Expression, Incomplete |
@@ -169,11 +178,4 @@
169178
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='ArrayInitializer'\] | Incomplete |
170179
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='Dimension'\] | Incomplete |
171180
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='Javadoc'\] | Documentation, Comment |
172-
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='NormalAnnotation'\] | Incomplete |
173-
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='MemberRef'\] | Incomplete |
174-
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='MemberValuePair'\] | Incomplete |
175-
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='MethodRef'\] | Incomplete |
176-
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='MethodRefParameter'\] | Incomplete |
177-
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='TagElement'\] | Incomplete |
178-
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='TextElement'\] | Incomplete |
179181
| /self::\*\[@InternalType='CompilationUnit'\]//\*\[@InternalType='TypeParameter'\] | Incomplete |

TODO.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ but there are some missing:
2323

2424
* BlockComment
2525
* LineComment
26-
* NameQualifiedType
27-
* ParameterizedType
28-
* QualifiedType
29-
* SingleMemberAnnotation
30-
* TypeMethodReference
31-
* UnionType
32-
* WildcardType
3326

3427
Comments are not provided by default by the native driver. This should eventually be fixed.
3528

driver/normalizer/annotation.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,17 @@ var AnnotationRules = On(jdt.CompilationUnit).Roles(File).Descendants(
249249

250250
On(jdt.AssertStatement).Roles(Assert, Statement),
251251

252+
// Annotations
253+
On(jdt.MarkerAnnotation).Roles(Incomplete),
254+
On(jdt.MemberRef).Roles(Incomplete),
255+
On(jdt.MemberValuePair).Roles(Incomplete),
256+
On(jdt.MethodRef).Roles(Incomplete),
257+
On(jdt.MethodRefParameter).Roles(Incomplete),
258+
On(jdt.NormalAnnotation).Roles(Incomplete),
259+
On(jdt.SingleMemberAnnotation).Roles(Incomplete),
260+
On(jdt.TagElement).Roles(Incomplete),
261+
On(jdt.TextElement).Roles(Incomplete),
262+
252263
// Other expressions
253264
On(jdt.ArrayAccess).Roles(Expression, Incomplete),
254265
On(jdt.ArrayCreation).Roles(Expression, Incomplete),
@@ -272,12 +283,5 @@ var AnnotationRules = On(jdt.CompilationUnit).Roles(File).Descendants(
272283
On(jdt.ArrayInitializer).Roles(Incomplete),
273284
On(jdt.Dimension).Roles(Incomplete),
274285
On(jdt.Javadoc).Roles(Documentation, Comment),
275-
On(jdt.NormalAnnotation).Roles(Incomplete),
276-
On(jdt.MemberRef).Roles(Incomplete),
277-
On(jdt.MemberValuePair).Roles(Incomplete),
278-
On(jdt.MethodRef).Roles(Incomplete),
279-
On(jdt.MethodRefParameter).Roles(Incomplete),
280-
On(jdt.TagElement).Roles(Incomplete),
281-
On(jdt.TextElement).Roles(Incomplete),
282286
On(jdt.TypeParameter).Roles(Incomplete),
283287
)

tests/name_qualified_type.native

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
{
2+
"status": "ok",
3+
"errors": [],
4+
"ast": {
5+
"CompilationUnit": {
6+
"imports": [
7+
{
8+
"internalClass": "ImportDeclaration",
9+
"line": 1,
10+
"name": {
11+
"internalClass": "QualifiedName",
12+
"name": {
13+
"identifier": "annotation",
14+
"internalClass": "SimpleName",
15+
"line": 1,
16+
"startPosition": 17
17+
},
18+
"qualifier": {
19+
"internalClass": "QualifiedName",
20+
"name": {
21+
"identifier": "lang",
22+
"internalClass": "SimpleName",
23+
"line": 1,
24+
"startPosition": 12
25+
},
26+
"qualifier": {
27+
"identifier": "java",
28+
"internalClass": "SimpleName",
29+
"line": 1,
30+
"startPosition": 7
31+
}
32+
}
33+
},
34+
"onDemand": "true",
35+
"startPosition": 0,
36+
"static": "false"
37+
}
38+
],
39+
"internalClass": "CompilationUnit",
40+
"types": [
41+
{
42+
"internalClass": "AnnotationTypeDeclaration",
43+
"modifiers": [
44+
{
45+
"internalClass": "SingleMemberAnnotation",
46+
"typeName": {
47+
"identifier": "Target",
48+
"internalClass": "SimpleName",
49+
"line": 3,
50+
"startPosition": 33
51+
},
52+
"value": {
53+
"internalClass": "QualifiedName",
54+
"name": {
55+
"identifier": "TYPE_USE",
56+
"internalClass": "SimpleName",
57+
"line": 3,
58+
"startPosition": 52
59+
},
60+
"qualifier": {
61+
"identifier": "ElementType",
62+
"internalClass": "SimpleName",
63+
"line": 3,
64+
"startPosition": 40
65+
}
66+
}
67+
}
68+
],
69+
"name": {
70+
"identifier": "X",
71+
"internalClass": "SimpleName",
72+
"line": 4,
73+
"startPosition": 73
74+
}
75+
},
76+
{
77+
"bodyDeclarations": [
78+
{
79+
"body": {
80+
"internalClass": "Block",
81+
"statements": [
82+
{
83+
"fragments": [
84+
{
85+
"internalClass": "VariableDeclarationFragment",
86+
"name": {
87+
"identifier": "date",
88+
"internalClass": "SimpleName",
89+
"line": 8,
90+
"startPosition": 117
91+
}
92+
}
93+
],
94+
"internalClass": "VariableDeclarationStatement",
95+
"type": {
96+
"annotations": [
97+
{
98+
"internalClass": "MarkerAnnotation",
99+
"typeName": {
100+
"identifier": "X",
101+
"internalClass": "SimpleName",
102+
"line": 8,
103+
"startPosition": 110
104+
}
105+
}
106+
],
107+
"internalClass": "NameQualifiedType",
108+
"name": {
109+
"identifier": "Date",
110+
"internalClass": "SimpleName",
111+
"line": 8,
112+
"startPosition": 112
113+
},
114+
"qualifier": {
115+
"internalClass": "QualifiedName",
116+
"name": {
117+
"identifier": "util",
118+
"internalClass": "SimpleName",
119+
"line": 8,
120+
"startPosition": 104
121+
},
122+
"qualifier": {
123+
"identifier": "java",
124+
"internalClass": "SimpleName",
125+
"line": 8,
126+
"startPosition": 99
127+
}
128+
}
129+
}
130+
}
131+
]
132+
},
133+
"constructor": "true",
134+
"internalClass": "MethodDeclaration",
135+
"line": 7,
136+
"name": {
137+
"identifier": "A",
138+
"internalClass": "SimpleName",
139+
"line": 7,
140+
"startPosition": 89
141+
},
142+
"startPosition": 89
143+
}
144+
],
145+
"interface": "false",
146+
"internalClass": "TypeDeclaration",
147+
"line": 6,
148+
"name": {
149+
"identifier": "A",
150+
"internalClass": "SimpleName",
151+
"line": 6,
152+
"startPosition": 84
153+
},
154+
"startPosition": 78
155+
}
156+
]
157+
}
158+
}
159+
}

tests/name_qualified_type.source

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import java.lang.annotation.*;
2+
3+
@Target(ElementType.TYPE_USE)
4+
@interface X{}
5+
6+
class A{
7+
A() {
8+
java.util.@X Date date;
9+
}
10+
}
11+

0 commit comments

Comments
 (0)