@@ -138,9 +138,9 @@ object JavaParsers {
138138 // ------------- general parsing ---------------------------
139139
140140 /** skip parent or brace enclosed sequence of things */
141- def skipAhead (): Unit = {
142- var nparens = 0
143- var nbraces = 0
141+ def skipAhead (initnparens : Int , initnbraces : Int ): Unit = {
142+ var nparens = initnparens
143+ var nbraces = initnbraces
144144 do {
145145 in.token match {
146146 case LPAREN =>
@@ -160,6 +160,8 @@ object JavaParsers {
160160 } while (in.token != EOF && (nparens > 0 || nbraces > 0 ))
161161 }
162162
163+ def skipAhead (): Unit = skipAhead(0 ,0 )
164+
163165 def skipTo (tokens : Int * ): Unit = {
164166 while (! (tokens contains in.token) && in.token != EOF ) {
165167 if (in.token == LBRACE ) { skipAhead(); accept(RBRACE ) }
@@ -327,20 +329,42 @@ object JavaParsers {
327329 }
328330
329331 def annotations (): List [Tree ] = {
330- // var annots = new ListBuffer[Tree]
332+ var annots = new ListBuffer [Tree ]
331333 while (in.token == AT ) {
332334 in.nextToken()
333- annotation()
335+ annotation() match {
336+ case Some (anno) => annots += anno
337+ case _ =>
338+ }
334339 }
335- List () // don't pass on annotations for now
340+ annots.toList
336341 }
337342
338343 /** Annotation ::= TypeName [`(` AnnotationArgument {`,` AnnotationArgument} `)`]
339344 */
340- def annotation (): Unit = {
341- qualId()
342- if (in.token == LPAREN ) { skipAhead(); accept(RPAREN ) }
343- else if (in.token == LBRACE ) { skipAhead(); accept(RBRACE ) }
345+ def annotation (): Option [Tree ] = {
346+ val id = convertToTypeId(qualId())
347+ var skipAnno = false
348+
349+ // only parse annotations without arguments
350+ if (in.token == LPAREN ) {
351+ in.nextToken()
352+ if (in.token != RPAREN ) {
353+ skipAnno = true
354+ skipAhead(1 , 0 )
355+ }
356+ accept(RPAREN )
357+ } else if (in.token == LBRACE ) {
358+ in.nextToken()
359+ if (in.token != RBRACE ) {
360+ skipAnno = true
361+ skipAhead(0 , 1 )
362+ }
363+ accept(RBRACE )
364+ }
365+
366+ if (skipAnno) None
367+ else Some (ensureApplied(Select (New (id), nme.CONSTRUCTOR )))
344368 }
345369
346370 def modifiers (inInterface : Boolean ): Modifiers = {
@@ -358,7 +382,10 @@ object JavaParsers {
358382 in.token match {
359383 case AT if (in.lookaheadToken != INTERFACE ) =>
360384 in.nextToken()
361- annotation()
385+ annotation() match {
386+ case Some (anno) => annots :+= anno
387+ case _ =>
388+ }
362389 case PUBLIC =>
363390 isPackageAccess = false
364391 in.nextToken()
0 commit comments