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

Commit c279e2f

Browse files
Denys Smirnovdennwc
authored andcommitted
add roles for primitive type; fix #83
Signed-off-by: Denys Smirnov <[email protected]>
1 parent ebbe634 commit c279e2f

File tree

69 files changed

+876
-615
lines changed

Some content is hidden

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

69 files changed

+876
-615
lines changed

driver/normalizer/annotation.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ var (
107107
"true": {role.ArgsList},
108108
"false": {},
109109
})
110+
primitiveRoles = StringToRolesMap(map[string][]role.Role{
111+
"boolean": {role.Boolean},
112+
"byte": {role.Byte},
113+
"char": {role.Character},
114+
"short": {role.Number},
115+
"int": {role.Number},
116+
"long": {role.Number},
117+
"float": {role.Number},
118+
"double": {role.Number},
119+
"void": {},
120+
})
110121
)
111122

112123
func annotateModifiers(typ string, mod string, roles ...role.Role) Mapping {
@@ -142,10 +153,11 @@ var Annotations = []Mapping{
142153
},
143154
role.Expression, role.Identifier,
144155
),
145-
AnnotateType("PrimitiveType",
156+
AnnotateTypeCustom("PrimitiveType",
146157
FieldRoles{
147-
"primitiveTypeCode": {Rename: uast.KeyToken},
158+
"primitiveTypeCode": {Rename: uast.KeyToken, Op: Var("typ")},
148159
},
160+
LookupArrOpVar("typ", primitiveRoles),
149161
role.Type, role.Primitive,
150162
),
151163

fixtures/annotation_type_member_declaration.java.sem.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
},
7878
type: { '@type': "PrimitiveType",
7979
'@token': "int",
80-
'@role': [Primitive, Type],
80+
'@role': [Number, Primitive, Type],
8181
'@pos': { '@type': "uast:Positions",
8282
start: { '@type': "uast:Position",
8383
offset: 17,

fixtures/annotation_type_member_declaration.java.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
},
7979
type: { '@type': "PrimitiveType",
8080
'@token': "int",
81-
'@role': [Primitive, Type],
81+
'@role': [Number, Primitive, Type],
8282
'@pos': { '@type': "uast:Positions",
8383
start: { '@type': "uast:Position",
8484
offset: 17,

fixtures/array.java.sem.uast

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
],
174174
elementType: { '@type': "PrimitiveType",
175175
'@token': "int",
176-
'@role': [Primitive, Type],
176+
'@role': [Number, Primitive, Type],
177177
'@pos': { '@type': "uast:Positions",
178178
start: { '@type': "uast:Position",
179179
offset: 46,
@@ -242,7 +242,7 @@
242242
],
243243
elementType: { '@type': "PrimitiveType",
244244
'@token': "int",
245-
'@role': [Primitive, Type],
245+
'@role': [Number, Primitive, Type],
246246
'@pos': { '@type': "uast:Positions",
247247
start: { '@type': "uast:Position",
248248
offset: 32,
@@ -355,7 +355,7 @@
355355
modifiers: ~,
356356
type: { '@type': "PrimitiveType",
357357
'@token': "int",
358-
'@role': [Primitive, Type],
358+
'@role': [Number, Primitive, Type],
359359
'@pos': { '@type': "uast:Positions",
360360
start: { '@type': "uast:Position",
361361
offset: 58,

fixtures/array.java.uast

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
],
156156
elementType: { '@type': "PrimitiveType",
157157
'@token': "int",
158-
'@role': [Primitive, Type],
158+
'@role': [Number, Primitive, Type],
159159
'@pos': { '@type': "uast:Positions",
160160
start: { '@type': "uast:Position",
161161
offset: 46,
@@ -225,7 +225,7 @@
225225
],
226226
elementType: { '@type': "PrimitiveType",
227227
'@token': "int",
228-
'@role': [Primitive, Type],
228+
'@role': [Number, Primitive, Type],
229229
'@pos': { '@type': "uast:Positions",
230230
start: { '@type': "uast:Position",
231231
offset: 32,
@@ -340,7 +340,7 @@
340340
modifiers: ~,
341341
type: { '@type': "PrimitiveType",
342342
'@token': "int",
343-
'@role': [Primitive, Type],
343+
'@role': [Number, Primitive, Type],
344344
'@pos': { '@type': "uast:Positions",
345345
start: { '@type': "uast:Position",
346346
offset: 58,

fixtures/array_initializer.java.sem.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
],
192192
elementType: { '@type': "PrimitiveType",
193193
'@token': "int",
194-
'@role': [Primitive, Type],
194+
'@role': [Number, Primitive, Type],
195195
'@pos': { '@type': "uast:Positions",
196196
start: { '@type': "uast:Position",
197197
offset: 32,

fixtures/array_initializer.java.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
],
175175
elementType: { '@type': "PrimitiveType",
176176
'@token': "int",
177-
'@role': [Primitive, Type],
177+
'@role': [Number, Primitive, Type],
178178
'@pos': { '@type': "uast:Positions",
179179
start: { '@type': "uast:Position",
180180
offset: 32,

fixtures/binary_expression.java.sem.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
modifiers: ~,
179179
type: { '@type': "PrimitiveType",
180180
'@token': "int",
181-
'@role': [Primitive, Type],
181+
'@role': [Number, Primitive, Type],
182182
'@pos': { '@type': "uast:Positions",
183183
start: { '@type': "uast:Position",
184184
offset: 33,

fixtures/binary_expression.java.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
modifiers: ~,
162162
type: { '@type': "PrimitiveType",
163163
'@token': "int",
164-
'@role': [Primitive, Type],
164+
'@role': [Number, Primitive, Type],
165165
'@pos': { '@type': "uast:Positions",
166166
start: { '@type': "uast:Position",
167167
offset: 33,

fixtures/boolean_operators.java.sem.uast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
modifiers: ~,
179179
type: { '@type': "PrimitiveType",
180180
'@token': "boolean",
181-
'@role': [Primitive, Type],
181+
'@role': [Boolean, Primitive, Type],
182182
'@pos': { '@type': "uast:Positions",
183183
start: { '@type': "uast:Position",
184184
offset: 33,

0 commit comments

Comments
 (0)