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

Commit 5435997

Browse files
Denys Smirnovdennwc
authored andcommitted
transform complex Javadoc into uast:Comment
Signed-off-by: Denys Smirnov <[email protected]>
1 parent eace9f9 commit 5435997

File tree

7 files changed

+84
-60
lines changed

7 files changed

+84
-60
lines changed

driver/normalizer/normalizer.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,30 @@ var Normalizers = []Mapping{
232232
},
233233
CommentNode(true, "comm", nil),
234234
)),
235+
236+
MapSemantic("Javadoc", uast.Group{}, MapObj(
237+
Obj{
238+
"tags": Var("parts"),
239+
},
240+
Obj{
241+
"Nodes": Var("parts"),
242+
},
243+
)),
244+
MapSemantic("TagElement", uast.Group{}, MapObj(
245+
Obj{
246+
"fragments": Var("parts"),
247+
"tagName": Is(nil),
248+
},
249+
Obj{
250+
"Nodes": Var("parts"),
251+
},
252+
)),
253+
MapSemantic("TextElement", uast.Comment{}, MapObj(
254+
Obj{
255+
"text": CommentText([2]string{"", ""}, "comm"),
256+
},
257+
CommentNode(false, "comm", nil),
258+
)),
235259
}
236260

237261
var argsPart = Each("args", UASTType(uast.Argument{}, Obj{

fixtures/javadoc.java.sem.uast

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@
7070
},
7171
bodyDeclarations: ~,
7272
interface: "false",
73-
javadoc: { '@type': "java:Javadoc",
74-
'@role': [Comment, Documentation],
73+
javadoc: { '@type': "uast:Group",
7574
'@pos': { '@type': "uast:Positions",
7675
start: { '@type': "uast:Position",
7776
offset: 0,
@@ -84,9 +83,8 @@
8483
col: 33,
8584
},
8685
},
87-
tags: [
88-
{ '@type': "java:TagElement",
89-
'@role': [Comment, Documentation, Incomplete],
86+
Nodes: [
87+
{ '@type': "uast:Group",
9088
'@pos': { '@type': "uast:Positions",
9189
start: { '@type': "uast:Position",
9290
offset: 4,
@@ -99,9 +97,8 @@
9997
col: 31,
10098
},
10199
},
102-
fragments: [
103-
{ '@type': "java:TextElement",
104-
'@role': [Comment, Documentation, Incomplete],
100+
Nodes: [
101+
{ '@type': "uast:Comment",
105102
'@pos': { '@type': "uast:Positions",
106103
start: { '@type': "uast:Position",
107104
offset: 4,
@@ -114,10 +111,13 @@
114111
col: 31,
115112
},
116113
},
117-
text: "This is a javadoc comment ",
114+
Block: false,
115+
Prefix: "",
116+
Suffix: " ",
117+
Tab: "",
118+
Text: "This is a javadoc comment",
118119
},
119120
],
120-
tagName: ~,
121121
},
122122
],
123123
},

fixtures/member_ref.java.sem.uast

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
},
4545
},
4646
Nodes: [
47-
{ '@type': "java:Javadoc",
48-
'@role': [Comment, Documentation],
47+
{ '@type': "uast:Group",
4948
'@pos': { '@type': "uast:Positions",
5049
start: { '@type': "uast:Position",
5150
offset: 15,
@@ -58,9 +57,8 @@
5857
col: 20,
5958
},
6059
},
61-
tags: [
62-
{ '@type': "java:TagElement",
63-
'@role': [Comment, Documentation, Incomplete],
60+
Nodes: [
61+
{ '@type': "uast:Group",
6462
'@pos': { '@type': "uast:Positions",
6563
start: { '@type': "uast:Position",
6664
offset: 19,
@@ -73,7 +71,7 @@
7371
col: 18,
7472
},
7573
},
76-
fragments: [
74+
Nodes: [
7775
{ '@type': "java:TagElement",
7876
'@role': [Comment, Documentation, Incomplete],
7977
'@pos': { '@type': "uast:Positions",
@@ -123,8 +121,7 @@
123121
],
124122
tagName: "@link",
125123
},
126-
{ '@type': "java:TextElement",
127-
'@role': [Comment, Documentation, Incomplete],
124+
{ '@type': "uast:Comment",
128125
'@pos': { '@type': "uast:Positions",
129126
start: { '@type': "uast:Position",
130127
offset: 29,
@@ -137,10 +134,13 @@
137134
col: 18,
138135
},
139136
},
140-
text: " ",
137+
Block: false,
138+
Prefix: " ",
139+
Suffix: "",
140+
Tab: "",
141+
Text: "",
141142
},
142143
],
143-
tagName: ~,
144144
},
145145
],
146146
},

fixtures/method_ref.java.sem.uast

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
},
4545
},
4646
Nodes: [
47-
{ '@type': "java:Javadoc",
48-
'@role': [Comment, Documentation],
47+
{ '@type': "uast:Group",
4948
'@pos': { '@type': "uast:Positions",
5049
start: { '@type': "uast:Position",
5150
offset: 15,
@@ -58,9 +57,8 @@
5857
col: 30,
5958
},
6059
},
61-
tags: [
62-
{ '@type': "java:TagElement",
63-
'@role': [Comment, Documentation, Incomplete],
60+
Nodes: [
61+
{ '@type': "uast:Group",
6462
'@pos': { '@type': "uast:Positions",
6563
start: { '@type': "uast:Position",
6664
offset: 19,
@@ -73,7 +71,7 @@
7371
col: 28,
7472
},
7573
},
76-
fragments: [
74+
Nodes: [
7775
{ '@type': "java:TagElement",
7876
'@role': [Comment, Documentation, Incomplete],
7977
'@pos': { '@type': "uast:Positions",
@@ -173,8 +171,7 @@
173171
],
174172
tagName: "@link",
175173
},
176-
{ '@type': "java:TextElement",
177-
'@role': [Comment, Documentation, Incomplete],
174+
{ '@type': "uast:Comment",
178175
'@pos': { '@type': "uast:Positions",
179176
start: { '@type': "uast:Position",
180177
offset: 39,
@@ -187,10 +184,13 @@
187184
col: 28,
188185
},
189186
},
190-
text: " ",
187+
Block: false,
188+
Prefix: " ",
189+
Suffix: "",
190+
Tab: "",
191+
Text: "",
191192
},
192193
],
193-
tagName: ~,
194194
},
195195
],
196196
},

fixtures/u2_class_doc.java.sem.uast

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
},
3232
bodyDeclarations: ~,
3333
interface: "false",
34-
javadoc: { '@type': "java:Javadoc",
35-
'@role': [Comment, Documentation],
34+
javadoc: { '@type': "uast:Group",
3635
'@pos': { '@type': "uast:Positions",
3736
start: { '@type': "uast:Position",
3837
offset: 0,
@@ -45,9 +44,8 @@
4544
col: 4,
4645
},
4746
},
48-
tags: [
49-
{ '@type': "java:TagElement",
50-
'@role': [Comment, Documentation, Incomplete],
47+
Nodes: [
48+
{ '@type': "uast:Group",
5149
'@pos': { '@type': "uast:Positions",
5250
start: { '@type': "uast:Position",
5351
offset: 7,
@@ -60,9 +58,8 @@
6058
col: 16,
6159
},
6260
},
63-
fragments: [
64-
{ '@type': "java:TextElement",
65-
'@role': [Comment, Documentation, Incomplete],
61+
Nodes: [
62+
{ '@type': "uast:Comment",
6663
'@pos': { '@type': "uast:Positions",
6764
start: { '@type': "uast:Position",
6865
offset: 7,
@@ -75,10 +72,13 @@
7572
col: 16,
7673
},
7774
},
78-
text: "Some javadoc",
75+
Block: false,
76+
Prefix: "",
77+
Suffix: "",
78+
Tab: "",
79+
Text: "Some javadoc",
7980
},
8081
],
81-
tagName: ~,
8282
},
8383
],
8484
},

fixtures/u2_func_doc.java.sem.uast

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
},
4545
},
4646
Nodes: [
47-
{ '@type': "java:Javadoc",
48-
'@role': [Comment, Documentation],
47+
{ '@type': "uast:Group",
4948
'@pos': { '@type': "uast:Positions",
5049
start: { '@type': "uast:Position",
5150
offset: 21,
@@ -58,9 +57,8 @@
5857
col: 8,
5958
},
6059
},
61-
tags: [
62-
{ '@type': "java:TagElement",
63-
'@role': [Comment, Documentation, Incomplete],
60+
Nodes: [
61+
{ '@type': "uast:Group",
6462
'@pos': { '@type': "uast:Positions",
6563
start: { '@type': "uast:Position",
6664
offset: 32,
@@ -73,9 +71,8 @@
7371
col: 23,
7472
},
7573
},
76-
fragments: [
77-
{ '@type': "java:TextElement",
78-
'@role': [Comment, Documentation, Incomplete],
74+
Nodes: [
75+
{ '@type': "uast:Comment",
7976
'@pos': { '@type': "uast:Positions",
8077
start: { '@type': "uast:Position",
8178
offset: 32,
@@ -88,10 +85,13 @@
8885
col: 23,
8986
},
9087
},
91-
text: "Javadoc comment",
88+
Block: false,
89+
Prefix: "",
90+
Suffix: "",
91+
Tab: "",
92+
Text: "Javadoc comment",
9293
},
9394
],
94-
tagName: ~,
9595
},
9696
],
9797
},

fixtures/u2_type_interface_doc.java.sem.uast

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
},
3232
bodyDeclarations: ~,
3333
interface: "true",
34-
javadoc: { '@type': "java:Javadoc",
35-
'@role': [Comment, Documentation],
34+
javadoc: { '@type': "uast:Group",
3635
'@pos': { '@type': "uast:Positions",
3736
start: { '@type': "uast:Position",
3837
offset: 0,
@@ -45,9 +44,8 @@
4544
col: 4,
4645
},
4746
},
48-
tags: [
49-
{ '@type': "java:TagElement",
50-
'@role': [Comment, Documentation, Incomplete],
47+
Nodes: [
48+
{ '@type': "uast:Group",
5149
'@pos': { '@type': "uast:Positions",
5250
start: { '@type': "uast:Position",
5351
offset: 7,
@@ -60,9 +58,8 @@
6058
col: 19,
6159
},
6260
},
63-
fragments: [
64-
{ '@type': "java:TextElement",
65-
'@role': [Comment, Documentation, Incomplete],
61+
Nodes: [
62+
{ '@type': "uast:Comment",
6663
'@pos': { '@type': "uast:Positions",
6764
start: { '@type': "uast:Position",
6865
offset: 7,
@@ -75,10 +72,13 @@
7572
col: 19,
7673
},
7774
},
78-
text: "Javadoc comment",
75+
Block: false,
76+
Prefix: "",
77+
Suffix: "",
78+
Tab: "",
79+
Text: "Javadoc comment",
7980
},
8081
],
81-
tagName: ~,
8282
},
8383
],
8484
},

0 commit comments

Comments
 (0)