mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
Java: replace with text block should not be available on non-string literals (IDEA-354921)
GitOrigin-RevId: b86751e38c0349fcafd72ed04b39ed5283c2c06a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2415769d5c
commit
dd0e596d3d
@@ -85,9 +85,8 @@ public final class TextBlockMigrationInspection extends AbstractBaseJavaLocalIns
|
||||
@Override
|
||||
public void visitLiteralExpression(@NotNull PsiLiteralExpression expression) {
|
||||
if (PsiUtil.skipParenthesizedExprUp(expression.getParent()) instanceof PsiPolyadicExpression) return;
|
||||
PsiLiteralExpression literal = getLiteralExpression(expression);
|
||||
if (literal == null) return;
|
||||
String text = literal.getText();
|
||||
if (!ExpressionUtils.hasStringType(expression)) return;
|
||||
String text = expression.getText();
|
||||
int newLineIdx = getNewLineIndex(text, 0);
|
||||
if (mySuggestLiteralReplacement && newLineIdx != -1 && getNewLineIndex(text, newLineIdx + 1) != -1) {
|
||||
boolean quickFixOnly = isOnTheFly && InspectionProjectProfileManager.isInformationLevel(getShortName(), expression);
|
||||
@@ -189,10 +188,6 @@ public final class TextBlockMigrationInspection extends AbstractBaseJavaLocalIns
|
||||
return getEscapedCharIndex(text, start, 'n');
|
||||
}
|
||||
|
||||
private static int getQuoteIndex(@NotNull String text) {
|
||||
return getEscapedCharIndex(text, 0, '"');
|
||||
}
|
||||
|
||||
private static int getEscapedCharIndex(@NotNull String text, int start, char escapedChar) {
|
||||
int i = start;
|
||||
while (i < text.length()) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace with text block" "false"
|
||||
|
||||
class NonStringLiteral {
|
||||
|
||||
void empty() {
|
||||
String empty = <caret>null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user