@@ -137,9 +137,9 @@ object JavaParsers {
137
137
// ------------- general parsing ---------------------------
138
138
139
139
/** skip parent or brace enclosed sequence of things */
140
- def skipAhead (): Unit = {
141
- var nparens = 0
142
- var nbraces = 0
140
+ def skipAhead (initnparens : Int , initnbraces : Int ): Unit = {
141
+ var nparens = initnparens
142
+ var nbraces = initnbraces
143
143
while ({
144
144
in.token match {
145
145
case LPAREN =>
@@ -161,6 +161,8 @@ object JavaParsers {
161
161
()
162
162
}
163
163
164
+ def skipAhead (): Unit = skipAhead(0 ,0 )
165
+
164
166
def skipTo (tokens : Int * ): Unit =
165
167
while (! (tokens contains in.token) && in.token != EOF )
166
168
if (in.token == LBRACE ) { skipAhead(); accept(RBRACE ) }
@@ -329,20 +331,42 @@ object JavaParsers {
329
331
}
330
332
331
333
def annotations (): List [Tree ] = {
332
- // var annots = new ListBuffer[Tree]
334
+ var annots = new ListBuffer [Tree ]
333
335
while (in.token == AT ) {
334
336
in.nextToken()
335
- annotation()
337
+ annotation() match {
338
+ case Some (anno) => annots += anno
339
+ case _ =>
340
+ }
336
341
}
337
- List () // don't pass on annotations for now
342
+ annots.toList
338
343
}
339
344
340
345
/** Annotation ::= TypeName [`(` AnnotationArgument {`,` AnnotationArgument} `)`]
341
346
*/
342
- def annotation (): Unit = {
343
- qualId()
344
- if (in.token == LPAREN ) { skipAhead(); accept(RPAREN ) }
345
- else if (in.token == LBRACE ) { skipAhead(); accept(RBRACE ) }
347
+ def annotation (): Option [Tree ] = {
348
+ val id = convertToTypeId(qualId())
349
+ var skipAnno = false
350
+
351
+ // only parse annotations without arguments
352
+ if (in.token == LPAREN ) {
353
+ in.nextToken()
354
+ if (in.token != RPAREN ) {
355
+ skipAnno = true
356
+ skipAhead(1 , 0 )
357
+ }
358
+ accept(RPAREN )
359
+ } else if (in.token == LBRACE ) {
360
+ in.nextToken()
361
+ if (in.token != RBRACE ) {
362
+ skipAnno = true
363
+ skipAhead(0 , 1 )
364
+ }
365
+ accept(RBRACE )
366
+ }
367
+
368
+ if (skipAnno) None
369
+ else Some (ensureApplied(Select (New (id), nme.CONSTRUCTOR )))
346
370
}
347
371
348
372
def modifiers (inInterface : Boolean ): Modifiers = {
@@ -360,7 +384,10 @@ object JavaParsers {
360
384
in.token match {
361
385
case AT if (in.lookaheadToken != INTERFACE ) =>
362
386
in.nextToken()
363
- annotation()
387
+ annotation() match {
388
+ case Some (anno) => annots :+= anno
389
+ case _ =>
390
+ }
364
391
case PUBLIC =>
365
392
isPackageAccess = false
366
393
in.nextToken()
0 commit comments