Rename JavaTokenFactory
This commit is contained in:
@ -232,7 +232,7 @@ options {
|
||||
STATIC = false;
|
||||
USER_CHAR_STREAM = true;
|
||||
JDK_VERSION = "1.5";
|
||||
TOKEN_FACTORY = "JavaTokenUtils";
|
||||
TOKEN_FACTORY = "JavaTokenFactory";
|
||||
|
||||
MULTI = true;
|
||||
VISITOR = true;
|
||||
@ -2999,14 +2999,14 @@ void AssertStatement() :
|
||||
void RUNSIGNEDSHIFT() #void:
|
||||
{}
|
||||
{
|
||||
LOOKAHEAD({ JavaTokenUtils.getRealKind(getToken(1)) == RUNSIGNEDSHIFT})
|
||||
LOOKAHEAD({ JavaTokenFactory.getRealKind(getToken(1)) == RUNSIGNEDSHIFT})
|
||||
">" ">" ">"
|
||||
}
|
||||
|
||||
void RSIGNEDSHIFT() #void:
|
||||
{}
|
||||
{
|
||||
LOOKAHEAD({ JavaTokenUtils.getRealKind(getToken(1)) == RSIGNEDSHIFT})
|
||||
LOOKAHEAD({ JavaTokenFactory.getRealKind(getToken(1)) == RSIGNEDSHIFT})
|
||||
">" ">"
|
||||
}
|
||||
|
||||
|
@ -145,20 +145,20 @@
|
||||
|
||||
|
||||
<replace file="${target-package-dir}/JavaParserTokenManager.java">
|
||||
<replacetoken><![CDATA[t = JavaTokenUtils.newToken(jjmatchedKind, curTokenImage);
|
||||
<replacetoken><![CDATA[t = JavaTokenFactory.newToken(jjmatchedKind, curTokenImage);
|
||||
|
||||
t.beginLine = beginLine;
|
||||
t.endLine = endLine;
|
||||
t.beginColumn = beginColumn;
|
||||
t.endColumn = endColumn;]]></replacetoken>
|
||||
<replacevalue>
|
||||
<![CDATA[t = JavaTokenUtils.newToken(jjmatchedKind, curTokenImage, beginLine, endLine, beginColumn, endColumn);]]></replacevalue>
|
||||
<![CDATA[t = JavaTokenFactory.newToken(jjmatchedKind, curTokenImage, beginLine, endLine, beginColumn, endColumn);]]></replacevalue>
|
||||
</replace>
|
||||
|
||||
<replaceregexp file="${target-package-dir}/JavaParserTokenManager.java" flags="s">
|
||||
<regexp pattern="protected net.sourceforge.pmd.lang.ast.impl.JavaccToken jjFillToken.*?}" />
|
||||
<substitution
|
||||
expression="protected net.sourceforge.pmd.lang.ast.impl.JavaccToken jjFillToken() {return JavaTokenUtils.newToken(jjmatchedKind, input_stream);}"/>
|
||||
expression="protected net.sourceforge.pmd.lang.ast.impl.JavaccToken jjFillToken() {return JavaTokenFactory.newToken(jjmatchedKind, input_stream);}"/>
|
||||
</replaceregexp>
|
||||
|
||||
|
||||
|
@ -9,15 +9,18 @@ import net.sourceforge.pmd.lang.ast.impl.JavaCharStream;
|
||||
import net.sourceforge.pmd.lang.ast.impl.JavaccToken;
|
||||
import net.sourceforge.pmd.lang.ast.impl.TokenDocument;
|
||||
|
||||
final class JavaTokenUtils {
|
||||
final class JavaTokenFactory {
|
||||
|
||||
private JavaTokenUtils() {
|
||||
private JavaTokenFactory() {
|
||||
|
||||
}
|
||||
|
||||
static JavaccToken newToken(int kind, CharStream charStream) {
|
||||
JavaCharStream jcs = (JavaCharStream) charStream;
|
||||
|
||||
// Most tokens have an entry in there, it's used to share the
|
||||
// image string for keywords & punctuation. Those represent ~40%
|
||||
// of token instances
|
||||
String image = JavaParserTokenManager.jjstrLiteralImages[kind];
|
||||
|
||||
switch (kind) {
|
||||
@ -32,12 +35,12 @@ final class JavaTokenUtils {
|
||||
jcs.getEndOffset(),
|
||||
jcs.getTokenDocument()
|
||||
);
|
||||
case JavaParserConstants.WHITESPACE:
|
||||
// unlikely that anybody cares about that, and since
|
||||
// they're still 30% of all tokens best make this assumption
|
||||
|
||||
// btw 40% of all tokens have a compile-time string constant
|
||||
// as image (jjstrLiteralImages) so they're shared.
|
||||
case JavaParserConstants.WHITESPACE:
|
||||
// We don't create a new string for the image of whitespace tokens eagerly
|
||||
|
||||
// It's unlikely that anybody cares about that, and since
|
||||
// they're still 30% of all tokens this is advantageous
|
||||
return new LazyImageToken(
|
||||
kind,
|
||||
jcs.getStartOffset(),
|
Reference in New Issue
Block a user