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

Commit 0df0dea

Browse files
committed
Add annotations for ThrowStatement.
1 parent be81e96 commit 0df0dea

4 files changed

Lines changed: 156 additions & 0 deletions

File tree

driver/normalizer/annotation.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ var AnnotationRules = On(Any).Self(
165165
On(jdt.PropertyFinally).Roles(TryFinally),
166166
),
167167

168+
On(jdt.ThrowStatement).Roles(Throw, Statement),
169+
168170
On(jdt.AssertStatement).Roles(Assert, Statement),
169171

170172
// Others

tests/throw.native

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
"expression": {
16+
"internalClass": "NullLiteral"
17+
},
18+
"internalClass": "ThrowStatement"
19+
}
20+
]
21+
},
22+
"constructor": "false",
23+
"internalClass": "MethodDeclaration",
24+
"line": 2,
25+
"name": {
26+
"identifier": "code",
27+
"internalClass": "SimpleName",
28+
"line": 2,
29+
"startPosition": 20
30+
},
31+
"returnType2": {
32+
"internalClass": "PrimitiveType",
33+
"line": 2,
34+
"primitiveTypeCode": "void",
35+
"startPosition": 15
36+
},
37+
"startPosition": 15
38+
}
39+
],
40+
"interface": "false",
41+
"internalClass": "TypeDeclaration",
42+
"line": 1,
43+
"name": {
44+
"identifier": "Code",
45+
"internalClass": "SimpleName",
46+
"line": 1,
47+
"startPosition": 6
48+
},
49+
"startPosition": 0
50+
}
51+
]
52+
}
53+
}
54+
}

tests/throw.source

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Code {
2+
void code() {
3+
throw null;
4+
}
5+
}

tests/throw.uast

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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: 0
13+
. . . }
14+
. . . Properties: {
15+
. . . . interface: false
16+
. . . . internalRole: types
17+
. . . }
18+
. . . Children: {
19+
. . . . 0: SimpleName {
20+
. . . . . Roles: SimpleIdentifier
21+
. . . . . TOKEN "Code"
22+
. . . . . StartPosition: {
23+
. . . . . . Offset: 6
24+
. . . . . . Line: 1
25+
. . . . . . Col: 0
26+
. . . . . }
27+
. . . . . Properties: {
28+
. . . . . . internalRole: name
29+
. . . . . }
30+
. . . . }
31+
. . . . 1: MethodDeclaration {
32+
. . . . . Roles: VisibleFromPackage,FunctionDeclaration
33+
. . . . . StartPosition: {
34+
. . . . . . Offset: 15
35+
. . . . . . Line: 2
36+
. . . . . . Col: 0
37+
. . . . . }
38+
. . . . . Properties: {
39+
. . . . . . constructor: false
40+
. . . . . . internalRole: bodyDeclarations
41+
. . . . . }
42+
. . . . . Children: {
43+
. . . . . . 0: PrimitiveType {
44+
. . . . . . . TOKEN "void"
45+
. . . . . . . StartPosition: {
46+
. . . . . . . . Offset: 15
47+
. . . . . . . . Line: 2
48+
. . . . . . . . Col: 0
49+
. . . . . . . }
50+
. . . . . . . Properties: {
51+
. . . . . . . . internalRole: returnType2
52+
. . . . . . . }
53+
. . . . . . }
54+
. . . . . . 1: SimpleName {
55+
. . . . . . . Roles: SimpleIdentifier,FunctionDeclarationName
56+
. . . . . . . TOKEN "code"
57+
. . . . . . . StartPosition: {
58+
. . . . . . . . Offset: 20
59+
. . . . . . . . Line: 2
60+
. . . . . . . . Col: 0
61+
. . . . . . . }
62+
. . . . . . . Properties: {
63+
. . . . . . . . internalRole: name
64+
. . . . . . . }
65+
. . . . . . }
66+
. . . . . . 2: Block {
67+
. . . . . . . Roles: FunctionDeclarationBody,BlockScope,Block
68+
. . . . . . . Properties: {
69+
. . . . . . . . internalRole: body
70+
. . . . . . . }
71+
. . . . . . . Children: {
72+
. . . . . . . . 0: ThrowStatement {
73+
. . . . . . . . . Roles: Throw,Statement
74+
. . . . . . . . . Properties: {
75+
. . . . . . . . . . internalRole: statements
76+
. . . . . . . . . }
77+
. . . . . . . . . Children: {
78+
. . . . . . . . . . 0: NullLiteral {
79+
. . . . . . . . . . . Roles: NullLiteral
80+
. . . . . . . . . . . TOKEN "null"
81+
. . . . . . . . . . . Properties: {
82+
. . . . . . . . . . . . internalRole: expression
83+
. . . . . . . . . . . }
84+
. . . . . . . . . . }
85+
. . . . . . . . . }
86+
. . . . . . . . }
87+
. . . . . . . }
88+
. . . . . . }
89+
. . . . . }
90+
. . . . }
91+
. . . }
92+
. . }
93+
. }
94+
}
95+

0 commit comments

Comments
 (0)