diff --git a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfParser.java b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfParser.java index 4d91f1518d..5457a9b494 100644 --- a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfParser.java +++ b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfParser.java @@ -6,24 +6,19 @@ package net.sourceforge.pmd.lang.vf.ast; import java.io.Reader; -import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.lang.AbstractParser; -import net.sourceforge.pmd.lang.LanguageVersionHandler; +import org.checkerframework.checker.nullness.qual.Nullable; + import net.sourceforge.pmd.lang.ParserOptions; import net.sourceforge.pmd.lang.TokenManager; -import net.sourceforge.pmd.lang.ast.AbstractTokenManager; -import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.lang.ast.CharStream; import net.sourceforge.pmd.lang.ast.ParseException; -import net.sourceforge.pmd.lang.ast.impl.javacc.CharStreamFactory; +import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccTokenDocument; +import net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeParserAdapter; /** - * Adapter for the VfParser. - * - * @deprecated This is internal API, use {@link LanguageVersionHandler#getParser(ParserOptions)}. + * Parser for the VisualForce language. */ -@Deprecated -@InternalApi -public class VfParser extends AbstractParser { +public final class VfParser extends JjtreeParserAdapter { public VfParser(ParserOptions parserOptions) { super(parserOptions); @@ -35,9 +30,18 @@ public class VfParser extends AbstractParser { } @Override - public Node parse(String fileName, Reader source) throws ParseException { - AbstractTokenManager.setFileName(fileName); - return new VfParserImpl(CharStreamFactory.simpleCharStream(source)).CompilationUnit(); + protected JavaccTokenDocument newDocument(String fullText) { + return new JavaccTokenDocument(fullText) { + @Override + protected @Nullable String describeKindImpl(int kind) { + return VfTokenKinds.describe(kind); + } + }; + } + + @Override + protected ASTCompilationUnit parseImpl(CharStream cs, ParserOptions options) throws ParseException { + return new VfParserImpl(cs).CompilationUnit(); } }