Ejemplo n.º 1
0
  /*
   * annotation
   *   : "[" annotationEntry+ "]"
   *   : annotationEntry
   *   ;
   */
  private boolean parseAnnotation(boolean allowShortAnnotations) {
    if (at(LBRACKET)) {
      PsiBuilder.Marker annotation = mark();

      myBuilder.disableNewlines();
      advance(); // LBRACKET

      if (!at(IDENTIFIER)) {
        error("Expecting a list of attributes");
      } else {
        parseAnnotationEntry();
        while (at(COMMA)) {
          errorAndAdvance("No commas needed to separate attributes");
        }

        while (at(IDENTIFIER)) {
          parseAnnotationEntry();
          while (at(COMMA)) {
            errorAndAdvance("No commas needed to separate attributes");
          }
        }
      }

      expect(RBRACKET, "Expecting ']' to close an attribute annotation");
      myBuilder.restoreNewlinesState();

      annotation.done(ANNOTATION);
      return true;
    } else if (allowShortAnnotations && at(IDENTIFIER)) {
      parseAnnotationEntry();
      return true;
    }
    return false;
  }