mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 13:55:39 +02:00
Fix for 191823: [Indent] Indentation issues with shift right operator
This commit is contained in:
parent
fdb43fb3c6
commit
2f99eaf29c
2 changed files with 35 additions and 0 deletions
|
@ -331,6 +331,10 @@ public final class CHeuristicScanner implements Symbols {
|
||||||
case LANGLE:
|
case LANGLE:
|
||||||
return TokenLESSTHAN;
|
return TokenLESSTHAN;
|
||||||
case RANGLE:
|
case RANGLE:
|
||||||
|
if (peekNextChar() == RANGLE) {
|
||||||
|
++fPos;
|
||||||
|
return TokenSHIFTRIGHT;
|
||||||
|
}
|
||||||
return TokenGREATERTHAN;
|
return TokenGREATERTHAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,6 +407,10 @@ public final class CHeuristicScanner implements Symbols {
|
||||||
case LANGLE:
|
case LANGLE:
|
||||||
return TokenLESSTHAN;
|
return TokenLESSTHAN;
|
||||||
case RANGLE:
|
case RANGLE:
|
||||||
|
if (peekPreviousChar() == RANGLE) {
|
||||||
|
--fPos;
|
||||||
|
return TokenSHIFTRIGHT;
|
||||||
|
}
|
||||||
return TokenGREATERTHAN;
|
return TokenGREATERTHAN;
|
||||||
case DOT:
|
case DOT:
|
||||||
return TokenDOT;
|
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.
|
* Returns one of the keyword constants or <code>TokenIDENT</code> for a scanned identifier.
|
||||||
*
|
*
|
||||||
|
|
|
@ -34,6 +34,7 @@ public interface Symbols {
|
||||||
int TokenDOT= 15;
|
int TokenDOT= 15;
|
||||||
int TokenMINUS= 16;
|
int TokenMINUS= 16;
|
||||||
int TokenTILDE= 17;
|
int TokenTILDE= 17;
|
||||||
|
int TokenSHIFTRIGHT= 18;
|
||||||
int TokenIF= 109;
|
int TokenIF= 109;
|
||||||
int TokenDO= 1010;
|
int TokenDO= 1010;
|
||||||
int TokenFOR= 1011;
|
int TokenFOR= 1011;
|
||||||
|
|
Loading…
Add table
Reference in a new issue