### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core
Index: formatter/org/eclipse/jdt/internal/formatter/Scribe.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java,v
retrieving revision 1.125
diff -u -r1.125 Scribe.java
--- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 23 Apr 2008 22:29:00 -0000 1.125
+++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 25 Apr 2008 13:11:11 -0000
@@ -1157,7 +1157,8 @@
this.scanner.getNextChar();
this.column += 2;
this.scanner.skipComments = true;
-
+ StringBuffer tokensBuffer = new StringBuffer();
+
// Consume text token per token
int maxColumn = this.formatter.preferences.comment_line_length + 1;
int previousToken = -1;
@@ -1172,7 +1173,6 @@
int lineNumber = scannerLine;
int lastTextLine = -1;
boolean openedString = false;
- boolean openedChar = false;
while (!this.scanner.atEnd()) {
// Consume token
@@ -1183,29 +1183,20 @@
String msg = iie.getMessage();
boolean insertSpace = (previousToken == TerminalTokens.TokenNameWHITESPACE || newLine) && !firstWord;
if (msg == Scanner.INVALID_CHARACTER_CONSTANT) {
- if (openedChar) {
- openedChar = false;
- } else {
- if (insertSpace) {
- buffer.append(' ');
- this.column++;
- }
- openedChar = true;
+ if (insertSpace) {
+ tokensBuffer.append(' ');
}
- buffer.append('\'');
- this.column++;
+ tokensBuffer.append('\'');
} else if (msg == Scanner.INVALID_CHAR_IN_STRING) {
if (openedString) {
openedString = false;
} else {
if (insertSpace) {
- buffer.append(' ');
- this.column++;
+ tokensBuffer.append(' ');
}
openedString = true;
}
- buffer.append('"');
- this.column++;
+ tokensBuffer.append('"');
} else {
// skip failure
}
@@ -1218,9 +1209,12 @@
}
// Look at specific tokens
- boolean insertSpace = (previousToken == TerminalTokens.TokenNameWHITESPACE || newLine) && !firstWord;
+ boolean insertSpace = (previousToken == TerminalTokens.TokenNameWHITESPACE || newLine) && (!firstWord || !hasTokens);
switch (token) {
case TerminalTokens.TokenNameWHITESPACE:
+ buffer.append(tokensBuffer);
+ this.column += tokensBuffer.length();
+ tokensBuffer.setLength(0);
previousToken = token;
lineNumber = Util.getLineNumber(this.scanner.getCurrentTokenEndPosition(), this.lineEnds, scannerLine>1 ? scannerLine-2 : 0, this.maxLines);
if (lineNumber > scannerLine) {
@@ -1230,8 +1224,14 @@
scannerLine = lineNumber;
continue;
case TerminalTokens.TokenNameMULTIPLY:
+ previousToken = token;
lineNumber = Util.getLineNumber(this.scanner.getCurrentTokenEndPosition(), this.lineEnds, scannerLine>1 ? scannerLine-2 : 0, this.maxLines);
if (this.scanner.currentCharacter == '/') {
+ // Add remaining buffered tokens
+ if (tokensBuffer.length() > 0) {
+ buffer.append(tokensBuffer);
+ this.column += tokensBuffer.length();
+ }
// end of comment
if (multiLines) {
buffer.append(this.lineSeparator);
@@ -1240,64 +1240,12 @@
}
buffer.append(' ');
buffer.append(BLOCK_FOOTER);
- this.column += BLOCK_LINE_PREFIX_LENGTH + 1;
+ this.column += BLOCK_FOOTER_LENGTH + 1;
this.scanner.getNextChar(); // reach the end of scanner
continue;
}
scannerLine = lineNumber;
continue;
- case TerminalTokens.TokenNameLESS:
- // We cannot break tags
- StringBuffer breakBuffer = new StringBuffer();
- int start = this.scanner.startPosition;
- int tokenLength = (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - this.scanner.startPosition;
- breakBuffer.append(this.scanner.source, this.scanner.startPosition, tokenLength);
- try {
- boolean closing = false;
- if ((token = this.scanner.getNextToken()) == TerminalTokens.TokenNameDIVIDE) {
- tokenLength = (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - this.scanner.startPosition;
- breakBuffer.append(this.scanner.source, this.scanner.startPosition, tokenLength);
- token = this.scanner.getNextToken();
- closing = true;
- }
- if (token == TerminalTokens.TokenNameIdentifier) {
- tokenLength = (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - this.scanner.startPosition;
- breakBuffer.append(this.scanner.source, this.scanner.startPosition, tokenLength);
- token = this.scanner.getNextToken();
- if (token == TerminalTokens.TokenNameGREATER) {
- tokenLength = (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - this.scanner.startPosition;
- breakBuffer.append(this.scanner.source, this.scanner.startPosition, tokenLength);
- if ((this.column + breakBuffer.length()) > maxColumn) {
- buffer.append(this.lineSeparator);
- this.column = 1;
- printIndentationIfNecessary(buffer);
- buffer.append(BLOCK_LINE_PREFIX);
- this.column += BLOCK_LINE_PREFIX_LENGTH;
- multiLines = true;
- } else if (!closing) {
- buffer.append(' ');
- this.column++;
- }
- buffer.append(breakBuffer);
- this.column += breakBuffer.length();
- previousToken = token;
- scannerLine = lineNumber;
- newLine = false;
- continue;
- }
- }
- }
- catch (InvalidInputException iie) {
- // forget as we're started after next token
- }
- // Need to retrieve correct position
- this.scanner.resetTo(start, currentTokenEndPosition-1);
- try {
- token = this.scanner.getNextToken();
- } catch (InvalidInputException e) {
- // will not happen
- }
- break;
}
// Look at gap and insert corresponding lines if necessary
@@ -1324,6 +1272,11 @@
}
}
for (int i=0; i 0) {
+ buffer.append(tokensBuffer);
+ tokensBuffer.setLength(0);
+ }
buffer.append(this.lineSeparator);
this.column = 1;
printIndentationIfNecessary(buffer);
@@ -1343,28 +1296,44 @@
hasTokens = true;
if (!hastTextOnFirstLine && scannerLine == firstLine) {
hastTextOnFirstLine = true;
- this.column++;
}
- this.column += tokenLength;
- if (previousToken == -1 || insertSpace) this.column++;
+ int lastColumn = this.column + tokensBuffer.length() + tokenLength;
+ if (previousToken == -1 || insertSpace) lastColumn++;
// Append next token inserting a new line if max line is reached
- if (!firstWord && this.column > maxColumn) {
+ if (!firstWord && lastColumn > maxColumn) {
+ String tokensString = tokensBuffer.toString().trim();
+ if ((firstColumn+tokensString.length()+tokenLength) > maxColumn) {
+ // there won't be enough room even if we break the line before the buffered tokens
+ // So add the buffered tokens now
+ if (buffer.length() == 0) {
+ buffer.append(' ');
+ this.column++;
+ }
+ buffer.append(tokensString);
+ this.column += tokensString.length();
+ tokensBuffer.setLength(0);
+ }
// not enough space on the line
buffer.append(this.lineSeparator);
this.column = 1;
printIndentationIfNecessary(buffer);
buffer.append(BLOCK_LINE_PREFIX);
this.column += BLOCK_LINE_PREFIX_LENGTH;
+ if (tokensBuffer.length() > 0) {
+ buffer.append(tokensString);
+ this.column += tokensString.length();
+ tokensBuffer.setLength(0);
+ }
buffer.append(this.scanner.source, tokenStart, tokenLength);
this.column += tokenLength;
multiLines = true;
} else {
// append token to the line
if (insertSpace) {
- if (buffer.length() > 0) buffer.append(' ');
+ tokensBuffer.append(' ');
}
- buffer.append(this.scanner.source, tokenStart, tokenLength);
+ tokensBuffer.append(this.scanner.source, tokenStart, tokenLength);
}
previousToken = token;
newLine = false;
@@ -1380,11 +1349,20 @@
replacement.append(this.lineSeparator);
this.column = 1;
printIndentationIfNecessary(replacement);
- replacement.append(BLOCK_LINE_PREFIX);
+ if (buffer.charAt(0) == ' ') {
+ replacement.append(' ');
+ replacement.append('*');
+ } else {
+ replacement.append(BLOCK_LINE_PREFIX);
+ this.column++;
+ }
this.column = col;
}
} else {
- if (hasTokens) replacement.append(' ');
+ if (buffer.charAt(0) != ' ') {
+ replacement.append(' ');
+ this.column++;
+ }
}
replacement.append(buffer);
addReplaceEdit(currentTokenStartPosition, currentTokenEndPosition-1, replacement.toString());
@@ -2057,18 +2035,20 @@
int maxNodes = block.nodesPtr;
// format tag section if necessary
+ int maxColumn = this.formatter.preferences.comment_line_length;
+ boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment;
if (!block.isDescription()) {
this.column += previousEnd - block.sourceStart + 1;
if (block.isInlined()) {
this.column++; // Add extra character for inline tag
}
- FormatJavadocNode reference= block.reference;
+ FormatJavadocReference reference= block.reference;
if (reference != null) {
- // format between tag name and reference
- addReplaceEdit(previousEnd+1, reference.sourceStart - 1, " "); //$NON-NLS-1$
- this.column++;
+ // format reference
+ StringBuffer buffer = new StringBuffer();
+ printJavadocBlockReference(buffer, reference, block);
+ addReplaceEdit(previousEnd+1, reference.sourceEnd, buffer.toString());
previousEnd = reference.sourceEnd;
- this.column += previousEnd - reference.sourceStart + 1;
}
// Nothing else to do if the tag has no node
@@ -2076,7 +2056,6 @@
}
// tag section: iterate through the blocks composing this tag but the last one
- int maxColumn = this.formatter.preferences.comment_line_length;
if (block.isHeaderLine()) maxColumn++;
for (int i=0; i<=maxNodes; i++) {
FormatJavadocNode node = block.nodes[i];
@@ -2084,10 +2063,11 @@
// Print empty lines before the node
int textLength = -1;
+ int newLines;
if (i == 0) {
- int newLines = this.formatter.preferences.comment_insert_new_line_for_parameter && block.isParamTag() ? 1 : 0;
+ newLines = this.formatter.preferences.comment_insert_new_line_for_parameter && !block.isInlined() && block.isParamTag() ? 1 : 0;
if (nodeStart > (previousEnd+1)) {
- printJavadocGapLines(previousEnd+1, nodeStart-1, newLines, this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment, false, null);
+ printJavadocGapLines(previousEnd+1, nodeStart-1, newLines, clearBlankLines, false, null);
} else {
StringBuffer buffer = new StringBuffer();
if (newLines > 0) {
@@ -2098,7 +2078,7 @@
}
}
} else {
- int newLines = this.column > this.formatter.preferences.comment_line_length ? 1 : 0;
+ newLines = this.column > this.formatter.preferences.comment_line_length ? 1 : 0;
if (node.isText()) {
// Need to verify if new line is necessary for immutable tag
FormatJavadocText text = (FormatJavadocText) node;
@@ -2137,12 +2117,12 @@
newLines = 1;
((FormatJavadocText)node).linesBefore = 1;
}
- printJavadocGapLines(previousEnd+1, nodeStart-1, newLines, this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment, false, null);
+ printJavadocGapLines(previousEnd+1, nodeStart-1, newLines, clearBlankLines, false, null);
} catch (InvalidInputException iie) {
// skip
}
} else {
- printJavadocGapLines(previousEnd+1, nodeStart-1, newLines, this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment, false, null);
+ printJavadocGapLines(previousEnd+1, nodeStart-1, newLines, clearBlankLines, false, null);
}
}
}
@@ -2156,6 +2136,15 @@
if (textLength == -1) {
textLength = getTextLength(block, text);
}
+ // Indent if new line was added
+ if (newLines > 0) {
+ int col = this.column;
+ StringBuffer buffer = new StringBuffer();
+ int textEnd = text.separatorsPtr == -1 ? text.sourceEnd : (int) (text.separators[0] >>> 32);
+ printJavadocTextLine(buffer, text.sourceStart, textEnd, block, true, true, true);
+ addReplaceEdit(text.sourceStart, textEnd, buffer.toString());
+ textLength -= this.column - col;
+ }
this.column += textLength;
} else {
printJavadocHtmlTag(text, block);
@@ -2172,6 +2161,132 @@
}
}
+ private void printJavadocBlockReference(StringBuffer buffer, FormatJavadocReference reference, FormatJavadocBlock block) {
+
+ boolean indentRootTags = this.formatter.preferences.comment_indent_root_tags && !block.isDescription();
+ boolean indentParamTag = this.formatter.preferences.comment_indent_parameter_description && block.isParamTag();
+ boolean headerLine = block.isHeaderLine() && this.lastNumberOfNewLines == 0;
+ StringBuffer tokensBuffer = new StringBuffer();
+
+ // First we need to know what is the indentation
+ int firstColumn = 1 + this.indentationLevel + BLOCK_LINE_PREFIX_LENGTH;
+ if (headerLine) firstColumn++;
+ StringBuffer indentationBuffer = null;
+ if (indentRootTags) {
+ int indentLevel = this.indentationLevel;
+ int indentations = this.numberOfIndentations;
+ this.numberOfIndentations += (BLOCK_LINE_PREFIX_LENGTH / this.indentationSize) + 1;
+ this.indentationLevel = this.numberOfIndentations * this.indentationSize;
+ int currentColumn = this.column;
+ this.column = firstColumn;
+ if (indentParamTag) {
+ this.indentationLevel += this.indentationSize;
+ this.numberOfIndentations++;
+ }
+ printIndentationIfNecessary(indentationBuffer = new StringBuffer());
+ firstColumn = this.indentationLevel + 1;
+ this.column = currentColumn;
+ this.indentationLevel = indentLevel;
+ this.numberOfIndentations = indentations;
+ }
+
+ // Scan the text token per token to compact it and size it the max line length
+ int maxColumn = this.formatter.preferences.comment_line_length + 1;
+ int previousToken = -1;
+ this.scanner.resetTo(reference.sourceStart, reference.sourceEnd);
+ while (!this.scanner.atEnd()) {
+ int token;
+ try {
+ token = this.scanner.getNextToken();
+ switch (token) {
+ case TerminalTokens.TokenNameWHITESPACE:
+ buffer.append(tokensBuffer);
+ this.column += tokensBuffer.length();
+ tokensBuffer.setLength(0);
+ if (CharOperation.indexOf('\n', this.scanner.source, this.scanner.startPosition, this.scanner.getCurrentTokenEndPosition()) >= 0) {
+ // consume line break
+ loop: while (true) {
+ token = this.scanner.getNextToken();
+ switch (token) {
+ case TerminalTokens.TokenNameWHITESPACE:
+ case TerminalTokens.TokenNameMULTIPLY:
+ previousToken = token; // will not insert space
+ continue;
+ default:
+ break loop;
+ }
+ }
+ break;
+ }
+ previousToken = token;
+ continue;
+ case TerminalTokens.TokenNameMULTIPLY:
+ previousToken = token;
+ continue;
+ }
+ } catch (InvalidInputException iie) {
+ continue;
+ }
+ int tokenStart = this.scanner.getCurrentTokenStartPosition();
+ int tokenLength = (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - tokenStart;
+ int lastColumn = this.column + tokensBuffer.length() + tokenLength;
+ boolean insertSpace = previousToken == TerminalTokens.TokenNameWHITESPACE || previousToken == -1;
+ if (insertSpace) lastColumn++;
+ if (headerLine) {
+ // special case when text is on the same line of the javadoc's header
+ if (lastColumn > maxColumn) {
+ lastColumn--; // new line gives an extra character
+ }
+ }
+ if (lastColumn > maxColumn) {
+ String tokensString = tokensBuffer.toString().trim();
+ int indentLength = indentationBuffer==null ? 0 : indentationBuffer.length();
+ if ((firstColumn-1+indentLength+tokensString.length()+tokenLength) > maxColumn) {
+ // there won't be enough room even if we break the line before the buffered tokens
+ // So add the buffered tokens now
+ if (buffer.length() == 0) {
+ buffer.append(' ');
+ this.column++;
+ }
+ buffer.append(tokensString);
+ this.column += tokensString.length();
+ tokensBuffer.setLength(0);
+ }
+ // not enough space on the line
+ buffer.append(this.lineSeparator);
+ this.column = 1;
+ printIndentationIfNecessary(buffer);
+ buffer.append(BLOCK_LINE_PREFIX);
+ this.column = headerLine ? firstColumn-1 : firstColumn;
+ if (indentationBuffer != null) {
+ buffer.append(indentationBuffer);
+ }
+ if (tokensBuffer.length() > 0) {
+ buffer.append(tokensString);
+ this.column += tokensString.length();
+ tokensBuffer.setLength(0);
+ }
+ buffer.append(this.scanner.source, tokenStart, tokenLength);
+ this.column += tokenLength;
+ if (headerLine) {
+ firstColumn--;
+ headerLine = false;
+ }
+ } else {
+ // append token to the line
+ if (insertSpace) {
+ tokensBuffer.append(' ');
+ }
+ tokensBuffer.append(this.scanner.source, tokenStart, tokenLength);
+ }
+ previousToken = token;
+ }
+ if (tokensBuffer.length() > 0) {
+ buffer.append(tokensBuffer);
+ this.column += tokensBuffer.length();
+ }
+ }
+
private int getTextLength(FormatJavadocBlock block, FormatJavadocText text) {
// Simple for one line tags
@@ -2482,7 +2597,7 @@
int textStart = text.sourceStart;
int nextStart = textStart;
int startLine = Util.getLineNumber(textStart, this.lineEnds, 0, this.maxLines);
- boolean textOnNewLine = (text == block.nodes[0] && ((block.isParamTag() && this.formatter.preferences.comment_insert_new_line_for_parameter) || !block.hasTextOnTagLine())) || text.linesBefore > 0;
+ boolean textOnNewLine = (text == block.nodes[0] && ((!block.isInlined() && block.isParamTag() && this.formatter.preferences.comment_insert_new_line_for_parameter) || !block.hasTextOnTagLine())) || text.linesBefore > 0;
int htmlTagID = text.getHtmlTagID();
StringBuffer buffer = new StringBuffer();
@@ -2510,7 +2625,6 @@
}
if (textStart < previousEnd) {
addReplaceEdit(textStart, previousEnd, buffer.toString());
-// this.column += buffer.length();
}
boolean immutable = htmlTag == null ? false : htmlTag.isImmutableHtmlTag();
boolean overEndLine = false;
@@ -2533,8 +2647,6 @@
if (indentationBuffer != null) {
addInsertEdit(node.sourceStart, indentationBuffer.toString());
}
-// buffer.append(' ');
-// this.column++;
}
} else {
linesAfter = printJavadocHtmlTag(htmlTag, block);
@@ -2554,7 +2666,7 @@
printJavadocGapLines(previousEnd+1, nextStart, linesAfter, clearBlankLines, false, buffer);
textOnNewLine = true;
}
- boolean needIndentation = buffer.length() == 0 && textOnNewLine;
+ boolean needIndentation = textOnNewLine;
if (idx > 0) {
if (!needIndentation && (text.htmlIndexes[idx-1] & JAVADOC_TAGS_ID_MASK) == JAVADOC_SEPARATOR_TAGS_ID) {
needIndentation = true;
@@ -2580,7 +2692,6 @@
if (clearBlankLines) {
// keep previously computed lines after
} else {
-// if (wasHtmlTag || idx==0 || (idx==max && ((text.htmlIndexes[max] & JAVADOC_TAGS_ID_MASK) == htmlTagID))) {
if (idx==0 || (idx==max && ((text.htmlIndexes[max] & JAVADOC_TAGS_ID_MASK) == htmlTagID)) || (idx < max && wasHtmlTag && (text.htmlIndexes[idx-1] & JAVADOC_TAGS_ID_MASK) != JAVADOC_IMMUTABLE_TAGS_ID)) {
if (linesAfter < linesGap) {
linesAfter = linesGap;
@@ -2668,7 +2779,7 @@
int textStart = text.sourceStart;
int nextStart = textStart;
int startLine = Util.getLineNumber(textStart, this.lineEnds, 0, this.maxLines);
- boolean textOnNewLine = (text == block.nodes[0] && block.isParamTag() && (this.formatter.preferences.comment_insert_new_line_for_parameter || !block.hasTextOnTagLine())) || text.linesBefore > 0;
+ boolean textOnNewLine = (text == block.nodes[0] && !block.isInlined() && block.isParamTag() && (this.formatter.preferences.comment_insert_new_line_for_parameter || !block.hasTextOnTagLine())) || text.linesBefore > 0 || this.column > (this.formatter.preferences.comment_line_length+1);
// Iterate on text line separators
for (int idx=0, max=text.separatorsPtr; idx<=max ; idx++) {
@@ -2719,7 +2830,7 @@
boolean indentRootTags = this.formatter.preferences.comment_indent_root_tags && !block.isDescription();
boolean indentParamTag = this.formatter.preferences.comment_indent_parameter_description && block.isParamTag();
boolean headerLine = (buffer.indexOf(Util.LINE_SEPARATOR) < 0) && block.isHeaderLine() && this.lastNumberOfNewLines == 0;
- StringBuffer textBuffer = isHtmlTag ? new StringBuffer() : buffer;
+ StringBuffer tokensBuffer = new StringBuffer();
// First we need to know what is the indentation
int firstColumn = 1 + this.indentationLevel + BLOCK_LINE_PREFIX_LENGTH;
@@ -2739,7 +2850,7 @@
printIndentationIfNecessary(indentationBuffer = new StringBuffer());
if (needIndentation) {
this.column = firstColumn;
- printIndentationIfNecessary(textBuffer);
+ printIndentationIfNecessary(buffer);
}
firstColumn = this.indentationLevel + 1;
this.column = currentColumn < firstColumn ? firstColumn : currentColumn;
@@ -2767,23 +2878,19 @@
String msg = iie.getMessage();
if (msg == Scanner.INVALID_CHARACTER_CONSTANT) {
if (insertSpace) {
- buffer.append(' ');
- this.column++;
+ tokensBuffer.append(' ');
}
- buffer.append('\'');
- this.column++;
+ tokensBuffer.append('\'');
} else if (msg == Scanner.INVALID_CHAR_IN_STRING) {
if (openedString) {
openedString = false;
} else {
if (insertSpace) {
- buffer.append(' ');
- this.column++;
+ tokensBuffer.append(' ');
}
openedString = true;
}
- buffer.append('"');
- this.column++;
+ tokensBuffer.append('"');
} else {
// skip failure
}
@@ -2795,24 +2902,26 @@
}
if (token == TerminalTokens.TokenNameWHITESPACE) {
previousToken = token;
+ buffer.append(tokensBuffer);
+ this.column += tokensBuffer.length();
+ tokensBuffer.setLength(0);
continue;
}
int tokenStart = this.scanner.getCurrentTokenStartPosition();
int tokenLength = (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - tokenStart;
boolean insertSpace = previousToken == TerminalTokens.TokenNameWHITESPACE || (tokenStart == textStart && this.column > firstColumn && !(firstText || isHtmlTag));
- this.column += tokenLength;
- if (insertSpace) this.column++;
- int col = column;
+ int lastColumn = this.column + tokensBuffer.length() + tokenLength;
+ if (insertSpace) lastColumn++;
if (headerLine) {
// special case when text is on the same line of the javadoc's header
- if (col > maxColumn) {
- col--; // new line gives an extra character
+ if (lastColumn > maxColumn) {
+ lastColumn--; // new line gives an extra character
this.lastNumberOfNewLines++; // in case we leave just after
}
}
- if (col > maxColumn) {
+ if (lastColumn > maxColumn) {
// not enough space on the line
- if (col == this.column) this.lastNumberOfNewLines++;
+ if (lastColumn == this.column) this.lastNumberOfNewLines++;
buffer.append(this.lineSeparator);
this.column = 1;
printIndentationIfNecessary(buffer);
@@ -2821,11 +2930,13 @@
if (indentationBuffer != null) {
buffer.append(indentationBuffer);
}
- if (isHtmlTag && buffer != textBuffer) {
- buffer.append(textBuffer);
- textBuffer = buffer;
- }
- textBuffer.append(this.scanner.source, tokenStart, tokenLength);
+ if (tokensBuffer.length() > 0) {
+ String tokensString = tokensBuffer.toString().trim();
+ buffer.append(tokensString);
+ this.column += tokensString.length();
+ tokensBuffer.setLength(0);
+ }
+ buffer.append(this.scanner.source, tokenStart, tokenLength);
this.column += tokenLength;
if (headerLine) {
firstColumn--;
@@ -2833,18 +2944,20 @@
}
} else {
// append token to the line
- if (insertSpace) {
- textBuffer.append(' ');
- }
- textBuffer.append(this.scanner.source, tokenStart, tokenLength);
+ if (insertSpace) {
+ tokensBuffer.append(' ');
+ }
+ tokensBuffer.append(this.scanner.source, tokenStart, tokenLength);
}
previousToken = token;
}
}
finally {
this.scanner.skipComments = false;
- if (isHtmlTag && buffer != textBuffer) {
- buffer.append(textBuffer);
+ // Add remaining buffered tokens
+ if (tokensBuffer.length() > 0) {
+ buffer.append(tokensBuffer);
+ this.column += tokensBuffer.length();
}
}
}
Index: formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java,v
retrieving revision 1.3
diff -u -r1.3 FormatterCommentParser.java
--- formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 23 Apr 2008 22:29:00 -0000 1.3
+++ formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 25 Apr 2008 13:11:10 -0000
@@ -72,34 +72,15 @@
* @see org.eclipse.jdt.internal.compiler.parser.JavadocParser#createMethodReference(java.lang.Object, java.util.List)
*/
protected Object createMethodReference(Object receiver, List arguments) throws InvalidInputException {
-
- // Get intermediate arguments positions
- long[] positions = null;
- if (arguments != null) {
- int size = arguments.size();
- positions = new long[size];
- for (int i=0; i>> 32), (int) positions[positions.length-1], lineStart);
}
/*
@@ -293,16 +274,6 @@
if (!valid) {
this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
this.index = this.tagSourceEnd+1;
-// char ch = peekChar();
-// if (ch != ' ' && !ScannerHelper.isWhitespace(ch)) {
-// // no space after the tag, just create a normal tag
-// return false;
-// }
-// this.scanner.getNextToken(); // consume first token
-// pushIdentifier(true, false); // force the identifier even if invalid
-// pushSeeRef(createTypeReference(0));
-// this.index = this.scanner.currentPosition;
-// valid = true;
}
return valid;
}
@@ -346,13 +317,7 @@
int start = (int) (this.identifierPositionStack[0] >>> 32);
int lineStart = this.scanner.getLineNumber(start);
FormatJavadocReference reference;
- if (isTypeParam) {
- reference = new FormatJavadocReference(start, (int) this.identifierPositionStack[2], lineStart);
- reference.positions = new long[3];
- System.arraycopy(this.identifierPositionStack, 0, reference.positions, 0, 3);
- } else {
- reference = new FormatJavadocReference(start, (int) this.identifierPositionStack[0], lineStart);
- }
+ reference = new FormatJavadocReference(start, (int) this.identifierPositionStack[isTypeParam ? 2 : 0], lineStart);
block.reference = reference;
block.sourceEnd = reference.sourceEnd;
pushOnAstStack(block, true);
@@ -416,7 +381,10 @@
} else {
// If last fragment is a tag, then use it as previous tag
FormatJavadocNode lastNode = previousBlock.nodes[previousBlock.nodesPtr];
- if (!lastNode.isText()) {
+ while (lastNode != null && lastNode.isText()) {
+ lastNode = lastNode.getLastNode();
+ }
+ if (lastNode != null) {
previousBlock = (FormatJavadocBlock) lastNode;
previousStart = previousBlock.sourceStart;
}
Index: formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java,v
retrieving revision 1.3
diff -u -r1.3 FormatJavadocBlock.java
--- formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java 23 Apr 2008 22:29:00 -0000 1.3
+++ formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java 25 Apr 2008 13:11:10 -0000
@@ -28,6 +28,7 @@
final static int ON_HEADER_LINE = 0x0004;
final static int TEXT_ON_TAG_LINE = 0x0008;
final static int ONE_LINE_TAG = 0x0010;
+ final static int PARAM_TAG = 0x0020;
// constants
final static int MAX_TAG_HIERARCHY = 10;
@@ -43,6 +44,14 @@
super(start, end, line);
this.tagValue = value;
this.tagEnd = end;
+ switch (value) {
+ case TAG_PARAM_VALUE:
+ // TODO why are following tags considered like @param by the formatter?
+ case TAG_SERIAL_FIELD_VALUE:
+ case TAG_THROWS_VALUE:
+ case TAG_EXCEPTION_VALUE:
+ flags |= PARAM_TAG;
+ }
}
private void addNode(FormatJavadocNode node) {
@@ -72,11 +81,17 @@
textHierarchy[i].sourceEnd = block.sourceEnd;
}
this.sourceEnd = block.sourceEnd;
+ if (isParamTag()) {
+ block.flags |= PARAM_TAG;
+ }
return;
}
}
}
addNode(block);
+ if (isParamTag()) {
+ block.flags |= PARAM_TAG;
+ }
}
void addText(FormatJavadocText text) {
@@ -264,15 +279,7 @@
* false
otherwise.
*/
public boolean isParamTag() {
- switch (this.tagValue) {
- case TAG_PARAM_VALUE:
- // TODO (eric) why are following tags considered like @param by the formatter?
- case TAG_SERIAL_FIELD_VALUE:
- case TAG_THROWS_VALUE:
- case TAG_EXCEPTION_VALUE:
- return true;
- }
- return false;
+ return (this.flags & PARAM_TAG) == PARAM_TAG;
}
protected void toString(StringBuffer buffer) {
Index: formatter/org/eclipse/jdt/internal/formatter/FormatJavadocReference.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/FormatJavadocReference.java,v
retrieving revision 1.3
diff -u -r1.3 FormatJavadocReference.java
--- formatter/org/eclipse/jdt/internal/formatter/FormatJavadocReference.java 23 Apr 2008 22:29:00 -0000 1.3
+++ formatter/org/eclipse/jdt/internal/formatter/FormatJavadocReference.java 25 Apr 2008 13:11:10 -0000
@@ -19,7 +19,6 @@
*
*/
public class FormatJavadocReference extends FormatJavadocNode {
- long[] positions; // positions of separators ('.') for qualified references
public FormatJavadocReference(int start, int end, int line) {
super(start, end, line);
@@ -29,11 +28,6 @@
super((int) (position >>> 32), (int) position, line);
}
-public FormatJavadocReference(long[] positions, int line) {
- super((int) (positions[0] >>> 32), (int) positions[positions.length-1], line);
- this.positions = positions;
-}
-
void clean() {
// Clean positions when used
}
#P org.eclipse.jdt.core.tests.model
Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java,v
retrieving revision 1.5
diff -u -r1.5 FormatterCommentsMassiveTests.java
--- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java 23 Apr 2008 22:29:05 -0000 1.5
+++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java 25 Apr 2008 13:11:13 -0000
@@ -132,13 +132,13 @@
*
* - 3.0 performance workspace (9951 units):
* - 0 error
- * - 199 failures
- * - 751 different lines leading spaces
+ * - 104 failures
+ * - 799 different lines leading spaces
*
* - ganymede workspace (25819 units):
* - 0 error
- * - 376 failures
- * - 1350 different lines leading spaces
+ * - 202 failures
+ * - 1410 different lines leading spaces
*
*
*
Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java,v
retrieving revision 1.3
diff -u -r1.3 FormatterCommentsTests.java
--- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 23 Apr 2008 22:29:05 -0000 1.3
+++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 25 Apr 2008 13:11:13 -0000
@@ -688,6 +688,12 @@
public void testTagParam04() throws JavaModelException {
formatUnit("tags.param", "X04.java");
}
+public void testTagParam05() throws JavaModelException {
+ formatUnit("tags.param", "X05.java");
+}
+public void testTagParam06() throws JavaModelException {
+ formatUnit("tags.param", "X06.java");
+}
/*
* Test formatter see tags
@@ -701,6 +707,15 @@
public void testTagSee03() throws JavaModelException {
formatUnit("tags.see", "X03.java");
}
+public void testTagSee04() throws JavaModelException {
+ formatUnit("tags.see", "X04.java");
+}
+public void testTagSee05() throws JavaModelException {
+ formatUnit("tags.see", "X05.java");
+}
+public void testTagSee06() throws JavaModelException {
+ formatUnit("tags.see", "X06.java");
+}
/*
* Test formatter see tags
@@ -803,6 +818,9 @@
public void testBlockComments10() throws JavaModelException {
formatUnit("comments.block", "X10.java");
}
+public void testBlockComments11() throws JavaModelException {
+ formatUnit("comments.block", "X11.java");
+}
/*
* Test formatter on example got from workspaces
@@ -869,8 +887,49 @@
public void testWkspEclipse13() throws JavaModelException {
formatUnit("wksp.eclipse", "X13.java");
}
+public void testWkspEclipse14() throws JavaModelException {
+ formatUnit("wksp.eclipse", "X14.java");
+}
// JUnit 3.8.2
public void testWkspJUnit01() throws JavaModelException {
formatUnit("wksp.junit", "X01.java");
}
+
+/**
+ * @bug 228652: [formatter] New line inserted while formatting a region of a compilation unit.
+ * @test Insure that no new line is inserted before the formatted region
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=228652"
+ */
+// TODO (frederic) See https://bugs.eclipse.org/bugs/show_bug.cgi?id=49187
+public void _testBug228652() {
+ String input =
+ "package a;\r\n" +
+ "\r\n" +
+ "public class Test {\r\n" +
+ "\r\n" +
+ " private int field;\r\n" +
+ " \r\n" +
+ " /**\r\n" +
+ " * fds \r\n" +
+ " */\r\n" +
+ " public void foo() {\r\n" +
+ " }\r\n" +
+ "}";
+
+ String expected =
+ "package a;\r\n" +
+ "\r\n" +
+ "public class Test {\r\n" +
+ "\r\n" +
+ " private int field;\r\n" +
+ " \r\n" +
+ " /**\r\n" +
+ " * fds\r\n" +
+ " */\r\n" +
+ " public void foo() {\r\n" +
+ " }\r\n" +
+ "}";
+
+ formatSource(input, expected, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, false, 62, 19, null);
+}
}
Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/clear_blank_lines/X01.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/clear_blank_lines/X01.java,v
retrieving revision 1.1
diff -u -r1.1 X01.java
--- workspace/FormatterJavadoc/test/wksp/eclipse/out/clear_blank_lines/X01.java 23 Apr 2008 10:13:41 -0000 1.1
+++ workspace/FormatterJavadoc/test/wksp/eclipse/out/clear_blank_lines/X01.java 25 Apr 2008 13:11:13 -0000
@@ -6,7 +6,8 @@
*
* @see {@link PropertyPage}
* @see {@link ILaunchConfiguration}
- * @see {@link org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog}
+ * @see {@link org.eclipse.debug.internal.ui.launchConfigurations.
+ * LaunchConfigurationsDialog}
* @see {@link IDebugHelpContextIds#DEFAULT_LAUNCHCONFIGURATION_PROPERTY_PAGE}
* CONTEXTLAUNCHING
* @since 3.3.0
Index: workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X03.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X03.java,v
retrieving revision 1.1
diff -u -r1.1 X03.java
--- workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X03.java 14 Apr 2008 21:52:20 -0000 1.1
+++ workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X03.java 25 Apr 2008 13:11:13 -0000
@@ -8,8 +8,8 @@
}
/**
- * @see X03 Simple type reference (there's no desciption before this section
- * !)
+ * @see X03 Simple type reference (there's no desciption before this
+ * section!)
* @see X03.Y03.Z03 Qualified field reference (extended description to have
* it on two lines after the formatting...)
* @see test.tags.see.X03.Y03 Fully qualified field reference
Index: workspace/FormatterJavadoc/test/comments/block/out/default/X08.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/comments/block/out/default/X08.java,v
retrieving revision 1.1
diff -u -r1.1 X08.java
--- workspace/FormatterJavadoc/test/comments/block/out/default/X08.java 23 Apr 2008 22:29:05 -0000 1.1
+++ workspace/FormatterJavadoc/test/comments/block/out/default/X08.java 25 Apr 2008 13:11:13 -0000
@@ -6,8 +6,8 @@
if (true) {
if (true) {
if (condition /*
- * && useChange(d.fDirection) && !d.
- * fIsWhitespace
+ * && useChange(d.fDirection) &&
+ * !d.fIsWhitespace
*/) {
}
}
Index: workspace/FormatterJavadoc/test/comments/block/out/default/X05e.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/comments/block/out/default/X05e.java,v
retrieving revision 1.1
diff -u -r1.1 X05e.java
--- workspace/FormatterJavadoc/test/comments/block/out/default/X05e.java 23 Apr 2008 10:13:39 -0000 1.1
+++ workspace/FormatterJavadoc/test/comments/block/out/default/X05e.java 25 Apr 2008 13:11:13 -0000
@@ -17,8 +17,8 @@
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation and
- * /or other materials provided with the distribution.
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment: "This product includes software
@@ -44,8 +44,8 @@
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ==========================
- * ==========================================
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
*
* This software consists of voluntary contributions made by many individuals on
* behalf of the Apache Software Foundation. For more information on the Apache
Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X02.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X02.java,v
retrieving revision 1.1
diff -u -r1.1 X02.java
--- workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X02.java 23 Apr 2008 10:13:40 -0000 1.1
+++ workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X02.java 25 Apr 2008 13:11:13 -0000
@@ -6,8 +6,8 @@
* will remove the charset setting for this resource.
*
* This method changes resources; these changes will be reported in a
- * subsequent resource change event, including an indication that this file'
- * s encoding has changed.
+ * subsequent resource change event, including an indication that this
+ * file's encoding has changed.
*
*
* This method is long-running; progress and cancellation are provided by
Index: workspace/FormatterJavadoc/test/comments/block/out/clear_blank_lines/X05e.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/comments/block/out/clear_blank_lines/X05e.java,v
retrieving revision 1.1
diff -u -r1.1 X05e.java
--- workspace/FormatterJavadoc/test/comments/block/out/clear_blank_lines/X05e.java 23 Apr 2008 10:13:40 -0000 1.1
+++ workspace/FormatterJavadoc/test/comments/block/out/clear_blank_lines/X05e.java 25 Apr 2008 13:11:13 -0000
@@ -17,8 +17,8 @@
* end-user documentation included with the redistribution, if any, must include
* the following acknowledgment: "This product includes software developed by
* the Apache Software Foundation (http://www.apache.org/)." Alternately, this
- * acknowledgment may appear in the software itself, if and wherever such third-
- * party acknowledgments normally appear. 4. The names "Apache" and
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
* "Apache Software Foundation" and "Apache Lucene" must not be used to endorse
* or promote products derived from this software without prior written
* permission. For written permission, please contact apache@apache.org. 5.
@@ -34,11 +34,11 @@
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ==================================
- * ================================== This software consists of voluntary
- * contributions made by many individuals on behalf of the Apache Software
- * Foundation. For more information on the Apache Software Foundation, please
- * see .
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ==================================================================== This
+ * software consists of voluntary contributions made by many individuals on
+ * behalf of the Apache Software Foundation. For more information on the Apache
+ * Software Foundation, please see .
*/
class Y05 {
}
\ No newline at end of file
Index: workspace/FormatterJavadoc/test/comments/block/out/clear_blank_lines/X05.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/comments/block/out/clear_blank_lines/X05.java,v
retrieving revision 1.1
diff -u -r1.1 X05.java
--- workspace/FormatterJavadoc/test/comments/block/out/clear_blank_lines/X05.java 23 Apr 2008 10:13:40 -0000 1.1
+++ workspace/FormatterJavadoc/test/comments/block/out/clear_blank_lines/X05.java 25 Apr 2008 13:11:13 -0000
@@ -13,8 +13,8 @@
* end-user documentation included with the redistribution, if any, must include
* the following acknowledgment: "This product includes software developed by
* the Apache Software Foundation (http://www.apache.org/)." Alternately, this
- * acknowledgment may appear in the software itself, if and wherever such third-
- * party acknowledgments normally appear. 4. The names "Apache" and
+ * acknowledgment may appear in the software itself, if and wherever such
+ * third-party acknowledgments normally appear. 4. The names "Apache" and
* "Apache Software Foundation" and "Apache Lucene" must not be used to endorse
* or promote products derived from this software without prior written
* permission. For written permission, please contact apache@apache.org. 5.
@@ -30,11 +30,11 @@
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ==================================
- * ================================== This software consists of voluntary
- * contributions made by many individuals on behalf of the Apache Software
- * Foundation. For more information on the Apache Software Foundation, please
- * see .
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ==================================================================== This
+ * software consists of voluntary contributions made by many individuals on
+ * behalf of the Apache Software Foundation. For more information on the Apache
+ * Software Foundation, please see .
*/
public class X05 {
Index: src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java,v
retrieving revision 1.17
diff -u -r1.17 JavaDocTestCase.java
--- src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java 1 Aug 2007 18:20:09 -0000 1.17
+++ src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java 25 Apr 2008 13:11:13 -0000
@@ -935,4 +935,44 @@
String result=testFormat(input, options);
assertEquals(expected, result);
}
+
+ /**
+ * @bug 228652: [formatter] New line inserted while formatting a region of a compilation unit.
+ * @test Insure that no new line is inserted before the formatted region
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=228652"
+ */
+ public void testBug228652() {
+ Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
+
+ String input =
+ "package a;\r\n" +
+ "\r\n" +
+ "public class Test {\r\n" +
+ "\r\n" +
+ " private int field;\r\n" +
+ " \r\n" +
+ " /**\r\n" +
+ " * fds \r\n" +
+ " */\r\n" +
+ " public void foo() {\r\n" +
+ " }\r\n" +
+ "}";
+
+ String expected =
+ "package a;\r\n" +
+ "\r\n" +
+ "public class Test {\r\n" +
+ "\r\n" +
+ " private int field;\r\n" +
+ " \r\n" +
+ " /**\r\n" +
+ " * fds\r\n" +
+ " */\r\n" +
+ " public void foo() {\r\n" +
+ " }\r\n" +
+ "}";
+
+ String result = testFormat(input, 62, 19, CodeFormatter.K_JAVA_DOC, options);
+ assertEquals(expected, result);
+ }
}
Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X01.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X01.java,v
retrieving revision 1.1
diff -u -r1.1 X01.java
--- workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X01.java 23 Apr 2008 10:13:39 -0000 1.1
+++ workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X01.java 25 Apr 2008 13:11:13 -0000
@@ -6,7 +6,8 @@
*
* @see {@link PropertyPage}
* @see {@link ILaunchConfiguration}
- * @see {@link org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog}
+ * @see {@link
+ * org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog}
* @see {@link IDebugHelpContextIds#DEFAULT_LAUNCHCONFIGURATION_PROPERTY_PAGE}
*
* CONTEXTLAUNCHING
Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X02.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X02.java,v
retrieving revision 1.1
diff -u -r1.1 X02.java
--- workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X02.java 23 Apr 2008 10:13:39 -0000 1.1
+++ workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X02.java 25 Apr 2008 13:11:13 -0000
@@ -6,8 +6,8 @@
* will remove the charset setting for this resource.
*
* This method changes resources; these changes will be reported in a
- * subsequent resource change event, including an indication that this file'
- * s encoding has changed.
+ * subsequent resource change event, including an indication that this
+ * file's encoding has changed.
*
*
* This method is long-running; progress and cancellation are provided by
Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X08.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X08.java,v
retrieving revision 1.1
diff -u -r1.1 X08.java
--- workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X08.java 23 Apr 2008 22:29:05 -0000 1.1
+++ workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X08.java 25 Apr 2008 13:11:13 -0000
@@ -41,18 +41,18 @@
* isSaveNeeded
. The value true
triggers a subsequent
* call to save
where the modified resources can be saved.
*
- * The most important part of this implementation is the setup of the compare/
- * merge UI. The UI uses a simple browser metaphor to present compare results.
- * The top half of the layout shows the structural compare results (e.g. added,
- * deleted, and changed files), the bottom half the content compare results (e.g
- * . textual differences between two files). A selection in the top pane is fed
- * to the bottom pane. If a content viewer is registered for the type of the
- * selected object, this viewer is installed in the pane. In addition if a
- * structure viewer is registered for the selection type the top pane is split
- * horizontally to make room for another pane and the structure viewer is
- * installed in it. When comparing Java files this second structure viewer would
- * show the structural differences within a Java file, e.g. added, deleted or
- * changed methods and fields.
+ * The most important part of this implementation is the setup of the
+ * compare/merge UI. The UI uses a simple browser metaphor to present compare
+ * results. The top half of the layout shows the structural compare results
+ * (e.g. added, deleted, and changed files), the bottom half the content compare
+ * results (e.g. textual differences between two files). A selection in the top
+ * pane is fed to the bottom pane. If a content viewer is registered for the
+ * type of the selected object, this viewer is installed in the pane. In
+ * addition if a structure viewer is registered for the selection type the top
+ * pane is split horizontally to make room for another pane and the structure
+ * viewer is installed in it. When comparing Java files this second structure
+ * viewer would show the structural differences within a Java file, e.g. added,
+ * deleted or changed methods and fields.
*
* Subclasses provide custom setups, e.g. for a Catchup/Release operation by
* passing a subclass of CompareConfiguration
and by implementing
Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X01.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X01.java,v
retrieving revision 1.1
diff -u -r1.1 X01.java
--- workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X01.java 23 Apr 2008 10:13:39 -0000 1.1
+++ workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X01.java 25 Apr 2008 13:11:13 -0000
@@ -6,7 +6,8 @@
*
* @see {@link PropertyPage}
* @see {@link ILaunchConfiguration}
- * @see {@link org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog}
+ * @see {@link org.eclipse.debug.internal.ui.launchConfigurations.
+ * LaunchConfigurationsDialog}
* @see {@link IDebugHelpContextIds#DEFAULT_LAUNCHCONFIGURATION_PROPERTY_PAGE}
*
* CONTEXTLAUNCHING
Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X02.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X02.java,v
retrieving revision 1.1
diff -u -r1.1 X02.java
--- workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X02.java 23 Apr 2008 10:13:39 -0000 1.1
+++ workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X02.java 25 Apr 2008 13:11:13 -0000
@@ -6,8 +6,8 @@
* will remove the charset setting for this resource.
*
* This method changes resources; these changes will be reported in a
- * subsequent resource change event, including an indication that this file'
- * s encoding has changed.
+ * subsequent resource change event, including an indication that this
+ * file's encoding has changed.
*
*
* This method is long-running; progress and cancellation are provided by
Index: workspace/FormatterJavadoc/test/tags/see/out/default/X03.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/FormatterJavadoc/test/tags/see/out/default/X03.java,v
retrieving revision 1.1
diff -u -r1.1 X03.java
--- workspace/FormatterJavadoc/test/tags/see/out/default/X03.java 14 Apr 2008 21:52:16 -0000 1.1
+++ workspace/FormatterJavadoc/test/tags/see/out/default/X03.java 25 Apr 2008 13:11:13 -0000
@@ -8,8 +8,8 @@
}
/**
- * @see X03 Simple type reference (there's no desciption before this section
- * !)
+ * @see X03 Simple type reference (there's no desciption before this
+ * section!)
* @see X03.Y03.Z03 Qualified field reference (extended description to have
* it on two lines after the formatting...)
* @see test.tags.see.X03.Y03 Fully qualified field reference
Index: workspace/FormatterJavadoc/test/tags/param/out/dont_indent_descr/X06.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/param/out/dont_indent_descr/X06.java
diff -N workspace/FormatterJavadoc/test/tags/param/out/dont_indent_descr/X06.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/param/out/dont_indent_descr/X06.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,14 @@
+package test.tags.param;
+
+public class X06 {
+ /**
+ * Returns a collection of projects referenced by a build scope attribute.
+ *
+ * @param scope
+ * build scope attribute (ATTR_BUILD_SCOPE
)
+ * @return collection of porjects referred to by the scope attribute
+ */
+ int foo() {
+ return 0;
+ }
+}
Index: workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X06.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X06.java
diff -N workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X06.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X06.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,11 @@
+package test.tags.see;
+
+public class X06 {
+
+ /**
+ * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
+ void foo() {
+ }
+}
Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X14.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X14.java
diff -N workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X14.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X14.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,21 @@
+package test.wksp.eclipse;
+
+public class X14 {
+
+ /**
+ * Returns an open input stream on the contents of the specified help
+ * resource. The client is responsible for closing the stream when finished.
+ *
+ * @param href
+ * the URL (as a string) of the help resource
+ *
+ * Valid href are as described in {@link
+ * org.eclipse.help.IHelpResource#getHref IHelpResource.getHref}
+ *
+ * @return an input stream containing the contents of the help resource, or
+ * null
if the help resource could not be found and opened
+ */
+ int foo(String href) {
+ return 0;
+ }
+}
Index: workspace/FormatterJavadoc/test/comments/block/X11.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/comments/block/X11.java
diff -N workspace/FormatterJavadoc/test/comments/block/X11.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/comments/block/X11.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,11 @@
+package test.comments.block;
+
+public class X11 {
+
+public X11() {
+ this(false /*comment*/, false /*whitespace*/, false /*nls*/, 0 /*sourceLevel*/, null/*taskTag*/, null/*taskPriorities*/, true /*taskCaseSensitive*/);
+}
+
+public X11(boolean b, boolean c, boolean d, int i, Object object, Object object2, boolean e) {
+}
+}
Index: workspace/FormatterJavadoc/test/tags/see/X04.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/see/X04.java
diff -N workspace/FormatterJavadoc/test/tags/see/X04.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/see/X04.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,11 @@
+package test.tags.see;
+
+public class X04 {
+
+ /**
+ * When a preference changes, update the in-memory cache of the preference.
+ * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
+ */
+ void foo() {
+ }
+}
Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X14.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X14.java
diff -N workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X14.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X14.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,21 @@
+package test.wksp.eclipse;
+
+public class X14 {
+
+ /**
+ * Returns an open input stream on the contents of the specified help
+ * resource. The client is responsible for closing the stream when finished.
+ *
+ * @param href
+ * the URL (as a string) of the help resource
+ *
+ * Valid href are as described in {@link
+ * org.eclipse.help.IHelpResource#getHref IHelpResource.getHref}
+ *
+ * @return an input stream containing the contents of the help resource, or
+ * null
if the help resource could not be found and opened
+ */
+ int foo(String href) {
+ return 0;
+ }
+}
Index: workspace/FormatterJavadoc/test/tags/param/out/dont_indent_tags/X05.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/param/out/dont_indent_tags/X05.java
diff -N workspace/FormatterJavadoc/test/tags/param/out/dont_indent_tags/X05.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/param/out/dont_indent_tags/X05.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,12 @@
+package test.tags.param;
+
+public class X05 {
+ /**
+ * Test with exception tag.
+ *
+ * @exception Throwable
+ * if any exception is thrown
+ */
+ public void foo() throws Throwable {
+ }
+}
Index: workspace/FormatterJavadoc/test/comments/block/out/default/X11.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/comments/block/out/default/X11.java
diff -N workspace/FormatterJavadoc/test/comments/block/out/default/X11.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/comments/block/out/default/X11.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,14 @@
+package test.comments.block;
+
+public class X11 {
+
+ public X11() {
+ this(false /* comment */, false /* whitespace */, false /* nls */,
+ 0 /* sourceLevel */, null/* taskTag */,
+ null/* taskPriorities */, true /* taskCaseSensitive */);
+ }
+
+ public X11(boolean b, boolean c, boolean d, int i, Object object,
+ Object object2, boolean e) {
+ }
+}
Index: workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X05.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X05.java
diff -N workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X05.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X05.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,13 @@
+package test.tags.see;
+
+public class X05 {
+
+ class Y05 {
+ /**
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
+ * java.lang.String)
+ */
+ void foo() {
+ }
+ }
+}
Index: workspace/FormatterJavadoc/test/tags/see/out/default/X04.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/see/out/default/X04.java
diff -N workspace/FormatterJavadoc/test/tags/see/out/default/X04.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/see/out/default/X04.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,13 @@
+package test.tags.see;
+
+public class X04 {
+
+ /**
+ * When a preference changes, update the in-memory cache of the preference.
+ *
+ * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#
+ * propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
+ */
+ void foo() {
+ }
+}
Index: workspace/FormatterJavadoc/test/tags/see/out/default/X06.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/see/out/default/X06.java
diff -N workspace/FormatterJavadoc/test/tags/see/out/default/X06.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/see/out/default/X06.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,11 @@
+package test.tags.see;
+
+public class X06 {
+
+ /**
+ * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
+ void foo() {
+ }
+}
Index: workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X14.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X14.java
diff -N workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X14.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X14.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,21 @@
+package test.wksp.eclipse;
+
+public class X14 {
+
+ /**
+ * Returns an open input stream on the contents of the specified help
+ * resource. The client is responsible for closing the stream when finished.
+ *
+ * @param href
+ * the URL (as a string) of the help resource
+ *
+ * Valid href are as described in {@link
+ * org.eclipse.help.IHelpResource#getHref IHelpResource.getHref}
+ *
+ * @return an input stream containing the contents of the help resource, or
+ * null
if the help resource could not be found and opened
+ */
+ int foo(String href) {
+ return 0;
+ }
+}
Index: workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X04.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X04.java
diff -N workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X04.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/see/out/dont_indent_tags/X04.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,13 @@
+package test.tags.see;
+
+public class X04 {
+
+ /**
+ * When a preference changes, update the in-memory cache of the preference.
+ *
+ * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#
+ * propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
+ */
+ void foo() {
+ }
+}
Index: workspace/FormatterJavadoc/test/tags/see/X05.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/see/X05.java
diff -N workspace/FormatterJavadoc/test/tags/see/X05.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/see/X05.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,12 @@
+package test.tags.see;
+
+public class X05 {
+
+ class Y05 {
+ /**
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ */
+ void foo() {
+ }
+ }
+}
Index: workspace/FormatterJavadoc/test/tags/param/out/dont_indent_tags/X06.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/param/out/dont_indent_tags/X06.java
diff -N workspace/FormatterJavadoc/test/tags/param/out/dont_indent_tags/X06.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/param/out/dont_indent_tags/X06.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,14 @@
+package test.tags.param;
+
+public class X06 {
+ /**
+ * Returns a collection of projects referenced by a build scope attribute.
+ *
+ * @param scope
+ * build scope attribute (ATTR_BUILD_SCOPE
)
+ * @return collection of porjects referred to by the scope attribute
+ */
+ int foo() {
+ return 0;
+ }
+}
Index: workspace/FormatterJavadoc/test/tags/see/X06.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/see/X06.java
diff -N workspace/FormatterJavadoc/test/tags/see/X06.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/see/X06.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,10 @@
+package test.tags.see;
+
+public class X06 {
+
+ /**
+ * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
+ */
+ void foo() {
+ }
+}
Index: workspace/FormatterJavadoc/test/tags/param/out/dont_indent_descr/X05.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/param/out/dont_indent_descr/X05.java
diff -N workspace/FormatterJavadoc/test/tags/param/out/dont_indent_descr/X05.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/param/out/dont_indent_descr/X05.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,12 @@
+package test.tags.param;
+
+public class X05 {
+ /**
+ * Test with exception tag.
+ *
+ * @exception Throwable
+ * if any exception is thrown
+ */
+ public void foo() throws Throwable {
+ }
+}
Index: workspace/FormatterJavadoc/test/wksp/eclipse/X14.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/wksp/eclipse/X14.java
diff -N workspace/FormatterJavadoc/test/wksp/eclipse/X14.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/wksp/eclipse/X14.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,22 @@
+package test.wksp.eclipse;
+
+public class X14 {
+
+ /**
+ * Returns an open input stream on the contents of the specified help
+ * resource. The client is responsible for closing the stream when finished.
+ *
+ * @param href
+ * the URL (as a string) of the help resource
+ *
+ * Valid href are as described in
+ * {@link org.eclipse.help.IHelpResource#getHref IHelpResource.getHref}
+ *
+ * @return an input stream containing the contents of the help resource, or
+ * null
if the help resource could not be found and
+ * opened
+ */
+ int foo(String href) {
+ return 0;
+ }
+}
Index: workspace/FormatterJavadoc/test/tags/see/out/default/X05.java
===================================================================
RCS file: workspace/FormatterJavadoc/test/tags/see/out/default/X05.java
diff -N workspace/FormatterJavadoc/test/tags/see/out/default/X05.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ workspace/FormatterJavadoc/test/tags/see/out/default/X05.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,13 @@
+package test.tags.see;
+
+public class X05 {
+
+ class Y05 {
+ /**
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
+ * java.lang.String)
+ */
+ void foo() {
+ }
+ }
+}