CPP-1843 Typing :: in switch case statement breaks indentation

This commit is contained in:
Alexey Utkin
2018-03-11 19:32:41 +03:00
parent ffc516e529
commit eb9f44c274
2 changed files with 6 additions and 8 deletions
@@ -157,9 +157,9 @@ public class SemanticEditorPosition {
public void moveToLeftParenthesisBackwardsSkippingNested(@NotNull SyntaxElement leftParenthesis,
@NotNull SyntaxElement rightParenthesis,
@NotNull Condition<SyntaxElement> terminationCondition) {
@NotNull Condition<SemanticEditorPosition> 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<SyntaxElement> terminationCondition) {
@NotNull Condition<SemanticEditorPosition> terminationCondition) {
return copyAnd(
position -> position.moveToLeftParenthesisBackwardsSkippingNested(leftParenthesis, rightParenthesis, terminationCondition));
}
@@ -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));