mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-31442 Fix handling of multline expressions in f-strings following other statements
This commit is contained in:
@@ -111,6 +111,11 @@ public class PythonIndentingProcessor extends MergingLexerAdapter {
|
||||
return super.getTokenEnd();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getBaseTokenText() {
|
||||
return getBufferSequence().subSequence(getBaseTokenStart(), getBaseTokenEnd()).toString();
|
||||
}
|
||||
|
||||
private boolean isBaseAt(IElementType tokenType) {
|
||||
return getBaseTokenType() == tokenType;
|
||||
}
|
||||
@@ -189,10 +194,12 @@ public class PythonIndentingProcessor extends MergingLexerAdapter {
|
||||
}
|
||||
|
||||
private void checkFString() {
|
||||
final String tokenText = getTokenText();
|
||||
final String tokenText = getBaseTokenText();
|
||||
if (isBaseAt(PyTokenTypes.FSTRING_START)) {
|
||||
final int prefixLength = PyStringLiteralUtil.getPrefixLength(tokenText);
|
||||
myFStringStack.push(tokenText.substring(prefixLength));
|
||||
final String openingQuotes = tokenText.substring(prefixLength);
|
||||
assert !openingQuotes.isEmpty();
|
||||
myFStringStack.push(openingQuotes);
|
||||
}
|
||||
else if (isBaseAt(PyTokenTypes.FSTRING_END)) {
|
||||
while (!myFStringStack.isEmpty()) {
|
||||
|
||||
@@ -725,6 +725,10 @@ public class PythonParsingTest extends ParsingTestCase {
|
||||
doTest(LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
public void testMultilineFStringContainingMultilineExpressionAfterStatementBreak() {
|
||||
doTest(LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
public void testNestedMultilineFStringsWithMultilineExpressions() {
|
||||
doTest(LanguageLevel.PYTHON36);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user