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

Collapse All | Expand All

(-)formatter/org/eclipse/jdt/internal/formatter/comment/Java2HTMLEntityReader.java (+19 lines)
Lines 14-19 Link Here
14
import java.util.HashMap;
14
import java.util.HashMap;
15
import java.util.Map;
15
import java.util.Map;
16
16
17
import org.eclipse.jdt.internal.compiler.parser.*;
18
17
/**
19
/**
18
 * <code>SubstitutionTextReader</code> that will substitute html entities for
20
 * <code>SubstitutionTextReader</code> that will substitute html entities for
19
 * html symbols encountered in the original text. Line breaks and whitespaces
21
 * html symbols encountered in the original text. Line breaks and whitespaces
Lines 25-30 Link Here
25
27
26
	/** The hardcoded entity map. */
28
	/** The hardcoded entity map. */
27
	private static final Map fgEntityLookup;
29
	private static final Map fgEntityLookup;
30
31
	/**
32
	 * True if we have not yet seen a non-whitespace character on the current
33
	 * line.
34
	 */
35
	private boolean beginLine = true;
28
	
36
	
29
	static {
37
	static {
30
		fgEntityLookup= new HashMap(7);
38
		fgEntityLookup= new HashMap(7);
Lines 50-55 Link Here
50
	 * @see org.eclipse.jdt.internal.ui.text.SubstitutionTextReader#computeSubstitution(int)
58
	 * @see org.eclipse.jdt.internal.ui.text.SubstitutionTextReader#computeSubstitution(int)
51
	 */
59
	 */
52
	protected String computeSubstitution(int c) {
60
	protected String computeSubstitution(int c) {
61
		/*
62
		 * When @ is first on a line, translate it to &#064; so it isn't
63
		 * misinterpreted as a Javadoc tag.
64
		 * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=197169
65
		 */
66
		if (c == '@')
67
			return beginLine ? "&#064;" : null; //$NON-NLS-1$
68
		else if (c == '\n' || c == '\r')
69
			beginLine = true;
70
		else if (!ScannerHelper.isWhitespace((char) c))
71
			beginLine = false;
53
		String lookup= (String) fgEntityLookup.get(String.valueOf((char) c));
72
		String lookup= (String) fgEntityLookup.get(String.valueOf((char) c));
54
		return lookup;
73
		return lookup;
55
	}
74
	}

Return to bug 197169