mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
When '.' is typed on a new line, automatically adjust line indent for a chained call (solves IDEA-255648)
GitOrigin-RevId: 21315bb550bacc92cd2958c505eb0b5a989ee858
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a0b11d47da
commit
0887e2cfb8
@@ -366,9 +366,29 @@ public class JavaTypedHandler extends TypedHandlerDelegate {
|
||||
else if (c == ',' && handleAnnotationParameter(project, editor, file)) {
|
||||
return Result.STOP;
|
||||
}
|
||||
else if (c == '.') {
|
||||
if (handleDotTyped(project, editor, file)) {
|
||||
return Result.STOP;
|
||||
}
|
||||
}
|
||||
return Result.CONTINUE;
|
||||
}
|
||||
|
||||
private static boolean handleDotTyped(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
|
||||
int offset = editor.getCaretModel().getOffset() - 1;
|
||||
if (offset >= 0) {
|
||||
Document document = editor.getDocument();
|
||||
int line = document.getLineNumber(offset);
|
||||
int lineStart = document.getLineStartOffset(line);
|
||||
if (StringUtil.isEmptyOrSpaces(document.getCharsSequence().subSequence(lineStart, offset))) {
|
||||
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
|
||||
CodeStyleManager.getInstance(project).adjustLineIndent(file, offset);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean handleAnnotationParameter(Project project, @NotNull Editor editor, @NotNull PsiFile file) {
|
||||
int caret = editor.getCaretModel().getOffset();
|
||||
if (mightBeInsideDefaultAnnotationAttribute(editor, caret - 2)) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Test {
|
||||
void foo1() {
|
||||
foo(
|
||||
strings
|
||||
.stream()
|
||||
.<caret>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Test {
|
||||
void foo1() {
|
||||
foo(
|
||||
strings
|
||||
.stream()
|
||||
<caret>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -152,6 +152,8 @@ public class JavaTypingTest extends BasePlatformTestCase {
|
||||
|
||||
public void testEqualAfterBitwiseOp() { doTest('='); }
|
||||
|
||||
public void testDotOnNewLine() { doTest('.'); }
|
||||
|
||||
public void testEqualAfterBitwiseOp2() {
|
||||
myFixture.configureByFile(getTestName(true) + "_before.java");
|
||||
CommonCodeStyleSettings settings = CodeStyle.getLanguageSettings(myFixture.getFile());
|
||||
|
||||
Reference in New Issue
Block a user