1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 18:05:33 +02:00

Fix formatter handling of destructors and windows line endings

This commit is contained in:
Anton Leherbauer 2006-11-24 13:56:23 +00:00
parent 773b11c204
commit d309f414c0
3 changed files with 12 additions and 2 deletions

View file

@ -1274,6 +1274,10 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
scribe.printNextToken(Token.tIDENTIFIER, false);
scribe.printNextToken(Token.tCOLONCOLON);
}
if (peekNextToken() == Token.tCOMPL) {
// destructor
scribe.printNextToken(Token.tCOMPL, false);
}
scribe.printNextToken(Token.tIDENTIFIER, false);
return PROCESS_SKIP;
}

View file

@ -603,6 +603,10 @@ public class Scribe {
}
public void printRaw(int startOffset, int length) {
if (startOffset + length < scanner.getCurrentPosition()) {
// safeguard: don't move backwards
return;
}
boolean savedPreserveWS= preserveWhitespace;
boolean savedPreserveNL= preserveNewlines;
boolean savedSkipOverInactive= skipOverInactive;
@ -1353,10 +1357,10 @@ public class Scribe {
boolean hasWhitespaces= false;
boolean hasComment= false;
boolean hasLineComment= false;
int count= 0;
while ((currentToken= scanner.nextToken()) != null) {
switch (currentToken.type) {
case Token.tWHITESPACE:
int count= 0;
char[] whiteSpaces= scanner.getCurrentTokenSource();
for (int i= 0, max= whiteSpaces.length; i < max; i++) {
switch (whiteSpaces[i]) {

View file

@ -729,7 +729,9 @@ public class SimpleScanner {
while (c != '\n' && c != EOFCHAR) {
c = getChar();
}
ungetChar(c);
if (c == EOFCHAR) {
ungetChar(c);
}
}
private boolean matchMultilineComment() {