Пример #1
0
  /*
   * operation? prefixExpression
   */
  private void parsePrefixExpression() {
    //        System.out.println("pre at "  + myBuilder.getTokenText());

    if (at(AT)) {
      if (!parseLocalDeclaration()) {
        PsiBuilder.Marker expression = mark();
        myJetParsing.parseAnnotations(DEFAULT);
        parsePrefixExpression();
        expression.done(ANNOTATED_EXPRESSION);
      }
    } else {
      myBuilder.disableJoiningComplexTokens();
      if (isAtLabelDefinitionOrMissingIdentifier()) {
        myBuilder.restoreJoiningComplexTokensState();
        parseLabeledExpression();
      } else if (atSet(Precedence.PREFIX.getOperations())) {
        PsiBuilder.Marker expression = mark();

        parseOperationReference();

        myBuilder.restoreJoiningComplexTokensState();

        parsePrefixExpression();
        expression.done(PREFIX_EXPRESSION);
      } else {
        myBuilder.restoreJoiningComplexTokensState();
        parsePostfixExpression();
      }
    }
  }
Пример #2
0
  /*
   * annotatedLambda
   *  : ("@" annotationEntry)* labelDefinition? functionLiteral
   */
  private boolean parseAnnotatedLambda(boolean preferBlock) {
    PsiBuilder.Marker annotated = mark();

    boolean wereAnnotations = myJetParsing.parseAnnotations(DEFAULT);
    PsiBuilder.Marker labeled = mark();

    boolean wasLabel = isAtLabelDefinitionOrMissingIdentifier();
    if (wasLabel) {
      parseLabelDefinition();
    }

    if (!at(LBRACE)) {
      annotated.rollbackTo();
      return false;
    }

    parseFunctionLiteral(preferBlock);

    doneOrDrop(labeled, LABELED_EXPRESSION, wasLabel);
    doneOrDrop(annotated, ANNOTATED_EXPRESSION, wereAnnotations);

    return true;
  }