Link Here
|
62 |
* @see org.eclipse.jdt.internal.ui.text.SubstitutionTextReader#computeSubstitution(int) |
62 |
* @see org.eclipse.jdt.internal.ui.text.SubstitutionTextReader#computeSubstitution(int) |
63 |
*/ |
63 |
*/ |
64 |
protected String computeSubstitution(int c) throws IOException { |
64 |
protected String computeSubstitution(int c) throws IOException { |
65 |
/* |
65 |
StringBuffer buf = new StringBuffer(); |
66 |
* When @ is first on a line, translate it to @ so it isn't |
66 |
// Accumulate *s into the buffer until we see something other than *. |
67 |
* misinterpreted as a Javadoc tag. |
67 |
while (c == '*') { |
68 |
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=197169 |
|
|
69 |
*/ |
70 |
if (c == '@') { |
71 |
return (this.bits & BEGIN_LINE) != 0 ? "@" : null; //$NON-NLS-1$ |
72 |
} |
73 |
if (c == '*') { |
74 |
this.bits &= ~BEGIN_LINE; |
68 |
this.bits &= ~BEGIN_LINE; |
75 |
int next = nextChar(); |
69 |
c = nextChar(); |
76 |
if (next == '/') { |
70 |
buf.append('*'); |
77 |
return "*/"; //$NON-NLS-1$ |
71 |
} |
78 |
} |
72 |
if (c == -1) |
79 |
if (next == -1) { |
73 |
// Snippet must have ended with *s. Just return them. |
80 |
return "*"; //$NON-NLS-1$ |
74 |
return buf.toString(); |
81 |
} |
75 |
if (c == '/' && buf.length() > 0) { |
82 |
return "*" + (char) next; //$NON-NLS-1$ |
76 |
/* |
|
|
77 |
* Translate a * that precedes a / to * so it isn't |
78 |
* misinterpreted as the end of the Javadoc comment that contains |
79 |
* the code we are formatting. |
80 |
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=109636 |
81 |
*/ |
82 |
buf.setLength(buf.length() - 1); |
83 |
buf.append("*/"); //$NON-NLS-1$ |
84 |
} else if (c == '@' && (this.bits & BEGIN_LINE) != 0) { |
85 |
/* |
86 |
* When @ is first on a line, translate it to @ so it isn't |
87 |
* misinterpreted as a Javadoc tag. |
88 |
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=197169 |
89 |
*/ |
90 |
buf.append("@"); //$NON-NLS-1$ |
91 |
} else { |
92 |
/* |
93 |
* Ordinary processing. If the character needs an entity in HTML, |
94 |
* add the entity, otherwise add the character. |
95 |
*/ |
96 |
String entity = (String) fgEntityLookup.get(String.valueOf((char) c)); |
97 |
if (entity != null) |
98 |
buf.append(entity); |
99 |
else |
100 |
buf.append((char) c); |
83 |
} |
101 |
} |
|
|
102 |
// Update bits for the benefit of the next character. |
84 |
if (c == '\n' || c == '\r') { |
103 |
if (c == '\n' || c == '\r') { |
85 |
this.bits |= BEGIN_LINE; |
104 |
this.bits |= BEGIN_LINE; |
86 |
} else if (!ScannerHelper.isWhitespace((char) c)) { |
105 |
} else if (!ScannerHelper.isWhitespace((char) c)) { |
87 |
this.bits &= ~BEGIN_LINE; |
106 |
this.bits &= ~BEGIN_LINE; |
88 |
} |
107 |
} |
89 |
return (String) fgEntityLookup.get(String.valueOf((char) c)); |
108 |
return buf.toString(); |
90 |
} |
109 |
} |
91 |
} |
110 |
} |