mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Cosmetics.
Fix mixed indentation Change-Id: Iba3193013c2e6cd5e21e0d61f47b244dfafe0582 Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
This commit is contained in:
parent
30cde08c83
commit
21dacc15fd
1 changed files with 92 additions and 92 deletions
|
@ -239,7 +239,7 @@ public class Scribe {
|
|||
length -= i;
|
||||
if (i > 0) {
|
||||
replacement = i == replacementLength ?
|
||||
EMPTY_STRING : replacement.subSequence(i, replacementLength);
|
||||
EMPTY_STRING : replacement.subSequence(i, replacementLength);
|
||||
}
|
||||
if (length > 0 || replacement.length() > 0) {
|
||||
edits[editsIndex++]= new OptimizedReplaceEdit(offset, length, replacement);
|
||||
|
@ -1308,24 +1308,24 @@ public class Scribe {
|
|||
}
|
||||
|
||||
private void printLineComment() {
|
||||
int currentTokenStartPosition = scanner.getCurrentTokenStartPosition();
|
||||
int currentTokenEndPosition = scanner.getCurrentTokenEndPosition() + 1;
|
||||
scanner.resetTo(currentTokenStartPosition, currentTokenEndPosition);
|
||||
int currentCharacter;
|
||||
int start = currentTokenStartPosition;
|
||||
int nextCharacterStart = currentTokenStartPosition;
|
||||
int currentTokenStartPosition = scanner.getCurrentTokenStartPosition();
|
||||
int currentTokenEndPosition = scanner.getCurrentTokenEndPosition() + 1;
|
||||
scanner.resetTo(currentTokenStartPosition, currentTokenEndPosition);
|
||||
int currentCharacter;
|
||||
int start = currentTokenStartPosition;
|
||||
int nextCharacterStart = currentTokenStartPosition;
|
||||
|
||||
// Print comment line indentation
|
||||
int commentIndentationLevel;
|
||||
boolean onFirstColumn = isOnFirstColumn(start);
|
||||
if (indentationLevel == 0) {
|
||||
commentIndentationLevel = column - 1;
|
||||
} else {
|
||||
// Print comment line indentation
|
||||
int commentIndentationLevel;
|
||||
boolean onFirstColumn = isOnFirstColumn(start);
|
||||
if (indentationLevel == 0) {
|
||||
commentIndentationLevel = column - 1;
|
||||
} else {
|
||||
if (onFirstColumn && preferences.never_indent_line_comments_on_first_column) {
|
||||
commentIndentationLevel = column - 1;
|
||||
} else {
|
||||
// Indentation may be specific for contiguous comment
|
||||
// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=293300
|
||||
commentIndentationLevel = column - 1;
|
||||
} else {
|
||||
// Indentation may be specific for contiguous comment
|
||||
// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=293300
|
||||
if (lastLineComment.contiguous) {
|
||||
// The leading spaces have been set while looping in the printComment(int) method
|
||||
int currentCommentIndentation = computeIndentation(lastLineComment.leadingSpaces, 0);
|
||||
|
@ -1344,17 +1344,17 @@ public class Scribe {
|
|||
indentationLevel = lastLineComment.indentation;
|
||||
printIndentationIfNecessary();
|
||||
indentationLevel = currentIndentationLevel;
|
||||
commentIndentationLevel = lastLineComment.indentation;
|
||||
commentIndentationLevel = lastLineComment.indentation;
|
||||
} else {
|
||||
printIndentationIfNecessary();
|
||||
commentIndentationLevel = column - 1;
|
||||
commentIndentationLevel = column - 1;
|
||||
}
|
||||
} else {
|
||||
printIndentationIfNecessary();
|
||||
commentIndentationLevel = column - 1;
|
||||
printIndentationIfNecessary();
|
||||
commentIndentationLevel = column - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare white space before the comment.
|
||||
StringBuilder whitespace = null;
|
||||
|
@ -1374,9 +1374,9 @@ public class Scribe {
|
|||
}
|
||||
}
|
||||
|
||||
// Store line comment information
|
||||
// Store line comment information
|
||||
lastLineComment.currentIndentation = getIndentationOfOffset(currentTokenStartPosition);
|
||||
lastLineComment.contiguous = true;
|
||||
lastLineComment.contiguous = true;
|
||||
|
||||
while (true) {
|
||||
Location location = new Location(this, scanner.getCurrentPosition());
|
||||
|
@ -1386,35 +1386,35 @@ public class Scribe {
|
|||
if (whitespace != null) {
|
||||
addInsertEdit(currentTokenStartPosition, whitespace);
|
||||
commentIndent = computeIndentation(whitespace, commentIndentationLevel);
|
||||
needSpace = false;
|
||||
pendingSpace = false;
|
||||
needSpace = false;
|
||||
pendingSpace = false;
|
||||
}
|
||||
lastLineComment.indentation = commentIndent;
|
||||
|
||||
int previousStart = currentTokenStartPosition;
|
||||
int previousStart = currentTokenStartPosition;
|
||||
|
||||
int indent = commentIndent;
|
||||
loop: while (nextCharacterStart <= currentTokenEndPosition &&
|
||||
(currentCharacter = scanner.getNextChar()) != -1) {
|
||||
nextCharacterStart = scanner.getCurrentPosition();
|
||||
int indent = commentIndent;
|
||||
loop: while (nextCharacterStart <= currentTokenEndPosition &&
|
||||
(currentCharacter = scanner.getNextChar()) != -1) {
|
||||
nextCharacterStart = scanner.getCurrentPosition();
|
||||
|
||||
switch (currentCharacter) {
|
||||
switch (currentCharacter) {
|
||||
case '\r':
|
||||
case '\n':
|
||||
start = previousStart;
|
||||
break loop;
|
||||
}
|
||||
indent = computeIndentation((char) currentCharacter, indent);
|
||||
previousStart = nextCharacterStart;
|
||||
}
|
||||
}
|
||||
indent = computeIndentation((char) currentCharacter, indent);
|
||||
previousStart = nextCharacterStart;
|
||||
}
|
||||
|
||||
if (start != currentTokenStartPosition) {
|
||||
// This means that the line comment doesn't end the file
|
||||
addReplaceEdit(start, currentTokenEndPosition - 1, lineSeparator);
|
||||
line++;
|
||||
column = 1;
|
||||
lastNumberOfNewLines = 1;
|
||||
}
|
||||
if (start != currentTokenStartPosition) {
|
||||
// This means that the line comment doesn't end the file
|
||||
addReplaceEdit(start, currentTokenEndPosition - 1, lineSeparator);
|
||||
line++;
|
||||
column = 1;
|
||||
lastNumberOfNewLines = 1;
|
||||
}
|
||||
if (!checkLineWrapping || indent <= pageWidth || whitespace == null ||
|
||||
commentIndent - commentIndentationLevel <= preferences.comment_min_distance_between_code_and_line_comment) {
|
||||
break;
|
||||
|
@ -1423,44 +1423,44 @@ public class Scribe {
|
|||
// Maximum line length was exceeded. Try to reduce white space before the comment by
|
||||
// removing the last white space character.
|
||||
whitespace.deleteCharAt(whitespace.length() - 1);
|
||||
if (computeIndentation(lastLineComment.leadingSpaces, commentIndentationLevel) - commentIndentationLevel <
|
||||
preferences.comment_min_distance_between_code_and_line_comment) {
|
||||
// The white space shrank too much. Rebuild it to satisfy the minimum distance
|
||||
// requirement.
|
||||
whitespace.delete(0, whitespace.length());
|
||||
for (int i = 0; i < preferences.comment_min_distance_between_code_and_line_comment; i++) {
|
||||
if (computeIndentation(lastLineComment.leadingSpaces, commentIndentationLevel) - commentIndentationLevel <
|
||||
preferences.comment_min_distance_between_code_and_line_comment) {
|
||||
// The white space shrank too much. Rebuild it to satisfy the minimum distance
|
||||
// requirement.
|
||||
whitespace.delete(0, whitespace.length());
|
||||
for (int i = 0; i < preferences.comment_min_distance_between_code_and_line_comment; i++) {
|
||||
whitespace.append(' ');
|
||||
}
|
||||
}
|
||||
resetAt(location);
|
||||
}
|
||||
resetAt(location);
|
||||
scanner.resetTo(location.inputOffset, scanner.eofPosition);
|
||||
}
|
||||
|
||||
needSpace = false;
|
||||
pendingSpace = false;
|
||||
// realign to the proper value
|
||||
if (currentAlignment != null) {
|
||||
if (memberAlignment != null) {
|
||||
// select the last alignment
|
||||
if (currentAlignment.location.inputOffset > memberAlignment.location.inputOffset) {
|
||||
if (currentAlignment.couldBreak() && currentAlignment.wasSplit) {
|
||||
currentAlignment.performFragmentEffect();
|
||||
}
|
||||
} else {
|
||||
indentationLevel = Math.max(indentationLevel, memberAlignment.breakIndentationLevel);
|
||||
}
|
||||
} else if (currentAlignment.couldBreak() && currentAlignment.wasSplit) {
|
||||
currentAlignment.performFragmentEffect();
|
||||
}
|
||||
if (currentAlignment.name.equals(Alignment.BINARY_EXPRESSION) &&
|
||||
currentAlignment.enclosing != null &&
|
||||
currentAlignment.enclosing.equals(Alignment.BINARY_EXPRESSION) &&
|
||||
indentationLevel < currentAlignment.breakIndentationLevel) {
|
||||
indentationLevel = currentAlignment.breakIndentationLevel;
|
||||
}
|
||||
}
|
||||
scanner.resetTo(currentTokenEndPosition, scannerEndPosition);
|
||||
}
|
||||
needSpace = false;
|
||||
pendingSpace = false;
|
||||
// realign to the proper value
|
||||
if (currentAlignment != null) {
|
||||
if (memberAlignment != null) {
|
||||
// select the last alignment
|
||||
if (currentAlignment.location.inputOffset > memberAlignment.location.inputOffset) {
|
||||
if (currentAlignment.couldBreak() && currentAlignment.wasSplit) {
|
||||
currentAlignment.performFragmentEffect();
|
||||
}
|
||||
} else {
|
||||
indentationLevel = Math.max(indentationLevel, memberAlignment.breakIndentationLevel);
|
||||
}
|
||||
} else if (currentAlignment.couldBreak() && currentAlignment.wasSplit) {
|
||||
currentAlignment.performFragmentEffect();
|
||||
}
|
||||
if (currentAlignment.name.equals(Alignment.BINARY_EXPRESSION) &&
|
||||
currentAlignment.enclosing != null &&
|
||||
currentAlignment.enclosing.equals(Alignment.BINARY_EXPRESSION) &&
|
||||
indentationLevel < currentAlignment.breakIndentationLevel) {
|
||||
indentationLevel = currentAlignment.breakIndentationLevel;
|
||||
}
|
||||
}
|
||||
scanner.resetTo(currentTokenEndPosition, scannerEndPosition);
|
||||
}
|
||||
|
||||
public void printEmptyLines(int linesNumber) {
|
||||
printEmptyLines(linesNumber, scanner.getCurrentTokenEndPosition() + 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue