Relax assertion in parser for a recovery case with annotations

^KT-24937 Fixed
This commit is contained in:
Denis Zharkov
2018-12-10 16:03:45 +03:00
parent 3727fabb0f
commit 5992896d76
8 changed files with 509 additions and 1 deletions
@@ -750,7 +750,10 @@ public class KotlinParsing extends AbstractKotlinParsing {
*/
private boolean parseAnnotation(AnnotationParsingMode mode) {
assert _at(IDENTIFIER) ||
(_at(AT) && !WHITE_SPACE_OR_COMMENT_BIT_SET.contains(myBuilder.rawLookup(1)));
// We have "@ann" or "@:ann" or "@ :ann", but not "@ ann"
// (it's guaranteed that call sites do not allow the latter case)
(_at(AT) && (!isNextRawTokenCommentOrWhitespace() || lookahead(1) == COLON))
: "Invalid annotation prefix";
PsiBuilder.Marker annotation = mark();
@@ -780,6 +783,10 @@ public class KotlinParsing extends AbstractKotlinParsing {
return true;
}
private boolean isNextRawTokenCommentOrWhitespace() {
return WHITE_SPACE_OR_COMMENT_BIT_SET.contains(myBuilder.rawLookup(1));
}
public enum NameParsingMode {
REQUIRED,
ALLOWED,