mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Support indent after comma in parameter lists
This commit is contained in:
+8
-1
@@ -147,7 +147,7 @@ public abstract class SemanticEditorPosition {
|
||||
public int getStartOffset() {
|
||||
return myIterator.getStart();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public boolean isAtAnyOf(@NotNull SyntaxElement... syntaxElements) {
|
||||
if (!myIterator.atEnd()) {
|
||||
@@ -172,6 +172,13 @@ public abstract class SemanticEditorPosition {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean hasEmptyLineAfter(int offset) {
|
||||
for (int i = offset; i < myIterator.getEnd(); i ++) {
|
||||
if (myChars.charAt(i) == '\n') return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public EditorEx getEditor() {
|
||||
return myEditor;
|
||||
}
|
||||
|
||||
+7
-1
@@ -57,7 +57,13 @@ class IndentCalculator {
|
||||
return CharArrayUtil.shiftBackward(currPosition.getChars(), currPosition.getStartOffset(), " \t\n\r");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public final static BaseLineOffsetCalculator LINE_AFTER = new BaseLineOffsetCalculator() {
|
||||
@Override
|
||||
public int getOffsetInBaseIndentLine(@NotNull SemanticEditorPosition currPosition) {
|
||||
return CharArrayUtil.shiftForward(currPosition.getChars(), currPosition.getStartOffset(), " \t\n\r");
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
String getIndentString(@Nullable Language language, @NotNull SemanticEditorPosition currPosition) {
|
||||
|
||||
+6
-2
@@ -85,9 +85,13 @@ public abstract class JavaLikeLangLineIndentProvider implements LineIndentProvid
|
||||
if (getPosition(editor, offset).matchesRule(
|
||||
position -> position.isAt(Whitespace) &&
|
||||
position.isAtMultiline())) {
|
||||
//noinspection StatementWithEmptyBody
|
||||
if (getPosition(editor, offset).before().isAt(Comma)) {
|
||||
// TODO: Add support
|
||||
SemanticEditorPosition position = getPosition(editor,offset);
|
||||
if (position.hasEmptyLineAfter(offset) &&
|
||||
!position.after().isAtAnyOf(ArrayClosingBracket, BlockOpeningBrace, BlockClosingBrace, RightParenthesis) &&
|
||||
!position.isAtEnd()) {
|
||||
return myFactory.createIndentCalculator(NONE, IndentCalculator.LINE_AFTER);
|
||||
}
|
||||
}
|
||||
else if (getPosition(editor, offset + 1).isAt(BlockClosingBrace)) {
|
||||
return myFactory.createIndentCalculator(
|
||||
|
||||
Reference in New Issue
Block a user