diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CHeuristicScannerTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CHeuristicScannerTest.java index b938ae4d856..1e8ada99eb8 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CHeuristicScannerTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CHeuristicScannerTest.java @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.cdt.internal.ui.text.CHeuristicScanner; import org.eclipse.cdt.internal.ui.text.CIndenter; import org.eclipse.cdt.internal.ui.text.FastCPartitionScanner; +import org.eclipse.cdt.internal.ui.text.Symbols; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; @@ -678,4 +679,19 @@ public class CHeuristicScannerTest extends TestCase { String indent = fScanner.computeIndentation(fDocument.getLength() - 8).toString(); Assert.assertEquals(" ", indent); } + + public void testNextTokenDoubleChar() throws Exception { + fDocument.set("::"); + assertEquals(fHeuristicScanner.nextToken(0, fDocument.getLength() - 1), Symbols.TokenDOUBLECOLON); + fDocument.set("<<"); + assertEquals(fHeuristicScanner.nextToken(0, fDocument.getLength() - 1), Symbols.TokenSHIFTLEFT); + fDocument.set("<="); + assertEquals(fHeuristicScanner.nextToken(0, fDocument.getLength() - 1), Symbols.TokenOTHER); + fDocument.set(">>"); + assertEquals(fHeuristicScanner.nextToken(0, fDocument.getLength() - 1), Symbols.TokenSHIFTRIGHT); + fDocument.set(">="); + assertEquals(fHeuristicScanner.nextToken(0, fDocument.getLength() - 1), Symbols.TokenOTHER); + fDocument.set("->"); + assertEquals(fHeuristicScanner.nextToken(0, fDocument.getLength() - 1), Symbols.TokenARROW); + } } 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 c0d5ad56c9c..aee44827c18 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 @@ -1054,4 +1054,17 @@ public class CIndenterTest extends BaseUITestCase { public void testIndentationAfterFunctionHeaderWithReturnTypeTemplateSpecification_Bug537568() throws Exception { assertIndenterResult(); } + + //MyFunctionCall(::My::Namespace::MyType::Value1, + //var1, + //::My::Namespace::MyType::Value2, + //var2); + + //MyFunctionCall(::My::Namespace::MyType::Value1, + // var1, + // ::My::Namespace::MyType::Value2, + // var2); + public void testIndentationAfterArgumentWithQualifier_Bug516393() throws Exception { + assertIndenterResult(); // global scope + } } 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 02f7af3cad5..75f95b6128f 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 @@ -347,7 +347,7 @@ public final class CHeuristicScanner implements Symbols { case SEMICOLON: return TokenSEMICOLON; case COLON: - switch (peekNextChar()) { + switch (peekPreviousChar()) { case COLON: ++fPos; return TokenDOUBLECOLON; @@ -360,7 +360,7 @@ public final class CHeuristicScanner implements Symbols { case EQUAL: return TokenEQUAL; case LANGLE: - switch (peekNextChar()) { + switch (peekPreviousChar()) { case LANGLE: ++fPos; return TokenSHIFTLEFT; @@ -370,7 +370,7 @@ public final class CHeuristicScanner implements Symbols { } return TokenLESSTHAN; case RANGLE: - switch (peekNextChar()) { + switch (peekPreviousChar()) { case RANGLE: ++fPos; return TokenSHIFTRIGHT; @@ -382,7 +382,7 @@ public final class CHeuristicScanner implements Symbols { case DOT: return TokenDOT; case MINUS: - switch (peekNextChar()) { + switch (peekPreviousChar()) { case RANGLE: ++fPos; return TokenARROW; @@ -519,19 +519,6 @@ public final class CHeuristicScanner implements Symbols { return TokenOTHER; } - /** - * @return the next char without shifting the position - */ - private char peekNextChar() { - if (fPos + 1 < fDocument.getLength()) { - try { - return fDocument.getChar(fPos + 1); - } catch (BadLocationException exc) { - } - } - return (char) -1; - } - /** * @return the previous char without shifting the position */