private boolean parseValueParameter(boolean rollbackOnFailure) { PsiBuilder.Marker parameter = mark(); parseModifierListWithShortAnnotations( MODIFIER_LIST, TokenSet.create(IDENTIFIER), TokenSet.create(COMMA, RPAR, COLON)); if (at(VAR_KEYWORD) || at(VAL_KEYWORD)) { advance(); // VAR_KEYWORD | VAL_KEYWORD } if (!parseFunctionParameterRest() && rollbackOnFailure) { parameter.rollbackTo(); return false; } parameter.done(VALUE_PARAMETER); return true; }
/* * typeParameter * : modifiers SimpleName (":" userType)? * ; */ private void parseTypeParameter() { if (atSet(TYPE_PARAMETER_GT_RECOVERY_SET)) { error("Type parameter declaration expected"); return; } PsiBuilder.Marker mark = mark(); parseModifierListWithShortAnnotations( MODIFIER_LIST, TokenSet.create(IDENTIFIER), TokenSet.create(COMMA, GT, COLON)); expect(IDENTIFIER, "Type parameter name expected", TokenSet.EMPTY); if (at(COLON)) { advance(); // COLON parseTypeRef(); } mark.done(TYPE_PARAMETER); }
/* * getterOrSetter * : modifiers ("get" | "set") * : * ( "get" "(" ")" * | * "set" "(" modifiers parameter ")" * ) functionBody * ; */ private boolean parsePropertyGetterOrSetter() { PsiBuilder.Marker getterOrSetter = mark(); parseModifierList(MODIFIER_LIST, false); if (!at(GET_KEYWORD) && !at(SET_KEYWORD)) { getterOrSetter.rollbackTo(); return false; } boolean setter = at(SET_KEYWORD); advance(); // GET_KEYWORD or SET_KEYWORD if (!at(LPAR)) { // Account for Jet-114 (val a : int get {...}) TokenSet ACCESSOR_FIRST_OR_PROPERTY_END = TokenSet.orSet( MODIFIER_KEYWORDS, TokenSet.create(LBRACKET, GET_KEYWORD, SET_KEYWORD, EOL_OR_SEMICOLON, RBRACE)); if (!atSet(ACCESSOR_FIRST_OR_PROPERTY_END)) { errorUntil( "Accessor body expected", TokenSet.orSet(ACCESSOR_FIRST_OR_PROPERTY_END, TokenSet.create(LBRACE, LPAR, EQ))); } else { getterOrSetter.done(PROPERTY_ACCESSOR); return true; } } myBuilder.disableNewlines(); expect(LPAR, "Expecting '('", TokenSet.create(RPAR, IDENTIFIER, COLON, LBRACE, EQ)); if (setter) { PsiBuilder.Marker parameterList = mark(); PsiBuilder.Marker setterParameter = mark(); parseModifierListWithShortAnnotations( MODIFIER_LIST, TokenSet.create(IDENTIFIER), TokenSet.create(RPAR, COMMA, COLON)); expect(IDENTIFIER, "Expecting parameter name", TokenSet.create(RPAR, COLON, LBRACE, EQ)); if (at(COLON)) { advance(); // COLON parseTypeRef(); } setterParameter.done(VALUE_PARAMETER); parameterList.done(VALUE_PARAMETER_LIST); } if (!at(RPAR)) errorUntil("Expecting ')'", TokenSet.create(RPAR, COLON, LBRACE, EQ, EOL_OR_SEMICOLON)); expect(RPAR, "Expecting ')'", TokenSet.create(RPAR, COLON, LBRACE, EQ)); myBuilder.restoreNewlinesState(); if (at(COLON)) { advance(); parseTypeRef(); } parseFunctionBody(); getterOrSetter.done(PROPERTY_ACCESSOR); return true; }