From 2f99eaf29c7340551771a11b4e133f9054e043e8 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Wed, 13 Jun 2007 08:42:16 +0000 Subject: [PATCH] Fix for 191823: [Indent] Indentation issues with shift right operator --- .../internal/ui/text/CHeuristicScanner.java | 34 +++++++++++++++++++ .../eclipse/cdt/internal/ui/text/Symbols.java | 1 + 2 files changed, 35 insertions(+) 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 b530475dc08..4ce61d2113b 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 @@ -331,6 +331,10 @@ public final class CHeuristicScanner implements Symbols { case LANGLE: return TokenLESSTHAN; case RANGLE: + if (peekNextChar() == RANGLE) { + ++fPos; + return TokenSHIFTRIGHT; + } return TokenGREATERTHAN; } @@ -403,6 +407,10 @@ public final class CHeuristicScanner implements Symbols { case LANGLE: return TokenLESSTHAN; case RANGLE: + if (peekPreviousChar() == RANGLE) { + --fPos; + return TokenSHIFTRIGHT; + } return TokenGREATERTHAN; case DOT: return TokenDOT; @@ -439,6 +447,32 @@ public final class CHeuristicScanner implements Symbols { } + /** + * @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 + */ + private char peekPreviousChar() { + if (fPos >= 0) { + try { + return fDocument.getChar(fPos); + } catch (BadLocationException exc) { + } + } + return (char)-1; + } + /** * Returns one of the keyword constants or TokenIDENT for a scanned identifier. * diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Symbols.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Symbols.java index 7ec5bcae367..fed73e3fa18 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Symbols.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Symbols.java @@ -34,6 +34,7 @@ public interface Symbols { int TokenDOT= 15; int TokenMINUS= 16; int TokenTILDE= 17; + int TokenSHIFTRIGHT= 18; int TokenIF= 109; int TokenDO= 1010; int TokenFOR= 1011;