@@ -2,6 +2,7 @@ package test
2
2
3
3
import dotty .tools .dotc .core .Contexts .Context
4
4
import dotty .tools .dotc .ast .Trees ._
5
+ import dotty .tools .dotc .parsing .Parsers .Comment
5
6
6
7
import org .junit .Assert ._
7
8
import org .junit .Test
@@ -31,7 +32,7 @@ class DottyDocParsingTests extends DottyTest {
31
32
32
33
checkFrontend(source) {
33
34
case PackageDef (_, Seq (c : TypeDef )) =>
34
- assert(c.rawComment == None , " Should not have a comment, mainly used for exhaustive tests" )
35
+ assert(c.getAttachment( Comment ) == None , " Should not have a comment, mainly used for exhaustive tests" )
35
36
}
36
37
}
37
38
@@ -46,7 +47,7 @@ class DottyDocParsingTests extends DottyTest {
46
47
47
48
checkFrontend(source) {
48
49
case PackageDef (_, Seq (t @ TypeDef (name, _))) if name.toString == " Class" =>
49
- checkDocString(t.rawComment , " /** Hello world! */" )
50
+ checkDocString(t.getAttachment( Comment ) , " /** Hello world! */" )
50
51
}
51
52
}
52
53
@@ -61,7 +62,7 @@ class DottyDocParsingTests extends DottyTest {
61
62
62
63
checkFrontend(source) {
63
64
case PackageDef (_, Seq (t @ TypeDef (name, _))) if name.toString == " Class" =>
64
- checkDocString(t.rawComment , " /** Hello /* multiple open */ world! */" )
65
+ checkDocString(t.getAttachment( Comment ) , " /** Hello /* multiple open */ world! */" )
65
66
}
66
67
}
67
68
@ Test def multipleClassesInPackage () = {
@@ -79,8 +80,8 @@ class DottyDocParsingTests extends DottyTest {
79
80
checkCompile(" frontend" , source) { (_, ctx) =>
80
81
ctx.compilationUnit.untpdTree match {
81
82
case PackageDef (_, Seq (c1 @ TypeDef (_,_), c2 @ TypeDef (_,_))) => {
82
- checkDocString(c1.rawComment , " /** Class1 docstring */" )
83
- checkDocString(c2.rawComment , " /** Class2 docstring */" )
83
+ checkDocString(c1.getAttachment( Comment ) , " /** Class1 docstring */" )
84
+ checkDocString(c2.getAttachment( Comment ) , " /** Class2 docstring */" )
84
85
}
85
86
}
86
87
}
@@ -94,15 +95,15 @@ class DottyDocParsingTests extends DottyTest {
94
95
""" .stripMargin
95
96
96
97
checkFrontend(source) {
97
- case PackageDef (_, Seq (t @ TypeDef (_,_))) => checkDocString(t.rawComment , " /** Class without package */" )
98
+ case PackageDef (_, Seq (t @ TypeDef (_,_))) => checkDocString(t.getAttachment( Comment ) , " /** Class without package */" )
98
99
}
99
100
}
100
101
101
102
@ Test def SingleTraitWihoutPackage () = {
102
103
val source = " /** Trait docstring */\n trait Trait"
103
104
104
105
checkFrontend(source) {
105
- case PackageDef (_, Seq (t @ TypeDef (_,_))) => checkDocString(t.rawComment , " /** Trait docstring */" )
106
+ case PackageDef (_, Seq (t @ TypeDef (_,_))) => checkDocString(t.getAttachment( Comment ) , " /** Trait docstring */" )
106
107
}
107
108
}
108
109
@@ -118,8 +119,8 @@ class DottyDocParsingTests extends DottyTest {
118
119
119
120
checkFrontend(source) {
120
121
case PackageDef (_, Seq (t1 @ TypeDef (_,_), t2 @ TypeDef (_,_))) => {
121
- checkDocString(t1.rawComment , " /** Trait1 docstring */" )
122
- checkDocString(t2.rawComment , " /** Trait2 docstring */" )
122
+ checkDocString(t1.getAttachment( Comment ) , " /** Trait1 docstring */" )
123
+ checkDocString(t2.getAttachment( Comment ) , " /** Trait2 docstring */" )
123
124
}
124
125
}
125
126
}
@@ -144,10 +145,10 @@ class DottyDocParsingTests extends DottyTest {
144
145
145
146
checkFrontend(source) {
146
147
case PackageDef (_, Seq (t1 @ TypeDef (_,_), c2 @ TypeDef (_,_), cc3 @ TypeDef (_,_), _, ac4 @ TypeDef (_,_))) => {
147
- checkDocString(t1.rawComment , " /** Trait1 docstring */" )
148
- checkDocString(c2.rawComment , " /** Class2 docstring */" )
149
- checkDocString(cc3.rawComment , " /** CaseClass3 docstring */" )
150
- checkDocString(ac4.rawComment , " /** AbstractClass4 docstring */" )
148
+ checkDocString(t1.getAttachment( Comment ) , " /** Trait1 docstring */" )
149
+ checkDocString(c2.getAttachment( Comment ) , " /** Class2 docstring */" )
150
+ checkDocString(cc3.getAttachment( Comment ) , " /** CaseClass3 docstring */" )
151
+ checkDocString(ac4.getAttachment( Comment ) , " /** AbstractClass4 docstring */" )
151
152
}
152
153
}
153
154
}
@@ -164,9 +165,9 @@ class DottyDocParsingTests extends DottyTest {
164
165
165
166
checkFrontend(source) {
166
167
case PackageDef (_, Seq (outer @ TypeDef (_, tpl @ Template (_,_,_,_)))) => {
167
- checkDocString(outer.rawComment , " /** Outer docstring */" )
168
+ checkDocString(outer.getAttachment( Comment ) , " /** Outer docstring */" )
168
169
tpl.body match {
169
- case (inner @ TypeDef (_,_)) :: _ => checkDocString(inner.rawComment , " /** Inner docstring */" )
170
+ case (inner @ TypeDef (_,_)) :: _ => checkDocString(inner.getAttachment( Comment ) , " /** Inner docstring */" )
170
171
case _ => assert(false , " Couldn't find inner class" )
171
172
}
172
173
}
@@ -188,10 +189,10 @@ class DottyDocParsingTests extends DottyTest {
188
189
189
190
checkFrontend(source) {
190
191
case PackageDef (_, Seq (o1 @ TypeDef (_, tpl @ Template (_,_,_,_)), o2 @ TypeDef (_,_))) => {
191
- checkDocString(o1.rawComment , " /** Outer1 docstring */" )
192
- checkDocString(o2.rawComment , " /** Outer2 docstring */" )
192
+ checkDocString(o1.getAttachment( Comment ) , " /** Outer1 docstring */" )
193
+ checkDocString(o2.getAttachment( Comment ) , " /** Outer2 docstring */" )
193
194
tpl.body match {
194
- case (inner @ TypeDef (_,_)) :: _ => checkDocString(inner.rawComment , " /** Inner docstring */" )
195
+ case (inner @ TypeDef (_,_)) :: _ => checkDocString(inner.getAttachment( Comment ) , " /** Inner docstring */" )
195
196
case _ => assert(false , " Couldn't find inner class" )
196
197
}
197
198
}
@@ -213,9 +214,9 @@ class DottyDocParsingTests extends DottyTest {
213
214
checkFrontend(source) {
214
215
case p @ PackageDef (_, Seq (o1 : MemberDef [Untyped ], o2 : MemberDef [Untyped ])) => {
215
216
assertEquals(o1.name.toString, " Object1" )
216
- checkDocString(o1.rawComment , " /** Object1 docstring */" )
217
+ checkDocString(o1.getAttachment( Comment ) , " /** Object1 docstring */" )
217
218
assertEquals(o2.name.toString, " Object2" )
218
- checkDocString(o2.rawComment , " /** Object2 docstring */" )
219
+ checkDocString(o2.getAttachment( Comment ) , " /** Object2 docstring */" )
219
220
}
220
221
}
221
222
}
@@ -240,12 +241,12 @@ class DottyDocParsingTests extends DottyTest {
240
241
checkFrontend(source) {
241
242
case p @ PackageDef (_, Seq (o1 : ModuleDef , o2 : ModuleDef )) => {
242
243
assert(o1.name.toString == " Object1" )
243
- checkDocString(o1.rawComment , " /** Object1 docstring */" )
244
+ checkDocString(o1.getAttachment( Comment ) , " /** Object1 docstring */" )
244
245
assert(o2.name.toString == " Object2" )
245
- checkDocString(o2.rawComment , " /** Object2 docstring */" )
246
+ checkDocString(o2.getAttachment( Comment ) , " /** Object2 docstring */" )
246
247
247
248
o2.impl.body match {
248
- case _ :: (inner @ TypeDef (_,_)) :: _ => checkDocString(inner.rawComment , " /** Inner docstring */" )
249
+ case _ :: (inner @ TypeDef (_,_)) :: _ => checkDocString(inner.getAttachment( Comment ) , " /** Inner docstring */" )
249
250
case _ => assert(false , " Couldn't find inner class" )
250
251
}
251
252
}
@@ -274,14 +275,14 @@ class DottyDocParsingTests extends DottyTest {
274
275
import dotty .tools .dotc .ast .untpd ._
275
276
checkFrontend(source) {
276
277
case PackageDef (_, Seq (p : ModuleDef )) => {
277
- checkDocString(p.rawComment , " /** Package object docstring */" )
278
+ checkDocString(p.getAttachment( Comment ) , " /** Package object docstring */" )
278
279
279
280
p.impl.body match {
280
281
case (b : TypeDef ) :: (t : TypeDef ) :: (o : ModuleDef ) :: Nil => {
281
- checkDocString(b.rawComment , " /** Boo docstring */" )
282
- checkDocString(t.rawComment , " /** Trait docstring */" )
283
- checkDocString(o.rawComment , " /** InnerObject docstring */" )
284
- checkDocString(o.impl.body.head.asInstanceOf [TypeDef ].rawComment , " /** InnerClass docstring */" )
282
+ checkDocString(b.getAttachment( Comment ) , " /** Boo docstring */" )
283
+ checkDocString(t.getAttachment( Comment ) , " /** Trait docstring */" )
284
+ checkDocString(o.getAttachment( Comment ) , " /** InnerObject docstring */" )
285
+ checkDocString(o.impl.body.head.asInstanceOf [TypeDef ].getAttachment( Comment ) , " /** InnerClass docstring */" )
285
286
}
286
287
case _ => assert(false , " Incorrect structure inside package object" )
287
288
}
@@ -301,7 +302,7 @@ class DottyDocParsingTests extends DottyTest {
301
302
import dotty .tools .dotc .ast .untpd ._
302
303
checkFrontend(source) {
303
304
case PackageDef (_, Seq (c : TypeDef )) =>
304
- checkDocString(c.rawComment , " /** Real comment */" )
305
+ checkDocString(c.getAttachment( Comment ) , " /** Real comment */" )
305
306
}
306
307
}
307
308
@@ -320,7 +321,7 @@ class DottyDocParsingTests extends DottyTest {
320
321
import dotty .tools .dotc .ast .untpd ._
321
322
checkFrontend(source) {
322
323
case PackageDef (_, Seq (c : TypeDef )) =>
323
- checkDocString(c.rawComment , " /** Real comment */" )
324
+ checkDocString(c.getAttachment( Comment ) , " /** Real comment */" )
324
325
}
325
326
}
326
327
@@ -346,9 +347,9 @@ class DottyDocParsingTests extends DottyTest {
346
347
case PackageDef (_, Seq (o : ModuleDef )) => {
347
348
o.impl.body match {
348
349
case (v1 : MemberDef ) :: (v2 : MemberDef ) :: (v3 : MemberDef ) :: Nil => {
349
- checkDocString(v1.rawComment , " /** val1 */" )
350
- checkDocString(v2.rawComment , " /** val2 */" )
351
- checkDocString(v3.rawComment , " /** val3 */" )
350
+ checkDocString(v1.getAttachment( Comment ) , " /** val1 */" )
351
+ checkDocString(v2.getAttachment( Comment ) , " /** val2 */" )
352
+ checkDocString(v3.getAttachment( Comment ) , " /** val3 */" )
352
353
}
353
354
case _ => assert(false , " Incorrect structure inside object" )
354
355
}
@@ -378,9 +379,9 @@ class DottyDocParsingTests extends DottyTest {
378
379
case PackageDef (_, Seq (o : ModuleDef )) => {
379
380
o.impl.body match {
380
381
case (v1 : MemberDef ) :: (v2 : MemberDef ) :: (v3 : MemberDef ) :: Nil => {
381
- checkDocString(v1.rawComment , " /** var1 */" )
382
- checkDocString(v2.rawComment , " /** var2 */" )
383
- checkDocString(v3.rawComment , " /** var3 */" )
382
+ checkDocString(v1.getAttachment( Comment ) , " /** var1 */" )
383
+ checkDocString(v2.getAttachment( Comment ) , " /** var2 */" )
384
+ checkDocString(v3.getAttachment( Comment ) , " /** var3 */" )
384
385
}
385
386
case _ => assert(false , " Incorrect structure inside object" )
386
387
}
@@ -410,9 +411,9 @@ class DottyDocParsingTests extends DottyTest {
410
411
case PackageDef (_, Seq (o : ModuleDef )) => {
411
412
o.impl.body match {
412
413
case (v1 : MemberDef ) :: (v2 : MemberDef ) :: (v3 : MemberDef ) :: Nil => {
413
- checkDocString(v1.rawComment , " /** def1 */" )
414
- checkDocString(v2.rawComment , " /** def2 */" )
415
- checkDocString(v3.rawComment , " /** def3 */" )
414
+ checkDocString(v1.getAttachment( Comment ) , " /** def1 */" )
415
+ checkDocString(v2.getAttachment( Comment ) , " /** def2 */" )
416
+ checkDocString(v3.getAttachment( Comment ) , " /** def3 */" )
416
417
}
417
418
case _ => assert(false , " Incorrect structure inside object" )
418
419
}
@@ -442,9 +443,9 @@ class DottyDocParsingTests extends DottyTest {
442
443
case PackageDef (_, Seq (o : ModuleDef )) => {
443
444
o.impl.body match {
444
445
case (v1 : MemberDef ) :: (v2 : MemberDef ) :: (v3 : MemberDef ) :: Nil => {
445
- checkDocString(v1.rawComment , " /** type1 */" )
446
- checkDocString(v2.rawComment , " /** type2 */" )
447
- checkDocString(v3.rawComment , " /** type3 */" )
446
+ checkDocString(v1.getAttachment( Comment ) , " /** type1 */" )
447
+ checkDocString(v2.getAttachment( Comment ) , " /** type2 */" )
448
+ checkDocString(v3.getAttachment( Comment ) , " /** type3 */" )
448
449
}
449
450
case _ => assert(false , " Incorrect structure inside object" )
450
451
}
0 commit comments