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

Commit 20ac9ca

Browse files
authored
Merge pull request #55 from abeaumont/feature/new-roles
annotations: Annotate new SDK roles and some additional fixes.
2 parents b95e7c9 + 8cc5948 commit 20ac9ca

43 files changed

Lines changed: 195 additions & 193 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

driver/normalizer/annotation.go

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ var AnnotationRules = On(jdt.CompilationUnit).Roles(uast.File).Descendants(
4141
),
4242

4343
// Type declarations
44-
On(jdt.AnonymousClassDeclaration).Roles(uast.Expression, uast.Declaration, uast.Type, uast.Incomplete).Children(
44+
On(jdt.AnonymousClassDeclaration).Roles(uast.Expression, uast.Declaration, uast.Type, uast.Anonymous).Children(
4545
On(jdt.PropertyBodyDeclarations).Roles(uast.Body),
4646
),
47-
On(jdt.AnnotationTypeDeclaration).Roles(uast.Declaration, uast.Type, uast.Incomplete).Children(
47+
On(jdt.AnnotationTypeDeclaration).Roles(uast.Declaration, uast.Type, uast.Annotation).Children(
4848
On(jdt.PropertyBodyDeclarations).Roles(uast.Body),
4949
),
50-
On(jdt.EnumDeclaration).Roles(uast.Declaration, uast.Type, uast.Incomplete),
50+
On(jdt.EnumDeclaration).Roles(uast.Declaration, uast.Type, uast.Enumeration),
5151

5252
// ClassDeclaration | InterfaceDeclaration
5353
On(jdt.TypeDeclaration).Roles(uast.Declaration, uast.Type),
5454
// Local (TypeDeclaration | EnumDeclaration)
55-
On(jdt.TypeDeclarationStatement).Roles(uast.Statement, uast.Declaration, uast.Type, uast.Incomplete),
55+
On(jdt.TypeDeclarationStatement).Roles(uast.Statement, uast.Declaration, uast.Type),
5656

5757
// Method declarations
5858
On(jdt.MethodDeclaration).Roles(uast.Declaration, uast.Function).Children(
@@ -64,10 +64,7 @@ var AnnotationRules = On(jdt.CompilationUnit).Roles(uast.File).Descendants(
6464
On(jdt.PropertyName).Roles(uast.Function, uast.Name),
6565
),
6666
),
67-
// FIXME: A lambda expression is not really a function declaration
68-
// but current UAST doesn't provide anything else for function definitions
69-
// so I'm considering a lambda expression a function declaration for now
70-
On(jdt.LambdaExpression).Roles(uast.Declaration, uast.Function, uast.Incomplete).Children(
67+
On(jdt.LambdaExpression).Roles(uast.Declaration, uast.Function, uast.Anonymous).Children(
7168
On(jdt.PropertyBody).Roles(uast.Function, uast.Body),
7269
On(jdt.PropertyParameters).Roles(uast.Function, uast.Argument).Self(
7370
On(HasProperty("varargs", "true")).Roles(uast.Function, uast.ArgsList),
@@ -82,15 +79,15 @@ var AnnotationRules = On(jdt.CompilationUnit).Roles(uast.File).Descendants(
8279
),
8380

8481
// Other declarations
85-
On(jdt.AnnotationTypeMemberDeclaration).Roles(uast.Declaration, uast.Type, uast.Incomplete),
86-
On(jdt.EnumConstantDeclaration).Roles(uast.Declaration, uast.Incomplete),
87-
On(jdt.FieldDeclaration).Roles(uast.Declaration, uast.Incomplete),
82+
On(jdt.AnnotationTypeMemberDeclaration).Roles(uast.Declaration, uast.Type, uast.Annotation),
83+
On(jdt.EnumConstantDeclaration).Roles(uast.Declaration, uast.Enumeration),
84+
On(jdt.FieldDeclaration).Roles(uast.Declaration, uast.Variable),
8885
// TODO: differentiate between static (class) and instance initialization
8986
On(jdt.Initializer).Roles(uast.Initialization, uast.Block, uast.Incomplete),
90-
On(jdt.SingleVariableDeclaration).Roles(uast.Declaration, uast.Incomplete),
91-
On(jdt.VariableDeclarationExpression).Roles(uast.Expression, uast.Declaration, uast.Incomplete),
92-
On(jdt.VariableDeclarationFragment).Roles(uast.Declaration, uast.Incomplete),
93-
On(jdt.VariableDeclarationStatement).Roles(uast.Statement, uast.Declaration, uast.Incomplete),
87+
On(jdt.SingleVariableDeclaration).Roles(uast.Declaration, uast.Variable),
88+
On(jdt.VariableDeclarationExpression).Roles(uast.Expression, uast.Declaration, uast.Variable),
89+
On(jdt.VariableDeclarationFragment).Roles(uast.Declaration, uast.Variable),
90+
On(jdt.VariableDeclarationStatement).Roles(uast.Statement, uast.Declaration, uast.Variable),
9491

9592
// Literals
9693
On(jdt.BooleanLiteral).Roles(uast.Expression, uast.Literal, uast.Boolean),
@@ -176,14 +173,20 @@ var AnnotationRules = On(jdt.CompilationUnit).Roles(uast.File).Descendants(
176173

177174
// Operators
178175
On(jdt.InfixExpression).Roles(uast.Expression, uast.Binary, uast.Operator).Self(
179-
On(HasProperty("operator", "+")).Roles(uast.Add),
180-
On(HasProperty("operator", "-")).Roles(uast.Substract),
181-
On(HasProperty("operator", "*")).Roles(uast.Multiply),
182-
On(HasProperty("operator", "/")).Roles(uast.Divide),
183-
On(HasProperty("operator", "%")).Roles(uast.Modulo),
176+
On(HasProperty("operator", "+")).Roles(uast.Add, uast.Arithmetic),
177+
On(HasProperty("operator", "-")).Roles(uast.Substract, uast.Arithmetic),
178+
On(HasProperty("operator", "*")).Roles(uast.Multiply, uast.Arithmetic),
179+
On(HasProperty("operator", "/")).Roles(uast.Divide, uast.Arithmetic),
180+
On(HasProperty("operator", "%")).Roles(uast.Modulo, uast.Arithmetic),
184181
On(HasProperty("operator", "<<")).Roles(uast.Bitwise, uast.LeftShift),
185182
On(HasProperty("operator", ">>")).Roles(uast.Bitwise, uast.RightShift),
186183
On(HasProperty("operator", ">>>")).Roles(uast.Bitwise, uast.RightShift, uast.Unsigned),
184+
On(HasProperty("operator", "<")).Roles(uast.LessThan, uast.Relational),
185+
On(HasProperty("operator", ">")).Roles(uast.GreaterThan, uast.Relational),
186+
On(HasProperty("operator", "<=")).Roles(uast.LessThanOrEqual, uast.Relational),
187+
On(HasProperty("operator", ">=")).Roles(uast.GreaterThanOrEqual, uast.Relational),
188+
On(HasProperty("operator", "==")).Roles(uast.Equal, uast.Relational),
189+
On(HasProperty("operator", "==")).Roles(uast.Equal, uast.Not, uast.Relational),
187190
On(HasProperty("operator", "&")).Roles(uast.Bitwise, uast.And),
188191
On(HasProperty("operator", "|")).Roles(uast.Bitwise, uast.Or),
189192
On(HasProperty("operator", "&&")).Roles(uast.Boolean, uast.And),
@@ -195,8 +198,8 @@ var AnnotationRules = On(jdt.CompilationUnit).Roles(uast.File).Descendants(
195198
),
196199

197200
On(jdt.PostfixExpression).Roles(uast.Expression, uast.Operator, uast.Unary, uast.Postfix).Self(
198-
On(HasProperty("operator", "++")).Roles(uast.Increment),
199-
On(HasProperty("operator", "--")).Roles(uast.Increment),
201+
On(HasProperty("operator", "++")).Roles(uast.Increment, uast.Arithmetic),
202+
On(HasProperty("operator", "--")).Roles(uast.Increment, uast.Arithmetic),
200203
),
201204

202205
On(jdt.PrefixExpression).Roles(uast.Expression, uast.Operator, uast.Unary).Self(
@@ -260,7 +263,7 @@ var AnnotationRules = On(jdt.CompilationUnit).Roles(uast.File).Descendants(
260263

261264
// Exceptions
262265
On(jdt.TryStatement).Roles(uast.Statement, uast.Try).Children(
263-
// TODO: TryWithResourcesStatement
266+
On(jdt.PropertyResources).Roles(uast.Try),
264267
On(jdt.PropertyBody).Roles(uast.Try, uast.Body),
265268
On(jdt.PropertyCatchClauses).Roles(uast.Try, uast.Catch),
266269
On(jdt.PropertyFinally).Roles(uast.Try, uast.Finally),
@@ -271,21 +274,23 @@ var AnnotationRules = On(jdt.CompilationUnit).Roles(uast.File).Descendants(
271274
On(jdt.AssertStatement).Roles(uast.Statement, uast.Assert),
272275

273276
// Annotations
274-
On(jdt.MarkerAnnotation).Roles(uast.Incomplete),
275-
On(jdt.MemberRef).Roles(uast.Incomplete),
276-
On(jdt.MemberValuePair).Roles(uast.Incomplete),
277-
On(jdt.MethodRef).Roles(uast.Incomplete),
278-
On(jdt.MethodRefParameter).Roles(uast.Incomplete),
279-
On(jdt.NormalAnnotation).Roles(uast.Incomplete),
280-
On(jdt.SingleMemberAnnotation).Roles(uast.Incomplete),
281-
On(jdt.TagElement).Roles(uast.Incomplete),
282-
On(jdt.TextElement).Roles(uast.Incomplete),
277+
On(jdt.MarkerAnnotation).Roles(uast.Annotation, uast.Incomplete),
278+
On(jdt.NormalAnnotation).Roles(uast.Annotation, uast.Incomplete),
279+
On(jdt.SingleMemberAnnotation).Roles(uast.Annotation, uast.Incomplete),
280+
On(jdt.MemberValuePair).Roles(uast.Annotation, uast.Incomplete),
283281

284282
// Comments
285283
On(jdt.BlockComment).Roles(uast.Comment),
286284
On(jdt.Javadoc).Roles(uast.Documentation, uast.Comment),
287285
On(jdt.LineComment).Roles(uast.Comment),
288286

287+
// Javadoc tags
288+
On(jdt.MemberRef).Roles(uast.Documentation, uast.Variable, uast.Incomplete),
289+
On(jdt.MethodRef).Roles(uast.Documentation, uast.Function, uast.Incomplete),
290+
On(jdt.MethodRefParameter).Roles(uast.Documentation, uast.Function, uast.Incomplete),
291+
On(jdt.TagElement).Roles(uast.Documentation, uast.Incomplete),
292+
On(jdt.TextElement).Roles(uast.Documentation, uast.Incomplete),
293+
289294
// Other expressions
290295
On(jdt.ArrayAccess).Roles(uast.Expression, uast.Incomplete),
291296
On(jdt.ArrayCreation).Roles(uast.Expression, uast.Incomplete),

fixtures/annotation_type_declaration.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CompilationUnit {
55
. Roles: File
66
. Children: {
77
. . 0: AnnotationTypeDeclaration {
8-
. . . Roles: Declaration,Type,Incomplete
8+
. . . Roles: Declaration,Type,Annotation
99
. . . Properties: {
1010
. . . . internalRole: types
1111
. . . }

fixtures/annotation_type_member_declaration.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CompilationUnit {
55
. Roles: File
66
. Children: {
77
. . 0: AnnotationTypeDeclaration {
8-
. . . Roles: Declaration,Type,Incomplete
8+
. . . Roles: Declaration,Type,Annotation
99
. . . Properties: {
1010
. . . . internalRole: types
1111
. . . }
@@ -28,7 +28,7 @@ CompilationUnit {
2828
. . . . . }
2929
. . . . }
3030
. . . . 1: AnnotationTypeMemberDeclaration {
31-
. . . . . Roles: Body,Declaration,Type,Incomplete
31+
. . . . . Roles: Body,Declaration,Type,Annotation
3232
. . . . . Properties: {
3333
. . . . . . internalRole: bodyDeclarations
3434
. . . . . }

fixtures/anonymous_class_declaration.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ CompilationUnit {
169169
. . . . . . . . . . . . . }
170170
. . . . . . . . . . . . }
171171
. . . . . . . . . . . . 1: AnonymousClassDeclaration {
172-
. . . . . . . . . . . . . Roles: Expression,Declaration,Type,Incomplete
172+
. . . . . . . . . . . . . Roles: Expression,Declaration,Type,Anonymous
173173
. . . . . . . . . . . . . Properties: {
174174
. . . . . . . . . . . . . . internalRole: anonymousClassDeclaration
175175
. . . . . . . . . . . . . }

fixtures/array.uast

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ CompilationUnit {
9696
. . . . . . . }
9797
. . . . . . . Children: {
9898
. . . . . . . . 0: VariableDeclarationStatement {
99-
. . . . . . . . . Roles: Statement,Declaration,Incomplete
99+
. . . . . . . . . Roles: Statement,Declaration,Variable
100100
. . . . . . . . . Properties: {
101101
. . . . . . . . . . internalRole: statements
102102
. . . . . . . . . }
@@ -133,7 +133,7 @@ CompilationUnit {
133133
. . . . . . . . . . . }
134134
. . . . . . . . . . }
135135
. . . . . . . . . . 1: VariableDeclarationFragment {
136-
. . . . . . . . . . . Roles: Declaration,Incomplete
136+
. . . . . . . . . . . Roles: Declaration,Variable
137137
. . . . . . . . . . . Properties: {
138138
. . . . . . . . . . . . internalRole: fragments
139139
. . . . . . . . . . . }
@@ -216,7 +216,7 @@ CompilationUnit {
216216
. . . . . . . . . }
217217
. . . . . . . . }
218218
. . . . . . . . 1: VariableDeclarationStatement {
219-
. . . . . . . . . Roles: Statement,Declaration,Incomplete
219+
. . . . . . . . . Roles: Statement,Declaration,Variable
220220
. . . . . . . . . Properties: {
221221
. . . . . . . . . . internalRole: statements
222222
. . . . . . . . . }
@@ -239,7 +239,7 @@ CompilationUnit {
239239
. . . . . . . . . . . }
240240
. . . . . . . . . . }
241241
. . . . . . . . . . 1: VariableDeclarationFragment {
242-
. . . . . . . . . . . Roles: Declaration,Incomplete
242+
. . . . . . . . . . . Roles: Declaration,Variable
243243
. . . . . . . . . . . Properties: {
244244
. . . . . . . . . . . . internalRole: fragments
245245
. . . . . . . . . . . }

fixtures/array_initializer.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ CompilationUnit {
9696
. . . . . . . }
9797
. . . . . . . Children: {
9898
. . . . . . . . 0: VariableDeclarationStatement {
99-
. . . . . . . . . Roles: Statement,Declaration,Incomplete
99+
. . . . . . . . . Roles: Statement,Declaration,Variable
100100
. . . . . . . . . Properties: {
101101
. . . . . . . . . . internalRole: statements
102102
. . . . . . . . . }
@@ -133,7 +133,7 @@ CompilationUnit {
133133
. . . . . . . . . . . }
134134
. . . . . . . . . . }
135135
. . . . . . . . . . 1: VariableDeclarationFragment {
136-
. . . . . . . . . . . Roles: Declaration,Incomplete
136+
. . . . . . . . . . . Roles: Declaration,Variable
137137
. . . . . . . . . . . Properties: {
138138
. . . . . . . . . . . . internalRole: fragments
139139
. . . . . . . . . . . }

fixtures/binary_expression.uast

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ CompilationUnit {
9696
. . . . . . . }
9797
. . . . . . . Children: {
9898
. . . . . . . . 0: VariableDeclarationStatement {
99-
. . . . . . . . . Roles: Statement,Declaration,Incomplete
99+
. . . . . . . . . Roles: Statement,Declaration,Variable
100100
. . . . . . . . . Properties: {
101101
. . . . . . . . . . internalRole: statements
102102
. . . . . . . . . }
@@ -119,7 +119,7 @@ CompilationUnit {
119119
. . . . . . . . . . . }
120120
. . . . . . . . . . }
121121
. . . . . . . . . . 1: VariableDeclarationFragment {
122-
. . . . . . . . . . . Roles: Declaration,Incomplete
122+
. . . . . . . . . . . Roles: Declaration,Variable
123123
. . . . . . . . . . . Properties: {
124124
. . . . . . . . . . . . internalRole: fragments
125125
. . . . . . . . . . . }
@@ -142,7 +142,7 @@ CompilationUnit {
142142
. . . . . . . . . . . . . }
143143
. . . . . . . . . . . . }
144144
. . . . . . . . . . . . 1: InfixExpression {
145-
. . . . . . . . . . . . . Roles: Expression,Binary,Operator,Add
145+
. . . . . . . . . . . . . Roles: Expression,Binary,Operator,Add,Arithmetic
146146
. . . . . . . . . . . . . StartPosition: {
147147
. . . . . . . . . . . . . . Offset: 41
148148
. . . . . . . . . . . . . . Line: 3

fixtures/boolean_operators.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ CompilationUnit {
9696
. . . . . . . }
9797
. . . . . . . Children: {
9898
. . . . . . . . 0: VariableDeclarationStatement {
99-
. . . . . . . . . Roles: Statement,Declaration,Incomplete
99+
. . . . . . . . . Roles: Statement,Declaration,Variable
100100
. . . . . . . . . Properties: {
101101
. . . . . . . . . . internalRole: statements
102102
. . . . . . . . . }
@@ -119,7 +119,7 @@ CompilationUnit {
119119
. . . . . . . . . . . }
120120
. . . . . . . . . . }
121121
. . . . . . . . . . 1: VariableDeclarationFragment {
122-
. . . . . . . . . . . Roles: Declaration,Incomplete
122+
. . . . . . . . . . . Roles: Declaration,Variable
123123
. . . . . . . . . . . Properties: {
124124
. . . . . . . . . . . . internalRole: fragments
125125
. . . . . . . . . . . }

fixtures/cast_expression.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ CompilationUnit {
9696
. . . . . . . }
9797
. . . . . . . Children: {
9898
. . . . . . . . 0: VariableDeclarationStatement {
99-
. . . . . . . . . Roles: Statement,Declaration,Incomplete
99+
. . . . . . . . . Roles: Statement,Declaration,Variable
100100
. . . . . . . . . Properties: {
101101
. . . . . . . . . . internalRole: statements
102102
. . . . . . . . . }
@@ -119,7 +119,7 @@ CompilationUnit {
119119
. . . . . . . . . . . }
120120
. . . . . . . . . . }
121121
. . . . . . . . . . 1: VariableDeclarationFragment {
122-
. . . . . . . . . . . Roles: Declaration,Incomplete
122+
. . . . . . . . . . . Roles: Declaration,Variable
123123
. . . . . . . . . . . Properties: {
124124
. . . . . . . . . . . . internalRole: fragments
125125
. . . . . . . . . . . }

fixtures/character_literal.uast

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ CompilationUnit {
9696
. . . . . . . }
9797
. . . . . . . Children: {
9898
. . . . . . . . 0: VariableDeclarationStatement {
99-
. . . . . . . . . Roles: Statement,Declaration,Incomplete
99+
. . . . . . . . . Roles: Statement,Declaration,Variable
100100
. . . . . . . . . Properties: {
101101
. . . . . . . . . . internalRole: statements
102102
. . . . . . . . . }
@@ -119,7 +119,7 @@ CompilationUnit {
119119
. . . . . . . . . . . }
120120
. . . . . . . . . . }
121121
. . . . . . . . . . 1: VariableDeclarationFragment {
122-
. . . . . . . . . . . Roles: Declaration,Incomplete
122+
. . . . . . . . . . . Roles: Declaration,Variable
123123
. . . . . . . . . . . Properties: {
124124
. . . . . . . . . . . . internalRole: fragments
125125
. . . . . . . . . . . }

0 commit comments

Comments
 (0)