diff options
author | Andrey Mozzhuhin | 2020-04-13 18:32:45 +0000 |
---|---|---|
committer | Andrey Mozzhuhin | 2020-04-13 18:32:45 +0000 |
commit | a145e695c0939c546f33d48e9f95dcdf993e477c (patch) | |
tree | c0725eaf87aad56d2bb006673cd5d6e3a315d87e /core/org.eclipse.cdt.ui | |
parent | 2a075e3ec8c77af1b52017d250b967a02a74e6a7 (diff) | |
download | org.eclipse.cdt-a145e695c0939c546f33d48e9f95dcdf993e477c.tar.gz org.eclipse.cdt-a145e695c0939c546f33d48e9f95dcdf993e477c.tar.xz org.eclipse.cdt-a145e695c0939c546f33d48e9f95dcdf993e477c.zip |
Bug 516393: Fix scan of double char tokens in CHeuristicScanner
Scanning of double char tokens (::, >>, >=, <<, <=, ->) is broken in
nextToken(). In each case, peekNextChar() was used to get second
character, but scanner position was already on second char and
peekPreviousChar() need to be used.
Change-Id: Ibd447c7cde8783e8ffe547d5f9bc09d11c1c60a7
Signed-off-by: Andrey Mozzhuhin <amozzhuhin@yandex.ru>
Diffstat (limited to 'core/org.eclipse.cdt.ui')
-rw-r--r-- | core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java | 21 |
1 files changed, 4 insertions, 17 deletions
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; @@ -520,19 +520,6 @@ 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() { |