Merge branch 'pr-2675'

[core] Deprecate parser options 
This commit is contained in:
Andreas Dangel
2020-08-02 16:53:24 +02:00
11 changed files with 65 additions and 12 deletions
docs/pages
pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex
pmd-core/src/main/java/net/sourceforge/pmd
pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript
pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml

@ -44,9 +44,16 @@ This is a {{ site.pmd.release_type }} release.
#### Deprecated API #### Deprecated API
##### For removal
* {% jdoc !!pmd-java::lang.java.ast.ASTThrowStatement#getFirstClassOrInterfaceTypeImage() %} * {% jdoc !!pmd-java::lang.java.ast.ASTThrowStatement#getFirstClassOrInterfaceTypeImage() %}
* {% jdoc !!core::Rule#getParserOptions() %}
* {% jdoc !!core::lang.Parser#getParserOptions() %}
* {% jdoc !!core::lang.AbstractParser %}
* {% jdoc apex::lang.apex.ApexParserOptions %}
* {% jdoc xml::lang.xml.XmlParserOptions %}
* {% jdoc xml::lang.xml.rule.XmlXpathRule %}
* Properties of {% jdoc xml::lang.xml.rule.AbstractXmlRule %}
* {% jdoc javascript::lang.ecmascript.EcmascriptParserOptions %}
* {% jdoc javascript::lang.ecmascript.rule.EcmascriptXPathRule %}
### External Contributions ### External Contributions

@ -6,6 +6,10 @@ package net.sourceforge.pmd.lang.apex;
import net.sourceforge.pmd.lang.ParserOptions; import net.sourceforge.pmd.lang.ParserOptions;
/**
* @deprecated Not useful
*/
@Deprecated
public class ApexParserOptions extends ParserOptions { public class ApexParserOptions extends ParserOptions {
// empty class for now, since we don't have extra options for Apex // empty class for now, since we don't have extra options for Apex

@ -255,7 +255,12 @@ public interface Rule extends PropertySource {
* should return a new instance on each call. * should return a new instance on each call.
* *
* @return the parser options * @return the parser options
*
* @deprecated This was never implemented and will never be. PMD
* cannot parse files once per rule. Let this method assume
* its default by not overriding it.
*/ */
@Deprecated
ParserOptions getParserOptions(); ParserOptions getParserOptions();
/** /**

@ -10,7 +10,10 @@ import java.io.Reader;
* This is a generic implementation of the Parser interface. * This is a generic implementation of the Parser interface.
* *
* @see Parser * @see Parser
*
* @deprecated This will become useless in PMD 7. Implement or use {@link Parser} directly
*/ */
@Deprecated
public abstract class AbstractParser implements Parser { public abstract class AbstractParser implements Parser {
protected final ParserOptions parserOptions; protected final ParserOptions parserOptions;

@ -16,9 +16,13 @@ import net.sourceforge.pmd.lang.ast.ParseException;
* @author Pieter_Van_Raemdonck - Application Engineers NV/SA - www.ae.be * @author Pieter_Van_Raemdonck - Application Engineers NV/SA - www.ae.be
*/ */
public interface Parser { public interface Parser {
/** /**
* Get the ParserOptions used by this Parser. * Get the ParserOptions used by this Parser.
*
* @deprecated Parser options should be a parameter to {@link #parse(String, Reader)}
*/ */
@Deprecated
ParserOptions getParserOptions(); ParserOptions getParserOptions();
/** /**

@ -229,6 +229,7 @@ public abstract class AbstractRule extends AbstractPropertySource implements Rul
* @see Rule#setPriority(RulePriority) * @see Rule#setPriority(RulePriority)
*/ */
@Override @Override
@Deprecated
public ParserOptions getParserOptions() { public ParserOptions getParserOptions() {
return new ParserOptions(); return new ParserOptions();
} }

@ -13,7 +13,10 @@ import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.properties.BooleanProperty; import net.sourceforge.pmd.properties.BooleanProperty;
import net.sourceforge.pmd.properties.EnumeratedProperty; import net.sourceforge.pmd.properties.EnumeratedProperty;
/**
* @deprecated Will be removed in 7.0 TODO refactor this into language versions?
*/
@Deprecated
public class EcmascriptParserOptions extends ParserOptions { public class EcmascriptParserOptions extends ParserOptions {
public enum Version { public enum Version {

@ -12,7 +12,10 @@ import net.sourceforge.pmd.lang.ecmascript.EcmascriptParserOptions.Version;
import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.lang.rule.XPathRule;
import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyDescriptor;
/**
* @deprecated Parser options are deprecated, use {@link XPathRule} directly
*/
@Deprecated
public class EcmascriptXPathRule extends XPathRule { public class EcmascriptXPathRule extends XPathRule {
private static final PropertyDescriptor<Boolean> RECORDING_COMMENTS_DESCRIPTOR = EcmascriptParserOptions.RECORDING_COMMENTS_DESCRIPTOR; private static final PropertyDescriptor<Boolean> RECORDING_COMMENTS_DESCRIPTOR = EcmascriptParserOptions.RECORDING_COMMENTS_DESCRIPTOR;

@ -16,31 +16,36 @@ import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.lang.ParserOptions; import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.properties.BooleanProperty; import net.sourceforge.pmd.properties.BooleanProperty;
/**
* @deprecated Parser options will be removed with 7.0, these options
* will assume their default values then.
*/
@Deprecated
public class XmlParserOptions extends ParserOptions { public class XmlParserOptions extends ParserOptions {
// Note: The UI order values are chosen to be larger than those built into // Note: The UI order values are chosen to be larger than those built into
// XPathRule. // XPathRule.
public static final BooleanProperty COALESCING_DESCRIPTOR = new BooleanProperty("coalescing", public static final BooleanProperty COALESCING_DESCRIPTOR = new BooleanProperty("coalescing",
"Specifies that the XML parser convert CDATA nodes to Text nodes and append it to the adjacent (if any) text node.", "deprecated!Specifies that the XML parser convert CDATA nodes to Text nodes and append it to the adjacent (if any) text node.",
Boolean.FALSE, 3.0f); Boolean.FALSE, 3.0f);
public static final BooleanProperty EXPAND_ENTITY_REFERENCES_DESCRIPTOR = new BooleanProperty( public static final BooleanProperty EXPAND_ENTITY_REFERENCES_DESCRIPTOR = new BooleanProperty(
"expandEntityReferences", "Specifies that the XML parser expand entity reference nodes.", Boolean.TRUE, "expandEntityReferences", "deprecated!Specifies that the XML parser expand entity reference nodes.", Boolean.TRUE,
4.0f); 4.0f);
public static final BooleanProperty IGNORING_COMMENTS_DESCRIPTOR = new BooleanProperty("ignoringComments", public static final BooleanProperty IGNORING_COMMENTS_DESCRIPTOR = new BooleanProperty("ignoringComments",
"Specifies that the XML parser ignore comments.", Boolean.FALSE, 5.0f); "deprecated!Specifies that the XML parser ignore comments.", Boolean.FALSE, 5.0f);
public static final BooleanProperty IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = new BooleanProperty( public static final BooleanProperty IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = new BooleanProperty(
"ignoringElementContentWhitespace", "ignoringElementContentWhitespace",
"Specifies that the XML parser eliminate whitespace in element content. Setting this to 'true' will force validating.", "deprecated!Specifies that the XML parser eliminate whitespace in element content. Setting this to 'true' will force validating.",
Boolean.FALSE, 6.0f); Boolean.FALSE, 6.0f);
public static final BooleanProperty NAMESPACE_AWARE_DESCRIPTOR = new BooleanProperty("namespaceAware", public static final BooleanProperty NAMESPACE_AWARE_DESCRIPTOR = new BooleanProperty("namespaceAware",
"Specifies that the XML parser will provide support for XML namespaces.", Boolean.TRUE, 7.0f); "deprecated!Specifies that the XML parser will provide support for XML namespaces.", Boolean.TRUE, 7.0f);
public static final BooleanProperty VALIDATING_DESCRIPTOR = new BooleanProperty("validating", public static final BooleanProperty VALIDATING_DESCRIPTOR = new BooleanProperty("validating",
"Specifies that the XML parser will validate documents as they are parsed. This only works for DTDs.", "deprecated!Specifies that the XML parser will validate documents as they are parsed. This only works for DTDs.",
Boolean.FALSE, 8.0f); Boolean.FALSE, 8.0f);
public static final BooleanProperty XINCLUDE_AWARE_DESCRIPTOR = new BooleanProperty("xincludeAware", public static final BooleanProperty XINCLUDE_AWARE_DESCRIPTOR = new BooleanProperty("xincludeAware",
"Specifies that the XML parser will process XInclude markup.", Boolean.FALSE, 9.0f); "deprecated!Specifies that the XML parser will process XInclude markup.", Boolean.FALSE, 9.0f);
public static final BooleanProperty LOOKUP_DESCRIPTOR_DTD = new BooleanProperty("xincludeAware", public static final BooleanProperty LOOKUP_DESCRIPTOR_DTD = new BooleanProperty("xincludeAware",
"Specifies whether XML parser will attempt to lookup the DTD.", Boolean.FALSE, 10.0f); "deprecated!Specifies whether XML parser will attempt to lookup the DTD.", Boolean.FALSE, 10.0f);
public static final EntityResolver SILENT_ENTITY_RESOLVER = new EntityResolver() { public static final EntityResolver SILENT_ENTITY_RESOLVER = new EntityResolver() {
@Override @Override

@ -25,12 +25,19 @@ import net.sourceforge.pmd.properties.BooleanProperty;
*/ */
public class AbstractXmlRule extends AbstractRule implements ImmutableLanguage { public class AbstractXmlRule extends AbstractRule implements ImmutableLanguage {
@Deprecated
public static final BooleanProperty COALESCING_DESCRIPTOR = XmlParserOptions.COALESCING_DESCRIPTOR; public static final BooleanProperty COALESCING_DESCRIPTOR = XmlParserOptions.COALESCING_DESCRIPTOR;
@Deprecated
public static final BooleanProperty EXPAND_ENTITY_REFERENCES_DESCRIPTOR = XmlParserOptions.EXPAND_ENTITY_REFERENCES_DESCRIPTOR; public static final BooleanProperty EXPAND_ENTITY_REFERENCES_DESCRIPTOR = XmlParserOptions.EXPAND_ENTITY_REFERENCES_DESCRIPTOR;
@Deprecated
public static final BooleanProperty IGNORING_COMMENTS_DESCRIPTOR = XmlParserOptions.IGNORING_COMMENTS_DESCRIPTOR; public static final BooleanProperty IGNORING_COMMENTS_DESCRIPTOR = XmlParserOptions.IGNORING_COMMENTS_DESCRIPTOR;
@Deprecated
public static final BooleanProperty IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = XmlParserOptions.IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR; public static final BooleanProperty IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = XmlParserOptions.IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR;
@Deprecated
public static final BooleanProperty NAMESPACE_AWARE_DESCRIPTOR = XmlParserOptions.NAMESPACE_AWARE_DESCRIPTOR; public static final BooleanProperty NAMESPACE_AWARE_DESCRIPTOR = XmlParserOptions.NAMESPACE_AWARE_DESCRIPTOR;
@Deprecated
public static final BooleanProperty VALIDATING_DESCRIPTOR = XmlParserOptions.VALIDATING_DESCRIPTOR; public static final BooleanProperty VALIDATING_DESCRIPTOR = XmlParserOptions.VALIDATING_DESCRIPTOR;
@Deprecated
public static final BooleanProperty XINCLUDE_AWARE_DESCRIPTOR = XmlParserOptions.XINCLUDE_AWARE_DESCRIPTOR; public static final BooleanProperty XINCLUDE_AWARE_DESCRIPTOR = XmlParserOptions.XINCLUDE_AWARE_DESCRIPTOR;
public AbstractXmlRule() { public AbstractXmlRule() {

@ -11,14 +11,25 @@ import net.sourceforge.pmd.lang.xml.XmlLanguageModule;
import net.sourceforge.pmd.lang.xml.XmlParserOptions; import net.sourceforge.pmd.lang.xml.XmlParserOptions;
import net.sourceforge.pmd.properties.BooleanProperty; import net.sourceforge.pmd.properties.BooleanProperty;
/**
* @deprecated Parser options are deprecated, use {@link XPathRule} directly
*/
@Deprecated
public class XmlXPathRule extends XPathRule { public class XmlXPathRule extends XPathRule {
@Deprecated
public static final BooleanProperty COALESCING_DESCRIPTOR = XmlParserOptions.COALESCING_DESCRIPTOR; public static final BooleanProperty COALESCING_DESCRIPTOR = XmlParserOptions.COALESCING_DESCRIPTOR;
@Deprecated
public static final BooleanProperty EXPAND_ENTITY_REFERENCES_DESCRIPTOR = XmlParserOptions.EXPAND_ENTITY_REFERENCES_DESCRIPTOR; public static final BooleanProperty EXPAND_ENTITY_REFERENCES_DESCRIPTOR = XmlParserOptions.EXPAND_ENTITY_REFERENCES_DESCRIPTOR;
@Deprecated
public static final BooleanProperty IGNORING_COMMENTS_DESCRIPTOR = XmlParserOptions.IGNORING_COMMENTS_DESCRIPTOR; public static final BooleanProperty IGNORING_COMMENTS_DESCRIPTOR = XmlParserOptions.IGNORING_COMMENTS_DESCRIPTOR;
@Deprecated
public static final BooleanProperty IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = XmlParserOptions.IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR; public static final BooleanProperty IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR = XmlParserOptions.IGNORING_ELEMENT_CONTENT_WHITESPACE_DESCRIPTOR;
@Deprecated
public static final BooleanProperty NAMESPACE_AWARE_DESCRIPTOR = XmlParserOptions.NAMESPACE_AWARE_DESCRIPTOR; public static final BooleanProperty NAMESPACE_AWARE_DESCRIPTOR = XmlParserOptions.NAMESPACE_AWARE_DESCRIPTOR;
@Deprecated
public static final BooleanProperty VALIDATING_DESCRIPTOR = XmlParserOptions.VALIDATING_DESCRIPTOR; public static final BooleanProperty VALIDATING_DESCRIPTOR = XmlParserOptions.VALIDATING_DESCRIPTOR;
@Deprecated
public static final BooleanProperty XINCLUDE_AWARE_DESCRIPTOR = XmlParserOptions.XINCLUDE_AWARE_DESCRIPTOR; public static final BooleanProperty XINCLUDE_AWARE_DESCRIPTOR = XmlParserOptions.XINCLUDE_AWARE_DESCRIPTOR;
public XmlXPathRule() { public XmlXPathRule() {