Lines 2793-2816
Link Here
|
2793 |
} |
2793 |
} |
2794 |
int lastColumn = this.column + length; |
2794 |
int lastColumn = this.column + length; |
2795 |
while (!this.scanner.atEnd()) { |
2795 |
while (!this.scanner.atEnd()) { |
2796 |
int token = this.scanner.getNextToken(); |
2796 |
try { |
2797 |
switch (token) { |
2797 |
int token = this.scanner.getNextToken(); |
2798 |
case TerminalTokens.TokenNameWHITESPACE: |
2798 |
switch (token) { |
2799 |
if (CharOperation.indexOf('\n', this.scanner.source, this.scanner.startPosition, this.scanner.currentPosition) >= 0) { |
2799 |
case TerminalTokens.TokenNameWHITESPACE: |
2800 |
return newLines; |
2800 |
if (CharOperation.indexOf('\n', this.scanner.source, this.scanner.startPosition, this.scanner.currentPosition) >= 0) { |
2801 |
} |
2801 |
return newLines; |
2802 |
length = 1; |
2802 |
} |
2803 |
break; |
2803 |
length = 1; |
2804 |
case TerminalTokens.TokenNameMULTIPLY: |
2804 |
break; |
2805 |
if (newLine) { |
2805 |
case TerminalTokens.TokenNameMULTIPLY: |
2806 |
newLine = false; |
2806 |
if (newLine) { |
2807 |
continue; |
2807 |
newLine = false; |
2808 |
} |
2808 |
continue; |
2809 |
length = 1; |
2809 |
} |
2810 |
break; |
2810 |
length = 1; |
2811 |
default: |
2811 |
break; |
2812 |
length = (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - this.scanner.startPosition; |
2812 |
default: |
2813 |
break; |
2813 |
length = (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - this.scanner.startPosition; |
|
|
2814 |
break; |
2815 |
} |
2816 |
} |
2817 |
catch (InvalidInputException iie) { |
2818 |
// maybe an unterminated string or comment |
2819 |
length = (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - this.scanner.startPosition; |
2814 |
} |
2820 |
} |
2815 |
lastColumn += length; |
2821 |
lastColumn += length; |
2816 |
if (lastColumn > maxColumn) { |
2822 |
if (lastColumn > maxColumn) { |
Lines 3008-3014
Link Here
|
3008 |
} |
3014 |
} |
3009 |
textLength += (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - this.scanner.startPosition; |
3015 |
textLength += (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - this.scanner.startPosition; |
3010 |
} catch (InvalidInputException e) { |
3016 |
} catch (InvalidInputException e) { |
3011 |
return textLength; |
3017 |
// maybe an unterminated string or comment |
|
|
3018 |
textLength += (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - this.scanner.startPosition; |
3012 |
} |
3019 |
} |
3013 |
} |
3020 |
} |
3014 |
return textLength; |
3021 |
return textLength; |
Lines 3167-3172
Link Here
|
3167 |
int linePtr = this.scanner.linePtr; |
3174 |
int linePtr = this.scanner.linePtr; |
3168 |
int lineCount = 0; |
3175 |
int lineCount = 0; |
3169 |
int start = textStartPosition; |
3176 |
int start = textStartPosition; |
|
|
3177 |
boolean endsOnMultiply = false; |
3170 |
while (!this.scanner.atEnd()) { |
3178 |
while (!this.scanner.atEnd()) { |
3171 |
switch (this.scanner.getNextToken()) { |
3179 |
switch (this.scanner.getNextToken()) { |
3172 |
case TerminalTokens.TokenNameMULTIPLY: |
3180 |
case TerminalTokens.TokenNameMULTIPLY: |
Lines 3224-3229
Link Here
|
3224 |
// next start is just after the current token |
3232 |
// next start is just after the current token |
3225 |
start = this.scanner.currentPosition; |
3233 |
start = this.scanner.currentPosition; |
3226 |
linePtr = this.scanner.linePtr; |
3234 |
linePtr = this.scanner.linePtr; |
|
|
3235 |
endsOnMultiply = true; |
3236 |
break; |
3237 |
default: |
3238 |
endsOnMultiply = false; |
3227 |
break; |
3239 |
break; |
3228 |
} |
3240 |
} |
3229 |
} |
3241 |
} |
Lines 3277-3282
Link Here
|
3277 |
} else { |
3289 |
} else { |
3278 |
output.append(buffer); |
3290 |
output.append(buffer); |
3279 |
} |
3291 |
} |
|
|
3292 |
this.needSpace = false; |
3293 |
} else if (endsOnMultiply) { |
3294 |
if (output == null) { |
3295 |
addInsertEdit(textEndPosition+1, " "); //$NON-NLS-1$ |
3296 |
} else { |
3297 |
output.append(' '); |
3298 |
} |
3299 |
this.needSpace = false; |
3280 |
} |
3300 |
} |
3281 |
this.column++; |
3301 |
this.column++; |
3282 |
} |
3302 |
} |
Lines 3427-3433
Link Here
|
3427 |
} |
3447 |
} |
3428 |
} else { |
3448 |
} else { |
3429 |
if (idx > 0 && linesAfter > 0) { |
3449 |
if (idx > 0 && linesAfter > 0) { |
3430 |
printJavadocGapLines(previousEnd+1, nextStart, linesAfter, clearBlankLines, false, buffer); |
3450 |
printJavadocGapLines(previousEnd+1, nextStart-1, linesAfter, clearBlankLines, false, buffer); |
3431 |
textOnNewLine = true; |
3451 |
textOnNewLine = true; |
3432 |
} |
3452 |
} |
3433 |
boolean needIndentation = textOnNewLine; |
3453 |
boolean needIndentation = textOnNewLine; |
Lines 3506-3514
Link Here
|
3506 |
// Format gap lines before code |
3526 |
// Format gap lines before code |
3507 |
int newLines = linesGap; |
3527 |
int newLines = linesGap; |
3508 |
if (newLines == 0) newLines=1; |
3528 |
if (newLines == 0) newLines=1; |
|
|
3529 |
this.needSpace = needLeadingSpace; |
3509 |
printJavadocGapLines(end+1, nextStart-1, newLines, false/* clear first blank lines inside <pre> tag as done by old formatter */, false, null); |
3530 |
printJavadocGapLines(end+1, nextStart-1, newLines, false/* clear first blank lines inside <pre> tag as done by old formatter */, false, null); |
3510 |
if (needLeadingSpace) { |
3531 |
if (this.needSpace) { |
3511 |
addInsertEdit(nextStart, " "); //$NON-NLS-1$ |
3532 |
addInsertEdit(nextStart, " "); //$NON-NLS-1$ |
|
|
3533 |
this.needSpace = false; |
3512 |
} |
3534 |
} |
3513 |
// Format the code |
3535 |
// Format the code |
3514 |
printCodeSnippet(nextStart, codeEnd); |
3536 |
printCodeSnippet(nextStart, codeEnd); |