### 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.4 diff -u -r1.4 Java2HTMLEntityReader.java --- formatter/org/eclipse/jdt/internal/formatter/comment/Java2HTMLEntityReader.java 30 Jul 2007 20:20:14 -0000 1.4 +++ formatter/org/eclipse/jdt/internal/formatter/comment/Java2HTMLEntityReader.java 31 Jul 2007 02:26:49 -0000 @@ -11,6 +11,7 @@ *******************************************************************************/ package org.eclipse.jdt.internal.formatter.comment; +import java.io.IOException; import java.io.Reader; import java.util.HashMap; import java.util.Map; @@ -26,6 +27,8 @@ */ public class Java2HTMLEntityReader extends SubstitutionTextReader { + private static final int BEGIN_LINE = 0x01; + /** The hardcoded entity map. */ private static final Map fgEntityLookup; @@ -33,8 +36,8 @@ * True if we have not yet seen a non-whitespace character on the current * line. */ - private boolean beginLine = true; - + private int bits = BEGIN_LINE; + static { fgEntityLookup= new HashMap(7); fgEntityLookup.put("<", "<"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -58,18 +61,30 @@ /* * @see org.eclipse.jdt.internal.ui.text.SubstitutionTextReader#computeSubstitution(int) */ - protected String computeSubstitution(int c) { + protected String computeSubstitution(int c) throws IOException { /* * 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 this.beginLine ? "@" : null; //$NON-NLS-1$ - else if (c == '\n' || c == '\r') - this.beginLine = true; - else if (!ScannerHelper.isWhitespace((char) c)) { - this.beginLine = false; + if (c == '@') { + return (this.bits & BEGIN_LINE) != 0 ? "@" : null; //$NON-NLS-1$ + } + if (c == '*') { + this.bits &= ~BEGIN_LINE; + int next = nextChar(); + if (next == '/') { + return "*/"; //$NON-NLS-1$ + } + if (next == -1) { + return "*"; //$NON-NLS-1$ + } + return "*" + (char) next; //$NON-NLS-1$ + } + if (c == '\n' || c == '\r') { + this.bits |= BEGIN_LINE; + } else if (!ScannerHelper.isWhitespace((char) c)) { + this.bits &= ~BEGIN_LINE; } return (String) fgEntityLookup.get(String.valueOf((char) c)); }