1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 14:15:23 +02:00

Fix for 191823: [Indent] Indentation issues with shift right operator

This commit is contained in:
Anton Leherbauer 2007-06-13 08:42:16 +00:00
parent fdb43fb3c6
commit 2f99eaf29c
2 changed files with 35 additions and 0 deletions

View file

@ -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 <code>TokenIDENT</code> for a scanned identifier.
*

View file

@ -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;