diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java index 5b9090a9802..65714557421 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java @@ -68,7 +68,7 @@ public class CIndenterTest extends BaseUITestCase { //foo(arg, // "string"); - public void testIndentationOfStringAsLastArgument_Bug192412() throws Exception { + public void testIndentationOfStringLiteralAsLastArgument_Bug192412() throws Exception { assertIndenterResult(); } @@ -82,4 +82,37 @@ public class CIndenterTest extends BaseUITestCase { public void testIndentationAfterArrowOperator_Bug192412() throws Exception { assertIndenterResult(); } + + //if (1) + //foo>>bar; + // dontIndent(); + + //if (1) + // foo>>bar; + //dontIndent(); + public void testIndentationAfterShiftRight_Bug192412() throws Exception { + assertIndenterResult(); + } + + //if (1) + //foo >= bar(); + // dontIndent(); + + //if (1) + // foo >= bar(); + //dontIndent(); + public void testIndentationAfterGreaterOrEquals_Bug192412() throws Exception { + assertIndenterResult(); + } + + //int x; + // + //int y; + + //int x; + // + //int y; + public void testIndentationOfEmptyLine_Bug192412() throws Exception { + assertIndenterResult(); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java index b2cb54f94e1..5baf95b9abc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java @@ -102,11 +102,11 @@ public class IndentAction extends TextEditorAction { fCaretOffset= -1; try { - document.addPosition(end); firstLine= document.getLineOfOffset(offset); // check for marginal (zero-length) lines int minusOne= length == 0 ? 0 : 1; nLines= document.getLineOfOffset(offset + length - minusOne) - firstLine + 1; + document.addPosition(end); } catch (BadLocationException e) { // will only happen on concurrent modification CUIPlugin.getDefault().log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "", e)); //$NON-NLS-1$ @@ -144,11 +144,11 @@ public class IndentAction extends TextEditorAction { if (newOffset != -1 && (hasChanged || newOffset != offset || newLength != length)) selectAndReveal(newOffset, newLength); - document.removePosition(end); } catch (BadLocationException e) { // will only happen on concurrent modification CUIPlugin.getDefault().log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "ConcurrentModification in IndentAction", e)); //$NON-NLS-1$ } finally { + document.removePosition(end); if (target != null) target.endCompoundChange(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java index 9ce4ebbaa85..ee758fa2072 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java @@ -345,6 +345,9 @@ public final class CHeuristicScanner implements Symbols { case RANGLE: ++fPos; return TokenSHIFTRIGHT; + case EQUAL: + ++fPos; + return TokenOTHER; } return TokenGREATERTHAN; case DOT: @@ -425,6 +428,13 @@ public final class CHeuristicScanner implements Symbols { case QUESTIONMARK: return TokenQUESTIONMARK; case EQUAL: + switch (peekPreviousChar()) { + case RANGLE: + --fPos; + case LANGLE: + --fPos; + return TokenOTHER; + } return TokenEQUAL; case LANGLE: return TokenLESSTHAN;