mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
TailTypes#CASE_ARROW: do not add if arrow is present even with different spacing (IDEA-204074)
This commit is contained in:
@@ -21,7 +21,6 @@ import com.intellij.codeInsight.completion.simple.ParenthesesTailType;
|
||||
import com.intellij.codeInsight.completion.simple.RParenthTailType;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiSwitchBlock;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.siyeh.ig.psiutils.SwitchUtils;
|
||||
@@ -142,11 +141,17 @@ public class TailTypes {
|
||||
@Override
|
||||
public boolean isApplicable(@NotNull InsertionContext context) {
|
||||
Document document = context.getDocument();
|
||||
int offset = context.getTailOffset();
|
||||
int length = document.getTextLength();
|
||||
int endOffset = offset + ARROW.length();
|
||||
if (endOffset > length) return true;
|
||||
return !document.getText(new TextRange(offset, endOffset)).equals(ARROW);
|
||||
CharSequence chars = document.getCharsSequence();
|
||||
int offset;
|
||||
for(offset = context.getTailOffset(); offset < length; offset++) {
|
||||
char c = chars.charAt(offset);
|
||||
if (c != '\n' && c != ' ' && c != '\t') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
boolean hasArrow = offset + 2 < length && chars.subSequence(offset, offset + 2).toString().equals("->");
|
||||
return !hasArrow;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,8 @@ public class ConstConfig {
|
||||
|
||||
void test(X x) {
|
||||
switch (x) {
|
||||
case BAR, FO<caret> -> {}
|
||||
case BAR, FO<caret> ->
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -3,7 +3,8 @@ public class ConstConfig {
|
||||
|
||||
void test(X x) {
|
||||
switch (x) {
|
||||
case BAR, FOO<caret> -> {}
|
||||
case BAR, FOO<caret> ->
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user