Reduce importance of parser options
This commit is contained in:
@ -19,7 +19,7 @@ class EcmascriptHandler extends AbstractPmdLanguageVersionHandler {
|
||||
|
||||
@Override
|
||||
public Parser getParser(ParserOptions parserOptions) {
|
||||
return new EcmascriptParser(rhinoVersion, parserOptions.getSuppressMarker());
|
||||
return new EcmascriptParser(rhinoVersion);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import org.mozilla.javascript.ast.Comment;
|
||||
import org.mozilla.javascript.ast.ErrorCollector;
|
||||
import org.mozilla.javascript.ast.ParseProblem;
|
||||
|
||||
import net.sourceforge.pmd.internal.util.AssertionUtil;
|
||||
import net.sourceforge.pmd.lang.ast.AstInfo;
|
||||
import net.sourceforge.pmd.lang.ast.FileAnalysisException;
|
||||
import net.sourceforge.pmd.lang.ast.ParseException;
|
||||
@ -24,11 +23,9 @@ import net.sourceforge.pmd.lang.ast.RootNode;
|
||||
|
||||
public final class EcmascriptParser implements net.sourceforge.pmd.lang.ast.Parser {
|
||||
private final int esVersion;
|
||||
private final String suppressMarker;
|
||||
|
||||
public EcmascriptParser(int version, String suppressMarker) {
|
||||
public EcmascriptParser(int version) {
|
||||
this.esVersion = version;
|
||||
this.suppressMarker = AssertionUtil.requireParamNotNull("suppression marker", suppressMarker);
|
||||
}
|
||||
|
||||
private AstRoot parseEcmascript(final String sourceCode, final List<ParseProblem> parseProblems) throws ParseException {
|
||||
@ -61,6 +58,7 @@ public final class EcmascriptParser implements net.sourceforge.pmd.lang.ast.Pars
|
||||
final EcmascriptTreeBuilder treeBuilder = new EcmascriptTreeBuilder(sourceCode, parseProblems);
|
||||
final ASTAstRoot tree = (ASTAstRoot) treeBuilder.build(astRoot);
|
||||
|
||||
String suppressMarker = task.getCommentMarker();
|
||||
Map<Integer, String> suppressMap = new HashMap<>();
|
||||
if (astRoot.getComments() != null) {
|
||||
for (Comment comment : astRoot.getComments()) {
|
||||
|
@ -16,8 +16,8 @@ import org.mozilla.javascript.ast.AstRoot;
|
||||
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.Report;
|
||||
import net.sourceforge.pmd.lang.ParserOptions;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.ast.Parser.ParserTask;
|
||||
import net.sourceforge.pmd.lang.ecmascript.rule.AbstractEcmascriptRule;
|
||||
|
||||
public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
@ -150,9 +150,8 @@ public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
assertEquals(" I know what I'm doing", root.getAstInfo().getSuppressionComments().get(2));
|
||||
assertEquals(1, root.getAstInfo().getSuppressionComments().size());
|
||||
|
||||
ParserOptions parserOptions = new ParserOptions();
|
||||
parserOptions.setSuppressMarker("FOOOO");
|
||||
root = js.withParserOptions(parserOptions).parse("function(x) {\n" + "y = y; //NOPMD xyz\n" + "x = x; //FOOOO I know what I'm doing\n" + "}\n");
|
||||
root = js.withParserConfig(p -> p.setProperty(ParserTask.COMMENT_MARKER, "FOOOO"))
|
||||
.parse("function(x) {\n" + "y = y; //NOPMD xyz\n" + "x = x; //FOOOO I know what I'm doing\n" + "}\n");
|
||||
assertEquals(" I know what I'm doing", root.getAstInfo().getSuppressionComments().get(3));
|
||||
assertEquals(1, root.getAstInfo().getSuppressionComments().size());
|
||||
}
|
||||
|
Reference in New Issue
Block a user