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

Collapse All | Expand All

(-)formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java (-2 / +5 lines)
Lines 355-360 Link Here
355
		this.scanner.resetTo(this.index, this.javadocEnd);
355
		this.scanner.resetTo(this.index, this.javadocEnd);
356
		return true;
356
		return true;
357
	}
357
	}
358
	this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value
358
	return false;
359
	return false;
359
}
360
}
360
361
Lines 381-386 Link Here
381
			}
382
			}
382
			this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
383
			this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
383
		}
384
		}
385
		this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value
384
	}
386
	}
385
	return valid;
387
	return valid;
386
}
388
}
Lines 393-398 Link Here
393
	if (!valid) {
395
	if (!valid) {
394
		this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
396
		this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
395
		this.index = this.tagSourceEnd+1;
397
		this.index = this.tagSourceEnd+1;
398
		this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value
396
	}
399
	}
397
	return valid;
400
	return valid;
398
}
401
}
Lines 504-510 Link Here
504
			if (length == TAG_LINK_LENGTH && CharOperation.equals(TAG_LINK, tagName)) {
507
			if (length == TAG_LINK_LENGTH && CharOperation.equals(TAG_LINK, tagName)) {
505
				this.tagValue = TAG_LINK_VALUE;
508
				this.tagValue = TAG_LINK_VALUE;
506
				if (this.inlineTagStarted || (this.kind & COMPLETION_PARSER) != 0) {
509
				if (this.inlineTagStarted || (this.kind & COMPLETION_PARSER) != 0) {
507
					valid= parseReference();
510
					valid = parseReference();
508
				} else {
511
				} else {
509
					// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=53290
512
					// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=53290
510
					// Cannot have @link outside inline comment
513
					// Cannot have @link outside inline comment
Lines 603-609 Link Here
603
	} else if (this.invalidTagName) {
606
	} else if (this.invalidTagName) {
604
		this.textStart = previousPosition;
607
		this.textStart = previousPosition;
605
	} else if (this.astPtr == ptr) {
608
	} else if (this.astPtr == ptr) {
606
		this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value
607
		createTag();
609
		createTag();
608
	}
610
	}
609
	return true;
611
	return true;
Lines 618-623 Link Here
618
		// If invalid, restart from the end tag position
620
		// If invalid, restart from the end tag position
619
		this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
621
		this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd);
620
		this.index = this.tagSourceEnd+1;
622
		this.index = this.tagSourceEnd+1;
623
		this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value
621
	}
624
	}
622
	return valid;
625
	return valid;
623
}
626
}
(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (+8 lines)
Lines 2548-2553 Link Here
2548
					} else {
2548
					} else {
2549
						printJavadocHtmlTag(text, block, newLines>0);
2549
						printJavadocHtmlTag(text, block, newLines>0);
2550
					}
2550
					}
2551
				} else if (block.isImmutable()){
2552
					// Indent if new line was added
2553
					if (newLines > 0 && this.commentIndentation != null) {
2554
				    	addInsertEdit(node.sourceStart, this.commentIndentation);
2555
				    	this.column += this.commentIndentation.length();
2556
					}
2557
					printJavadocHtmlImmutableTag(text, block, newLines > 0);
2558
					this.column += getTextLength(block, text);
2551
				} else {
2559
				} else {
2552
					printJavadocText(text, block, newLines>0);
2560
					printJavadocText(text, block, newLines>0);
2553
				}
2561
				}
(-)formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java (+15 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
			this.flags |= IMMUTABLE;
60
			break;
56
	}
61
	}
57
}
62
}
58
63
Lines 322-327 Link Here
322
	return (this.flags & PARAM_TAG) == PARAM_TAG;
327
	return (this.flags & PARAM_TAG) == PARAM_TAG;
323
}
328
}
324
329
330
/**
331
 * Returns whether the block is immutable or not.
332
 *
333
 * @return <code>true</code> if the block is immutable,
334
 * 	<code>false</code> otherwise.
335
 */
336
public boolean isImmutable() {
337
	return (this.flags & IMMUTABLE) == IMMUTABLE;
338
}
339
325
void setHeaderLine(int javadocLineStart) {
340
void setHeaderLine(int javadocLineStart) {
326
	if (javadocLineStart == this.lineStart) {
341
	if (javadocLineStart == this.lineStart) {
327
		this.flags |= ON_HEADER_LINE;
342
		this.flags |= ON_HEADER_LINE;
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java (+19 lines)
Lines 4396-4401 Link Here
4396
}
4396
}
4397
4397
4398
/**
4398
/**
4399
 * @bug 260381: [formatter] Javadoc formatter breaks {@code ...} tags.
4400
 * @test Ensure that the @code tag is similar to <code> HTML tag
4401
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260381"
4402
 */
4403
public void testBug260381() throws JavaModelException {
4404
	this.formatterPrefs.join_wrapped_lines = false;
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
4417
/**
4399
 * @bug 260798: [formatter] Strange behavior of never join lines
4418
 * @bug 260798: [formatter] Strange behavior of never join lines
4400
 * @test Ensure that the formatter indents lines correctly when never join lines pref is activated
4419
 * @test Ensure that the formatter indents lines correctly when never join lines pref is activated
4401
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260798"
4420
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260798"

Return to bug 260381