### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: formatter/org/eclipse/jdt/internal/formatter/comment/Java2HTMLEntityReader.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/comment/Java2HTMLEntityReader.java,v retrieving revision 1.3 diff -u -r1.3 Java2HTMLEntityReader.java --- formatter/org/eclipse/jdt/internal/formatter/comment/Java2HTMLEntityReader.java 10 May 2006 18:03:41 -0000 1.3 +++ formatter/org/eclipse/jdt/internal/formatter/comment/Java2HTMLEntityReader.java 27 Jul 2007 18:27:58 -0000 @@ -14,6 +14,8 @@ import java.util.HashMap; import java.util.Map; +import org.eclipse.jdt.internal.compiler.parser.*; + /** * SubstitutionTextReader that will substitute html entities for * html symbols encountered in the original text. Line breaks and whitespaces @@ -25,6 +27,12 @@ /** The hardcoded entity map. */ private static final Map fgEntityLookup; + + /** + * True if we have not yet seen a non-whitespace character on the current + * line. + */ + private boolean beginLine = true; static { fgEntityLookup= new HashMap(7); @@ -50,6 +58,17 @@ * @see org.eclipse.jdt.internal.ui.text.SubstitutionTextReader#computeSubstitution(int) */ protected String computeSubstitution(int c) { + /* + * When @ is first on a line, translate it to @ so it isn't + * misinterpreted as a Javadoc tag. + * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=197169 + */ + if (c == '@') + return beginLine ? "@" : null; //$NON-NLS-1$ + else if (c == '\n' || c == '\r') + beginLine = true; + else if (!ScannerHelper.isWhitespace((char) c)) + beginLine = false; String lookup= (String) fgEntityLookup.get(String.valueOf((char) c)); return lookup; }