[java] minor parser optimization (IDEA-CR-19063)

This commit is contained in:
Roman Shevchenko
2017-03-08 14:28:07 +01:00
parent dcac209600
commit 166a500fde
2 changed files with 6 additions and 4 deletions
@@ -106,9 +106,11 @@ public class FileParser {
private static boolean stopImportListParsing(PsiBuilder b) {
IElementType type = b.getTokenType();
String text = b.getTokenText();
if (IMPORT_LIST_STOPPER_SET.contains(type)) return true;
if (type == JavaTokenType.IDENTIFIER && (PsiKeyword.OPEN.equals(text) || PsiKeyword.MODULE.equals(text))) return true;
if (type == JavaTokenType.IDENTIFIER) {
String text = b.getTokenText();
if (PsiKeyword.OPEN.equals(text) || PsiKeyword.MODULE.equals(text)) return true;
}
return false;
}
@@ -49,8 +49,8 @@ public class ModuleParser {
PsiBuilder.Marker firstAnnotation = myParser.getDeclarationParser().parseAnnotations(builder);
IElementType type = builder.getTokenType();
String text = builder.getTokenText();
if (type != JavaTokenType.IDENTIFIER || !(PsiKeyword.OPEN.equals(text) || PsiKeyword.MODULE.equals(text))) {
String text = type == JavaTokenType.IDENTIFIER ? builder.getTokenText() : null;
if (!(PsiKeyword.OPEN.equals(text) || PsiKeyword.MODULE.equals(text))) {
module.rollbackTo();
return null;
}