Пример #1
0
  /*
   * callSuffix
   *   : typeArguments? valueArguments annotatedLambda
   *   : typeArguments annotatedLambda
   *   ;
   */
  private boolean parseCallSuffix() {
    if (parseCallWithClosure()) {
      // do nothing
    } else if (at(LPAR)) {
      parseValueArgumentList();
      parseCallWithClosure();
    } else if (at(LT)) {
      PsiBuilder.Marker typeArgumentList = mark();
      if (myJetParsing.tryParseTypeArgumentList(TYPE_ARGUMENT_LIST_STOPPERS)) {
        typeArgumentList.done(TYPE_ARGUMENT_LIST);
        if (!myBuilder.newlineBeforeCurrentToken() && at(LPAR)) parseValueArgumentList();
        parseCallWithClosure();
      } else {
        typeArgumentList.rollbackTo();
        return false;
      }
    } else {
      return false;
    }

    return true;
  }
Пример #2
0
  /*
   * callableReference
   *   : (userType "?"*)? "::" SimpleName typeArguments?
   *   ;
   */
  private boolean parseDoubleColonExpression() {
    PsiBuilder.Marker expression = mark();

    if (!at(COLONCOLON)) {
      PsiBuilder.Marker typeReference = mark();
      myJetParsing.parseUserType();
      typeReference = myJetParsing.parseNullableTypeSuffix(typeReference);
      typeReference.done(TYPE_REFERENCE);

      if (!at(COLONCOLON)) {
        expression.rollbackTo();
        return false;
      }
    }

    advance(); // COLONCOLON

    if (at(CLASS_KEYWORD)) {
      advance(); // CLASS_KEYWORD
      expression.done(CLASS_LITERAL_EXPRESSION);
    } else {
      parseSimpleNameExpression();

      if (at(LT)) {
        PsiBuilder.Marker typeArgumentList = mark();
        if (myJetParsing.tryParseTypeArgumentList(TYPE_ARGUMENT_LIST_STOPPERS)) {
          typeArgumentList.error("Type arguments are not allowed");
        } else {
          typeArgumentList.rollbackTo();
        }
      }

      expression.done(CALLABLE_REFERENCE_EXPRESSION);
    }

    return true;
  }