@@ -137,9 +137,9 @@ object JavaParsers {
137137 // ------------- general parsing ---------------------------
138138
139139 /** 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
143143 while ({
144144 in.token match {
145145 case LPAREN =>
@@ -161,6 +161,8 @@ object JavaParsers {
161161 ()
162162 }
163163
164+ def skipAhead (): Unit = skipAhead(0 ,0 )
165+
164166 def skipTo (tokens : Int * ): Unit =
165167 while (! (tokens contains in.token) && in.token != EOF )
166168 if (in.token == LBRACE ) { skipAhead(); accept(RBRACE ) }
@@ -329,20 +331,42 @@ object JavaParsers {
329331 }
330332
331333 def annotations (): List [Tree ] = {
332- // var annots = new ListBuffer[Tree]
334+ var annots = new ListBuffer [Tree ]
333335 while (in.token == AT ) {
334336 in.nextToken()
335- annotation()
337+ annotation() match {
338+ case Some (anno) => annots += anno
339+ case _ =>
340+ }
336341 }
337- List () // don't pass on annotations for now
342+ annots.toList
338343 }
339344
340345 /** Annotation ::= TypeName [`(` AnnotationArgument {`,` AnnotationArgument} `)`]
341346 */
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 )))
346370 }
347371
348372 def modifiers (inInterface : Boolean ): Modifiers = {
@@ -360,7 +384,10 @@ object JavaParsers {
360384 in.token match {
361385 case AT if (in.lookaheadToken != INTERFACE ) =>
362386 in.nextToken()
363- annotation()
387+ annotation() match {
388+ case Some (anno) => annots :+= anno
389+ case _ =>
390+ }
364391 case PUBLIC =>
365392 isPackageAccess = false
366393 in.nextToken()
0 commit comments