mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Line indent provider: more cases fixed
This commit is contained in:
@@ -52,6 +52,7 @@ public class JavaLineIndentProvider extends JavaLikeLangLineIndentProvider {
|
||||
SYNTAX_MAP.put(JavaTokenType.C_STYLE_COMMENT, BlockComment);
|
||||
SYNTAX_MAP.put(JavaDocTokenType.DOC_COMMENT_START, DocBlockStart);
|
||||
SYNTAX_MAP.put(JavaDocTokenType.DOC_COMMENT_END, DocBlockEnd);
|
||||
SYNTAX_MAP.put(JavaTokenType.COMMA, Comma);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+14
@@ -88,6 +88,20 @@ public abstract class SemanticEditorPosition {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SemanticEditorPosition findLeftParenthesisBackwardsSkippingNested(@NotNull SyntaxElement leftParenthesis,
|
||||
@NotNull SyntaxElement rightParenthesis) {
|
||||
while (!myIterator.atEnd()) {
|
||||
if (rightParenthesis.equals(map(myIterator.getTokenType()))) {
|
||||
beforeParentheses(leftParenthesis, rightParenthesis);
|
||||
}
|
||||
else if (leftParenthesis.equals(map(myIterator.getTokenType()))) {
|
||||
break;
|
||||
}
|
||||
myIterator.retreat();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAfterOnSameLine(@NotNull SyntaxElement... syntaxElements) {
|
||||
myIterator.retreat();
|
||||
|
||||
+18
-2
@@ -54,7 +54,8 @@ public abstract class JavaLikeLangLineIndentProvider extends FormatterBasedLineI
|
||||
ForKeyword,
|
||||
BlockComment,
|
||||
DocBlockStart,
|
||||
DocBlockEnd
|
||||
DocBlockEnd,
|
||||
Comma
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +80,22 @@ public abstract class JavaLikeLangLineIndentProvider extends FormatterBasedLineI
|
||||
if (getPosition(editor, offset).matchesRule(
|
||||
position -> position.isAt(Whitespace) &&
|
||||
position.isAtMultiline())) {
|
||||
if (getPosition(editor, offset).matchesRule(
|
||||
//noinspection StatementWithEmptyBody
|
||||
if (getPosition(editor, offset).before().isAt(Comma)) {
|
||||
// TODO: Add support
|
||||
}
|
||||
else if (getPosition(editor, offset + 1).isAt(BlockClosingBrace)) {
|
||||
return myFactory.createIndentCalculator(
|
||||
NONE,
|
||||
position -> {
|
||||
position.findLeftParenthesisBackwardsSkippingNested(BlockOpeningBrace, BlockClosingBrace);
|
||||
if (!position.isAtEnd()) {
|
||||
return getBlockStartOffset(position);
|
||||
}
|
||||
return -1;
|
||||
});
|
||||
}
|
||||
else if (getPosition(editor, offset).matchesRule(
|
||||
position -> position
|
||||
.before()
|
||||
.beforeOptional(Semicolon)
|
||||
|
||||
Reference in New Issue
Block a user