Minor. Rename PropertyParsingMode -> DeclarationParsingMode

This commit is contained in:
Denis Zharkov
2018-12-20 10:30:51 +03:00
parent 8b3ffee183
commit 1688fed0b7
2 changed files with 9 additions and 15 deletions
@@ -852,7 +852,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
PsiBuilder.Marker atWhenStart = mark(); PsiBuilder.Marker atWhenStart = mark();
myKotlinParsing.parseAnnotationsList(DEFAULT, TokenSet.create(EQ, RPAR)); myKotlinParsing.parseAnnotationsList(DEFAULT, TokenSet.create(EQ, RPAR));
if (at(VAL_KEYWORD) || at(VAR_KEYWORD)) { if (at(VAL_KEYWORD) || at(VAR_KEYWORD)) {
IElementType declType = myKotlinParsing.parseProperty(KotlinParsing.PropertyParsingMode.LOCAL); IElementType declType = myKotlinParsing.parseProperty(KotlinParsing.DeclarationParsingMode.LOCAL);
atWhenStart.done(declType); atWhenStart.done(declType);
atWhenStart.setCustomEdgeTokenBinders(PrecedingDocCommentsBinder.INSTANCE, TrailingCommentsBinder.INSTANCE); atWhenStart.setCustomEdgeTokenBinders(PrecedingDocCommentsBinder.INSTANCE, TrailingCommentsBinder.INSTANCE);
@@ -1376,7 +1376,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
return myKotlinParsing.parseCommonDeclaration( return myKotlinParsing.parseCommonDeclaration(
modifierDetector, NameParsingMode.REQUIRED, modifierDetector, NameParsingMode.REQUIRED,
isScriptTopLevel ? KotlinParsing.PropertyParsingMode.SCRIPT_TOPLEVEL : KotlinParsing.PropertyParsingMode.LOCAL isScriptTopLevel ? KotlinParsing.DeclarationParsingMode.SCRIPT_TOPLEVEL : KotlinParsing.DeclarationParsingMode.LOCAL
); );
} }
@@ -416,7 +416,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
ModifierDetector detector = new ModifierDetector(); ModifierDetector detector = new ModifierDetector();
parseModifierList(detector, DEFAULT, TokenSet.EMPTY); parseModifierList(detector, DEFAULT, TokenSet.EMPTY);
IElementType declType = parseCommonDeclaration(detector, NameParsingMode.REQUIRED, PropertyParsingMode.MEMBER_OR_TOPLEVEL); IElementType declType = parseCommonDeclaration(detector, NameParsingMode.REQUIRED, DeclarationParsingMode.MEMBER_OR_TOPLEVEL);
if (declType == null && at(LBRACE)) { if (declType == null && at(LBRACE)) {
error("Expecting a top level declaration"); error("Expecting a top level declaration");
@@ -436,7 +436,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
public IElementType parseCommonDeclaration( public IElementType parseCommonDeclaration(
@NotNull ModifierDetector detector, @NotNull ModifierDetector detector,
@NotNull NameParsingMode nameParsingModeForObject, @NotNull NameParsingMode nameParsingModeForObject,
@NotNull PropertyParsingMode propertyParsingMode @NotNull DeclarationParsingMode declarationParsingMode
) { ) {
IElementType keywordToken = tt(); IElementType keywordToken = tt();
@@ -447,7 +447,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
return parseFunction(); return parseFunction();
} }
else if (keywordToken == VAL_KEYWORD || keywordToken == VAR_KEYWORD) { else if (keywordToken == VAL_KEYWORD || keywordToken == VAR_KEYWORD) {
return parseProperty(propertyParsingMode); return parseProperty(declarationParsingMode);
} }
else if (keywordToken == TYPE_ALIAS_KEYWORD) { else if (keywordToken == TYPE_ALIAS_KEYWORD) {
return parseTypeAlias(); return parseTypeAlias();
@@ -803,12 +803,6 @@ public class KotlinParsing extends AbstractKotlinParsing {
PROHIBITED PROHIBITED
} }
public enum DeclarationParsingMode {
TOP_LEVEL,
CLASS_MEMBER,
LOCAL
}
/* /*
* class * class
* : modifiers ("class" | "interface") SimpleName * : modifiers ("class" | "interface") SimpleName
@@ -1122,7 +1116,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
IElementType declType = parseCommonDeclaration( IElementType declType = parseCommonDeclaration(
modifierDetector, modifierDetector,
modifierDetector.isCompanionDetected() ? NameParsingMode.ALLOWED : NameParsingMode.REQUIRED, modifierDetector.isCompanionDetected() ? NameParsingMode.ALLOWED : NameParsingMode.REQUIRED,
PropertyParsingMode.MEMBER_OR_TOPLEVEL DeclarationParsingMode.MEMBER_OR_TOPLEVEL
); );
if (declType != null) return declType; if (declType != null) return declType;
@@ -1249,7 +1243,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
return TYPEALIAS; return TYPEALIAS;
} }
enum PropertyParsingMode { enum DeclarationParsingMode {
MEMBER_OR_TOPLEVEL(false, true), MEMBER_OR_TOPLEVEL(false, true),
LOCAL(true, false), LOCAL(true, false),
SCRIPT_TOPLEVEL(true, true); SCRIPT_TOPLEVEL(true, true);
@@ -1257,7 +1251,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
public final boolean destructuringAllowed; public final boolean destructuringAllowed;
public final boolean accessorsAllowed; public final boolean accessorsAllowed;
PropertyParsingMode(boolean destructuringAllowed, boolean accessorsAllowed) { DeclarationParsingMode(boolean destructuringAllowed, boolean accessorsAllowed) {
this.destructuringAllowed = destructuringAllowed; this.destructuringAllowed = destructuringAllowed;
this.accessorsAllowed = accessorsAllowed; this.accessorsAllowed = accessorsAllowed;
} }
@@ -1278,7 +1272,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
* (getter? setter? | setter? getter?) SEMI? * (getter? setter? | setter? getter?) SEMI?
* ; * ;
*/ */
public IElementType parseProperty(PropertyParsingMode mode) { public IElementType parseProperty(DeclarationParsingMode mode) {
assert (at(VAL_KEYWORD) || at(VAR_KEYWORD)); assert (at(VAL_KEYWORD) || at(VAR_KEYWORD));
advance(); advance();