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

Collapse All | Expand All

(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-8 / +10 lines)
Lines 1789-1795 Link Here
1789
    	int previousStart = currentTokenStartPosition;
1789
    	int previousStart = currentTokenStartPosition;
1790
1790
1791
		if (!isNlsTag && includesLineComments()) {
1791
		if (!isNlsTag && includesLineComments()) {
1792
			printLineComment(currentTokenStartPosition, currentTokenEndPosition);
1792
			printLineComment(currentTokenStartPosition, currentTokenEndPosition-1);
1793
		} else {
1793
		} else {
1794
			// do nothing!?
1794
			// do nothing!?
1795
	    	loop: while (nextCharacterStart <= currentTokenEndPosition && (currentCharacter = this.scanner.getNextChar()) != -1) {
1795
	    	loop: while (nextCharacterStart <= currentTokenEndPosition && (currentCharacter = this.scanner.getNextChar()) != -1) {
Lines 1843-1848 Link Here
1843
		this.numberOfIndentations = this.indentationLevel / this.indentationSize;
1843
		this.numberOfIndentations = this.indentationLevel / this.indentationSize;
1844
1844
1845
		// Consume the comment prefix
1845
		// Consume the comment prefix
1846
		this.scanner.resetTo(commentStart, commentEnd);
1846
		StringBuffer buffer = new StringBuffer();
1847
		StringBuffer buffer = new StringBuffer();
1847
		this.scanner.getNextChar();
1848
		this.scanner.getNextChar();
1848
		buffer.append(this.scanner.currentCharacter);
1849
		buffer.append(this.scanner.currentCharacter);
Lines 1856-1861 Link Here
1856
		int previousPosition = commentStart;
1857
		int previousPosition = commentStart;
1857
		char previousChar = 0;
1858
		char previousChar = 0;
1858
		boolean firstWord = true;
1859
		boolean firstWord = true;
1860
		this.scanner.skipComments = true;
1859
1861
1860
		// Consume text token per token
1862
		// Consume text token per token
1861
		while (!this.scanner.atEnd()) {
1863
		while (!this.scanner.atEnd()) {
Lines 1925-1931 Link Here
1925
			buffer.append(this.lineSeparator);
1927
			buffer.append(this.lineSeparator);
1926
			this.line++;
1928
			this.line++;
1927
			this.lastNumberOfNewLines++;
1929
			this.lastNumberOfNewLines++;
1928
		} else if (previousPosition < commentEnd) {
1930
		} else {
1929
			this.scanner.resetTo(previousPosition, commentEnd);
1931
			this.scanner.resetTo(previousPosition, commentEnd);
1930
			while (!this.scanner.atEnd()) {
1932
			while (!this.scanner.atEnd()) {
1931
				this.scanner.getNextChar();
1933
				this.scanner.getNextChar();
Lines 1941-1947 Link Here
1941
		}
1943
		}
1942
1944
1943
		// Replace the existing comment with new one
1945
		// Replace the existing comment with new one
1944
		addReplaceEdit(commentStart, commentEnd-1, buffer.toString());
1946
		addReplaceEdit(commentStart, commentEnd, buffer.toString());
1947
		this.scanner.skipComments = false;
1945
	}
1948
	}
1946
1949
1947
	public void printEmptyLines(int linesNumber) {
1950
	public void printEmptyLines(int linesNumber) {
Lines 2071-2079 Link Here
2071
		}
2074
		}
2072
		if (!block.isDescription()) {
2075
		if (!block.isDescription()) {
2073
			this.column += previousEnd - block.sourceStart + 1;
2076
			this.column += previousEnd - block.sourceStart + 1;
2074
			if (block.isInlined()) 	{
2075
				this.column++; // Add extra character for inline tag
2076
			}
2077
			FormatJavadocReference reference= block.reference;
2077
			FormatJavadocReference reference= block.reference;
2078
			if (reference != null) {
2078
			if (reference != null) {
2079
				// format reference
2079
				// format reference
Lines 2107-2113 Link Here
2107
	                    while (token == TerminalTokens.TokenNameWHITESPACE || token == TerminalTokens.TokenNameMULTIPLY) {
2107
	                    while (token == TerminalTokens.TokenNameWHITESPACE || token == TerminalTokens.TokenNameMULTIPLY) {
2108
	                    	token = this.scanner.getNextToken();
2108
	                    	token = this.scanner.getNextToken();
2109
	                    }
2109
	                    }
2110
	                    buffer.append(this.scanner.source, this.scanner.startPosition, this.scanner.currentPosition-this.scanner.startPosition);
2110
	                    if (token == TerminalTokens.TokenNameRBRACE) {
2111
		                    buffer.append(this.scanner.source, this.scanner.startPosition, this.scanner.currentPosition-this.scanner.startPosition);
2112
					    	this.column += (this.scanner.atEnd() ? this.scanner.eofPosition : this.scanner.currentPosition) - this.scanner.startPosition;
2113
	                    }
2111
                    } catch (InvalidInputException e) {
2114
                    } catch (InvalidInputException e) {
2112
						buffer.append('}');
2115
						buffer.append('}');
2113
                    }
2116
                    }
Lines 2118-2124 Link Here
2118
		}
2121
		}
2119
		
2122
		
2120
		// tag section: iterate through the blocks composing this tag but the last one
2123
		// tag section: iterate through the blocks composing this tag but the last one
2121
//		if (block.isHeaderLine()) maxColumn++;
2122
		for (int i=0; i<=maxNodes; i++) {
2124
		for (int i=0; i<=maxNodes; i++) {
2123
			FormatJavadocNode node = block.nodes[i];
2125
			FormatJavadocNode node = block.nodes[i];
2124
			int nodeStart = node.sourceStart;
2126
			int nodeStart = node.sourceStart;
(-)formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java (-45 / +64 lines)
Lines 26-31 Link Here
26
public class FormatterCommentParser extends JavadocParser implements IJavaDocTagConstants {
26
public class FormatterCommentParser extends JavadocParser implements IJavaDocTagConstants {
27
	char[][] htmlTags;
27
	char[][] htmlTags;
28
	int htmlTagsPtr = -1;
28
	int htmlTagsPtr = -1;
29
	private boolean invalidTagName;
29
	
30
	
30
FormatterCommentParser(Parser sourceParser) {
31
FormatterCommentParser(Parser sourceParser) {
31
	super(sourceParser);
32
	super(sourceParser);
Lines 115-120 Link Here
115
}
116
}
116
117
117
/*
118
/*
119
 * Return the html tag index in the various arrays of IJavaDocTagConstants.
120
 * The returned int is set as follow:
121
 * 	- the array index is set on bits 0 to 7
122
 * 	- the tag category is set on bit 8 to 15 (0xFF00 if no array includes the tag)
123
 */
124
private int getHtmlTagIndex(char[] htmlTag) {
125
	int length = htmlTag == null ? 0 : htmlTag.length;
126
	if (length > 0) {
127
		for (int i=0, max=JAVADOC_SINGLE_BREAK_TAG.length; i<max; i++) {
128
			char[] tag = JAVADOC_SINGLE_BREAK_TAG[i];
129
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
130
				return JAVADOC_SINGLE_BREAK_TAG_ID + i;
131
			}
132
		}
133
		for (int i=0, max=JAVADOC_CODE_TAGS.length; i<max; i++) {
134
			char[] tag = IJavaDocTagConstants.JAVADOC_CODE_TAGS[i];
135
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
136
				return JAVADOC_CODE_TAGS_ID + i;
137
			}
138
		}
139
		for (int i=0, max=IJavaDocTagConstants.JAVADOC_BREAK_TAGS.length; i<max; i++) {
140
			char[] tag = IJavaDocTagConstants.JAVADOC_BREAK_TAGS[i];
141
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
142
				return JAVADOC_BREAK_TAGS_ID + i;
143
			}
144
		}
145
		for (int i=0, max=IJavaDocTagConstants.JAVADOC_IMMUTABLE_TAGS.length; i<max; i++) {
146
			char[] tag = IJavaDocTagConstants.JAVADOC_IMMUTABLE_TAGS[i];
147
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
148
				return JAVADOC_IMMUTABLE_TAGS_ID + i;
149
			}
150
		}
151
		for (int i=0, max=IJavaDocTagConstants.JAVADOC_SEPARATOR_TAGS.length; i<max; i++) {
152
			char[] tag = IJavaDocTagConstants.JAVADOC_SEPARATOR_TAGS[i];
153
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
154
				return JAVADOC_SEPARATOR_TAGS_ID + i;
155
			}
156
		}
157
	}
158
	return JAVADOC_TAGS_ID_MASK;
159
}
160
161
protected char[] getTagName(int previousPosition, int currentPosition) {
162
	this.invalidTagName = false;
163
    if (currentPosition != this.scanner.startPosition) {
164
		this.invalidTagName = true;
165
		return null;
166
	}
167
	if (this.index >= this.scanner.eofPosition) {
168
		this.invalidTagName = true;
169
		return null;
170
	}
171
	this.tagSourceStart = this.scanner.getCurrentTokenStartPosition();
172
	this.tagSourceEnd = this.scanner.getCurrentTokenEndPosition();
173
	char[] tagName = this.scanner.getCurrentIdentifierSource();
174
    return tagName;
175
}
176
177
/*
118
 * Parse an HTML tag expected to be either opening (e.g. <tag_name> ) or
178
 * Parse an HTML tag expected to be either opening (e.g. <tag_name> ) or
119
 * closing (e.g. </tag_name>).
179
 * closing (e.g. </tag_name>).
120
 */
180
 */
Lines 132-138 Link Here
132
	    	case TerminalTokens.TokenNameIdentifier:
192
	    	case TerminalTokens.TokenNameIdentifier:
133
	    		// HTML tag opening
193
	    		// HTML tag opening
134
				htmlTag = this.scanner.getCurrentIdentifierSource();
194
				htmlTag = this.scanner.getCurrentIdentifierSource();
135
				htmlIndex = htmlTagIndex(htmlTag);
195
				htmlIndex = getHtmlTagIndex(htmlTag);
136
				if (htmlIndex == JAVADOC_TAGS_ID_MASK) return valid;
196
				if (htmlIndex == JAVADOC_TAGS_ID_MASK) return valid;
137
				if ((htmlIndex & JAVADOC_TAGS_ID_MASK) > JAVADOC_SINGLE_TAGS_ID) {
197
				if ((htmlIndex & JAVADOC_TAGS_ID_MASK) > JAVADOC_SINGLE_TAGS_ID) {
138
		    		if (this.htmlTagsPtr == -1 || !CharOperation.equals(this.htmlTags[this.htmlTagsPtr], htmlTag, false)) {
198
		    		if (this.htmlTagsPtr == -1 || !CharOperation.equals(this.htmlTags[this.htmlTagsPtr], htmlTag, false)) {
Lines 157-163 Link Here
157
	    			return valid;
217
	    			return valid;
158
	    		}
218
	    		}
159
				char[] identifier = this.scanner.getCurrentIdentifierSource();
219
				char[] identifier = this.scanner.getCurrentIdentifierSource();
160
				htmlIndex = htmlTagIndex(identifier);
220
				htmlIndex = getHtmlTagIndex(identifier);
161
				if (htmlIndex == JAVADOC_TAGS_ID_MASK) return valid;
221
				if (htmlIndex == JAVADOC_TAGS_ID_MASK) return valid;
162
	    		while (!CharOperation.equals(htmlTag, identifier, false)) {
222
	    		while (!CharOperation.equals(htmlTag, identifier, false)) {
163
	    			if (htmlTagsPtr <= 0) {
223
	    			if (htmlTagsPtr <= 0) {
Lines 202-250 Link Here
202
    return valid;
262
    return valid;
203
}
263
}
204
264
205
/*
206
 * Return the html tag index in the various arrays of IJavaDocTagConstants.
207
 * The returned int is set as follow:
208
 * 	- the array index is set on bits 0 to 7
209
 * 	- the tag category is set on bit 8 to 15 (0xFF00 if no array includes the tag)
210
 */
211
private int htmlTagIndex(char[] htmlTag) {
212
	int length = htmlTag == null ? 0 : htmlTag.length;
213
	if (length > 0) {
214
		for (int i=0, max=JAVADOC_SINGLE_BREAK_TAG.length; i<max; i++) {
215
			char[] tag = JAVADOC_SINGLE_BREAK_TAG[i];
216
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
217
				return JAVADOC_SINGLE_BREAK_TAG_ID + i;
218
			}
219
		}
220
		for (int i=0, max=JAVADOC_CODE_TAGS.length; i<max; i++) {
221
			char[] tag = IJavaDocTagConstants.JAVADOC_CODE_TAGS[i];
222
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
223
				return JAVADOC_CODE_TAGS_ID + i;
224
			}
225
		}
226
		for (int i=0, max=IJavaDocTagConstants.JAVADOC_BREAK_TAGS.length; i<max; i++) {
227
			char[] tag = IJavaDocTagConstants.JAVADOC_BREAK_TAGS[i];
228
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
229
				return JAVADOC_BREAK_TAGS_ID + i;
230
			}
231
		}
232
		for (int i=0, max=IJavaDocTagConstants.JAVADOC_IMMUTABLE_TAGS.length; i<max; i++) {
233
			char[] tag = IJavaDocTagConstants.JAVADOC_IMMUTABLE_TAGS[i];
234
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
235
				return JAVADOC_IMMUTABLE_TAGS_ID + i;
236
			}
237
		}
238
		for (int i=0, max=IJavaDocTagConstants.JAVADOC_SEPARATOR_TAGS.length; i<max; i++) {
239
			char[] tag = IJavaDocTagConstants.JAVADOC_SEPARATOR_TAGS[i];
240
			if (length == tag.length && CharOperation.equals(htmlTag, tag, false)) {
241
				return JAVADOC_SEPARATOR_TAGS_ID + i;
242
			}
243
		}
244
	}
245
	return JAVADOC_TAGS_ID_MASK;
246
}
247
248
/* (non-Javadoc)
265
/* (non-Javadoc)
249
 * @see org.eclipse.jdt.internal.compiler.parser.JavadocParser#parseParam()
266
 * @see org.eclipse.jdt.internal.compiler.parser.JavadocParser#parseParam()
250
 */
267
 */
Lines 303-308 Link Here
303
				createTag();
320
				createTag();
304
				break;
321
				break;
305
		}
322
		}
323
	} else if (this.invalidTagName) {
324
		this.textStart = previousPosition;
306
	} else if (this.astPtr == ptr) {
325
	} else if (this.astPtr == ptr) {
307
		createTag();
326
		createTag();
308
	}
327
	}
(-)formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatter.java (-26 / +26 lines)
Lines 61-73 Link Here
61
	 * released.
61
	 * released.
62
	 * The default is to enable old version of formatting to minimize impacts on
62
	 * The default is to enable old version of formatting to minimize impacts on
63
	 * existing clients.
63
	 * existing clients.
64
	 * TODO (eric) remove when bug 102780 will have been stabilized
64
	 * TODO remove when bugs 102780 & 227043 will have been stabilized
65
	 */
65
	 */
66
	private final static String NEW_COMMENTS_FORMAT = System.getProperty("org.eclipse.jdt.core.formatter.comments.new"); //$NON-NLS-1$
66
	private final static String NEW_COMMENTS_FORMAT = System.getProperty("org.eclipse.jdt.core.formatter.comments.new"); //$NON-NLS-1$
67
	private static final boolean ENABLE_NEW_COMMENTS_FORMAT = JavaCore.ENABLED.equals(NEW_COMMENTS_FORMAT);
67
	public static final boolean ENABLE_NEW_COMMENTS_FORMAT = !JavaCore.DISABLED.equals(NEW_COMMENTS_FORMAT);
68
	private static final boolean FORCE_NEW_COMMENTS_FORMAT = "forced".equals(NEW_COMMENTS_FORMAT); //$NON-NLS-1$
68
//	private static final boolean FORCE_NEW_COMMENTS_FORMAT = "forced".equals(NEW_COMMENTS_FORMAT); //$NON-NLS-1$
69
	private static final String WARNING_FORMAT_COMMENTS = "WARNING: Comments are still formatted using regions!"; //$NON-NLS-1$
69
//	private static final String WARNING_FORMAT_COMMENTS = "WARNING: Comments are still formatted using regions!"; //$NON-NLS-1$
70
	private static boolean PRINTED_FORMAT_COMMENTS_WARNING = false;
70
//	private static boolean PRINTED_FORMAT_COMMENTS_WARNING = false;
71
71
72
	// Scanner use to probe the kind of the source given to the formatter
72
	// Scanner use to probe the kind of the source given to the formatter
73
	private static Scanner PROBING_SCANNER;
73
	private static Scanner PROBING_SCANNER;
Lines 179-202 Link Here
179
				if (ENABLE_NEW_COMMENTS_FORMAT) {
179
				if (ENABLE_NEW_COMMENTS_FORMAT) {
180
	                return formatComment(kind & K_MASK, source, indentationLevel, lineSeparator, new IRegion[] {new Region(offset, length)});
180
	                return formatComment(kind & K_MASK, source, indentationLevel, lineSeparator, new IRegion[] {new Region(offset, length)});
181
				}
181
				}
182
				if (FORCE_NEW_COMMENTS_FORMAT) {
182
//				if (FORCE_NEW_COMMENTS_FORMAT) {
183
					// Skip the javadoc formatting using this constant
183
//					// Skip the javadoc formatting using this constant
184
					return null;
184
//					return null;
185
				}
185
//				}
186
				// In all other cases, use the old way to format javadoc comments
186
//				// In all other cases, use the old way to format javadoc comments
187
				if (!PRINTED_FORMAT_COMMENTS_WARNING) {
187
//				if (!PRINTED_FORMAT_COMMENTS_WARNING) {
188
					if (DEBUG) System.out.println(WARNING_FORMAT_COMMENTS);
188
//					if (DEBUG) System.out.println(WARNING_FORMAT_COMMENTS);
189
					PRINTED_FORMAT_COMMENTS_WARNING = true;
189
//					PRINTED_FORMAT_COMMENTS_WARNING = true;
190
				}
190
//				}
191
			case K_MULTI_LINE_COMMENT :
191
			case K_MULTI_LINE_COMMENT :
192
			case K_SINGLE_LINE_COMMENT :
192
			case K_SINGLE_LINE_COMMENT :
193
				if (ENABLE_NEW_COMMENTS_FORMAT) {
193
				if (ENABLE_NEW_COMMENTS_FORMAT) {
194
	                return formatComment(kind & K_MASK, source, indentationLevel, lineSeparator, new IRegion[] {new Region(offset, length)});
194
	                return formatComment(kind & K_MASK, source, indentationLevel, lineSeparator, new IRegion[] {new Region(offset, length)});
195
				}
195
				}
196
				if (FORCE_NEW_COMMENTS_FORMAT) {
196
//				if (FORCE_NEW_COMMENTS_FORMAT) {
197
					// Skip the javadoc formatting using this constant
197
//					// Skip the javadoc formatting using this constant
198
					return null;
198
//					return null;
199
				}
199
//				}
200
				this.codeSnippetParsingUtil = new CodeSnippetParsingUtil();
200
				this.codeSnippetParsingUtil = new CodeSnippetParsingUtil();
201
				return formatComment(kind, source, indentationLevel, lineSeparator, new IRegion[] {new Region(offset, length)}, false);
201
				return formatComment(kind, source, indentationLevel, lineSeparator, new IRegion[] {new Region(offset, length)}, false);
202
		}
202
		}
Lines 217-230 Link Here
217
			case K_CLASS_BODY_DECLARATIONS :
217
			case K_CLASS_BODY_DECLARATIONS :
218
				return formatClassBodyDeclarations(source, indentationLevel, lineSeparator, regions);
218
				return formatClassBodyDeclarations(source, indentationLevel, lineSeparator, regions);
219
			case K_COMPILATION_UNIT :
219
			case K_COMPILATION_UNIT :
220
				boolean includeComments =  (kind & F_INCLUDE_COMMENTS) != 0 || FORCE_NEW_COMMENTS_FORMAT;
220
				boolean includeComments =  (kind & F_INCLUDE_COMMENTS) != 0; // || FORCE_NEW_COMMENTS_FORMAT;
221
				return formatCompilationUnit(source, indentationLevel, lineSeparator, regions, includeComments);
221
				return formatCompilationUnit(source, indentationLevel, lineSeparator, regions, includeComments);
222
			case K_EXPRESSION :
222
			case K_EXPRESSION :
223
				return formatExpression(source, indentationLevel, lineSeparator, regions);
223
				return formatExpression(source, indentationLevel, lineSeparator, regions);
224
			case K_STATEMENTS :
224
			case K_STATEMENTS :
225
				return formatStatements(source, indentationLevel, lineSeparator, regions);
225
				return formatStatements(source, indentationLevel, lineSeparator, regions);
226
			case K_UNKNOWN :
226
			case K_UNKNOWN :
227
				includeComments =  (kind & F_INCLUDE_COMMENTS) != 0 || FORCE_NEW_COMMENTS_FORMAT;
227
				includeComments =  (kind & F_INCLUDE_COMMENTS) != 0; // || FORCE_NEW_COMMENTS_FORMAT;
228
				return probeFormatting(source, indentationLevel, lineSeparator, regions, includeComments);
228
				return probeFormatting(source, indentationLevel, lineSeparator, regions, includeComments);
229
			case K_JAVA_DOC :
229
			case K_JAVA_DOC :
230
			case K_MULTI_LINE_COMMENT :
230
			case K_MULTI_LINE_COMMENT :
Lines 538-551 Link Here
538
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=227043
538
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=227043
539
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102780
539
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=102780
540
				// use the integrated comment formatter to format comment
540
				// use the integrated comment formatter to format comment
541
				if (ENABLE_NEW_COMMENTS_FORMAT || FORCE_NEW_COMMENTS_FORMAT) {
541
				if (ENABLE_NEW_COMMENTS_FORMAT /*|| FORCE_NEW_COMMENTS_FORMAT*/) {
542
					return formatComment(kind, source, indentationLevel, lineSeparator, regions);
542
					return formatComment(kind, source, indentationLevel, lineSeparator, regions);
543
				}
543
				}
544
				// In all other cases, use the old way to format javadoc comments
544
//				// In all other cases, use the old way to format javadoc comments
545
				if (!PRINTED_FORMAT_COMMENTS_WARNING) {
545
//				if (!PRINTED_FORMAT_COMMENTS_WARNING) {
546
					if (DEBUG) System.out.println(WARNING_FORMAT_COMMENTS);
546
//					if (DEBUG) System.out.println(WARNING_FORMAT_COMMENTS);
547
					PRINTED_FORMAT_COMMENTS_WARNING = true;
547
//					PRINTED_FORMAT_COMMENTS_WARNING = true;
548
				}
548
//				}
549
				return formatComment(kind, source, indentationLevel, lineSeparator, regions, includeComments);
549
				return formatComment(kind, source, indentationLevel, lineSeparator, regions, includeComments);
550
			}
550
			}
551
		} catch (InvalidInputException e) {
551
		} catch (InvalidInputException e) {
(-)compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java (-15 / +21 lines)
Lines 334-339 Link Here
334
		return null;
334
		return null;
335
	}
335
	}
336
336
337
	protected char[] getTagName(int previousPosition, int currentPosition) {
338
	    if (currentPosition != this.scanner.startPosition) {
339
			this.tagSourceStart = previousPosition;
340
			this.tagSourceEnd = currentPosition;
341
			if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidTag(this.tagSourceStart, this.tagSourceEnd);
342
			return null;
343
		}
344
		if (this.index >= this.scanner.eofPosition) {
345
			this.tagSourceStart = previousPosition;
346
			this.tagSourceEnd = this.tokenPreviousPosition;
347
			if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidTag(this.tagSourceStart, this.tagSourceEnd);
348
			return null;
349
		}
350
		this.tagSourceStart = this.scanner.getCurrentTokenStartPosition();
351
		this.tagSourceEnd = this.scanner.getCurrentTokenEndPosition();
352
		char[] tagName = this.scanner.getCurrentIdentifierSource();
353
	    return tagName;
354
    }
355
337
	/*
356
	/*
338
	 * Parse @throws tag declaration and flag missing description if corresponding option is enabled
357
	 * Parse @throws tag declaration and flag missing description if corresponding option is enabled
339
	 */
358
	 */
Lines 411-431 Link Here
411
		// Read tag name
430
		// Read tag name
412
		int currentPosition = this.index;
431
		int currentPosition = this.index;
413
		int token = readTokenAndConsume();
432
		int token = readTokenAndConsume();
414
		if (currentPosition != this.scanner.startPosition) {
433
		char[] tagName = getTagName(previousPosition, currentPosition);
415
			this.tagSourceStart = previousPosition;
434
		if (tagName == null) return false;
416
			this.tagSourceEnd = currentPosition;
417
			if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidTag(this.tagSourceStart, this.tagSourceEnd);
418
			return false;
419
		}
420
		if (this.index >= this.scanner.eofPosition) {
421
			this.tagSourceStart = previousPosition;
422
			this.tagSourceEnd = this.tokenPreviousPosition;
423
			if (this.reportProblems) this.sourceParser.problemReporter().javadocInvalidTag(this.tagSourceStart, this.tagSourceEnd);
424
			return false;
425
		}
426
		this.tagSourceStart = this.scanner.getCurrentTokenStartPosition();
427
		this.tagSourceEnd = this.scanner.getCurrentTokenEndPosition();
428
		char[] tagName = this.scanner.getCurrentIdentifierSource();
429
	
435
	
430
		// Try to get tag name other than java identifier
436
		// Try to get tag name other than java identifier
431
		// (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=51660)
437
		// (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=51660)
(-)compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java (-1 / +1 lines)
Lines 287-293 Link Here
287
								if (this.lineStarted && this.textStart != -1 && this.textStart < textEndPosition) {
287
								if (this.lineStarted && this.textStart != -1 && this.textStart < textEndPosition) {
288
									pushText(this.textStart, textEndPosition);
288
									pushText(this.textStart, textEndPosition);
289
								}
289
								}
290
								refreshInlineTagPosition(textEndPosition);
290
								refreshInlineTagPosition(previousPosition);
291
							}
291
							}
292
							if (!isFormatterParser) this.textStart = this.index;
292
							if (!isFormatterParser) this.textStart = this.index;
293
							this.inlineTagStarted = false;
293
							this.inlineTagStarted = false;
(-)src/org/eclipse/jdt/core/tests/formatter/comment/JavaDocTestCase.java (-14 / +51 lines)
Lines 19-24 Link Here
19
import org.eclipse.jdt.core.formatter.CodeFormatter;
19
import org.eclipse.jdt.core.formatter.CodeFormatter;
20
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
20
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
21
21
22
import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter;
22
import org.eclipse.jdt.internal.formatter.comment.JavaDocLine;
23
import org.eclipse.jdt.internal.formatter.comment.JavaDocLine;
23
import org.eclipse.jdt.internal.formatter.comment.MultiCommentLine;
24
import org.eclipse.jdt.internal.formatter.comment.MultiCommentLine;
24
import org.eclipse.text.edits.TextEdit;
25
import org.eclipse.text.edits.TextEdit;
Lines 557-574 Link Here
557
	}
558
	}
558
	
559
	
559
	/**
560
	/**
560
	 * [formatting] Javadoc Formatter mishandles spaces in comments
561
     * [formatting] Javadoc Formatter mishandles spaces in comments
561
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49686
562
     * https://bugs.eclipse.org/bugs/show_bug.cgi?id=49686
562
	 */
563
     */
563
	public void testMultilineInlineTag2() {
564
    public void testMultilineInlineTag2() {
564
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "20"); //$NON-NLS-1$
565
    	setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "20"); //$NON-NLS-1$
565
		final String prefix= PREFIX + DELIMITER + INFIX + "{@link Objecterr}s";
566
    	final String prefix= PREFIX + DELIMITER + INFIX + "{@link Objecterr}";
566
		final String postfix= "are cool." + DELIMITER + POSTFIX;
567
    	final String postfix= "s are cool." + DELIMITER + POSTFIX;
567
		String input= prefix + " " + postfix;  //$NON-NLS-1$
568
    	String input= prefix + postfix;  //$NON-NLS-1$
568
		String expected= prefix + DELIMITER + INFIX + postfix;
569
    	String expected= prefix + DELIMITER + INFIX + postfix;
569
		String result= testFormat(input);
570
    	String result= testFormat(input);
570
		assertEquals(expected, result);
571
    	assertEquals(expected, result);
571
	}
572
    }
572
	
573
	
573
	/**
574
	/**
574
	 * [formatting] Javadoc Formatter mishandles spaces in comments
575
	 * [formatting] Javadoc Formatter mishandles spaces in comments
Lines 697-702 Link Here
697
		
698
		
698
		String expected = "/**" + DELIMITER +
699
		String expected = "/**" + DELIMITER +
699
				" * <pre>" + DELIMITER + 
700
				" * <pre>" + DELIMITER + 
701
				(DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT ? " * " +  DELIMITER : "") +
700
				" * </pre>" + DELIMITER + 
702
				" * </pre>" + DELIMITER + 
701
				" * " +  DELIMITER +
703
				" * " +  DELIMITER +
702
				" * " + DELIMITER + 
704
				" * " + DELIMITER + 
Lines 874-881 Link Here
874
				" * </code>" + DELIMITER + 
876
				" * </code>" + DELIMITER + 
875
				" */";
877
				" */";
876
		
878
		
877
		String expected =
879
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
878
				"/**" + DELIMITER + 
880
			? input // do not change as <code> is an immutable tag
881
			:	"/**" + DELIMITER + 
879
				" * <code>" + DELIMITER + 
882
				" * <code>" + DELIMITER + 
880
				" * <pre>" + DELIMITER + 
883
				" * <pre>" + DELIMITER + 
881
				" * setLeadingComment(&quot;/* traditional comment &#42;/&quot;); // correct" + DELIMITER + 
884
				" * setLeadingComment(&quot;/* traditional comment &#42;/&quot;); // correct" + DELIMITER + 
Lines 936-941 Link Here
936
		assertEquals(expected, result);
939
		assertEquals(expected, result);
937
	}
940
	}
938
941
942
	public void test109636_4() {
943
		if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) {
944
			Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
945
946
			String input =
947
					"/**" + DELIMITER + 
948
					" * <pre>" + DELIMITER + 
949
					" * setLeadingComment(\"/&#42; traditional comment &#42;/\");  // correct" + DELIMITER + 
950
					" * setLeadingComment(\"missing comment delimiters\");  // wrong" + DELIMITER + 
951
					" * setLeadingComment(\"/&#42; unterminated traditional comment \");  // wrong" + DELIMITER + 
952
					" * setLeadingComment(\"/&#42; broken\\n traditional comment &#42;/\");  // correct" + DELIMITER + 
953
					" * setLeadingComment(\"// end-of-line comment\\n\");  // correct" + DELIMITER + 
954
					" * setLeadingComment(\"// end-of-line comment without line terminator\");  // correct" + DELIMITER + 
955
					" * setLeadingComment(\"// broken\\n end-of-line comment\\n\");  // wrong" + DELIMITER + 
956
					" * </pre>" + DELIMITER + 
957
					" */";
958
		
959
			String expected =
960
					"/**" + DELIMITER + 
961
					" * <pre>" + DELIMITER + 
962
					" * setLeadingComment(&quot;/* traditional comment &#42;/&quot;); // correct" + DELIMITER + 
963
					" * setLeadingComment(&quot;missing comment delimiters&quot;); // wrong" + DELIMITER + 
964
					" * setLeadingComment(&quot;/* unterminated traditional comment &quot;); // wrong" + DELIMITER + 
965
					" * setLeadingComment(&quot;/* broken\\n traditional comment &#42;/&quot;); // correct" + DELIMITER + 
966
					" * setLeadingComment(&quot;// end-of-line comment\\n&quot;); // correct" + DELIMITER + 
967
					" * setLeadingComment(&quot;// end-of-line comment without line terminator&quot;); // correct" + DELIMITER + 
968
					" * setLeadingComment(&quot;// broken\\n end-of-line comment\\n&quot;); // wrong" + DELIMITER + 
969
					" * </pre>" + DELIMITER + 
970
					" */";
971
			String result=testFormat(input, options);
972
			assertEquals(expected, result);
973
		}
974
	}
975
939
	/**
976
	/**
940
	 * @bug 228652: [formatter] New line inserted while formatting a region of a compilation unit.
977
	 * @bug 228652: [formatter] New line inserted while formatting a region of a compilation unit.
941
	 * @test Insure that no new line is inserted before the formatted region
978
	 * @test Insure that no new line is inserted before the formatted region
(-)src/org/eclipse/jdt/core/tests/formatter/comment/MultiLineTestCase.java (-1 / +6 lines)
Lines 17-22 Link Here
17
17
18
import junit.framework.Test;
18
import junit.framework.Test;
19
19
20
import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter;
20
import org.eclipse.jdt.internal.formatter.comment.MultiCommentLine;
21
import org.eclipse.jdt.internal.formatter.comment.MultiCommentLine;
21
22
22
public class MultiLineTestCase extends CommentTestCase {
23
public class MultiLineTestCase extends CommentTestCase {
Lines 115-121 Link Here
115
				" * Member comment\n" +//$NON-NLS-1$ 
116
				" * Member comment\n" +//$NON-NLS-1$ 
116
				" */";//$NON-NLS-1$
117
				" */";//$NON-NLS-1$
117
		String result= testFormat(input, 0, input.length(), CodeFormatter.K_MULTI_LINE_COMMENT , 2);
118
		String result= testFormat(input, 0, input.length(), CodeFormatter.K_MULTI_LINE_COMMENT , 2);
118
		String expectedOutput = "/***********************************************************************\n" + 
119
		String expectedOutput = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
120
			?	"/**\n" + 
121
				" * Member comment\n" + 
122
				" */"
123
			:	"/***********************************************************************\n" + 
119
				"	 * Member comment\n" + 
124
				"	 * Member comment\n" + 
120
				"	 */";
125
				"	 */";
121
		assertEquals("Different output", expectedOutput, result);
126
		assertEquals("Different output", expectedOutput, result);
(-)src/org/eclipse/jdt/core/tests/formatter/comment/CommentsTestSuite.java (-8 / +2 lines)
Lines 22-37 Link Here
22
	public static Test suite() {
22
	public static Test suite() {
23
		return new CommentsTestSuite();
23
		return new CommentsTestSuite();
24
	}
24
	}
25
	
25
26
	// TODO (frederic) Fix the failures on SingleLineTestCase when new formatter is enabled...
27
	public CommentsTestSuite() {
26
	public CommentsTestSuite() {
28
		addTest(MultiLineTestCase.suite());
27
		addTest(MultiLineTestCase.suite());
29
		String newFormatter = System.getProperty("org.eclipse.jdt.core.formatter.comments.new");
28
		addTest(SingleLineTestCase.suite());
30
		if (newFormatter == null) {
31
			addTest(SingleLineTestCase.suite());
32
		} else {
33
			System.out.println("SingleLineTestCase temporarily disabled as new formatter is enabled!");
34
		}
35
		addTest(JavaDocTestCase.suite());
29
		addTest(JavaDocTestCase.suite());
36
	}
30
	}
37
}
31
}
(-)src/org/eclipse/jdt/core/tests/formatter/comment/SingleLineTestCase.java (-22 / +82 lines)
Lines 16-21 Link Here
16
import org.eclipse.jdt.core.formatter.CodeFormatter;
16
import org.eclipse.jdt.core.formatter.CodeFormatter;
17
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
17
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
18
18
19
import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter;
19
import org.eclipse.jdt.internal.formatter.comment.SingleCommentLine;
20
import org.eclipse.jdt.internal.formatter.comment.SingleCommentLine;
20
21
21
public class SingleLineTestCase extends CommentTestCase {
22
public class SingleLineTestCase extends CommentTestCase {
Lines 41-69 Link Here
41
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$
42
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$
42
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, DefaultCodeFormatterConstants.FALSE);
43
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, DefaultCodeFormatterConstants.FALSE);
43
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE);
44
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE);
44
		assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\ttest" + DELIMITER + "//" + DELIMITER + "//\t\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
45
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
46
			? PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + "//"+ DELIMITER + PREFIX + "test"
47
			: PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER;
48
		assertEquals(expected, testFormat("//test\ttest" + DELIMITER + "//" + DELIMITER + "//\t\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
45
	}
49
	}
46
50
47
	public void testClearBlankLines2() {
51
	public void testClearBlankLines2() {
48
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$
52
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$
49
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, DefaultCodeFormatterConstants.FALSE);
53
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, DefaultCodeFormatterConstants.FALSE);
50
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE);
54
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE);
51
		assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\t\ttest" + DELIMITER + PREFIX + DELIMITER + "//\t\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
55
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
56
			? PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + "//"+ DELIMITER + PREFIX + "test"
57
			: PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER;
58
		assertEquals(expected, testFormat("//test\t\ttest" + DELIMITER + PREFIX + DELIMITER + "//\t\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
52
	}
59
	}
53
60
54
	public void testClearBlankLines3() {
61
	public void testClearBlankLines3() {
55
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$
62
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$
56
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, DefaultCodeFormatterConstants.FALSE);
63
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, DefaultCodeFormatterConstants.FALSE);
57
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE);
64
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, DefaultCodeFormatterConstants.FALSE);
58
		assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\ttest" + DELIMITER + "//" + DELIMITER + PREFIX + "test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
65
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
66
			? PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + "//"+ DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test"
67
			: PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER;
68
		assertEquals(expected, testFormat("//test\ttest" + DELIMITER + "//" + DELIMITER + PREFIX + "test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
59
	}
69
	}
60
70
61
	public void testCommentBegin1() {
71
	public void testCommentBegin1() {
62
		assertEquals(PREFIX + "test" + DELIMITER, testFormat("//test")); //$NON-NLS-1$ //$NON-NLS-2$
72
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
73
			? PREFIX + "test"
74
			: PREFIX + "test" + DELIMITER;
75
		assertEquals(expected, testFormat("//test")); //$NON-NLS-1$ //$NON-NLS-2$
63
	}
76
	}
64
77
65
	public void testCommentBegin2() {
78
	public void testCommentBegin2() {
66
		assertEquals(PREFIX + "test" + DELIMITER, testFormat(PREFIX + "test")); //$NON-NLS-1$ //$NON-NLS-2$
79
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
80
			? PREFIX + "test"
81
			: PREFIX + "test" + DELIMITER;
82
		assertEquals(expected, testFormat(PREFIX + "test")); //$NON-NLS-1$ //$NON-NLS-2$
67
	}
83
	}
68
84
69
	public void testCommentBegin3() {
85
	public void testCommentBegin3() {
Lines 71-81 Link Here
71
	}
87
	}
72
88
73
	public void testCommentDelimiter1() {
89
	public void testCommentDelimiter1() {
74
		assertEquals(PREFIX + "test" + DELIMITER, testFormat("//\t\ttest " + DELIMITER + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$
90
		String expected = PREFIX + "test" + DELIMITER;
91
		if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected += DELIMITER;
92
		assertEquals(expected, testFormat("//\t\ttest " + DELIMITER + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$
75
	}
93
	}
76
94
77
	public void testCommentDelimiter2() {
95
	public void testCommentDelimiter2() {
78
		assertEquals(PREFIX + "test" + DELIMITER, testFormat(PREFIX + "test " + DELIMITER + DELIMITER + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$
96
		String expected = PREFIX + "test" + DELIMITER;
97
		if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected += DELIMITER ;
98
		assertEquals(expected, testFormat(PREFIX + "test " + DELIMITER + DELIMITER + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$
79
	}
99
	}
80
100
81
	public void testCommentNls1() {
101
	public void testCommentNls1() {
Lines 103-132 Link Here
103
	}
123
	}
104
124
105
	public void testCommentSpace1() {
125
	public void testCommentSpace1() {
106
		assertEquals(PREFIX + "test test" + DELIMITER, testFormat("//test\t \t test")); //$NON-NLS-1$ //$NON-NLS-2$
126
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
127
			? PREFIX + "test test"
128
			: PREFIX + "test test" + DELIMITER;
129
		assertEquals(expected, testFormat("//test\t \t test")); //$NON-NLS-1$ //$NON-NLS-2$
107
	}
130
	}
108
131
109
	public void testCommentSpace2() {
132
	public void testCommentSpace2() {
110
		assertEquals(PREFIX + "test test" + DELIMITER, testFormat("//test test")); //$NON-NLS-1$ //$NON-NLS-2$
133
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
134
			? PREFIX + "test test"
135
			: PREFIX + "test test" + DELIMITER;
136
		assertEquals(expected, testFormat("//test test")); //$NON-NLS-1$ //$NON-NLS-2$
111
	}
137
	}
112
138
113
	public void testCommentSpace3() {
139
	public void testCommentSpace3() {
114
		assertEquals(PREFIX + "test test" + DELIMITER, testFormat(PREFIX + "test \t    \t test")); //$NON-NLS-1$ //$NON-NLS-2$
140
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
141
			? PREFIX + "test test"
142
			: PREFIX + "test test" + DELIMITER;
143
		assertEquals(expected, testFormat(PREFIX + "test \t    \t test")); //$NON-NLS-1$ //$NON-NLS-2$
115
	}
144
	}
116
145
117
	public void testCommentWrapping1() {
146
	public void testCommentWrapping1() {
118
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$
147
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$
119
		assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
148
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
149
			? PREFIX + "test" + DELIMITER + PREFIX + "test"
150
			: PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER;
151
		assertEquals(expected, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
120
	}
152
	}
121
153
122
	public void testCommentWrapping2() {
154
	public void testCommentWrapping2() {
123
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "1"); //$NON-NLS-1$
155
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "1"); //$NON-NLS-1$
124
		assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
156
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
157
			? PREFIX + "test" + DELIMITER + PREFIX + "test"
158
			: PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER;
159
		assertEquals(expected, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
125
	}
160
	}
126
161
127
	public void testCommentWrapping3() {
162
	public void testCommentWrapping3() {
128
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "32"); //$NON-NLS-1$
163
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "32"); //$NON-NLS-1$
129
		assertEquals(PREFIX + "test test" + DELIMITER, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
164
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
165
			? PREFIX + "test test"
166
			: PREFIX + "test test" + DELIMITER;
167
		assertEquals(expected, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
130
	}
168
	}
131
169
132
	public void testCommentWrapping4() {
170
	public void testCommentWrapping4() {
Lines 148-185 Link Here
148
	public void testHeaderComment1() {
186
	public void testHeaderComment1() {
149
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, DefaultCodeFormatterConstants.FALSE);
187
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, DefaultCodeFormatterConstants.FALSE);
150
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "12"); //$NON-NLS-1$
188
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "12"); //$NON-NLS-1$
151
		assertEquals(PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER, testFormat("//test\t\t\t\ttest" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
189
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
190
			? PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test"
191
			: PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER;
192
		assertEquals(expected, testFormat("//test\t\t\t\ttest" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
152
	}
193
	}
153
194
154
	public void testHeaderComment2() {
195
	public void testHeaderComment2() {
155
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, DefaultCodeFormatterConstants.FALSE);
196
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, DefaultCodeFormatterConstants.FALSE);
156
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "24"); //$NON-NLS-1$
197
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "24"); //$NON-NLS-1$
157
		assertEquals(PREFIX + "test test test test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\t\t\t" + DELIMITER + PREFIX + "test test test test" + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
198
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
199
			? "// test" + DELIMITER + PREFIX + "test test test test" + DELIMITER
200
			: PREFIX + "test test test test" + DELIMITER + PREFIX + "test" + DELIMITER;
201
		assertEquals(expected, testFormat("//test\t\t\t" + DELIMITER + PREFIX + "test test test test" + DELIMITER)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
158
	}
202
	}
159
203
160
	public void testIllegalLineLength1() {
204
	public void testIllegalLineLength1() {
161
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "1"); //$NON-NLS-1$
205
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "1"); //$NON-NLS-1$
162
		assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
206
		String expected =PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER;
207
		if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected = expected.substring(0, expected.length()-DELIMITER.length());
208
		assertEquals(expected, testFormat("//test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
163
	}
209
	}
164
210
165
	public void testIllegalLineLength2() {
211
	public void testIllegalLineLength2() {
166
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "-16"); //$NON-NLS-1$
212
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "-16"); //$NON-NLS-1$
167
		assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat(PREFIX + "\t\t test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
213
		String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER;
214
		if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected = expected.substring(0, expected.length()-DELIMITER.length());
215
		assertEquals(expected, testFormat(PREFIX + "\t\t test\ttest")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
168
	}
216
	}
169
217
170
	public void testMultipleComments1() {
218
	public void testMultipleComments1() {
171
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$
219
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "5"); //$NON-NLS-1$
172
		assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test test" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
220
		String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER;
221
		if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected = expected.substring(0, expected.length()-DELIMITER.length());
222
		assertEquals(expected, testFormat("//test test" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
173
	}
223
	}
174
224
175
	public void testMultipleComments2() {
225
	public void testMultipleComments2() {
176
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "12"); //$NON-NLS-1$
226
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "12"); //$NON-NLS-1$
177
		assertEquals(PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//test test\ttest" + DELIMITER + PREFIX + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
227
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT
228
			? "// test test" + DELIMITER +
229
				"// test" + DELIMITER +
230
				"//" + DELIMITER +
231
				"// test test" + DELIMITER +
232
				"// test test"
233
			: PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test test" + DELIMITER + PREFIX + "test" + DELIMITER;
234
		assertEquals(expected, testFormat("//test test\ttest" + DELIMITER + PREFIX + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
178
	}
235
	}
179
236
180
	public void testMultipleComments3() {
237
	public void testMultipleComments3() {
181
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "11"); //$NON-NLS-1$
238
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "11"); //$NON-NLS-1$
182
		assertEquals(PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER, testFormat("//   test\t\t\ttest\ttest" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
239
		String expected = PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER + PREFIX + "test" + DELIMITER;
240
		if (DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT) expected = expected.substring(0, expected.length()-DELIMITER.length());
241
		assertEquals(expected, testFormat("//   test\t\t\ttest\ttest" + DELIMITER + PREFIX + "test test test test")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
183
	}
242
	}
184
	
243
	
185
	public void testIndentedComment1() {
244
	public void testIndentedComment1() {
Lines 208-220 Link Here
208
	
267
	
209
	public void testNoChange1() {
268
	public void testNoChange1() {
210
		String content= PREFIX;
269
		String content= PREFIX;
211
		assertEquals(content, testFormat(content));
270
		String expected = DefaultCodeFormatter.ENABLE_NEW_COMMENTS_FORMAT ? "//" : content;
271
		assertEquals(expected, testFormat(content));
212
	}
272
	}
213
	
273
	
214
	public void testNoFormat1() {
274
	public void testNoFormat1() {
215
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, DefaultCodeFormatterConstants.FALSE);
275
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, DefaultCodeFormatterConstants.FALSE);
216
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "1");
276
		setUserOption(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "1");
217
		String content= PREFIX + "test test";
277
		String content = PREFIX + "test test";
218
		assertEquals(content, testFormat(content));
278
		assertEquals(content, testFormat(content));
219
	}
279
	}
220
	public void _test109581() {
280
	public void _test109581() {
(-)workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X19.java (-12 / +12 lines)
Lines 17-34 Link Here
17
	 * source string. It includes entries for comments of all kinds (line,
17
	 * source string. It includes entries for comments of all kinds (line,
18
	 * block, and doc), arranged in order of increasing source position.
18
	 * block, and doc), arranged in order of increasing source position.
19
	 * </p>
19
	 * </p>
20
	 * Note on comment parenting: The {@link ASTNode#getParent() getParent()}
20
	 * Note on comment parenting: The {@link ASTNode#getParent() getParent()} of
21
	 * of a doc comment associated with a body declaration is the body
21
	 * a doc comment associated with a body declaration is the body declaration
22
	 * declaration node; for these comment nodes {@link ASTNode#getRoot()
22
	 * node; for these comment nodes {@link ASTNode#getRoot() getRoot()} will
23
	 * getRoot()} will return the compilation unit (assuming an unmodified AST)
23
	 * return the compilation unit (assuming an unmodified AST) reflecting the
24
	 * reflecting the fact that these nodes are property located in the AST for
24
	 * fact that these nodes are property located in the AST for the compilation
25
	 * the compilation unit. However, for other comment nodes, {@link
25
	 * unit. However, for other comment nodes, {@link ASTNode#getParent()
26
	 * ASTNode#getParent() getParent()} will return <code>null</code>, and
26
	 * getParent()} will return <code>null</code>, and {@link ASTNode#getRoot()
27
	 * {@link ASTNode#getRoot() getRoot()} will return the comment node itself,
27
	 * getRoot()} will return the comment node itself, indicating that these
28
	 * indicating that these comment nodes are not directly connected to the AST
28
	 * comment nodes are not directly connected to the AST for the compilation
29
	 * for the compilation unit. The {@link Comment#getAlternateRoot
29
	 * unit. The {@link Comment#getAlternateRoot Comment.getAlternateRoot}
30
	 * Comment.getAlternateRoot} method provides a way to navigate from a
30
	 * method provides a way to navigate from a comment to its compilation unit.
31
	 * comment to its compilation unit. </p>
31
	 * </p>
32
	 * <p>
32
	 * <p>
33
	 * A note on visitors: The only comment nodes that will be visited when
33
	 * A note on visitors: The only comment nodes that will be visited when
34
	 * visiting a compilation unit are the doc comments parented by body
34
	 * visiting a compilation unit are the doc comments parented by body
(-)workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X18.java (-4 / +4 lines)
Lines 43-52 Link Here
43
	 * </p>
43
	 * </p>
44
	 * <p>
44
	 * <p>
45
	 * Lexical or syntax errors detected while parsing can result in a result
45
	 * Lexical or syntax errors detected while parsing can result in a result
46
	 * node being marked as {@link ASTNode#MALFORMED MALFORMED} . In more
46
	 * node being marked as {@link ASTNode#MALFORMED MALFORMED} . In more severe
47
	 * severe failure cases where the parser is unable to recognize the input,
47
	 * failure cases where the parser is unable to recognize the input, this
48
	 * this method returns a {@link CompilationUnit CompilationUnit} node with
48
	 * method returns a {@link CompilationUnit CompilationUnit} node with at
49
	 * at least the compiler messages.
49
	 * least the compiler messages.
50
	 * </p>
50
	 * </p>
51
	 * <p>
51
	 * <p>
52
	 * Each node in the subtree (other than the contrived nodes) carries source
52
	 * Each node in the subtree (other than the contrived nodes) carries source
(-)workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X18.java (-4 / +4 lines)
Lines 43-52 Link Here
43
	 * </p>
43
	 * </p>
44
	 * <p>
44
	 * <p>
45
	 * Lexical or syntax errors detected while parsing can result in a result
45
	 * Lexical or syntax errors detected while parsing can result in a result
46
	 * node being marked as {@link ASTNode#MALFORMED MALFORMED} . In more
46
	 * node being marked as {@link ASTNode#MALFORMED MALFORMED} . In more severe
47
	 * severe failure cases where the parser is unable to recognize the input,
47
	 * failure cases where the parser is unable to recognize the input, this
48
	 * this method returns a {@link CompilationUnit CompilationUnit} node with
48
	 * method returns a {@link CompilationUnit CompilationUnit} node with at
49
	 * at least the compiler messages.
49
	 * least the compiler messages.
50
	 * </p>
50
	 * </p>
51
	 * <p>
51
	 * <p>
52
	 * Each node in the subtree (other than the contrived nodes) carries source
52
	 * Each node in the subtree (other than the contrived nodes) carries source
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsMassiveTests.java (-17 / +6 lines)
Lines 124-139 Link Here
124
 * <ul>
124
 * <ul>
125
 * 	<li>3.0 performance workspace (9951 units):<ul>
125
 * 	<li>3.0 performance workspace (9951 units):<ul>
126
 * 		<li>0 error</li>
126
 * 		<li>0 error</li>
127
 * 		<li>27 failures</li>
127
 * 		<li>17 failures</li>
128
 * 		<li>8 failures due to old formatter</li>
128
 * 		<li>8 failures due to old formatter</li>
129
 * 		<li>863 files have different lines leading spaces</li>
129
 * 		<li>722 files have different lines leading spaces</li>
130
 * 		<li>15 files have different spaces</li>
130
 * 		<li>10 files have different spaces</li>
131
 *		</ul></li>
131
 *		</ul></li>
132
 *		<li>ganymede workspace (25819 units):<ul>
132
 *		<li>ganymede workspace (25819 units):<ul>
133
 * 		<li>0 error</li>
133
 * 		<li>0 error</li>
134
 * 		<li>81 files has still different output while reformatting!</li>
134
 * 		<li>64 files has still different output while reformatting!</li>
135
 * 		<li>1606 files have different line leading spaces when reformatting!</li>
135
 * 		<li>1366 files have different line leading spaces when reformatting!</li>
136
 * 		<li>91 files have different spaces when reformatting!</li>
136
 * 		<li>11 files have different spaces when reformatting!</li>
137
 *		</ul></li>
137
 *		</ul></li>
138
 * </ul>
138
 * </ul>
139
 */
139
 */
Lines 388-404 Link Here
388
				commentEnd = -commentEnd;
388
				commentEnd = -commentEnd;
389
				if (commentStart < 0) { // line comments have negative start position
389
				if (commentStart < 0) { // line comments have negative start position
390
					commentStart = -commentStart;
390
					commentStart = -commentStart;
391
					String comment = formattedComments[i];
392
					if (comment.trim().length() > 2) { // non empty comment
393
						char ch = source.charAt(commentEnd);
394
						if (ch == '\r' || ch == '\n') {
395
							commentEnd++;
396
							ch = source.charAt(commentEnd);
397
							if (ch == '\r' || ch == '\n') {
398
								commentEnd++;
399
							}
400
						}
401
					}
402
				}
391
				}
403
			}
392
			}
404
			document.replace(commentStart, commentEnd - commentStart, formattedComments[i]);
393
			document.replace(commentStart, commentEnd - commentStart, formattedComments[i]);
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java (+13 lines)
Lines 665-670 Link Here
665
public void testTagOthers02() throws JavaModelException {
665
public void testTagOthers02() throws JavaModelException {
666
	formatUnit("tags.others", "X02.java");
666
	formatUnit("tags.others", "X02.java");
667
}
667
}
668
public void testTagOthers03() throws JavaModelException {
669
	formatUnit("tags.others", "X03.java");
670
}
668
671
669
/*
672
/*
670
 * Test formatter @param
673
 * Test formatter @param
Lines 755-760 Link Here
755
public void testLineComments05() throws JavaModelException {
758
public void testLineComments05() throws JavaModelException {
756
	formatUnit("comments.line", "X05.java");
759
	formatUnit("comments.line", "X05.java");
757
}
760
}
761
public void testLineComments06() throws JavaModelException {
762
	formatUnit("comments.line", "X06.java");
763
}
758
764
759
/*
765
/*
760
 * Test formatter block lines
766
 * Test formatter block lines
Lines 916-922 Link Here
916
public void testWkspEclipse20() throws JavaModelException {
922
public void testWkspEclipse20() throws JavaModelException {
917
	formatUnit("wksp.eclipse", "X20.java");
923
	formatUnit("wksp.eclipse", "X20.java");
918
}
924
}
925
public void testWkspEclipse21() throws JavaModelException {
926
	formatUnit("wksp.eclipse", "X20.java");
927
}
919
// Ganymede
928
// Ganymede
929
// TODO pass this test
930
public void _testWkspGanymede01() throws JavaModelException {
931
	formatUnit("wksp.ganymede", "X02.java");
932
}
920
public void testWkspGanymede02() throws JavaModelException {
933
public void testWkspGanymede02() throws JavaModelException {
921
	formatUnit("wksp.ganymede", "X02.java");
934
	formatUnit("wksp.ganymede", "X02.java");
922
}
935
}
(-)workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X19.java (-12 / +12 lines)
Lines 17-34 Link Here
17
	 * source string. It includes entries for comments of all kinds (line,
17
	 * source string. It includes entries for comments of all kinds (line,
18
	 * block, and doc), arranged in order of increasing source position.
18
	 * block, and doc), arranged in order of increasing source position.
19
	 * </p>
19
	 * </p>
20
	 * Note on comment parenting: The {@link ASTNode#getParent() getParent()}
20
	 * Note on comment parenting: The {@link ASTNode#getParent() getParent()} of
21
	 * of a doc comment associated with a body declaration is the body
21
	 * a doc comment associated with a body declaration is the body declaration
22
	 * declaration node; for these comment nodes {@link ASTNode#getRoot()
22
	 * node; for these comment nodes {@link ASTNode#getRoot() getRoot()} will
23
	 * getRoot()} will return the compilation unit (assuming an unmodified AST)
23
	 * return the compilation unit (assuming an unmodified AST) reflecting the
24
	 * reflecting the fact that these nodes are property located in the AST for
24
	 * fact that these nodes are property located in the AST for the compilation
25
	 * the compilation unit. However, for other comment nodes, {@link
25
	 * unit. However, for other comment nodes, {@link ASTNode#getParent()
26
	 * ASTNode#getParent() getParent()} will return <code>null</code>, and
26
	 * getParent()} will return <code>null</code>, and {@link ASTNode#getRoot()
27
	 * {@link ASTNode#getRoot() getRoot()} will return the comment node itself,
27
	 * getRoot()} will return the comment node itself, indicating that these
28
	 * indicating that these comment nodes are not directly connected to the AST
28
	 * comment nodes are not directly connected to the AST for the compilation
29
	 * for the compilation unit. The {@link Comment#getAlternateRoot
29
	 * unit. The {@link Comment#getAlternateRoot Comment.getAlternateRoot}
30
	 * Comment.getAlternateRoot} method provides a way to navigate from a
30
	 * method provides a way to navigate from a comment to its compilation unit.
31
	 * comment to its compilation unit. </p>
31
	 * </p>
32
	 * <p>
32
	 * <p>
33
	 * A note on visitors: The only comment nodes that will be visited when
33
	 * A note on visitors: The only comment nodes that will be visited when
34
	 * visiting a compilation unit are the doc comments parented by body
34
	 * visiting a compilation unit are the doc comments parented by body
(-)workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X18.java (-4 / +4 lines)
Lines 43-52 Link Here
43
	 * </p>
43
	 * </p>
44
	 * <p>
44
	 * <p>
45
	 * Lexical or syntax errors detected while parsing can result in a result
45
	 * Lexical or syntax errors detected while parsing can result in a result
46
	 * node being marked as {@link ASTNode#MALFORMED MALFORMED} . In more
46
	 * node being marked as {@link ASTNode#MALFORMED MALFORMED} . In more severe
47
	 * severe failure cases where the parser is unable to recognize the input,
47
	 * failure cases where the parser is unable to recognize the input, this
48
	 * this method returns a {@link CompilationUnit CompilationUnit} node with
48
	 * method returns a {@link CompilationUnit CompilationUnit} node with at
49
	 * at least the compiler messages.
49
	 * least the compiler messages.
50
	 * </p>
50
	 * </p>
51
	 * <p>
51
	 * <p>
52
	 * Each node in the subtree (other than the contrived nodes) carries source
52
	 * Each node in the subtree (other than the contrived nodes) carries source
(-)workspace/Formatter/test553/A_in.java (-1 / +1 lines)
Line 1 Link Here
1
// This is a really long single line comment that should be wrapped on two lines once it is formatted
1
// This is a really long single line comment that should be wrapped on two lines once it is formatted
(-)workspace/FormatterJavadoc/test/tags/others/out/default/X03.java (+10 lines)
Added Link Here
1
package test.tags.others;
2
3
public interface X03 {
4
5
	/**
6
	 * A complex type can have one root compositor. @ return root complex type
7
	 * compositor
8
	 */
9
	int foo();
10
}
(-)workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_tags/X21.java (+65 lines)
Added Link Here
1
package test.wksp.eclipse;
2
3
public class X21 {
4
5
	/**
6
	 * Returns a search pattern based on a given string pattern. The string
7
	 * patterns support '*' wild-cards. The remaining parameters are used to
8
	 * narrow down the type of expected results. <br>
9
	 * Examples:
10
	 * <ul>
11
	 * <li>search for case insensitive references to <code>Object</code>:
12
	 * <code>createSearchPattern("Object", TYPE, REFERENCES, false);</code></li>
13
	 * <li>search for case sensitive references to exact <code>Object()</code>
14
	 * constructor:
15
	 * <code>createSearchPattern("java.lang.Object()", CONSTRUCTOR, REFERENCES, true);</code>
16
	 * </li>
17
	 * <li>search for implementers of <code>java.lang.Runnable</code>:
18
	 * <code>createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true);</code>
19
	 * </li>
20
	 * </ul>
21
	 * 
22
	 * @param stringPattern
23
	 * the given pattern
24
	 * @param searchFor
25
	 * determines the nature of the searched elements
26
	 * <ul>
27
	 * <li> <code>IJavaSearchConstants.CLASS</code> : only look for classes</li>
28
	 * <li> <code>IJavaSearchConstants.INTERFACE</code> : only look for
29
	 * interfaces</li>
30
	 * <li> <code>IJavaSearchConstants.TYPE</code> : look for both classes and
31
	 * interfaces</li>
32
	 * <li> <code>IJavaSearchConstants.FIELD</code> : look for fields</li>
33
	 * <li> <code>IJavaSearchConstants.METHOD</code> : look for methods</li>
34
	 * <li> <code>IJavaSearchConstants.CONSTRUCTOR</code> : look for
35
	 * constructors</li>
36
	 * <li> <code>IJavaSearchConstants.PACKAGE</code> : look for packages</li>
37
	 * </ul>
38
	 * @param limitTo
39
	 * determines the nature of the expected matches
40
	 * <ul>
41
	 * <li> <code>IJavaSearchConstants.DECLARATIONS</code> : will search
42
	 * declarations matching with the corresponding element. In case the element
43
	 * is a method, declarations of matching methods in subtypes will also be
44
	 * found, allowing to find declarations of abstract methods, etc.</li>
45
	 * 
46
	 * <li> <code>IJavaSearchConstants.REFERENCES</code> : will search
47
	 * references to the given element.</li>
48
	 * 
49
	 * <li> <code>IJavaSearchConstants.ALL_OCCURRENCES</code> : will search for
50
	 * either declarations or references as specified above.</li>
51
	 * 
52
	 * <li> <code>IJavaSearchConstants.IMPLEMENTORS</code> : for interface, will
53
	 * find all types which implements a given interface.</li>
54
	 * </ul>
55
	 * 
56
	 * @param isCaseSensitive
57
	 * indicates whether the search is case sensitive or not.
58
	 * @return a search pattern on the given string pattern, or
59
	 * <code>null</code> if the string pattern is ill-formed.
60
	 * @deprecated Use {@link SearchPattern#createPattern(String, int, int, int)
61
	 * } instead.
62
	 */
63
	void createSearchPattern() {
64
	}
65
}
(-)workspace/FormatterJavadoc/test/tags/others/X03.java (+10 lines)
Added Link Here
1
package test.tags.others;
2
3
public interface X03 {
4
5
/**
6
 * A complex type can have one root compositor.
7
 @ return root complex type compositor
8
 */
9
int foo();
10
}
(-)workspace/FormatterJavadoc/test/comments/line/X06.java (+15 lines)
Added Link Here
1
package test.comments.line;
2
3
public class X06 {
4
5
	String foo() {
6
//		// Move cursor on to the left if the proposal ends with '}'
7
		String str;
8
		// XXX: currently there's no smartness: position the cursor after the proposal
9
//		if (relativeOffset > 0 && proposal.charAt(relativeOffset - 1) == '}')
10
//			relativeOffset--;
11
		
12
		str = toString();
13
		return str;
14
	}
15
}
(-)workspace/FormatterJavadoc/test/wksp/eclipse/X21.java (+50 lines)
Added Link Here
1
package test.wksp.eclipse;
2
3
public class X21 {
4
5
	/**
6
	 * Returns a search pattern based on a given string pattern. The string patterns support '*' wild-cards.
7
	 * The remaining parameters are used to narrow down the type of expected results.
8
	 *
9
	 * <br>
10
	 *	Examples:
11
	 *	<ul>
12
	 * 		<li>search for case insensitive references to <code>Object</code>:
13
	 *			<code>createSearchPattern("Object", TYPE, REFERENCES, false);</code></li>
14
	 *  	<li>search for case sensitive references to exact <code>Object()</code> constructor:
15
	 *			<code>createSearchPattern("java.lang.Object()", CONSTRUCTOR, REFERENCES, true);</code></li>
16
	 *  	<li>search for implementers of <code>java.lang.Runnable</code>:
17
	 *			<code>createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true);</code></li>
18
	 *  </ul>
19
	 * @param stringPattern the given pattern
20
	 * @param searchFor determines the nature of the searched elements
21
	 *	<ul>
22
	 * 	<li><code>IJavaSearchConstants.CLASS</code>: only look for classes</li>
23
	 *		<li><code>IJavaSearchConstants.INTERFACE</code>: only look for interfaces</li>
24
	 * 	<li><code>IJavaSearchConstants.TYPE</code>: look for both classes and interfaces</li>
25
	 *		<li><code>IJavaSearchConstants.FIELD</code>: look for fields</li>
26
	 *		<li><code>IJavaSearchConstants.METHOD</code>: look for methods</li>
27
	 *		<li><code>IJavaSearchConstants.CONSTRUCTOR</code>: look for constructors</li>
28
	 *		<li><code>IJavaSearchConstants.PACKAGE</code>: look for packages</li>
29
	 *	</ul>
30
	 * @param limitTo determines the nature of the expected matches
31
	 *	<ul>
32
	 * 		<li><code>IJavaSearchConstants.DECLARATIONS</code>: will search declarations matching with the corresponding
33
	 * 			element. In case the element is a method, declarations of matching methods in subtypes will also
34
	 *  		be found, allowing to find declarations of abstract methods, etc.</li>
35
	 *
36
	 *		 <li><code>IJavaSearchConstants.REFERENCES</code>: will search references to the given element.</li>
37
	 *
38
	 *		 <li><code>IJavaSearchConstants.ALL_OCCURRENCES</code>: will search for either declarations or references as specified
39
	 *  		above.</li>
40
	 *
41
	 *		 <li><code>IJavaSearchConstants.IMPLEMENTORS</code>: for interface, will find all types which implements a given interface.</li>
42
	 *	</ul>
43
	 *
44
	 * @param isCaseSensitive indicates whether the search is case sensitive or not.
45
	 * @return a search pattern on the given string pattern, or <code>null</code> if the string pattern is ill-formed.
46
	 * @deprecated Use {@link SearchPattern#createPattern(String, int, int, int)} instead.
47
	 */
48
	void createSearchPattern() {
49
	}
50
}
(-)workspace/FormatterJavadoc/test/wksp/eclipse/out/default/X21.java (+69 lines)
Added Link Here
1
package test.wksp.eclipse;
2
3
public class X21 {
4
5
	/**
6
	 * Returns a search pattern based on a given string pattern. The string
7
	 * patterns support '*' wild-cards. The remaining parameters are used to
8
	 * narrow down the type of expected results. <br>
9
	 * Examples:
10
	 * <ul>
11
	 * <li>search for case insensitive references to <code>Object</code>:
12
	 * <code>createSearchPattern("Object", TYPE, REFERENCES, false);</code></li>
13
	 * <li>search for case sensitive references to exact <code>Object()</code>
14
	 * constructor:
15
	 * <code>createSearchPattern("java.lang.Object()", CONSTRUCTOR, REFERENCES, true);</code>
16
	 * </li>
17
	 * <li>search for implementers of <code>java.lang.Runnable</code>:
18
	 * <code>createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true);</code>
19
	 * </li>
20
	 * </ul>
21
	 * 
22
	 * @param stringPattern
23
	 * 		the given pattern
24
	 * @param searchFor
25
	 * 		determines the nature of the searched elements
26
	 * 		<ul>
27
	 * 		<li> <code>IJavaSearchConstants.CLASS</code> : only look for classes
28
	 * 		</li>
29
	 * 		<li> <code>IJavaSearchConstants.INTERFACE</code> : only look for
30
	 * 		interfaces</li>
31
	 * 		<li> <code>IJavaSearchConstants.TYPE</code> : look for both classes
32
	 * 		and interfaces</li>
33
	 * 		<li> <code>IJavaSearchConstants.FIELD</code> : look for fields</li>
34
	 * 		<li> <code>IJavaSearchConstants.METHOD</code> : look for methods
35
	 * 		</li>
36
	 * 		<li> <code>IJavaSearchConstants.CONSTRUCTOR</code> : look for
37
	 * 		constructors</li>
38
	 * 		<li> <code>IJavaSearchConstants.PACKAGE</code> : look for packages
39
	 * 		</li>
40
	 * 		</ul>
41
	 * @param limitTo
42
	 * 		determines the nature of the expected matches
43
	 * 		<ul>
44
	 * 		<li> <code>IJavaSearchConstants.DECLARATIONS</code> : will search
45
	 * 		declarations matching with the corresponding element. In case the
46
	 * 		element is a method, declarations of matching methods in subtypes
47
	 * 		will also be found, allowing to find declarations of abstract
48
	 * 		methods, etc.</li>
49
	 * 
50
	 * 		<li> <code>IJavaSearchConstants.REFERENCES</code> : will search
51
	 * 		references to the given element.</li>
52
	 * 
53
	 * 		<li> <code>IJavaSearchConstants.ALL_OCCURRENCES</code> : will search
54
	 * 		for either declarations or references as specified above.</li>
55
	 * 
56
	 * 		<li> <code>IJavaSearchConstants.IMPLEMENTORS</code> : for interface,
57
	 * 		will find all types which implements a given interface.</li>
58
	 * 		</ul>
59
	 * 
60
	 * @param isCaseSensitive
61
	 * 		indicates whether the search is case sensitive or not.
62
	 * @return a search pattern on the given string pattern, or
63
	 * 	<code>null</code> if the string pattern is ill-formed.
64
	 * @deprecated Use {@link SearchPattern#createPattern(String, int, int, int)
65
	 * 	} instead.
66
	 */
67
	void createSearchPattern() {
68
	}
69
}
(-)workspace/FormatterJavadoc/test/comments/line/out/default/X06.java (+16 lines)
Added Link Here
1
package test.comments.line;
2
3
public class X06 {
4
5
	String foo() {
6
		// // Move cursor on to the left if the proposal ends with '}'
7
		String str;
8
		// XXX: currently there's no smartness: position the cursor after the
9
		// proposal
10
		// if (relativeOffset > 0 && proposal.charAt(relativeOffset - 1) == '}')
11
		// relativeOffset--;
12
13
		str = toString();
14
		return str;
15
	}
16
}
(-)workspace/FormatterJavadoc/test/wksp/eclipse/out/dont_indent_descr/X21.java (+67 lines)
Added Link Here
1
package test.wksp.eclipse;
2
3
public class X21 {
4
5
	/**
6
	 * Returns a search pattern based on a given string pattern. The string
7
	 * patterns support '*' wild-cards. The remaining parameters are used to
8
	 * narrow down the type of expected results. <br>
9
	 * Examples:
10
	 * <ul>
11
	 * <li>search for case insensitive references to <code>Object</code>:
12
	 * <code>createSearchPattern("Object", TYPE, REFERENCES, false);</code></li>
13
	 * <li>search for case sensitive references to exact <code>Object()</code>
14
	 * constructor:
15
	 * <code>createSearchPattern("java.lang.Object()", CONSTRUCTOR, REFERENCES, true);</code>
16
	 * </li>
17
	 * <li>search for implementers of <code>java.lang.Runnable</code>:
18
	 * <code>createSearchPattern("java.lang.Runnable", TYPE, IMPLEMENTORS, true);</code>
19
	 * </li>
20
	 * </ul>
21
	 * 
22
	 * @param stringPattern
23
	 * 	the given pattern
24
	 * @param searchFor
25
	 * 	determines the nature of the searched elements
26
	 * 	<ul>
27
	 * 	<li> <code>IJavaSearchConstants.CLASS</code> : only look for classes
28
	 * 	</li>
29
	 * 	<li> <code>IJavaSearchConstants.INTERFACE</code> : only look for
30
	 * 	interfaces</li>
31
	 * 	<li> <code>IJavaSearchConstants.TYPE</code> : look for both classes and
32
	 * 	interfaces</li>
33
	 * 	<li> <code>IJavaSearchConstants.FIELD</code> : look for fields</li>
34
	 * 	<li> <code>IJavaSearchConstants.METHOD</code> : look for methods</li>
35
	 * 	<li> <code>IJavaSearchConstants.CONSTRUCTOR</code> : look for
36
	 * 	constructors</li>
37
	 * 	<li> <code>IJavaSearchConstants.PACKAGE</code> : look for packages</li>
38
	 * 	</ul>
39
	 * @param limitTo
40
	 * 	determines the nature of the expected matches
41
	 * 	<ul>
42
	 * 	<li> <code>IJavaSearchConstants.DECLARATIONS</code> : will search
43
	 * 	declarations matching with the corresponding element. In case the
44
	 * 	element is a method, declarations of matching methods in subtypes will
45
	 * 	also be found, allowing to find declarations of abstract methods, etc.
46
	 * 	</li>
47
	 * 
48
	 * 	<li> <code>IJavaSearchConstants.REFERENCES</code> : will search
49
	 * 	references to the given element.</li>
50
	 * 
51
	 * 	<li> <code>IJavaSearchConstants.ALL_OCCURRENCES</code> : will search for
52
	 * 	either declarations or references as specified above.</li>
53
	 * 
54
	 * 	<li> <code>IJavaSearchConstants.IMPLEMENTORS</code> : for interface,
55
	 * 	will find all types which implements a given interface.</li>
56
	 * 	</ul>
57
	 * 
58
	 * @param isCaseSensitive
59
	 * 	indicates whether the search is case sensitive or not.
60
	 * @return a search pattern on the given string pattern, or
61
	 * 	<code>null</code> if the string pattern is ill-formed.
62
	 * @deprecated Use {@link SearchPattern#createPattern(String, int, int, int)
63
	 * 	} instead.
64
	 */
65
	void createSearchPattern() {
66
	}
67
}

Return to bug 227043