[core] Remove deprecated members in Reportable

Reportable#getBeginLine
Reportable#getBeginColumn
Reportable#getEndLine
Reportable#getEndColumn
This commit is contained in:
Andreas Dangel 2024-02-08 09:56:55 +01:00
parent 50cbfe6834
commit 5c02b62623
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3
5 changed files with 16 additions and 67 deletions

View File

@ -236,6 +236,11 @@ The following previously deprecated rules have been finally removed:
* method `copyPropertyDescriptors()` has been removed. Use {%jdoc core::properties.AbstractPropertySource#getPropertyDescriptors() %} instead.
* method `copyPropertyValues()` has been removed. Use {%jdoc core::properties.AbstractPropertySource#getPropertiesByPropertyDescriptor() %}
or {%jdoc core::properties.AbstractPropertySource#getOverriddenPropertiesByPropertyDescriptor() %} instead.
* {%jdoc !!core::reporting.Reportable %} - the following methods have been removed. Use {%jdoc core::reporting.Reportable#getReportLocation() %} instead
* `getBeginLine()`
* `getBeginColumn()`
* `getEndLine()`
* `getEndColumn()`
* pmd-apex
* {%jdoc apex::lang.apex.ast.ApexNode %} and {% jdoc apex::lang.apex.ast.ASTApexFile %}
* `#getApexVersion()`: In PMD 6, this method has been deprecated but was defined in the class `ApexRootNode`.

View File

@ -203,11 +203,11 @@
<fileset dir="${target-package-dir}" />
</replaceregexp>
<replace token=".beginLine" value=".getBeginLine()">
<replace token=".beginLine" value=".getReportLocation().getStartLine()">
<fileset dir="${target-package-dir}" />
</replace>
<replace token=".beginColumn" value=".getBeginColumn()">
<replace token=".beginColumn" value=".getReportLocation().getStartColumn()">
<fileset dir="${target-package-dir}" />
</replace>

View File

@ -36,7 +36,7 @@ import net.sourceforge.pmd.util.DataMap.DataKey;
* like {@link #firstChild(Class)}, and {@link NodeStream}s.
* <li>The API used to describe nodes in a form understandable by XPath expressions:
* {@link #getXPathNodeName()}, {@link #getXPathAttributesIterator()}
* <li>Location metadata: eg {@link #getBeginLine()}, {@link #getBeginColumn()}
* <li>Location metadata: {@link #getReportLocation()}
* <li>An extensible metadata store: {@link #getUserMap()}
* </ul>
*
@ -48,8 +48,7 @@ import net.sourceforge.pmd.util.DataMap.DataKey;
* no JSP node should have a Java node as its child. Embedding nodes from
* different languages will not be done via these methods, and conforming
* implementations should ensure that every node returned by these methods
* are indeed of the same type. Possibly, a type parameter will be added to
* the Node interface in 7.0.0 to enforce it at compile-time.
* are indeed of the same type.
*/
public interface Node extends Reportable {
@ -127,25 +126,22 @@ public interface Node extends Reportable {
// Those are kept here because they're handled specially as XPath
// attributes, for now
// -> [core] Deprecate XPath attributes for node coordinates (eg @BeginLine) #3876 (https://github.com/pmd/pmd/issues/3876)
@Override
default int getBeginLine() {
return Reportable.super.getBeginLine();
return getReportLocation().getStartLine();
}
@Override
default int getBeginColumn() {
return Reportable.super.getBeginColumn();
return getReportLocation().getStartColumn();
}
@Override
default int getEndLine() {
return Reportable.super.getEndLine();
return getReportLocation().getEndLine();
}
@Override
default int getEndColumn() {
return Reportable.super.getEndColumn();
return getReportLocation().getEndColumn();
}

View File

@ -5,7 +5,6 @@
package net.sourceforge.pmd.reporting;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
import net.sourceforge.pmd.lang.ast.GenericToken;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.document.FileLocation;
@ -26,58 +25,7 @@ public interface Reportable {
/**
* Returns the location at which this element should be reported.
*
* <p>Use this instead of {@link #getBeginColumn()}/{@link #getBeginLine()}, etc.
* <p>Use this instead of {@link Node#getBeginColumn()}/{@link Node#getBeginLine()}, etc.
*/
FileLocation getReportLocation();
/**
* Gets the line where the token's region begins
*
* @deprecated Use {@link #getReportLocation()}
*/
@Deprecated
@DeprecatedUntil700
default int getBeginLine() {
return getReportLocation().getStartPos().getLine();
}
/**
* Gets the line where the token's region ends
*
* @deprecated Use {@link #getReportLocation()}
*/
@Deprecated
@DeprecatedUntil700
default int getEndLine() {
return getReportLocation().getEndPos().getLine();
}
/**
* Gets the column offset from the start of the begin line where the token's region begins
*
* @deprecated Use {@link #getReportLocation()}
*/
@Deprecated
@DeprecatedUntil700
default int getBeginColumn() {
return getReportLocation().getStartPos().getColumn();
}
/**
* Gets the column offset from the start of the end line where the token's region ends
*
* @deprecated Use {@link #getReportLocation()}
*/
@Deprecated
@DeprecatedUntil700
default int getEndColumn() {
return getReportLocation().getEndPos().getColumn();
}
}

View File

@ -668,7 +668,7 @@ SPECIAL_TOKEN :
{
int startOfNOPMD = matchedToken.getImage().indexOf(suppressMarker);
if (startOfNOPMD != -1) {
suppressMap.put(matchedToken.getBeginLine(), matchedToken.getImage().substring(startOfNOPMD + suppressMarker.length()));
suppressMap.put(matchedToken.getReportLocation().getStartLine(), matchedToken.getImage().substring(startOfNOPMD + suppressMarker.length()));
}
comments.add(new JavaComment(matchedToken));
}