mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Cosmetics.
This commit is contained in:
parent
0d4ca399d0
commit
ea13804fa6
3 changed files with 34 additions and 42 deletions
|
@ -3313,8 +3313,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
// deal with (quite unexpected) comments right before lcurly
|
// deal with (quite unexpected) comments right before lcurly
|
||||||
scribe.printComment();
|
scribe.printComment();
|
||||||
if (DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP.equals(bracePosition)
|
if (DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP.equals(bracePosition)
|
||||||
&& (scribe.line > line || scribe.column >= preferences.page_width))
|
&& (scribe.line > line || scribe.column >= preferences.page_width)) {
|
||||||
{
|
|
||||||
scribe.startNewLine();
|
scribe.startNewLine();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -515,7 +515,8 @@ public class Scribe {
|
||||||
public void handleLineTooLong() {
|
public void handleLineTooLong() {
|
||||||
// search for closest breakable alignment, using tiebreak rules
|
// search for closest breakable alignment, using tiebreak rules
|
||||||
// look for outermost breakable one
|
// look for outermost breakable one
|
||||||
int relativeDepth= 0, outerMostDepth= -1;
|
int relativeDepth= 0;
|
||||||
|
int outerMostDepth= -1;
|
||||||
Alignment targetAlignment= currentAlignment;
|
Alignment targetAlignment= currentAlignment;
|
||||||
while (targetAlignment != null) {
|
while (targetAlignment != null) {
|
||||||
if (targetAlignment.tieBreakRule == Alignment.R_OUTERMOST && targetAlignment.couldBreak()) {
|
if (targetAlignment.tieBreakRule == Alignment.R_OUTERMOST && targetAlignment.couldBreak()) {
|
||||||
|
@ -1324,7 +1325,7 @@ public class Scribe {
|
||||||
print(currentToken.getLength(), considerSpaceIfAny);
|
print(currentToken.getLength(), considerSpaceIfAny);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printRule(StringBuilder stringBuffer) {
|
private void printRuler(StringBuilder stringBuffer) {
|
||||||
for (int i= 0; i < pageWidth; i++) {
|
for (int i= 0; i < pageWidth; i++) {
|
||||||
if ((i % tabLength) == 0) {
|
if ((i % tabLength) == 0) {
|
||||||
stringBuffer.append('+');
|
stringBuffer.append('+');
|
||||||
|
@ -1520,15 +1521,13 @@ public class Scribe {
|
||||||
buffer
|
buffer
|
||||||
.append(") - (tabSize = " + tabLength + ")")//$NON-NLS-1$//$NON-NLS-2$
|
.append(") - (tabSize = " + tabLength + ")")//$NON-NLS-1$//$NON-NLS-2$
|
||||||
.append(lineSeparator)
|
.append(lineSeparator)
|
||||||
.append(
|
.append("(line = " + line + ") - (column = " + column + ") - (identationLevel = " + indentationLevel + ")") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
"(line = " + line + ") - (column = " + column + ") - (identationLevel = " + indentationLevel + ")") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
||||||
.append(lineSeparator)
|
.append(lineSeparator)
|
||||||
.append(
|
.append("(needSpace = " + needSpace + ") - (lastNumberOfNewLines = " + lastNumberOfNewLines + ") - (checkLineWrapping = " + checkLineWrapping + ")") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
"(needSpace = " + needSpace + ") - (lastNumberOfNewLines = " + lastNumberOfNewLines + ") - (checkLineWrapping = " + checkLineWrapping + ")") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
||||||
.append(lineSeparator).append(
|
.append(lineSeparator).append(
|
||||||
"==================================================================================") //$NON-NLS-1$
|
"==================================================================================") //$NON-NLS-1$
|
||||||
.append(lineSeparator);
|
.append(lineSeparator);
|
||||||
printRule(buffer);
|
printRuler(buffer);
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,14 +13,12 @@ package org.eclipse.cdt.internal.formatter.align;
|
||||||
import org.eclipse.cdt.internal.formatter.Location;
|
import org.eclipse.cdt.internal.formatter.Location;
|
||||||
import org.eclipse.cdt.internal.formatter.Scribe;
|
import org.eclipse.cdt.internal.formatter.Scribe;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alignment management
|
* Alignment management
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class Alignment {
|
public class Alignment {
|
||||||
|
|
||||||
// name of alignment
|
// name of alignment
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
|
@ -134,7 +132,6 @@ public class Alignment {
|
||||||
|
|
||||||
// location to align and break on.
|
// location to align and break on.
|
||||||
public Alignment(String name, int mode, int tieBreakRule, Scribe scribe, int fragmentCount, int sourceRestart, int continuationIndent) {
|
public Alignment(String name, int mode, int tieBreakRule, Scribe scribe, int fragmentCount, int sourceRestart, int continuationIndent) {
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.location = new Location(scribe, sourceRestart);
|
this.location = new Location(scribe, sourceRestart);
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
|
@ -204,7 +201,6 @@ public class Alignment {
|
||||||
}
|
}
|
||||||
// backtrack only once all fragments got checked
|
// backtrack only once all fragments got checked
|
||||||
if (this.needRedoColumnAlignment && this.fragmentIndex == this.fragmentCount-1) { // alignment too small
|
if (this.needRedoColumnAlignment && this.fragmentIndex == this.fragmentCount-1) { // alignment too small
|
||||||
|
|
||||||
// if (CodeFormatterVisitor.DEBUG) {
|
// if (CodeFormatterVisitor.DEBUG) {
|
||||||
// System.out.println("ALIGNMENT TOO SMALL");
|
// System.out.println("ALIGNMENT TOO SMALL");
|
||||||
// System.out.println(this);
|
// System.out.println(this);
|
||||||
|
@ -320,7 +316,6 @@ public class Alignment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Alignment getAlignment(String targetName) {
|
public Alignment getAlignment(String targetName) {
|
||||||
|
|
||||||
if (targetName.equals(this.name)) return this;
|
if (targetName.equals(this.name)) return this;
|
||||||
if (this.enclosing == null) return null;
|
if (this.enclosing == null) return null;
|
||||||
|
|
||||||
|
@ -357,7 +352,6 @@ public class Alignment {
|
||||||
|
|
||||||
// reset fragment indentation/break status
|
// reset fragment indentation/break status
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
|
||||||
if (fragmentCount > 0) {
|
if (fragmentCount > 0) {
|
||||||
this.fragmentIndentations = new int[this.fragmentCount];
|
this.fragmentIndentations = new int[this.fragmentCount];
|
||||||
this.fragmentBreaks = new int[this.fragmentCount];
|
this.fragmentBreaks = new int[this.fragmentCount];
|
||||||
|
|
Loading…
Add table
Reference in a new issue