PY-27178 Parenthesised expression parsing doesn't hang at the end of file

Normally, it shouldn't happen, since Python lexer is supposed to put the
special STATEMENT_BREAK token right at the end of file, but apparently
it may not be the case during editing of an injected fragment.
This commit is contained in:
Mikhail Golubev
2017-11-30 19:49:29 +03:00
parent bf9a49d1be
commit f26af18f70
4 changed files with 11 additions and 1 deletions
@@ -305,7 +305,8 @@ public class ExpressionParsing extends Parsing {
else {
final PsiBuilder.Marker err = myBuilder.mark();
boolean empty = true;
while (myBuilder.getTokenType() != PyTokenTypes.RPAR &&
while (!myBuilder.eof() &&
myBuilder.getTokenType() != PyTokenTypes.RPAR &&
myBuilder.getTokenType() != PyTokenTypes.LINE_BREAK &&
myBuilder.getTokenType() != PyTokenTypes.STATEMENT_BREAK) {
myBuilder.advanceLexer();
@@ -0,0 +1,2 @@
def foo(bar):
# type: (foo.
@@ -0,0 +1,2 @@
def foo(bar):
# type: (foo<caret>
@@ -591,4 +591,9 @@ public class PyEditingTest extends PyTestCase {
" return bar, 'so' \\\n" +
" 'me'");
}
// PY-27178
public void testIncompleteFunctionTypeComment() {
doTypingTest('.');
}
}