diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/SemanticEditorPosition.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/SemanticEditorPosition.java index e91ed14f0709..e517ee86f2c4 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/SemanticEditorPosition.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/SemanticEditorPosition.java @@ -157,9 +157,9 @@ public class SemanticEditorPosition { public void moveToLeftParenthesisBackwardsSkippingNested(@NotNull SyntaxElement leftParenthesis, @NotNull SyntaxElement rightParenthesis, - @NotNull Condition terminationCondition) { + @NotNull Condition terminationCondition) { while (!myIterator.atEnd()) { - if (terminationCondition.value(map(myIterator.getTokenType()))) { + if (terminationCondition.value(this)) { break; } if (rightParenthesis.equals(map(myIterator.getTokenType()))) { @@ -174,7 +174,7 @@ public class SemanticEditorPosition { public SemanticEditorPosition findLeftParenthesisBackwardsSkippingNested(@NotNull SyntaxElement leftParenthesis, @NotNull SyntaxElement rightParenthesis, - @NotNull Condition terminationCondition) { + @NotNull Condition terminationCondition) { return copyAnd( position -> position.moveToLeftParenthesisBackwardsSkippingNested(leftParenthesis, rightParenthesis, terminationCondition)); } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java index 4a346ee3c3bf..57542627323c 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/lineIndent/JavaLikeLangLineIndentProvider.java @@ -21,7 +21,6 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.highlighter.HighlighterIterator; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Pair; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.psi.codeStyle.lineIndent.LineIndentProvider; @@ -98,8 +97,7 @@ public abstract class JavaLikeLangLineIndentProvider implements LineIndentProvid !position.after().matchesRule( p->p.isAtAnyOf(ArrayClosingBracket, BlockOpeningBrace, BlockClosingBrace, RightParenthesis) || p.isAtEnd()) && position.findLeftParenthesisBackwardsSkippingNested(LeftParenthesis, RightParenthesis, - element -> element == BlockClosingBrace || element == BlockOpeningBrace || - element == Semicolon) + self -> self.isAtAnyOf(BlockClosingBrace, BlockOpeningBrace, Semicolon)) .isAt(LeftParenthesis)) { return myFactory.createIndentCalculator(NONE, IndentCalculator.LINE_AFTER); } @@ -231,7 +229,7 @@ public abstract class JavaLikeLangLineIndentProvider implements LineIndentProvid } } - private int getDeepBlockStatementStartOffset(@NotNull SemanticEditorPosition position) { + protected int getDeepBlockStatementStartOffset(@NotNull SemanticEditorPosition position) { while (!(position.isAt(BlockOpeningBrace) || position.isAtEnd())) { position.moveBefore(); } @@ -311,7 +309,7 @@ public abstract class JavaLikeLangLineIndentProvider implements LineIndentProvid return true; } - protected SemanticEditorPosition getPosition(@NotNull Editor editor, int offset) { + public SemanticEditorPosition getPosition(@NotNull Editor editor, int offset) { return SemanticEditorPosition.createEditorPosition((EditorEx)editor, offset, (_editor, _offset) -> getIteratorAtPosition(_editor, _offset), tokenType -> mapType(tokenType));