mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-02 13:13:36 +02:00
Fix formatter handling of destructors and windows line endings
This commit is contained in:
parent
773b11c204
commit
d309f414c0
3 changed files with 12 additions and 2 deletions
|
@ -1274,6 +1274,10 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
||||||
scribe.printNextToken(Token.tIDENTIFIER, false);
|
scribe.printNextToken(Token.tIDENTIFIER, false);
|
||||||
scribe.printNextToken(Token.tCOLONCOLON);
|
scribe.printNextToken(Token.tCOLONCOLON);
|
||||||
}
|
}
|
||||||
|
if (peekNextToken() == Token.tCOMPL) {
|
||||||
|
// destructor
|
||||||
|
scribe.printNextToken(Token.tCOMPL, false);
|
||||||
|
}
|
||||||
scribe.printNextToken(Token.tIDENTIFIER, false);
|
scribe.printNextToken(Token.tIDENTIFIER, false);
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
|
@ -603,6 +603,10 @@ public class Scribe {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printRaw(int startOffset, int length) {
|
public void printRaw(int startOffset, int length) {
|
||||||
|
if (startOffset + length < scanner.getCurrentPosition()) {
|
||||||
|
// safeguard: don't move backwards
|
||||||
|
return;
|
||||||
|
}
|
||||||
boolean savedPreserveWS= preserveWhitespace;
|
boolean savedPreserveWS= preserveWhitespace;
|
||||||
boolean savedPreserveNL= preserveNewlines;
|
boolean savedPreserveNL= preserveNewlines;
|
||||||
boolean savedSkipOverInactive= skipOverInactive;
|
boolean savedSkipOverInactive= skipOverInactive;
|
||||||
|
@ -1353,10 +1357,10 @@ public class Scribe {
|
||||||
boolean hasWhitespaces= false;
|
boolean hasWhitespaces= false;
|
||||||
boolean hasComment= false;
|
boolean hasComment= false;
|
||||||
boolean hasLineComment= false;
|
boolean hasLineComment= false;
|
||||||
|
int count= 0;
|
||||||
while ((currentToken= scanner.nextToken()) != null) {
|
while ((currentToken= scanner.nextToken()) != null) {
|
||||||
switch (currentToken.type) {
|
switch (currentToken.type) {
|
||||||
case Token.tWHITESPACE:
|
case Token.tWHITESPACE:
|
||||||
int count= 0;
|
|
||||||
char[] whiteSpaces= scanner.getCurrentTokenSource();
|
char[] whiteSpaces= scanner.getCurrentTokenSource();
|
||||||
for (int i= 0, max= whiteSpaces.length; i < max; i++) {
|
for (int i= 0, max= whiteSpaces.length; i < max; i++) {
|
||||||
switch (whiteSpaces[i]) {
|
switch (whiteSpaces[i]) {
|
||||||
|
|
|
@ -729,7 +729,9 @@ public class SimpleScanner {
|
||||||
while (c != '\n' && c != EOFCHAR) {
|
while (c != '\n' && c != EOFCHAR) {
|
||||||
c = getChar();
|
c = getChar();
|
||||||
}
|
}
|
||||||
ungetChar(c);
|
if (c == EOFCHAR) {
|
||||||
|
ungetChar(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matchMultilineComment() {
|
private boolean matchMultilineComment() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue