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

Commit eebaf2f

Browse files
committed
annotations: Add a new sample for UnionType node type.
1 parent 6412941 commit eebaf2f

4 files changed

Lines changed: 268 additions & 1 deletion

File tree

TODO.md

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

2424
* BlockComment
2525
* LineComment
26-
* UnionType
2726
* WildcardType
2827

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

tests/union_type.native

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"status": "ok",
3+
"errors": [],
4+
"ast": {
5+
"CompilationUnit": {
6+
"internalClass": "CompilationUnit",
7+
"types": [
8+
{
9+
"bodyDeclarations": [
10+
{
11+
"body": {
12+
"internalClass": "Block",
13+
"statements": [
14+
{
15+
"body": {
16+
"internalClass": "Block"
17+
},
18+
"catchClauses": [
19+
{
20+
"body": {
21+
"internalClass": "Block"
22+
},
23+
"exception": {
24+
"internalClass": "SingleVariableDeclaration",
25+
"line": 4,
26+
"name": {
27+
"identifier": "e",
28+
"internalClass": "SimpleName",
29+
"line": 4,
30+
"startPosition": 83
31+
},
32+
"startPosition": 40,
33+
"type": {
34+
"internalClass": "UnionType",
35+
"types": [
36+
{
37+
"internalClass": "SimpleType",
38+
"name": {
39+
"identifier": "NullPointerException",
40+
"internalClass": "SimpleName",
41+
"line": 4,
42+
"startPosition": 40
43+
}
44+
},
45+
{
46+
"internalClass": "SimpleType",
47+
"name": {
48+
"identifier": "ArithmeticException",
49+
"internalClass": "SimpleName",
50+
"line": 4,
51+
"startPosition": 63
52+
}
53+
}
54+
]
55+
},
56+
"varargs": "false"
57+
},
58+
"internalClass": "CatchClause"
59+
}
60+
],
61+
"internalClass": "TryStatement"
62+
}
63+
]
64+
},
65+
"constructor": "true",
66+
"internalClass": "MethodDeclaration",
67+
"line": 2,
68+
"name": {
69+
"identifier": "A",
70+
"internalClass": "SimpleName",
71+
"line": 2,
72+
"startPosition": 12
73+
},
74+
"startPosition": 12
75+
}
76+
],
77+
"interface": "false",
78+
"internalClass": "TypeDeclaration",
79+
"line": 1,
80+
"name": {
81+
"identifier": "A",
82+
"internalClass": "SimpleName",
83+
"line": 1,
84+
"startPosition": 6
85+
},
86+
"startPosition": 0
87+
}
88+
]
89+
}
90+
}
91+
}

tests/union_type.source

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class A {
2+
A() {
3+
try {}
4+
catch (NullPointerException | ArithmeticException e) {}
5+
}
6+
}

tests/union_type.uast

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
Status: ok
2+
Errors:
3+
UAST:
4+
CompilationUnit {
5+
. Roles: File
6+
. Children: {
7+
. . 0: TypeDeclaration {
8+
. . . Roles: VisibleFromPackage,TypeDeclaration
9+
. . . StartPosition: {
10+
. . . . Offset: 0
11+
. . . . Line: 1
12+
. . . . Col: 1
13+
. . . }
14+
. . . Properties: {
15+
. . . . interface: false
16+
. . . . internalRole: types
17+
. . . }
18+
. . . Children: {
19+
. . . . 0: SimpleName {
20+
. . . . . Roles: SimpleIdentifier,Expression
21+
. . . . . TOKEN "A"
22+
. . . . . StartPosition: {
23+
. . . . . . Offset: 6
24+
. . . . . . Line: 1
25+
. . . . . . Col: 7
26+
. . . . . }
27+
. . . . . Properties: {
28+
. . . . . . internalRole: name
29+
. . . . . }
30+
. . . . }
31+
. . . . 1: MethodDeclaration {
32+
. . . . . Roles: VisibleFromPackage,FunctionDeclaration
33+
. . . . . StartPosition: {
34+
. . . . . . Offset: 12
35+
. . . . . . Line: 2
36+
. . . . . . Col: 3
37+
. . . . . }
38+
. . . . . Properties: {
39+
. . . . . . constructor: true
40+
. . . . . . internalRole: bodyDeclarations
41+
. . . . . }
42+
. . . . . Children: {
43+
. . . . . . 0: SimpleName {
44+
. . . . . . . Roles: SimpleIdentifier,Expression,FunctionDeclarationName
45+
. . . . . . . TOKEN "A"
46+
. . . . . . . StartPosition: {
47+
. . . . . . . . Offset: 12
48+
. . . . . . . . Line: 2
49+
. . . . . . . . Col: 3
50+
. . . . . . . }
51+
. . . . . . . Properties: {
52+
. . . . . . . . internalRole: name
53+
. . . . . . . }
54+
. . . . . . }
55+
. . . . . . 1: Block {
56+
. . . . . . . Roles: FunctionDeclarationBody,BlockScope,Block,Statement
57+
. . . . . . . Properties: {
58+
. . . . . . . . internalRole: body
59+
. . . . . . . }
60+
. . . . . . . Children: {
61+
. . . . . . . . 0: TryStatement {
62+
. . . . . . . . . Roles: Try,Statement
63+
. . . . . . . . . Properties: {
64+
. . . . . . . . . . internalRole: statements
65+
. . . . . . . . . }
66+
. . . . . . . . . Children: {
67+
. . . . . . . . . . 0: CatchClause {
68+
. . . . . . . . . . . Roles: TryCatch
69+
. . . . . . . . . . . Properties: {
70+
. . . . . . . . . . . . internalRole: catchClauses
71+
. . . . . . . . . . . }
72+
. . . . . . . . . . . Children: {
73+
. . . . . . . . . . . . 0: SingleVariableDeclaration {
74+
. . . . . . . . . . . . . Roles: Incomplete
75+
. . . . . . . . . . . . . StartPosition: {
76+
. . . . . . . . . . . . . . Offset: 40
77+
. . . . . . . . . . . . . . Line: 4
78+
. . . . . . . . . . . . . . Col: 12
79+
. . . . . . . . . . . . . }
80+
. . . . . . . . . . . . . Properties: {
81+
. . . . . . . . . . . . . . internalRole: exception
82+
. . . . . . . . . . . . . . varargs: false
83+
. . . . . . . . . . . . . }
84+
. . . . . . . . . . . . . Children: {
85+
. . . . . . . . . . . . . . 0: UnionType {
86+
. . . . . . . . . . . . . . . Roles: Incomplete
87+
. . . . . . . . . . . . . . . Properties: {
88+
. . . . . . . . . . . . . . . . internalRole: type
89+
. . . . . . . . . . . . . . . }
90+
. . . . . . . . . . . . . . . Children: {
91+
. . . . . . . . . . . . . . . . 0: SimpleType {
92+
. . . . . . . . . . . . . . . . . Roles: Incomplete
93+
. . . . . . . . . . . . . . . . . Properties: {
94+
. . . . . . . . . . . . . . . . . . internalRole: types
95+
. . . . . . . . . . . . . . . . . }
96+
. . . . . . . . . . . . . . . . . Children: {
97+
. . . . . . . . . . . . . . . . . . 0: SimpleName {
98+
. . . . . . . . . . . . . . . . . . . Roles: SimpleIdentifier,Expression
99+
. . . . . . . . . . . . . . . . . . . TOKEN "NullPointerException"
100+
. . . . . . . . . . . . . . . . . . . StartPosition: {
101+
. . . . . . . . . . . . . . . . . . . . Offset: 40
102+
. . . . . . . . . . . . . . . . . . . . Line: 4
103+
. . . . . . . . . . . . . . . . . . . . Col: 12
104+
. . . . . . . . . . . . . . . . . . . }
105+
. . . . . . . . . . . . . . . . . . . Properties: {
106+
. . . . . . . . . . . . . . . . . . . . internalRole: name
107+
. . . . . . . . . . . . . . . . . . . }
108+
. . . . . . . . . . . . . . . . . . }
109+
. . . . . . . . . . . . . . . . . }
110+
. . . . . . . . . . . . . . . . }
111+
. . . . . . . . . . . . . . . . 1: SimpleType {
112+
. . . . . . . . . . . . . . . . . Roles: Incomplete
113+
. . . . . . . . . . . . . . . . . Properties: {
114+
. . . . . . . . . . . . . . . . . . internalRole: types
115+
. . . . . . . . . . . . . . . . . }
116+
. . . . . . . . . . . . . . . . . Children: {
117+
. . . . . . . . . . . . . . . . . . 0: SimpleName {
118+
. . . . . . . . . . . . . . . . . . . Roles: SimpleIdentifier,Expression
119+
. . . . . . . . . . . . . . . . . . . TOKEN "ArithmeticException"
120+
. . . . . . . . . . . . . . . . . . . StartPosition: {
121+
. . . . . . . . . . . . . . . . . . . . Offset: 63
122+
. . . . . . . . . . . . . . . . . . . . Line: 4
123+
. . . . . . . . . . . . . . . . . . . . Col: 35
124+
. . . . . . . . . . . . . . . . . . . }
125+
. . . . . . . . . . . . . . . . . . . Properties: {
126+
. . . . . . . . . . . . . . . . . . . . internalRole: name
127+
. . . . . . . . . . . . . . . . . . . }
128+
. . . . . . . . . . . . . . . . . . }
129+
. . . . . . . . . . . . . . . . . }
130+
. . . . . . . . . . . . . . . . }
131+
. . . . . . . . . . . . . . . }
132+
. . . . . . . . . . . . . . }
133+
. . . . . . . . . . . . . . 1: SimpleName {
134+
. . . . . . . . . . . . . . . Roles: SimpleIdentifier,Expression
135+
. . . . . . . . . . . . . . . TOKEN "e"
136+
. . . . . . . . . . . . . . . StartPosition: {
137+
. . . . . . . . . . . . . . . . Offset: 83
138+
. . . . . . . . . . . . . . . . Line: 4
139+
. . . . . . . . . . . . . . . . Col: 55
140+
. . . . . . . . . . . . . . . }
141+
. . . . . . . . . . . . . . . Properties: {
142+
. . . . . . . . . . . . . . . . internalRole: name
143+
. . . . . . . . . . . . . . . }
144+
. . . . . . . . . . . . . . }
145+
. . . . . . . . . . . . . }
146+
. . . . . . . . . . . . }
147+
. . . . . . . . . . . . 1: Block {
148+
. . . . . . . . . . . . . Roles: BlockScope,Block,Statement
149+
. . . . . . . . . . . . . Properties: {
150+
. . . . . . . . . . . . . . internalRole: body
151+
. . . . . . . . . . . . . }
152+
. . . . . . . . . . . . }
153+
. . . . . . . . . . . }
154+
. . . . . . . . . . }
155+
. . . . . . . . . . 1: Block {
156+
. . . . . . . . . . . Roles: TryBody,BlockScope,Block,Statement
157+
. . . . . . . . . . . Properties: {
158+
. . . . . . . . . . . . internalRole: body
159+
. . . . . . . . . . . }
160+
. . . . . . . . . . }
161+
. . . . . . . . . }
162+
. . . . . . . . }
163+
. . . . . . . }
164+
. . . . . . }
165+
. . . . . }
166+
. . . . }
167+
. . . }
168+
. . }
169+
. }
170+
}
171+

0 commit comments

Comments
 (0)