View | Details | Raw Unified | Return to bug 260381 | Differences between
and this patch

Collapse All | Expand All

(-)formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java (-2 / +25 lines)
Lines 31-36 Link Here
31
	final static int PARAM_TAG = 0x0020;
31
	final static int PARAM_TAG = 0x0020;
32
	final static int IN_PARAM_TAG = 0x0040;
32
	final static int IN_PARAM_TAG = 0x0040;
33
	final static int IN_DESCRIPTION = 0x0080;
33
	final static int IN_DESCRIPTION = 0x0080;
34
	final static int IMMUTABLE = 0x0100;
34
35
35
	// constants
36
	// constants
36
	final static int MAX_TAG_HIERARCHY = 10;
37
	final static int MAX_TAG_HIERARCHY = 10;
Lines 53-58 Link Here
53
		case TAG_THROWS_VALUE:
54
		case TAG_THROWS_VALUE:
54
		case TAG_EXCEPTION_VALUE:
55
		case TAG_EXCEPTION_VALUE:
55
			this.flags |= PARAM_TAG;
56
			this.flags |= PARAM_TAG;
57
			break;
58
		case TAG_CODE_VALUE:
59
		case TAG_LITERAL_VALUE:
60
			this.flags |= IMMUTABLE;
61
			break;
56
	}
62
	}
57
}
63
}
58
64
Lines 141-146 Link Here
141
		}
147
		}
142
	}
148
	}
143
	addNode(text);
149
	addNode(text);
150
	if (isImmutable()) {
151
		text.immutable = true;
152
	}
144
}
153
}
145
154
146
void clean() {
155
void clean() {
Lines 322-327 Link Here
322
	return (this.flags & PARAM_TAG) == PARAM_TAG;
331
	return (this.flags & PARAM_TAG) == PARAM_TAG;
323
}
332
}
324
333
334
/**
335
 * Returns whether the block is immutable or not.
336
 * <p>
337
 * Currently, only @code inline tag block are considered as immutable.
338
 *
339
 * @return <code>true</code> if the block is immutable,
340
 * 	<code>false</code> otherwise.
341
 */
342
public boolean isImmutable() {
343
	return (this.flags & IMMUTABLE) == IMMUTABLE;
344
}
345
325
void setHeaderLine(int javadocLineStart) {
346
void setHeaderLine(int javadocLineStart) {
326
	if (javadocLineStart == this.lineStart) {
347
	if (javadocLineStart == this.lineStart) {
327
		this.flags |= ON_HEADER_LINE;
348
		this.flags |= ON_HEADER_LINE;
Lines 332-340 Link Here
332
}
353
}
333
354
334
protected void toString(StringBuffer buffer) {
355
protected void toString(StringBuffer buffer) {
335
	if ((this.flags & INLINED) != 0) buffer.append('{');
356
	boolean inlined = (this.flags & INLINED) != 0;
357
	if (inlined) buffer.append("	{"); //$NON-NLS-1$
336
	buffer.append('@');
358
	buffer.append('@');
337
	buffer.append(this.tagValue);
359
	buffer.append(TAG_NAMES[this.tagValue]);
338
	super.toString(buffer);
360
	super.toString(buffer);
339
	if (this.reference == null) {
361
	if (this.reference == null) {
340
		buffer.append('\n');
362
		buffer.append('\n');
Lines 345-350 Link Here
345
	}
367
	}
346
	if (this.nodesPtr > -1) {
368
	if (this.nodesPtr > -1) {
347
		for (int i = 0; i <= this.nodesPtr; i++) {
369
		for (int i = 0; i <= this.nodesPtr; i++) {
370
			if (inlined) buffer.append('\t');
348
			this.nodes[i].toString(buffer);
371
			this.nodes[i].toString(buffer);
349
		}
372
		}
350
	}
373
	}
(-)formatter/org/eclipse/jdt/internal/formatter/FormatJavadocNode.java (+11 lines)
Lines 56-61 Link Here
56
	return false;
56
	return false;
57
}
57
}
58
58
59
/**
60
 * Returns whether the node is immutable or not. If <code>true</code>, then
61
 * the formatter will leave it contents unchanged.
62
 *
63
 * @return <code>true</code> if the node is immutable, <code>false</code>
64
 * 	otherwise.
65
 */
66
public boolean isImmutable() {
67
	return false;
68
}
69
59
public String toString() {
70
public String toString() {
60
	StringBuffer buffer = new StringBuffer();
71
	StringBuffer buffer = new StringBuffer();
61
	toString(buffer);
72
	toString(buffer);
(-)formatter/org/eclipse/jdt/internal/formatter/FormatJavadocText.java (+18 lines)
Lines 31-36 Link Here
31
	long[] separators;
31
	long[] separators;
32
	int separatorsPtr = -1;
32
	int separatorsPtr = -1;
33
	private int htmlTagIndex = -1;
33
	private int htmlTagIndex = -1;
34
	boolean immutable = false;
34
	FormatJavadocNode[] htmlNodes;
35
	FormatJavadocNode[] htmlNodes;
35
	int[] htmlIndexes;
36
	int[] htmlIndexes;
36
	int htmlNodesPtr = -1;
37
	int htmlNodesPtr = -1;
Lines 49-54 Link Here
49
 * child node.
50
 * child node.
50
 */
51
 */
51
void appendText(FormatJavadocText text) {
52
void appendText(FormatJavadocText text) {
53
	this.immutable = text.immutable;
52
	if (this.depth == text.depth) {
54
	if (this.depth == text.depth) {
53
		addSeparator(text);
55
		addSeparator(text);
54
		this.sourceEnd = text.sourceEnd;
56
		this.sourceEnd = text.sourceEnd;
Lines 167-172 Link Here
167
 *
169
 *
168
 * @return <code>true</code> if the node is an immutable tag,
170
 * @return <code>true</code> if the node is an immutable tag,
169
 *		<code>false</code> otherwise.
171
 *		<code>false</code> otherwise.
172
 *@deprecated Use {@link #isImmutable()} instead
170
 */
173
 */
171
public boolean isImmutableHtmlTag() {
174
public boolean isImmutableHtmlTag() {
172
	return this.htmlTagIndex != -1 && (this.htmlTagIndex & JAVADOC_TAGS_ID_MASK) == JAVADOC_IMMUTABLE_TAGS_ID;
175
	return this.htmlTagIndex != -1 && (this.htmlTagIndex & JAVADOC_TAGS_ID_MASK) == JAVADOC_IMMUTABLE_TAGS_ID;
Lines 174-179 Link Here
174
}
177
}
175
178
176
/**
179
/**
180
 * Returns whether the text is immutable or not.
181
 * <p>
182
 * A text in considered as immutable when it  belongs to an immutable block
183
 * or when it's an immutable html tag.
184
 * </p>
185
 *
186
 * @return <code>true</code> if the node is an immutable tag,
187
 *		<code>false</code> otherwise.
188
 */
189
public boolean isImmutable() {
190
	return this.immutable || (this.htmlTagIndex != -1 && (this.htmlTagIndex & JAVADOC_TAGS_ID_MASK) == JAVADOC_IMMUTABLE_TAGS_ID);
191
192
}
193
194
/**
177
 * Returns whether the text at the given separator index position is after a
195
 * Returns whether the text at the given separator index position is after a
178
 * separator tag or not.
196
 * separator tag or not.
179
 *
197
 *
(-)formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java (-2 / +5 lines)
Lines 356-361 Link Here
356
		this.scanner.resetTo(this.index, this.javadocEnd);
356
		this.scanner.resetTo(this.index, this.javadocEnd);
357
		return true;
357
		return true;
358
	}
358
	}
359
	this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value
359
	return false;
360
	return false;
360
}
361
}
361
362
Lines 382-387 Link Here
382
			}
383
			}
383
			this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
384
			this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
384
		}
385
		}
386
		this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value
385
	}
387
	}
386
	return valid;
388
	return valid;
387
}
389
}
Lines 394-399 Link Here
394
	if (!valid) {
396
	if (!valid) {
395
		this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
397
		this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
396
		this.index = this.tagSourceEnd+1;
398
		this.index = this.tagSourceEnd+1;
399
		this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value
397
	}
400
	}
398
	return valid;
401
	return valid;
399
}
402
}
Lines 506-512 Link Here
506
			if (length == TAG_LINK_LENGTH && CharOperation.equals(TAG_LINK, tagName)) {
509
			if (length == TAG_LINK_LENGTH && CharOperation.equals(TAG_LINK, tagName)) {
507
				this.tagValue = TAG_LINK_VALUE;
510
				this.tagValue = TAG_LINK_VALUE;
508
				if (this.inlineTagStarted || (this.kind & COMPLETION_PARSER) != 0) {
511
				if (this.inlineTagStarted || (this.kind & COMPLETION_PARSER) != 0) {
509
					valid= parseReference();
512
					valid = parseReference();
510
				} else {
513
				} else {
511
					// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=53290
514
					// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=53290
512
					// Cannot have @link outside inline comment
515
					// Cannot have @link outside inline comment
Lines 605-611 Link Here
605
	} else if (this.invalidTagName) {
608
	} else if (this.invalidTagName) {
606
		this.textStart = previousPosition;
609
		this.textStart = previousPosition;
607
	} else if (this.astPtr == ptr) {
610
	} else if (this.astPtr == ptr) {
608
		this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value
609
		createTag();
611
		createTag();
610
	}
612
	}
611
	return true;
613
	return true;
Lines 620-625 Link Here
620
		// If invalid, restart from the end tag position
622
		// If invalid, restart from the end tag position
621
		this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
623
		this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
622
		this.index = this.tagSourceEnd+1;
624
		this.index = this.tagSourceEnd+1;
625
		this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value
623
	}
626
	}
624
	return valid;
627
	return valid;
625
}
628
}
(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-38 / +47 lines)
Lines 2866-2872 Link Here
2866
							if (newLines > 0)  newLines = 1;
2866
							if (newLines > 0)  newLines = 1;
2867
						}
2867
						}
2868
					}
2868
					}
2869
					if (newLines == 0) {
2869
					if (newLines == 0 && (!node.isImmutable() || block.reference != null)) {
2870
						newLines = printJavadocBlockNodesNewLines(block, node, previousEnd);
2870
						newLines = printJavadocBlockNodesNewLines(block, node, previousEnd);
2871
					}
2871
					}
2872
					printJavadocGapLines(previousEnd+1, nodeStart-1, newLines, clearBlankLines, false, null);
2872
					printJavadocGapLines(previousEnd+1, nodeStart-1, newLines, clearBlankLines, false, null);
Lines 2898-2915 Link Here
2898
			// Print node
2898
			// Print node
2899
			if (node.isText()) {
2899
			if (node.isText()) {
2900
				FormatJavadocText text = (FormatJavadocText) node;
2900
				FormatJavadocText text = (FormatJavadocText) node;
2901
				if (text.isHtmlTag()) {
2901
				if (text.isImmutable()) {
2902
					if (text.isImmutableHtmlTag()) {
2902
					// Indent if new line was added
2903
						// Indent if new line was added
2903
					if (newLines > 0 && this.commentIndentation != null) {
2904
						if (newLines > 0 && this.commentIndentation != null) {
2904
				    	addInsertEdit(node.sourceStart, this.commentIndentation);
2905
					    	addInsertEdit(node.sourceStart, this.commentIndentation);
2905
				    	this.column += this.commentIndentation.length();
2906
					    	this.column += this.commentIndentation.length();
2907
						}
2908
						printJavadocHtmlImmutableTag(text, block, newLines > 0);
2909
						this.column += getTextLength(block, text);
2910
					} else {
2911
						printJavadocHtmlTag(text, block, newLines>0);
2912
					}
2906
					}
2907
					printJavadocImmutableText(text, block, newLines > 0);
2908
					this.column += getTextLength(block, text);
2909
				} else if (text.isHtmlTag()) {
2910
					printJavadocHtmlTag(text, block, newLines>0);
2913
				} else {
2911
				} else {
2914
					printJavadocText(text, block, newLines>0);
2912
					printJavadocText(text, block, newLines>0);
2915
				}
2913
				}
Lines 2934-2948 Link Here
2934
 	    try {
2932
 	    try {
2935
			this.scanner.resetTo(nodeStart , node.sourceEnd);
2933
			this.scanner.resetTo(nodeStart , node.sourceEnd);
2936
	    	int length = 0;
2934
	    	int length = 0;
2937
	    	int newLines = 0;
2938
	    	boolean newLine = false;
2935
	    	boolean newLine = false;
2939
			boolean headerLine = block.isHeaderLine() && this.lastNumberOfNewLines == 0;
2936
			boolean headerLine = block.isHeaderLine() && this.lastNumberOfNewLines == 0;
2940
			int firstColumn = 1 + this.indentationLevel + BLOCK_LINE_PREFIX_LENGTH;
2937
			int firstColumn = 1 + this.indentationLevel + BLOCK_LINE_PREFIX_LENGTH;
2941
			if (this.commentIndentation != null) firstColumn += this.commentIndentation.length();
2938
			if (this.commentIndentation != null) firstColumn += this.commentIndentation.length();
2942
			if (headerLine) maxColumn++;
2939
			if (headerLine) maxColumn++;
2943
	    	if (node.isText()) {
2940
			FormatJavadocText text = null;
2944
	    		FormatJavadocText text = (FormatJavadocText)node;
2941
			boolean isImmutableNode = node.isImmutable();
2945
    			if (text.isImmutableHtmlTag()) {
2942
			boolean nodeIsText = node.isText();
2943
			if (nodeIsText) {
2944
	    		text = (FormatJavadocText)node;
2945
			} else {
2946
				FormatJavadocBlock inlinedBlock = (FormatJavadocBlock)node;
2947
				if (isImmutableNode) {
2948
					text = (FormatJavadocText) inlinedBlock.getLastNode();
2949
		    		length += inlinedBlock.tagEnd - inlinedBlock.sourceStart + 1;  // tag length
2950
			    	if (nodeStart > (previousEnd+1)) {
2951
			    		length++; // include space between nodes
2952
			    	}
2953
					this.scanner.resetTo(text.sourceStart , node.sourceEnd);
2954
				}
2955
			}
2956
	    	if (text != null) {
2957
    			if (isImmutableNode) {
2946
			    	if (nodeStart > (previousEnd+1)) {
2958
			    	if (nodeStart > (previousEnd+1)) {
2947
			    		length++; // include space between nodes
2959
			    		length++; // include space between nodes
2948
			    	}
2960
			    	}
Lines 2952-2959 Link Here
2952
		    				int token = this.scanner.getNextToken();
2964
		    				int token = this.scanner.getNextToken();
2953
		    				switch (token) {
2965
		    				switch (token) {
2954
		    					case TerminalTokens.TokenNameWHITESPACE:
2966
		    					case TerminalTokens.TokenNameWHITESPACE:
2955
		    						if (CharOperation.indexOf('\n', this.scanner.source, this.scanner.startPosition, this.scanner.currentPosition) >= 0) {
2967
		    						if (nodeIsText) {
2956
		    							return newLines;
2968
			    						if (CharOperation.indexOf('\n', this.scanner.source, this.scanner.startPosition, this.scanner.currentPosition) >= 0) {
2969
			    							return 0;
2970
			    						}
2957
		    						}
2971
		    						}
2958
		    						length = 1;
2972
		    						length = 1;
2959
		    						break;
2973
		    						break;
Lines 2975-2989 Link Here
2975
	    				}
2989
	    				}
2976
	    				lastColumn += length;
2990
	    				lastColumn += length;
2977
	    				if (lastColumn > maxColumn) {
2991
	    				if (lastColumn > maxColumn) {
2978
							newLines++;
2992
	    					return 1;
2979
				    		if (headerLine) {
2980
								maxColumn--;
2981
								headerLine = false;
2982
			    			}
2983
							lastColumn = firstColumn;
2984
						}
2993
						}
2985
	    			}
2994
	    			}
2986
	    			return newLines;
2995
	    			return 0;
2987
    			}
2996
    			}
2988
    			if (text.isHtmlTag()) {
2997
    			if (text.isHtmlTag()) {
2989
    				if (text.getHtmlTagID() == JAVADOC_SINGLE_BREAK_TAG_ID) {
2998
    				if (text.getHtmlTagID() == JAVADOC_SINGLE_BREAK_TAG_ID) {
Lines 3146-3152 Link Here
3146
	private int getTextLength(FormatJavadocBlock block, FormatJavadocText text) {
3155
	private int getTextLength(FormatJavadocBlock block, FormatJavadocText text) {
3147
3156
3148
		// Special case for immutable tags
3157
		// Special case for immutable tags
3149
		if (text.isImmutableHtmlTag()) {
3158
		if (text.isImmutable()) {
3150
			this.scanner.resetTo(text.sourceStart , text.sourceEnd);
3159
			this.scanner.resetTo(text.sourceStart , text.sourceEnd);
3151
			int textLength = 0;
3160
			int textLength = 0;
3152
			while (!this.scanner.atEnd()) {
3161
			while (!this.scanner.atEnd()) {
Lines 3468-3490 Link Here
3468
		}
3477
		}
3469
	}
3478
	}
3470
3479
3471
	private void printJavadocHtmlImmutableTag(FormatJavadocText text, FormatJavadocBlock block, boolean textOnNewLine) {
3480
	private void printJavadocImmutableText(FormatJavadocText text, FormatJavadocBlock block, boolean textOnNewLine) {
3472
3481
3473
		try {
3482
		try {
3474
			// Iterate on text line separators
3483
			// Iterate on text line separators
3475
			int lineNumber = text.lineStart;
3484
			int lineNumber = text.lineStart;
3476
			this.scanner.tokenizeWhiteSpace = false;
3485
			this.scanner.tokenizeWhiteSpace = false;
3477
			StringBuffer buffer = null;
3486
			StringBuffer buffer = null;
3478
			for (int idx=1, max=text.separatorsPtr; idx<max ; idx++) {
3487
			for (int idx=0, max=text.separatorsPtr; idx<=max ; idx++) {
3479
				int start = (int) text.separators[idx];
3488
				int start = (int) text.separators[idx];
3480
				int lineStart = Util.getLineNumber(start, this.lineEnds, lineNumber, this.maxLines);
3489
				int lineStart = Util.getLineNumber(start, this.lineEnds, lineNumber-1, this.maxLines);
3481
				if (buffer == null) {
3482
					buffer = new StringBuffer();
3483
					this.column = 1;
3484
					printIndentationIfNecessary(buffer);
3485
					buffer.append(BLOCK_LINE_PREFIX);
3486
					this.column += BLOCK_LINE_PREFIX_LENGTH;
3487
				}
3488
				while (lineNumber < lineStart) {
3490
				while (lineNumber < lineStart) {
3489
					int end = this.lineEnds[lineNumber-1];
3491
					int end = this.lineEnds[lineNumber-1];
3490
					this.scanner.resetTo(end, start);
3492
					this.scanner.resetTo(end, start);
Lines 3499-3504 Link Here
3499
					if (this.scanner.currentCharacter == ' ') {
3501
					if (this.scanner.currentCharacter == ' ') {
3500
						this.scanner.getNextChar();
3502
						this.scanner.getNextChar();
3501
					}
3503
					}
3504
					if (buffer == null) {
3505
						buffer = new StringBuffer();
3506
						this.column = 1;
3507
						printIndentationIfNecessary(buffer);
3508
						buffer.append(BLOCK_LINE_PREFIX);
3509
						this.column += BLOCK_LINE_PREFIX_LENGTH;
3510
					}
3502
					addReplaceEdit(end+1, this.scanner.getCurrentTokenEndPosition(), buffer.toString());
3511
					addReplaceEdit(end+1, this.scanner.getCurrentTokenEndPosition(), buffer.toString());
3503
					lineNumber++;
3512
					lineNumber++;
3504
				}
3513
				}
Lines 3562-3568 Link Here
3562
				if (textStart < previousEnd) {
3571
				if (textStart < previousEnd) {
3563
					addReplaceEdit(textStart, previousEnd, buffer.toString());
3572
					addReplaceEdit(textStart, previousEnd, buffer.toString());
3564
				}
3573
				}
3565
				boolean immutable = htmlTag == null ? false : htmlTag.isImmutableHtmlTag();
3574
				boolean immutable = node.isImmutable();
3566
				if (newLines == 0) {
3575
				if (newLines == 0) {
3567
					newLines = printJavadocBlockNodesNewLines(block, node, previousEnd);
3576
					newLines = printJavadocBlockNodesNewLines(block, node, previousEnd);
3568
				}
3577
				}
Lines 3579-3585 Link Here
3579
					    	addInsertEdit(node.sourceStart, this.commentIndentation);
3588
					    	addInsertEdit(node.sourceStart, this.commentIndentation);
3580
					    	this.column += this.commentIndentation.length();
3589
					    	this.column += this.commentIndentation.length();
3581
						}
3590
						}
3582
						printJavadocHtmlImmutableTag(htmlTag, block, textOnNewLine);
3591
						printJavadocImmutableText(htmlTag, block, textOnNewLine);
3583
						this.column += getTextLength(block, htmlTag);
3592
						this.column += getTextLength(block, htmlTag);
3584
						linesAfter = 0;
3593
						linesAfter = 0;
3585
					} else {
3594
					} else {
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java (-2 / +690 lines)
Lines 4071-4078 Link Here
4071
		"\n" + 
4071
		"\n" + 
4072
		"	/**\n" + 
4072
		"	/**\n" + 
4073
		"	 * Returns the change directly associated with this change element or <code\n" + 
4073
		"	 * Returns the change directly associated with this change element or <code\n" + 
4074
		"	 * null</code>\n" + 
4074
		"	 * null</code> if the element isn\'t associated with a change.\n" + 
4075
		"	 * if the element isn\'t associated with a change.\n" + 
4076
		"	 * \n" + 
4075
		"	 * \n" + 
4077
		"	 * @return the change or <code>null</code>\n" + 
4076
		"	 * @return the change or <code>null</code>\n" + 
4078
		"	 */\n" + 
4077
		"	 */\n" + 
Lines 4398-4403 Link Here
4398
}
4397
}
4399
4398
4400
/**
4399
/**
4400
 * @bug 260381: [formatter] Javadoc formatter breaks {@code ...} tags.
4401
 * @test Ensure that the @code tag is similar to <code> HTML tag
4402
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260381"
4403
 */
4404
public void testBug260381() throws JavaModelException {
4405
	String source = 
4406
		"/**\n" + 
4407
		" * Comments that can be formated in several lines...\n" + 
4408
		" * \n" + 
4409
		" * @author Myself\n" + 
4410
		" * @version {@code $Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $ $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $}\n" + 
4411
		" */\n" + 
4412
		"public class X01 {\n" + 
4413
		"}\n";
4414
	formatSource(source);
4415
}
4416
public void testBug260381b() throws JavaModelException {
4417
	String source = 
4418
		"/**\n" + 
4419
		" * Comments that can be formated in several lines...\n" + 
4420
		" * \n" + 
4421
		" * @author Myself\n" + 
4422
		" * @version <code>$Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $ $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $</code>\n" + 
4423
		" */\n" + 
4424
		"public class X01b {\n" + 
4425
		"}\n";
4426
	formatSource(source);
4427
}
4428
public void testBug260381c() throws JavaModelException {
4429
	String source = 
4430
		"/**\n" + 
4431
		" * Comments that can be formated in several lines...\n" + 
4432
		" * \n" + 
4433
		" * @author Myself\n" + 
4434
		" * @version\n" + 
4435
		" *          <code>3.0 xxxxxxxxxxxxxx xwxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</code>\n" + 
4436
		" */\n" + 
4437
		"public class X01c {\n" + 
4438
		"}\n";
4439
	formatSource(source,
4440
		"/**\n" + 
4441
		" * Comments that can be formated in several lines...\n" + 
4442
		" * \n" + 
4443
		" * @author Myself\n" + 
4444
		" * @version <code>3.0 xxxxxxxxxxxxxx xwxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</code>\n" + 
4445
		" */\n" + 
4446
		"public class X01c {\n" + 
4447
		"}\n"
4448
	);
4449
}
4450
public void testBug260381d() throws JavaModelException {
4451
	String source = 
4452
		"/**\n" + 
4453
		" * Comments that can be formated in several lines...\n" + 
4454
		" * \n" + 
4455
		" * @author Myself\n" + 
4456
		" *  @see Object <code>$Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $ $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $</code>\n" + 
4457
		" */\n" + 
4458
		"public class X02 {\n" + 
4459
		"}\n";
4460
	formatSource(source,
4461
		"/**\n" + 
4462
		" * Comments that can be formated in several lines...\n" + 
4463
		" * \n" + 
4464
		" * @author Myself\n" + 
4465
		" * @see Object\n" + 
4466
		" *      <code>$Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $ $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $</code>\n" + 
4467
		" */\n" + 
4468
		"public class X02 {\n" + 
4469
		"}\n"
4470
	);
4471
}
4472
public void testBug260381e() throws JavaModelException {
4473
	String source = 
4474
		"/**\n" + 
4475
		" * Comments that can be formated in several lines...\n" + 
4476
		" * \n" + 
4477
		" * {@code $Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $\n" + 
4478
		" * $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $}\n" + 
4479
		" */\n" + 
4480
		"public class X03 {\n" + 
4481
		"}\n";
4482
	formatSource(source);
4483
}
4484
public void testBug260381f() throws JavaModelException {
4485
	String source = 
4486
		"/**\n" + 
4487
		" * Literal inline tag should also be untouched by the formatter\n" + 
4488
		" * \n" + 
4489
		" * @version {@literal $Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $ $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $}\n" + 
4490
		" */\n" + 
4491
		"public class X04 {\n" + 
4492
		"\n" + 
4493
		"}\n";
4494
	formatSource(source);
4495
}
4496
public void testBug260381_wksp1_01() throws JavaModelException {
4497
	String source =
4498
		"package wksp1;\n" +
4499
		"\n" +
4500
		"public interface I01 {\n" +
4501
		"\n" +
4502
		"	/**\n" +
4503
		"	 * Returns all configured content types for the given source viewer. This list\n" +
4504
		"	 * tells the caller which content types must be configured for the given source \n" +
4505
		"	 * viewer, i.e. for which content types the given source viewer\'s functionalities\n" +
4506
		"	 * must be specified. This implementation always returns <code>\n" +
4507
		"	 * new String[] { IDocument.DEFAULT_CONTENT_TYPE }</code>.\n" +
4508
		"	 *\n" +
4509
		"	 * @param source the source viewer to be configured by this configuration\n" +
4510
		"	 * @return the configured content types for the given viewer\n" +
4511
		"	 */\n" +
4512
		"	public String[] getConfiguredContentTypes(String source);\n" +
4513
		"}\n";
4514
	formatSource(source,
4515
		"package wksp1;\n" +
4516
		"\n" +
4517
		"public interface I01 {\n" +
4518
		"\n" +
4519
		"	/**\n" +
4520
		"	 * Returns all configured content types for the given source viewer. This\n" +
4521
		"	 * list tells the caller which content types must be configured for the\n" +
4522
		"	 * given source viewer, i.e. for which content types the given source\n" +
4523
		"	 * viewer\'s functionalities must be specified. This implementation always\n" +
4524
		"	 * returns <code>\n" +
4525
		"	 * new String[] { IDocument.DEFAULT_CONTENT_TYPE }</code>.\n" +
4526
		"	 * \n" +
4527
		"	 * @param source\n" +
4528
		"	 *            the source viewer to be configured by this configuration\n" +
4529
		"	 * @return the configured content types for the given viewer\n" +
4530
		"	 */\n" +
4531
		"	public String[] getConfiguredContentTypes(String source);\n" +
4532
		"}\n"
4533
	);
4534
}
4535
public void testBug260381_wksp2_01() throws JavaModelException {
4536
	String source = 
4537
		"package wksp2;\n" + 
4538
		"public interface I01 {\n" + 
4539
		"	/**\n" + 
4540
		"	 * Returns the composition of two functions. For {@code f: A->B} and\n" + 
4541
		"	 * {@code g: B->C}, composition is defined as the function h such that\n" + 
4542
		"	 * {@code h(a) == g(f(a))} for each {@code a}.\n" + 
4543
		"	 *\n" + 
4544
		"	 * @see <a href=\"//en.wikipedia.org/wiki/Function_composition\">\n" + 
4545
		"	 * function composition</a>\n" + 
4546
		"	 *\n" + 
4547
		"	 * @param g the second function to apply\n" + 
4548
		"	 * @param f the first function to apply\n" + 
4549
		"	 * @return the composition of {@code f} and {@code g}\n" + 
4550
		"	 */\n" + 
4551
		"	void foo();\n" + 
4552
		"}\n";
4553
	formatSource(source,
4554
		"package wksp2;\n" + 
4555
		"\n" + 
4556
		"public interface I01 {\n" + 
4557
		"	/**\n" + 
4558
		"	 * Returns the composition of two functions. For {@code f: A->B} and\n" + 
4559
		"	 * {@code g: B->C}, composition is defined as the function h such that\n" + 
4560
		"	 * {@code h(a) == g(f(a))} for each {@code a}.\n" + 
4561
		"	 * \n" + 
4562
		"	 * @see <a href=\"//en.wikipedia.org/wiki/Function_composition\"> function\n" + 
4563
		"	 *      composition</a>\n" + 
4564
		"	 * \n" + 
4565
		"	 * @param g\n" + 
4566
		"	 *            the second function to apply\n" + 
4567
		"	 * @param f\n" + 
4568
		"	 *            the first function to apply\n" + 
4569
		"	 * @return the composition of {@code f} and {@code g}\n" + 
4570
		"	 */\n" + 
4571
		"	void foo();\n" + 
4572
		"}\n"
4573
	);
4574
}
4575
public void testBug260381_wksp2_01b() throws JavaModelException {
4576
	String source = 
4577
		"package wksp2;\n" + 
4578
		"public interface I01b {\n" + 
4579
		"  /**\n" + 
4580
		"   * Returns the composition of two functions. For <code> f: A->B</code> and\n" + 
4581
		"   * <code> g: B->C</code>, composition is defined as the function h such that\n" + 
4582
		"   * <code> h(a) == g(f(a))</code> for each <code> a</code>.\n" + 
4583
		"   *\n" + 
4584
		"   * @see <a href=\"//en.wikipedia.org/wiki/Function_composition\">\n" + 
4585
		"   * function composition</a>\n" + 
4586
		"   *\n" + 
4587
		"   * @param g the second function to apply\n" + 
4588
		"   * @param f the first function to apply\n" + 
4589
		"   * @return the composition of <code> f</code> and <code> g</code>\n" + 
4590
		"   */\n" + 
4591
		"  void foo();\n" + 
4592
		"}\n";
4593
	formatSource(source,
4594
		"package wksp2;\n" + 
4595
		"\n" + 
4596
		"public interface I01b {\n" + 
4597
		"	/**\n" + 
4598
		"	 * Returns the composition of two functions. For <code> f: A->B</code> and\n" + 
4599
		"	 * <code> g: B->C</code>, composition is defined as the function h such that\n" + 
4600
		"	 * <code> h(a) == g(f(a))</code> for each <code> a</code>.\n" + 
4601
		"	 * \n" + 
4602
		"	 * @see <a href=\"//en.wikipedia.org/wiki/Function_composition\"> function\n" + 
4603
		"	 *      composition</a>\n" + 
4604
		"	 * \n" + 
4605
		"	 * @param g\n" + 
4606
		"	 *            the second function to apply\n" + 
4607
		"	 * @param f\n" + 
4608
		"	 *            the first function to apply\n" + 
4609
		"	 * @return the composition of <code> f</code> and <code> g</code>\n" + 
4610
		"	 */\n" + 
4611
		"	void foo();\n" + 
4612
		"}\n"
4613
	);
4614
}
4615
public void testBug260381_wksp2_01c() throws JavaModelException {
4616
	String source = 
4617
		"package wksp2;\n" + 
4618
		"public interface I01c {\n" + 
4619
		"  /**\n" + 
4620
		"   * Returns the composition of two functions. For <code> f: A->B</code> and\n" + 
4621
		"   * <code>\n" + 
4622
		"   * g: B->C\n" + 
4623
		"   * </code>,\n" + 
4624
		"   * composition is defined as the function h such that\n" + 
4625
		"   * <code>\n" + 
4626
		"   *  h(a) == g(f(a))\n" + 
4627
		"   *  </code>\n" + 
4628
		"   *  for each\n" + 
4629
		"   *  <code>\n" + 
4630
		"   *  a\n" + 
4631
		"   *  </code>.\n" + 
4632
		"   *\n" + 
4633
		"   * @see <a href=\"//en.wikipedia.org/wiki/Function_composition\">\n" + 
4634
		"   * function composition</a>\n" + 
4635
		"   *\n" + 
4636
		"   * @param g the second function to apply\n" + 
4637
		"   * @param f the first function to apply\n" + 
4638
		"   * @return the composition of <code> f</code> and <code> g</code>\n" + 
4639
		"   */\n" + 
4640
		"  void foo();\n" + 
4641
		"}\n";
4642
	formatSource(source,
4643
		"package wksp2;\n" + 
4644
		"\n" + 
4645
		"public interface I01c {\n" + 
4646
		"	/**\n" + 
4647
		"	 * Returns the composition of two functions. For <code> f: A->B</code> and\n" + 
4648
		"	 * <code>\n" + 
4649
		"	 * g: B->C\n" + 
4650
		"	 * </code>, composition is defined as the function h such that <code>\n" + 
4651
		"	 *  h(a) == g(f(a))\n" + 
4652
		"	 *  </code> for each <code>\n" + 
4653
		"	 *  a\n" + 
4654
		"	 *  </code>.\n" + 
4655
		"	 * \n" + 
4656
		"	 * @see <a href=\"//en.wikipedia.org/wiki/Function_composition\"> function\n" + 
4657
		"	 *      composition</a>\n" + 
4658
		"	 * \n" + 
4659
		"	 * @param g\n" + 
4660
		"	 *            the second function to apply\n" + 
4661
		"	 * @param f\n" + 
4662
		"	 *            the first function to apply\n" + 
4663
		"	 * @return the composition of <code> f</code> and <code> g</code>\n" + 
4664
		"	 */\n" + 
4665
		"	void foo();\n" + 
4666
		"}\n"
4667
	);
4668
}
4669
public void testBug260381_wksp2_02() throws JavaModelException {
4670
	String source = 
4671
		"package wksp2;\n" + 
4672
		"\n" + 
4673
		"public interface I02 {\n" + 
4674
		"\n" + 
4675
		"  /**\n" + 
4676
		"   * Implementations of {@code computeNext} <b>must</b> invoke this method when\n" + 
4677
		"   * there are no elements left in the iteration.\n" + 
4678
		"   *\n" + 
4679
		"   * @return {@code null}; a convenience so your {@link #computeNext}\n" + 
4680
		"   *     implementation can use the simple statement {@code return endOfData();}\n" + 
4681
		"   */\n" + 
4682
		"  void foo();\n" + 
4683
		"}\n";
4684
	formatSource(source,
4685
		"package wksp2;\n" + 
4686
		"\n" + 
4687
		"public interface I02 {\n" + 
4688
		"\n" + 
4689
		"	/**\n" + 
4690
		"	 * Implementations of {@code computeNext} <b>must</b> invoke this method\n" + 
4691
		"	 * when there are no elements left in the iteration.\n" + 
4692
		"	 * \n" + 
4693
		"	 * @return {@code null}; a convenience so your {@link #computeNext}\n" + 
4694
		"	 *         implementation can use the simple statement\n" + 
4695
		"	 *         {@code return endOfData();}\n" + 
4696
		"	 */\n" + 
4697
		"	void foo();\n" + 
4698
		"}\n"
4699
	);
4700
}
4701
public void testBug260381_wksp2_03() throws JavaModelException {
4702
	String source = 
4703
		"package wksp2;\n" + 
4704
		"\n" + 
4705
		"public interface I03 {\n" + 
4706
		"  /**\n" + 
4707
		"   * A builder for creating immutable bimap instances, especially {@code public\n" + 
4708
		"   * static final} bimaps (\"constant bimaps\"). Example: <pre>   {@code\n" + 
4709
		"   *\n" + 
4710
		"   *   static final ImmutableBiMap<String, Integer> WORD_TO_INT =\n" + 
4711
		"   *       new ImmutableBiMap.Builder<String, Integer>()\n" + 
4712
		"   *           .put(\"one\", 1)\n" + 
4713
		"   *           .put(\"two\", 2)\n" + 
4714
		"   *           .put(\"three\", 3)\n" + 
4715
		"   *           .build();}</pre>\n" + 
4716
		"   *\n" + 
4717
		"   * For <i>small</i> immutable bimaps, the {@code ImmutableBiMap.of()} methods\n" + 
4718
		"   * are even more convenient.\n" + 
4719
		"   *\n" + 
4720
		"   * <p>Builder instances can be reused - it is safe to call {@link #build}\n" + 
4721
		"   * multiple times to build multiple bimaps in series. Each bimap is a superset\n" + 
4722
		"   * of the bimaps created before it.\n" + 
4723
		"   */\n" + 
4724
		"  void foo();\n" + 
4725
		"}\n";
4726
	formatSource(source,
4727
		"package wksp2;\n" + 
4728
		"\n" + 
4729
		"public interface I03 {\n" + 
4730
		"	/**\n" + 
4731
		"	 * A builder for creating immutable bimap instances, especially\n" + 
4732
		"	 * {@code public static final} bimaps (\"constant bimaps\"). Example:\n" + 
4733
		"	 * \n" + 
4734
		"	 * <pre>\n" + 
4735
		"	 * {\n" + 
4736
		"	 * 	&#064;code\n" + 
4737
		"	 * 	static final ImmutableBiMap&lt;String, Integer&gt; WORD_TO_INT = new ImmutableBiMap.Builder&lt;String, Integer&gt;()\n" + 
4738
		"	 * 			.put(&quot;one&quot;, 1).put(&quot;two&quot;, 2).put(&quot;three&quot;, 3).build();\n" + 
4739
		"	 * }\n" + 
4740
		"	 * </pre>\n" + 
4741
		"	 * \n" + 
4742
		"	 * For <i>small</i> immutable bimaps, the {@code ImmutableBiMap.of()}\n" + 
4743
		"	 * methods are even more convenient.\n" + 
4744
		"	 * \n" + 
4745
		"	 * <p>\n" + 
4746
		"	 * Builder instances can be reused - it is safe to call {@link #build}\n" + 
4747
		"	 * multiple times to build multiple bimaps in series. Each bimap is a\n" + 
4748
		"	 * superset of the bimaps created before it.\n" + 
4749
		"	 */\n" + 
4750
		"	void foo();\n" + 
4751
		"}\n"
4752
	);
4753
}
4754
public void testBug260381_wksp2_04() throws JavaModelException {
4755
	String source = 
4756
		"package wksp2;\n" + 
4757
		"\n" + 
4758
		"public interface I04 {\n" + 
4759
		"\n" + 
4760
		"  /**\n" + 
4761
		"   * Returns an immutable multiset containing the given elements.\n" + 
4762
		"   * \n" + 
4763
		"   * <p>The multiset is ordered by the first occurrence of each element. For\n" + 
4764
		"   * example, {@code ImmutableMultiset.copyOf(Arrays.asList(2, 3, 1, 3))} yields\n" + 
4765
		"   * a multiset with elements in the order {@code 2, 3, 3, 1}.\n" + 
4766
		"   *\n" + 
4767
		"   * <p>Note that if {@code c} is a {@code Collection<String>}, then {@code\n" + 
4768
		"   * ImmutableMultiset.copyOf(c)} returns an {@code ImmutableMultiset<String>}\n" + 
4769
		"   * containing each of the strings in {@code c}, while\n" + 
4770
		"   * {@code ImmutableMultiset.of(c)} returns an\n" + 
4771
		"   * {@code ImmutableMultiset<Collection<String>>} containing one element (the\n" + 
4772
		"   * given collection itself).\n" + 
4773
		"   *\n" + 
4774
		"   * <p><b>Note:</b> Despite what the method name suggests, if {@code elements}\n" + 
4775
		"   * is an {@code ImmutableMultiset}, no copy will actually be performed, and\n" + 
4776
		"   * the given multiset itself will be returned.\n" + 
4777
		"   *\n" + 
4778
		"   * @throws NullPointerException if any of {@code elements} is null\n" + 
4779
		"   */\n" + 
4780
		"  void foo();\n" + 
4781
		"}\n";
4782
	formatSource(source,
4783
		"package wksp2;\n" + 
4784
		"\n" + 
4785
		"public interface I04 {\n" + 
4786
		"\n" + 
4787
		"	/**\n" + 
4788
		"	 * Returns an immutable multiset containing the given elements.\n" + 
4789
		"	 * \n" + 
4790
		"	 * <p>\n" + 
4791
		"	 * The multiset is ordered by the first occurrence of each element. For\n" + 
4792
		"	 * example, {@code ImmutableMultiset.copyOf(Arrays.asList(2, 3, 1, 3))}\n" + 
4793
		"	 * yields a multiset with elements in the order {@code 2, 3, 3, 1}.\n" + 
4794
		"	 * \n" + 
4795
		"	 * <p>\n" + 
4796
		"	 * Note that if {@code c} is a {@code Collection<String>}, then\n" + 
4797
		"	 * {@code ImmutableMultiset.copyOf(c)} returns an\n" + 
4798
		"	 * {@code ImmutableMultiset<String>} containing each of the strings in\n" + 
4799
		"	 * {@code c}, while {@code ImmutableMultiset.of(c)} returns an\n" + 
4800
		"	 * {@code ImmutableMultiset<Collection<String>>} containing one element (the\n" + 
4801
		"	 * given collection itself).\n" + 
4802
		"	 * \n" + 
4803
		"	 * <p>\n" + 
4804
		"	 * <b>Note:</b> Despite what the method name suggests, if {@code elements}\n" + 
4805
		"	 * is an {@code ImmutableMultiset}, no copy will actually be performed, and\n" + 
4806
		"	 * the given multiset itself will be returned.\n" + 
4807
		"	 * \n" + 
4808
		"	 * @throws NullPointerException\n" + 
4809
		"	 *             if any of {@code elements} is null\n" + 
4810
		"	 */\n" + 
4811
		"	void foo();\n" + 
4812
		"}\n"
4813
	);
4814
}
4815
public void testBug260381_wksp2_05() throws JavaModelException {
4816
	String source = 
4817
		"package wksp2;\n" + 
4818
		"\n" + 
4819
		"public interface I05 {\n" + 
4820
		"\n" + 
4821
		"  /**\n" + 
4822
		"   * Indexes the specified values into a {@code Multimap} by applying a\n" + 
4823
		"   * specified function to each item in an {@code Iterable} of values. Each\n" + 
4824
		"   * value will be stored as a value in the specified multimap. The key used to\n" + 
4825
		"   * store that value in the multimap will be the result of calling the function\n" + 
4826
		"   * on that value. Depending on the multimap implementation, duplicate entries\n" + 
4827
		"   * (equal keys and equal values) may be collapsed.\n" + 
4828
		"   *\n" + 
4829
		"   * <p>For example,\n" + 
4830
		"   *\n" + 
4831
		"   * <pre class=\"code\">\n" + 
4832
		"   * List&lt;String> badGuys =\n" + 
4833
		"   *   Arrays.asList(\"Inky\", \"Blinky\", \"Pinky\", \"Pinky\", \"Clyde\");\n" + 
4834
		"   * Function&lt;String, Integer> stringLengthFunction = ...;\n" + 
4835
		"   * Multimap&lt;Integer, String> index = Multimaps.newHashMultimap();\n" + 
4836
		"   * Multimaps.index(badGuys, stringLengthFunction, index);\n" + 
4837
		"   * System.out.println(index); </pre>\n" + 
4838
		"   *\n" + 
4839
		"   * prints\n" + 
4840
		"   *\n" + 
4841
		"   * <pre class=\"code\">\n" + 
4842
		"   * {4=[Inky], 5=[Pinky, Clyde], 6=[Blinky]} </pre>\n" + 
4843
		"   *\n" + 
4844
		"   * The {@link HashMultimap} collapses the duplicate occurrence of\n" + 
4845
		"   * {@code (5, \"Pinky\")}.\n" + 
4846
		"   *\n" + 
4847
		"   * @param values the values to add to the multimap\n" + 
4848
		"   * @param keyFunction the function used to produce the key for each value\n" + 
4849
		"   * @param multimap the multimap to store the key value pairs\n" + 
4850
		"   */\n" + 
4851
		"  void foo();\n" + 
4852
		"}\n";
4853
	formatSource(source,
4854
		"package wksp2;\n" + 
4855
		"\n" + 
4856
		"public interface I05 {\n" + 
4857
		"\n" + 
4858
		"	/**\n" + 
4859
		"	 * Indexes the specified values into a {@code Multimap} by applying a\n" + 
4860
		"	 * specified function to each item in an {@code Iterable} of values. Each\n" + 
4861
		"	 * value will be stored as a value in the specified multimap. The key used\n" + 
4862
		"	 * to store that value in the multimap will be the result of calling the\n" + 
4863
		"	 * function on that value. Depending on the multimap implementation,\n" + 
4864
		"	 * duplicate entries (equal keys and equal values) may be collapsed.\n" + 
4865
		"	 * \n" + 
4866
		"	 * <p>\n" + 
4867
		"	 * For example,\n" + 
4868
		"	 * \n" + 
4869
		"	 * <pre class=\"code\">\n" + 
4870
		"	 * List&lt;String> badGuys =\n" + 
4871
		"	 *   Arrays.asList(\"Inky\", \"Blinky\", \"Pinky\", \"Pinky\", \"Clyde\");\n" + 
4872
		"	 * Function&lt;String, Integer> stringLengthFunction = ...;\n" + 
4873
		"	 * Multimap&lt;Integer, String> index = Multimaps.newHashMultimap();\n" + 
4874
		"	 * Multimaps.index(badGuys, stringLengthFunction, index);\n" + 
4875
		"	 * System.out.println(index);\n" + 
4876
		"	 * </pre>\n" + 
4877
		"	 * \n" + 
4878
		"	 * prints\n" + 
4879
		"	 * \n" + 
4880
		"	 * <pre class=\"code\">\n" + 
4881
		"	 * {4=[Inky], 5=[Pinky, Clyde], 6=[Blinky]}\n" + 
4882
		"	 * </pre>\n" + 
4883
		"	 * \n" + 
4884
		"	 * The {@link HashMultimap} collapses the duplicate occurrence of\n" + 
4885
		"	 * {@code (5, \"Pinky\")}.\n" + 
4886
		"	 * \n" + 
4887
		"	 * @param values\n" + 
4888
		"	 *            the values to add to the multimap\n" + 
4889
		"	 * @param keyFunction\n" + 
4890
		"	 *            the function used to produce the key for each value\n" + 
4891
		"	 * @param multimap\n" + 
4892
		"	 *            the multimap to store the key value pairs\n" + 
4893
		"	 */\n" + 
4894
		"	void foo();\n" + 
4895
		"}\n"
4896
	);
4897
}
4898
public void testBug260381_wksp2_06() throws JavaModelException {
4899
	String source = 
4900
		"package wksp2;\n" + 
4901
		"\n" + 
4902
		"public interface I06 {\n" + 
4903
		"\n" + 
4904
		"  /**\n" + 
4905
		"   * Adds a number of occurrences of an element to this multiset. Note that if\n" + 
4906
		"   * {@code occurrences == 1}, this method has the identical effect to {@link\n" + 
4907
		"   * #add(Object)}. This method is functionally equivalent (except in the case\n" + 
4908
		"   * of overflow) to the call {@code addAll(Collections.nCopies(element,\n" + 
4909
		"   * occurrences))}, which would presumably perform much more poorly.\n" + 
4910
		"   *\n" + 
4911
		"   * @param element the element to add occurrences of; may be {@code null} only\n" + 
4912
		"   *     if explicitly allowed by the implementation\n" + 
4913
		"   * @param occurrences the number of occurrences of this element to add. May\n" + 
4914
		"   *     be zero, in which case no change will be made.\n" + 
4915
		"   * @return the previous count of this element before the operation; possibly\n" + 
4916
		"   *     zero - TODO: make this the actual behavior!\n" + 
4917
		"   * @throws IllegalArgumentException if {@code occurrences} is negative, or if\n" + 
4918
		"   *     this operation would result in more than {@link Integer#MAX_VALUE}\n" + 
4919
		"   *     occurrences of the element \n" + 
4920
		"   * @throws NullPointerException if {@code element} is null and this\n" + 
4921
		"   *     implementation does not permit null elements. Note that if {@code\n" + 
4922
		"   *     occurrences} is zero, the implementation may opt to return normally.\n" + 
4923
		"   */\n" + 
4924
		"  boolean /*int*/ add(E element, int occurrences);\n" + 
4925
		"}\n";
4926
	formatSource(source,
4927
		"package wksp2;\n" + 
4928
		"\n" + 
4929
		"public interface I06 {\n" + 
4930
		"\n" + 
4931
		"	/**\n" + 
4932
		"	 * Adds a number of occurrences of an element to this multiset. Note that if\n" + 
4933
		"	 * {@code occurrences == 1}, this method has the identical effect to\n" + 
4934
		"	 * {@link #add(Object)}. This method is functionally equivalent (except in\n" + 
4935
		"	 * the case of overflow) to the call\n" + 
4936
		"	 * {@code addAll(Collections.nCopies(element, occurrences))}, which would\n" + 
4937
		"	 * presumably perform much more poorly.\n" + 
4938
		"	 * \n" + 
4939
		"	 * @param element\n" + 
4940
		"	 *            the element to add occurrences of; may be {@code null} only if\n" + 
4941
		"	 *            explicitly allowed by the implementation\n" + 
4942
		"	 * @param occurrences\n" + 
4943
		"	 *            the number of occurrences of this element to add. May be zero,\n" + 
4944
		"	 *            in which case no change will be made.\n" + 
4945
		"	 * @return the previous count of this element before the operation; possibly\n" + 
4946
		"	 *         zero - TODO: make this the actual behavior!\n" + 
4947
		"	 * @throws IllegalArgumentException\n" + 
4948
		"	 *             if {@code occurrences} is negative, or if this operation\n" + 
4949
		"	 *             would result in more than {@link Integer#MAX_VALUE}\n" + 
4950
		"	 *             occurrences of the element\n" + 
4951
		"	 * @throws NullPointerException\n" + 
4952
		"	 *             if {@code element} is null and this implementation does not\n" + 
4953
		"	 *             permit null elements. Note that if {@code occurrences} is\n" + 
4954
		"	 *             zero, the implementation may opt to return normally.\n" + 
4955
		"	 */\n" + 
4956
		"	boolean /* int */add(E element, int occurrences);\n" + 
4957
		"}\n"
4958
	);
4959
}
4960
public void testBug260381_wksp2_07() throws JavaModelException {
4961
	String source = 
4962
		"package wksp2;\n" + 
4963
		"\n" + 
4964
		"public interface I07 {\n" + 
4965
		"\n" + 
4966
		"  /**\n" + 
4967
		"   * Constructs a new, empty multiset, sorted according to the specified\n" + 
4968
		"   * comparator. All elements inserted into the multiset must be <i>mutually\n" + 
4969
		"   * comparable</i> by the specified comparator: {@code comparator.compare(e1,\n" + 
4970
		"   * e2)} must not throw a {@code ClassCastException} for any elements {@code\n" + 
4971
		"   * e1} and {@code e2} in the multiset. If the user attempts to add an element\n" + 
4972
		"   * to the multiset that violates this constraint, the {@code add(Object)} call\n" + 
4973
		"   * will throw a {@code ClassCastException}.\n" + 
4974
		"   *\n" + 
4975
		"   * @param comparator the comparator that will be used to sort this multiset. A\n" + 
4976
		"   *     null value indicates that the elements\' <i>natural ordering</i> should\n" + 
4977
		"   *     be used.\n" + 
4978
		"   */\n" + 
4979
		"  void foo();\n" + 
4980
		"}\n";
4981
	formatSource(source,
4982
		"package wksp2;\n" + 
4983
		"\n" + 
4984
		"public interface I07 {\n" + 
4985
		"\n" + 
4986
		"	/**\n" + 
4987
		"	 * Constructs a new, empty multiset, sorted according to the specified\n" + 
4988
		"	 * comparator. All elements inserted into the multiset must be <i>mutually\n" + 
4989
		"	 * comparable</i> by the specified comparator:\n" + 
4990
		"	 * {@code comparator.compare(e1, e2)} must not throw a\n" + 
4991
		"	 * {@code ClassCastException} for any elements {@code e1} and {@code e2} in\n" + 
4992
		"	 * the multiset. If the user attempts to add an element to the multiset that\n" + 
4993
		"	 * violates this constraint, the {@code add(Object)} call will throw a\n" + 
4994
		"	 * {@code ClassCastException}.\n" + 
4995
		"	 * \n" + 
4996
		"	 * @param comparator\n" + 
4997
		"	 *            the comparator that will be used to sort this multiset. A null\n" + 
4998
		"	 *            value indicates that the elements\' <i>natural ordering</i>\n" + 
4999
		"	 *            should be used.\n" + 
5000
		"	 */\n" + 
5001
		"	void foo();\n" + 
5002
		"}\n"
5003
	);
5004
}
5005
public void testBug260381_wksp2_08() throws JavaModelException {
5006
	String source =
5007
		"package wksp2;\n" +
5008
		"\n" +
5009
		"public interface I08 {\n" +
5010
		"\n" +
5011
		"	  /**\n" +
5012
		"	   * Returns the composition of a function and a predicate. For every {@code x},\n" +
5013
		"	   * the generated predicate returns {@code predicate(function(x))}.\n" +
5014
		"	   *\n" +
5015
		"	   * @return the composition of the provided function and predicate\n" +
5016
		"	   */\n" +
5017
		"	void foo();\n" +
5018
		"}\n";
5019
	formatSource(source,
5020
		"package wksp2;\n" +
5021
		"\n" +
5022
		"public interface I08 {\n" +
5023
		"\n" +
5024
		"	/**\n" +
5025
		"	 * Returns the composition of a function and a predicate. For every\n" +
5026
		"	 * {@code x}, the generated predicate returns {@code predicate(function(x))}\n" +
5027
		"	 * .\n" +
5028
		"	 * \n" +
5029
		"	 * @return the composition of the provided function and predicate\n" +
5030
		"	 */\n" +
5031
		"	void foo();\n" +
5032
		"}\n"
5033
	);
5034
}
5035
public void testBug260381_wksp2_09() throws JavaModelException {
5036
	String source =
5037
		"package wksp2;\n" +
5038
		"\n" +
5039
		"/**\n" +
5040
		"	A Conditional represents an if/then/else block.\n" +
5041
		"	When this is created the code  will already have\n" +
5042
		"	the conditional check code. The code is optimized for branch\n" +
5043
		"	offsets that fit in 2 bytes, though will handle 4 byte offsets.\n" +
5044
		"<code>\n" +
5045
		"     if condition\n" +
5046
		"	 then code\n" +
5047
		"	 else code\n" +
5048
		"</code>\n" +
5049
		"     what actually gets built is\n" +
5050
		"<code>\n" +
5051
		"     if !condition branch to eb:\n" +
5052
		"	  then code\n" +
5053
		"	  goto end:  // skip else\n" +
5054
		"	 eb:\n" +
5055
		"	  else code\n" +
5056
		"	 end:\n" +
5057
		"</code>\n" +
5058
		"*/\n" +
5059
		"public class X09 {\n" +
5060
		"\n" +
5061
		"}\n";
5062
	formatSource(source,
5063
		"package wksp2;\n" +
5064
		"\n" +
5065
		"/**\n" +
5066
		" * A Conditional represents an if/then/else block. When this is created the code\n" +
5067
		" * will already have the conditional check code. The code is optimized for\n" +
5068
		" * branch offsets that fit in 2 bytes, though will handle 4 byte offsets. <code>\n" +
5069
		"     if condition\n" +
5070
		"	 then code\n" +
5071
		"	 else code\n" +
5072
		"</code>\n" +
5073
		" * what actually gets built is <code>\n" +
5074
		"     if !condition branch to eb:\n" +
5075
		"	  then code\n" +
5076
		"	  goto end:  // skip else\n" +
5077
		"	 eb:\n" +
5078
		"	  else code\n" +
5079
		"	 end:\n" +
5080
		"</code>\n" +
5081
		" */\n" +
5082
		"public class X09 {\n" +
5083
		"\n" +
5084
		"}\n"
5085
	);
5086
}
5087
5088
/**
4401
 * @bug 260798: [formatter] Strange behavior of never join lines
5089
 * @bug 260798: [formatter] Strange behavior of never join lines
4402
 * @test Ensure that the formatter indents lines correctly when never join lines pref is activated
5090
 * @test Ensure that the formatter indents lines correctly when never join lines pref is activated
4403
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260798"
5091
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260798"

Return to bug 260381