Parsing: Drop redundant parameter as it always has the same value

This commit is contained in:
Denis Zharkov
2015-03-30 17:43:03 +03:00
parent af2bcfb524
commit cafa018066
2 changed files with 14 additions and 16 deletions
@@ -792,7 +792,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
int valPos = matchTokenStreamPredicate(new FirstBefore(new At(VAL_KEYWORD), new AtSet(RPAR, LBRACE, RBRACE, SEMICOLON, EQ))); int valPos = matchTokenStreamPredicate(new FirstBefore(new At(VAL_KEYWORD), new AtSet(RPAR, LBRACE, RBRACE, SEMICOLON, EQ)));
if (valPos >= 0) { if (valPos >= 0) {
PsiBuilder.Marker property = mark(); PsiBuilder.Marker property = mark();
myJetParsing.parseModifierList(MODIFIER_LIST, REGULAR_ANNOTATIONS_ALLOW_SHORTS); myJetParsing.parseModifierList(REGULAR_ANNOTATIONS_ALLOW_SHORTS);
myJetParsing.parseProperty(true); myJetParsing.parseProperty(true);
property.done(PROPERTY); property.done(PROPERTY);
} }
@@ -976,7 +976,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
private boolean parseLocalDeclaration() { private boolean parseLocalDeclaration() {
PsiBuilder.Marker decl = mark(); PsiBuilder.Marker decl = mark();
JetParsing.ModifierDetector detector = new JetParsing.ModifierDetector(); JetParsing.ModifierDetector detector = new JetParsing.ModifierDetector();
myJetParsing.parseModifierList(MODIFIER_LIST, detector, REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS); myJetParsing.parseModifierList(detector, REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS);
IElementType declType = parseLocalDeclarationRest(detector.isEnumDetected()); IElementType declType = parseLocalDeclarationRest(detector.isEnumDetected());
@@ -1221,7 +1221,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
PsiBuilder.Marker parameter = mark(); PsiBuilder.Marker parameter = mark();
int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtSet(COMMA, RPAR, COLON, ARROW, RBRACE, LBRACE))); int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtSet(COMMA, RPAR, COLON, ARROW, RBRACE, LBRACE)));
createTruncatedBuilder(parameterNamePos).parseModifierList(MODIFIER_LIST, REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS); createTruncatedBuilder(parameterNamePos).parseModifierList(REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS);
expect(IDENTIFIER, "Expecting parameter declaration"); expect(IDENTIFIER, "Expecting parameter declaration");
@@ -191,7 +191,7 @@ public class JetParsing extends AbstractJetParsing {
* ; * ;
*/ */
PsiBuilder.Marker packageDirective = mark(); PsiBuilder.Marker packageDirective = mark();
parseModifierList(MODIFIER_LIST, REGULAR_ANNOTATIONS_ALLOW_SHORTS); parseModifierList(REGULAR_ANNOTATIONS_ALLOW_SHORTS);
if (at(PACKAGE_KEYWORD)) { if (at(PACKAGE_KEYWORD)) {
advance(); // PACKAGE_KEYWORD advance(); // PACKAGE_KEYWORD
@@ -372,7 +372,7 @@ public class JetParsing extends AbstractJetParsing {
PsiBuilder.Marker decl = mark(); PsiBuilder.Marker decl = mark();
ModifierDetector detector = new ModifierDetector(); ModifierDetector detector = new ModifierDetector();
parseModifierList(MODIFIER_LIST, detector, REGULAR_ANNOTATIONS_ALLOW_SHORTS); parseModifierList(detector, REGULAR_ANNOTATIONS_ALLOW_SHORTS);
IElementType keywordToken = tt(); IElementType keywordToken = tt();
IElementType declType = null; IElementType declType = null;
@@ -410,10 +410,9 @@ public class JetParsing extends AbstractJetParsing {
* (modifier | annotation)* * (modifier | annotation)*
*/ */
boolean parseModifierList( boolean parseModifierList(
@NotNull IElementType nodeType,
@NotNull AnnotationParsingMode annotationParsingMode @NotNull AnnotationParsingMode annotationParsingMode
) { ) {
return parseModifierList(nodeType, null, annotationParsingMode); return parseModifierList(null, annotationParsingMode);
} }
/** /**
@@ -422,7 +421,6 @@ public class JetParsing extends AbstractJetParsing {
* Feeds modifiers (not annotations) into the passed consumer, if it is not null * Feeds modifiers (not annotations) into the passed consumer, if it is not null
*/ */
boolean parseModifierList( boolean parseModifierList(
@NotNull IElementType nodeType,
@Nullable Consumer<IElementType> tokenConsumer, @Nullable Consumer<IElementType> tokenConsumer,
@NotNull AnnotationParsingMode annotationParsingMode @NotNull AnnotationParsingMode annotationParsingMode
) { ) {
@@ -448,7 +446,7 @@ public class JetParsing extends AbstractJetParsing {
list.drop(); list.drop();
} }
else { else {
list.done(nodeType); list.done(MODIFIER_LIST);
} }
return !empty; return !empty;
} }
@@ -627,7 +625,7 @@ public class JetParsing extends AbstractJetParsing {
OptionalMarker constructorModifiersMarker = new OptionalMarker(object); OptionalMarker constructorModifiersMarker = new OptionalMarker(object);
PsiBuilder.Marker beforeConstructorModifiers = mark(); PsiBuilder.Marker beforeConstructorModifiers = mark();
PsiBuilder.Marker primaryConstructorMarker = mark(); PsiBuilder.Marker primaryConstructorMarker = mark();
boolean hasConstructorModifiers = parseModifierList(MODIFIER_LIST, REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS); boolean hasConstructorModifiers = parseModifierList(REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS);
// Some modifiers found, but no parentheses following: class has already ended, and we are looking at something else // Some modifiers found, but no parentheses following: class has already ended, and we are looking at something else
if (hasConstructorModifiers && !atSet(LPAR, LBRACE, COLON)) { if (hasConstructorModifiers && !atSet(LPAR, LBRACE, COLON)) {
@@ -709,7 +707,7 @@ public class JetParsing extends AbstractJetParsing {
TokenSet constructorNameFollow = TokenSet.create(SEMICOLON, COLON, LPAR, LT, LBRACE); TokenSet constructorNameFollow = TokenSet.create(SEMICOLON, COLON, LPAR, LT, LBRACE);
int lastId = findLastBefore(ENUM_MEMBER_FIRST, constructorNameFollow, false); int lastId = findLastBefore(ENUM_MEMBER_FIRST, constructorNameFollow, false);
ModifierDetector detector = new ModifierDetector(); ModifierDetector detector = new ModifierDetector();
createTruncatedBuilder(lastId).parseModifierList(MODIFIER_LIST, detector, REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS); createTruncatedBuilder(lastId).parseModifierList(detector, REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS);
IElementType type; IElementType type;
if (!atSet(SOFT_KEYWORDS_AT_MEMBER_START) && at(IDENTIFIER)) { if (!atSet(SOFT_KEYWORDS_AT_MEMBER_START) && at(IDENTIFIER)) {
@@ -806,7 +804,7 @@ public class JetParsing extends AbstractJetParsing {
PsiBuilder.Marker decl = mark(); PsiBuilder.Marker decl = mark();
ModifierDetector detector = new ModifierDetector(); ModifierDetector detector = new ModifierDetector();
parseModifierList(MODIFIER_LIST, detector, REGULAR_ANNOTATIONS_ALLOW_SHORTS_AT_MEMBER_MODIFIER_LIST); parseModifierList(detector, REGULAR_ANNOTATIONS_ALLOW_SHORTS_AT_MEMBER_MODIFIER_LIST);
IElementType declType = parseMemberDeclarationRest(detector.isEnumDetected(), detector.isDefaultDetected()); IElementType declType = parseMemberDeclarationRest(detector.isEnumDetected(), detector.isDefaultDetected());
@@ -1175,7 +1173,7 @@ public class JetParsing extends AbstractJetParsing {
private boolean parsePropertyGetterOrSetter() { private boolean parsePropertyGetterOrSetter() {
PsiBuilder.Marker getterOrSetter = mark(); PsiBuilder.Marker getterOrSetter = mark();
parseModifierList(MODIFIER_LIST, REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS); parseModifierList(REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS);
if (!at(GET_KEYWORD) && !at(SET_KEYWORD)) { if (!at(GET_KEYWORD) && !at(SET_KEYWORD)) {
getterOrSetter.rollbackTo(); getterOrSetter.rollbackTo();
@@ -1873,7 +1871,7 @@ public class JetParsing extends AbstractJetParsing {
// TokenSet stopAt = TokenSet.create(COMMA, COLON, GT); // TokenSet stopAt = TokenSet.create(COMMA, COLON, GT);
// parseModifierListWithShortAnnotations(MODIFIER_LIST, lookFor, stopAt); // parseModifierListWithShortAnnotations(MODIFIER_LIST, lookFor, stopAt);
// Currently we do not allow annotations // Currently we do not allow annotations
parseModifierList(MODIFIER_LIST, REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS); parseModifierList(REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS);
if (at(MUL)) { if (at(MUL)) {
advance(); // MUL advance(); // MUL
@@ -1899,7 +1897,7 @@ public class JetParsing extends AbstractJetParsing {
private void parseModifierListWithShortAnnotations(IElementType modifierList, TokenSet lookFor, TokenSet stopAt) { private void parseModifierListWithShortAnnotations(IElementType modifierList, TokenSet lookFor, TokenSet stopAt) {
int lastId = findLastBefore(lookFor, stopAt, false); int lastId = findLastBefore(lookFor, stopAt, false);
createTruncatedBuilder(lastId).parseModifierList(modifierList, REGULAR_ANNOTATIONS_ALLOW_SHORTS); createTruncatedBuilder(lastId).parseModifierList(REGULAR_ANNOTATIONS_ALLOW_SHORTS);
} }
/* /*
@@ -2001,7 +1999,7 @@ public class JetParsing extends AbstractJetParsing {
if (isFunctionTypeContents) { if (isFunctionTypeContents) {
if (!tryParseValueParameter(typeRequired)) { if (!tryParseValueParameter(typeRequired)) {
PsiBuilder.Marker valueParameter = mark(); PsiBuilder.Marker valueParameter = mark();
parseModifierList(MODIFIER_LIST, REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS); // lazy, out, ref parseModifierList(REGULAR_ANNOTATIONS_ONLY_WITH_BRACKETS); // lazy, out, ref
parseTypeRef(); parseTypeRef();
closeDeclarationWithCommentBinders(valueParameter, VALUE_PARAMETER, false); closeDeclarationWithCommentBinders(valueParameter, VALUE_PARAMETER, false);
} }