Merge pull request #4809 from adangel:issue-4348-internal-api

[core] Consolidate @InternalApi classes #4809
This commit is contained in:
Andreas Dangel 2024-02-22 17:03:03 +01:00
commit 609e364861
No known key found for this signature in database
GPG Key ID: 93450DF2DF9A3FA3
206 changed files with 1395 additions and 887 deletions

View File

@ -63,7 +63,7 @@ However, this also adds additional tasks, and it takes time to write down and do
## Change History
2022-09-30: Status changed to "Accepted".
2022-09-30: Status changed to "Accepted". ([#4072](https://github.com/pmd/pmd/pull/4072))
2022-09-06: Added section "Change History" to the template. Added "Last updated" to "Status" section.

View File

@ -66,6 +66,6 @@ Maintaining a polyglot code base with multiple languages is likely to be more ch
## Change History
2022-09-30: Changed status to "Accepted".
2022-09-30: Changed status to "Accepted". ([#4072](https://github.com/pmd/pmd/pull/4072))
2022-07-28: Proposed initial version.

View File

@ -5,8 +5,8 @@ permalink: pmd_projectdocs_decisions_adr_3.html
sidebaractiveurl: /pmd_projectdocs_decisions.html
adr: true
# Proposed / Accepted / Deprecated / Superseded
adr_status: "Proposed"
last_updated: December 2023
adr_status: "Accepted"
last_updated: February 2024
---
<!-- https://github.com/joelparkerhenderson/architecture-decision-record/blob/main/templates/decision-record-template-by-michael-nygard/index.md -->
@ -184,4 +184,6 @@ Non-concrete AST classes (like base classes or common interfaces) should follow
## Change History
2024-02-01: Changed status to "Accepted". ([#4756](https://github.com/pmd/pmd/pull/4756))
2023-12-01: Proposed initial version.

View File

@ -180,6 +180,7 @@ The rules have been moved into categories with PMD 6.
* [#4312](https://github.com/pmd/pmd/issues/4312): \[core] Remove unnecessary property `color` and system property `pmd.color` in `TextColorRenderer`
* [#4313](https://github.com/pmd/pmd/issues/4313): \[core] Remove support for &lt;lang&gt;-&lt;ruleset&gt; hyphen notation for ruleset references
* [#4314](https://github.com/pmd/pmd/issues/4314): \[core] Remove ruleset compatibility filter (RuleSetFactoryCompatibility) and CLI option `--no-ruleset-compatibility`
* [#4348](https://github.com/pmd/pmd/issues/4348): \[core] Consolidate @<!-- -->InternalApi classes
* [#4378](https://github.com/pmd/pmd/issues/4378): \[core] Ruleset loading processes commented rules
* [#4674](https://github.com/pmd/pmd/issues/4674): \[core] WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass
* [#4694](https://github.com/pmd/pmd/pull/4694): \[core] Fix line/col numbers in TokenMgrError
@ -267,20 +268,110 @@ in the migration guide for details.
* {%jdoc core::reporting.RuleContext %}
* {%jdoc core::reporting.RuleViolation %}
* {%jdoc core::reporting.ViolationSuppressor %}
* {%jdoc core::reporting.ParametricRuleViolation %} (moved from `net.sourcceforge.pmd.lang.rule`)
* {%jdoc core::lang.rule.xpath.XPathRule %} has been moved into subpackage {% jdoc_package core::lang.rule.xpath %}.
**Internalized classes**
**Internalized classes and interfaces and methods**
These were marked as `@InternalApi` previously.
The following classes/methods have been marked as @<!-- -->InternalApi before and are now moved into a `internal`
package or made (package) private and are _not accessible_ anymore.
* pmd-core
* `RuleFactory`: moved from `net.sourceforge.pmd.rules` into subpackage `lang.rule`.
* `net.sourceforge.pmd.cache.AbstractAnalysisCache` (moved to internal, now package private)
* `net.sourceforge.pmd.cache.AnalysisCache` (moved to internal)
* `net.sourceforge.pmd.cache.AnalysisCacheListener` (moved to internal)
* `net.sourceforge.pmd.cache.AnalysisResult` (moved to internal)
* `net.sourceforge.pmd.cache.CachedRuleMapper` (moved to internal, now package private)
* `net.sourceforge.pmd.cache.CachedRuleViolation` (moved to internal, now package private)
* `net.sourceforge.pmd.cache.ChecksumAware` (moved to internal)
* `net.sourceforge.pmd.cache.FileAnalysisCache` (moved to internal)
* `net.sourceforge.pmd.cache.NoopAnalysisCache` (moved to internal)
* `net.sourceforge.pmd.util.ResourceLoader` (moved to internal)
* {%jdoc !!core::cpd.Tokens %}
* Constructor is now package private.
* {%jdoc !!core::lang.LanguageProcessor.AnalysisTask %}
* Constructor is now package private.
* Method `withFiles(java.util.List)` is now package private. Note: it was not previously marked with @<!-- -->InternalApi.
* {%jdoc !!core::lang.rule.RuleTargetSelector %}
* Method `isRuleChain()` has been removed.
* {%jdoc !!core::renderers.AbstractAccumulatingRenderer %}
* {%jdoc core::renderers.AbstractAccumulatingRenderer#renderFileReport(core::reporting.Report) %} - this method is now final
and can't be overridden anymore.
* {%jdoc !!core::reporting.Report %}
* Constructor as well as the methods `addRuleViolation`, `addConfigError`, `addError` are now private.
* {%jdoc !!core::reporting.RuleContext %}
* Method `getRule()` is now package private.
* Method `create(FileAnalysisListener listener, Rule rule)` has been removed.
* `net.sourceforge.pmd.rules.RuleFactory`: moved into subpackage `lang.rule` and made package private.
It has now been hidden completely from public API.
* Many types have been moved from the base package `net.sourceforge.pmd` into subpackage `lang.rule.internal`.
* `RuleSetReference`
* `RuleSetReferenceId`
* `RuleSets`
* Many types have been moved from into subpackage `lang.rule.internal`.
* `net.sourceforge.pmd.RuleSetReference`
* `net.sourceforge.pmd.RuleSetReferenceId`
* `net.sourceforge.pmd.RuleSets`
* `net.sourceforge.pmd.lang.rule.ParametricRuleViolation` is now package private and moved to `net.sourceforge.pmd.reporting.ParametricRuleViolation`.
The only public API is {%jdoc core::reporting.RuleViolation %}.
* {%jdoc !!core::lang.rule.RuleSet %}
* Method `applies(Rule,LanguageVersion)` is now package private.
* Method `applies(TextFile)` has been removed.
* Method `applies(FileId)` is now package private.
* {%jdoc !!core::lang.rule.RuleSetLoader %}
* Method `loadRuleSetsWithoutException(java.util.List)` is now package private.
* {%jdoc !!core::lang.rule.RuleSetLoadException %}
* All constructors are package private now.
* {%jdoc !!core::lang.ast.LexException %} - the constructor `LexException(boolean, String, int, int, String, char)` is now package private.
It is only used by JavaCC-generated token managers.
* {%jdoc !!core::PMDConfiguration %}
* Method `setAnalysisCache(AnalysisCache)` is now package private. Use {%jdoc core::PMDConfiguration#setAnalysisCacheLocation(java.lang.String) %} instead.
* Method `getAnalysisCache()` is now package private.
* {%jdoc !!core::lang.document.FileCollector %}
* Method `newCollector(LanguageVersionDiscoverer, PmdReporter)` is now package private.
* Method `newCollector(PmdReporter)` is now package private.
* In order to create a FileCollector, use {%jdoc core::PmdAnalysis#files() %} instead.
* {%jdoc !!core::lang.rule.xpath.Attribute %}
* Method `replacementIfDeprecated()` is now package private.
* `net.sourceforge.pmd.properties.PropertyTypeId` - moved in subpackage `internal`.
* {%jdoc !!core::properties.PropertyDescriptor %} - method `getTypeId()` is now package private.
* pmd-ant
* {%jdoc !!ant::ant.Formatter %}
* Method `getRenderer()` has been removed.
* Method `start(String)` is private now.
* Method `end(Report)` has been removed.
* Method `isNoOutputSupplied()` is now package private.
* Method `newListener(Project)` is now package private.
* {%jdoc !!ant::ant.PMDTask %}
* Method `getRelativizeRoots()` has been removed.
* `net.sourceforge.pmd.ant.ReportException` is now package private. Note: It was not marked with @<!-- -->InternalApi before.
* pmd-apex
* {%jdoc !!apex::ast.ApexNode %}
* Method `getNode()` has been removed. It was only deprecated before and not marked with @<!-- -->InternalApi.
However, it gave access to the wrapped Jorje node and was thus internal API.
* {%jdoc !!apex::ast.AbstractApexNode %}
* Method `getNode()` is now package private.
* {%jdoc !!apex::multifile.ApexMultifileAnalysis %}
* Constructor is now package private.
* `net.sourceforge.pmd.lang.apex.rule.design.AbstractNcssCountRule` (now package private)
* `net.sourceforge.pmd.lang.apex.rule.AbstractApexUnitTestRule` (moved to package `net.sourceforge.pmd.apex.rule.bestpractices`, now package private)
* pmd-java
* `net.sourceforge.pmd.lang.java.rule.AbstractIgnoredAnnotationRule` (moved to internal)
* `net.sourceforge.pmd.lang.java.types.ast.LazyTypeResolver` (moved to internal)
* {%jdoc !!java::types.JMethodSig %}
* Method `internalApi()` has been removed.
* {%jdoc !!java::types.TypeOps %}
* Method `isSameTypeInInference(JTypeMirror,JTypeMirror)` is now package private.
* pmd-jsp
* {%jdoc !!jsp::ast.JspParser %}
* Method `getTokenBehavior()` has been removed.
* pmd-modelica
* {%jdoc !!modelica::ast.InternalApiBridge %} renamed from `InternalModelicaNodeApi`.
* {%jdoc !!modelica::resolver.InternalApiBridge %} renamed from `InternalModelicaResolverApi`.
* `net.sourceforge.pmd.lang.modelica.resolver.ModelicaSymbolFacade` has been removed.
* `net.sourceforge.pmd.lang.modelica.resolver.ResolutionContext` (moved to internal)
* `net.sourceforge.pmd.lang.modelica.resolver.ResolutionState` (moved to internal). Note: it was not previously marked with @<!-- -->InternalApi.
* `net.sourceforge.pmd.lang.modelica.resolver.Watchdog` (moved to internal). Note: it was not previously marked with @<!-- -->InternalApi.
* pmd-plsql
* `net.sourceforge.pmd.lang.plsql.rule.design.AbstractNcssCountRule` is now package private.
* pmd-scala
* {%jdoc !!scala::ScalaLanguageModule %}
* Method `dialectOf(LanguageVersion)` has been removed.
**Removed classes and methods (previously deprecated)**
@ -309,6 +400,9 @@ The following previously deprecated classes have been removed:
**Renamed classes, interfaces**
* pmd-core
* {%jdoc core::util.log.PmdReporter %} - has been renamed from `net.sourceforge.pmd.util.log.MessageReporter`
* pmd-java
* The interface `AccessNode` has been renamed to {% jdoc java::lang.ast.ModifierOwner %}. This is only relevant
for Java rules, which use that type directly e.g. through downcasting.
@ -771,6 +865,7 @@ See also [Detailed Release Notes for PMD 7]({{ baseurl }}pmd_release_notes_pmd7.
* [#4313](https://github.com/pmd/pmd/issues/4313): \[core] Remove support for &lt;lang&gt;-&lt;ruleset&gt; hyphen notation for ruleset references
* [#4314](https://github.com/pmd/pmd/issues/4314): \[core] Remove ruleset compatibility filter (RuleSetFactoryCompatibility) and CLI option `--no-ruleset-compatibility`
* [#4323](https://github.com/pmd/pmd/issues/4323): \[core] Refactor CPD integration
* [#4348](https://github.com/pmd/pmd/issues/4348): \[core] Consolidate @<!-- -->InternalApi classes
* [#4353](https://github.com/pmd/pmd/pull/4353): \[core] Micro optimizations for Node API
* [#4365](https://github.com/pmd/pmd/pull/4365): \[core] Improve benchmarking
* [#4397](https://github.com/pmd/pmd/pull/4397): \[core] Refactor CPD

View File

@ -225,8 +225,8 @@ The following previously deprecated methods have been removed:
* pmd-core
* `net.sourceforge.pmd.properties.PropertyBuilder.GenericCollectionPropertyBuilder#delim(char)`
* `net.sourceforge.pmd.properties.PropertySource#setProperty(...)`
* `net.sourceforge.pmd.properties.PropertyTypeId#factoryFor(...)`
* `net.sourceforge.pmd.properties.PropertyTypeId#typeIdFor(...)`
* `net.sourceforge.pmd.properties.internal.PropertyTypeId#factoryFor(...)`
* `net.sourceforge.pmd.properties.internal.PropertyTypeId#typeIdFor(...)`
* `net.sourceforge.pmd.properties.PropertyDescriptor`: removed methods errorFor, type, isMultiValue,
uiOrder, compareTo, isDefinedExternally, valueFrom, asDelimitedString

View File

@ -816,8 +816,8 @@ The following previously deprecated methods have been removed:
* pmd-core
* `net.sourceforge.pmd.properties.PropertyBuilder.GenericCollectionPropertyBuilder#delim(char)`
* `net.sourceforge.pmd.properties.PropertySource#setProperty(...)`
* `net.sourceforge.pmd.properties.PropertyTypeId#factoryFor(...)`
* `net.sourceforge.pmd.properties.PropertyTypeId#typeIdFor(...)`
* `net.sourceforge.pmd.properties.internal.PropertyTypeId#factoryFor(...)`
* `net.sourceforge.pmd.properties.internal.PropertyTypeId#typeIdFor(...)`
* `net.sourceforge.pmd.properties.PropertyDescriptor`: removed methods errorFor, type, isMultiValue,
uiOrder, compareTo, isDefinedExternally, valueFrom, asDelimitedString
@ -900,7 +900,7 @@ The following classes have been removed:
##### Internal APIs
* {% jdoc core::cpd.Tokens %}
* {% jdoc core::net.sourceforge.pmd.properties.PropertyTypeId %}
* {% jdoc core::net.sourceforge.pmd.properties.internal.PropertyTypeId %}
##### Deprecated API

View File

@ -283,7 +283,7 @@
<!-- Use own LexException instead of JavaCC's TokenMgrError -->
<replaceregexp>
<regexp pattern='throw new TokenMgrError\(EOFSeen' />
<substitution expression='throw new net.sourceforge.pmd.lang.ast.LexException(EOFSeen' />
<substitution expression='throw net.sourceforge.pmd.lang.ast.InternalApiBridge.newLexException(EOFSeen' />
<file name="${tokenmgr-file}" />
</replaceregexp>

View File

@ -26,7 +26,6 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Parameter;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.internal.util.IOUtil;
import net.sourceforge.pmd.lang.document.TextFile;
import net.sourceforge.pmd.renderers.Renderer;
@ -35,9 +34,22 @@ import net.sourceforge.pmd.reporting.FileAnalysisListener;
import net.sourceforge.pmd.reporting.FileNameRenderer;
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
import net.sourceforge.pmd.reporting.ListenerInitializer;
import net.sourceforge.pmd.reporting.Report;
@InternalApi
/**
* Part of PMD Ant task configuration. Setters of this class are interpreted by Ant as properties
* settable in the XML. This is therefore published API.
*
* <p>This class is used to configure a specific {@link Renderer} for outputting the violations. This is called
* a formatter in PMD Ant task configuration and might look like this:
*
* <pre>{@code
* <pmd>
* <formatter type="html" toFile="${build}/pmd_report.html"/>
* </pmd>
* }</pre>
*
* @see PMDTask#addFormatter(Formatter)
*/
public class Formatter {
private File toFile;
@ -68,15 +80,7 @@ public class Formatter {
this.parameters.add(parameter);
}
@Deprecated
@InternalApi
public Renderer getRenderer() {
return renderer;
}
@Deprecated
@InternalApi
public void start(String baseDir) {
private void start(String baseDir) {
Properties properties = createProperties();
@ -122,25 +126,7 @@ public class Formatter {
}
}
@Deprecated
@InternalApi
public void end(Report errorReport) {
try {
renderer.renderFileReport(errorReport);
renderer.end();
if (toConsole) {
writer.flush();
} else {
writer.close();
}
} catch (IOException ioe) {
throw new BuildException(ioe.getMessage(), ioe);
}
}
@Deprecated
@InternalApi
public boolean isNoOutputSupplied() {
boolean isNoOutputSupplied() {
return toFile == null && !toConsole;
}
@ -248,12 +234,8 @@ public class Formatter {
return null;
}
@Deprecated
@InternalApi
public GlobalAnalysisListener newListener(Project project) throws IOException {
GlobalAnalysisListener newListener(Project project) throws IOException {
start(project.getBaseDir().toString());
Renderer renderer = getRenderer();
return new GlobalAnalysisListener() {
final GlobalAnalysisListener listener = renderer.newListener();

View File

@ -0,0 +1,32 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.ant;
import java.io.IOException;
import org.apache.tools.ant.Project;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
/**
* Internal API.
*
* <p>Acts as a bridge between outer parts of PMD and the restricted access
* internal API of this package.
*
* <p><b>None of this is published API, and compatibility can be broken anytime!</b>
* Use this only at your own risk.
*
* @apiNote Internal API
*/
@InternalApi
public final class InternalApiBridge {
private InternalApiBridge() {}
public static GlobalAnalysisListener newListener(Formatter formatter, Project project) throws IOException {
return formatter.newListener(project);
}
}

View File

@ -4,7 +4,6 @@
package net.sourceforge.pmd.ant;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@ -15,9 +14,7 @@ import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.types.Resource;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.ant.internal.PMDTaskImpl;
import net.sourceforge.pmd.lang.rule.RulePriority;
@ -290,15 +287,4 @@ public class PMDTask extends Task {
public List<Path> getRelativizePathsWith() {
return relativizePathsWith;
}
@InternalApi
public List<java.nio.file.Path> getRelativizeRoots() {
List<java.nio.file.Path> paths = new ArrayList<>();
for (Path path : getRelativizePathsWith()) {
for (Resource resource : path) {
paths.add(Paths.get(resource.toString()));
}
}
return paths;
}
}

View File

@ -6,11 +6,12 @@ package net.sourceforge.pmd.ant;
/**
* @author Philippe T'Seyen
* @apiNote Internal API
*/
public class ReportException extends RuntimeException {
class ReportException extends RuntimeException {
private static final long serialVersionUID = 6043174086675858209L;
public ReportException(Throwable cause) {
ReportException(Throwable cause) {
super(cause);
}
}

View File

@ -4,6 +4,21 @@
package net.sourceforge.pmd.ant;
/**
* Part of PMD Ant task configuration. Setters of this class are interpreted by Ant as properties
* settable in the XML. This is therefore published API.
*
* <p>This class is used to configure {@link net.sourceforge.pmd.lang.rule.RuleSet} as nested XML tags.
* It might look like this:
*
* <pre>{@code
* <pmd>
* <ruleset>rulesets/java/quickstart.xml</ruleset>
* </pmd>
* }</pre>
*
* @see PMDTask#addRuleset(RuleSetWrapper)
*/
public class RuleSetWrapper {
private String file;

View File

@ -7,7 +7,19 @@ package net.sourceforge.pmd.ant;
import net.sourceforge.pmd.lang.Language;
/**
* Stores LanguageVersion terse name value.
* Part of PMD Ant task configuration. Setters of this class are interpreted by Ant as properties
* settable in the XML. This is therefore published API.
*
* <p>This class is used to configure the language and version to use.
* It might look like this:
*
* <pre>{@code
* <pmd>
* <sourceLanguage name="java" version="21"/>
* </pmd>
* }</pre>
*
* @see PMDTask#addConfiguredSourceLanguage(SourceLanguage)
*/
public class SourceLanguage {

View File

@ -4,7 +4,10 @@
package net.sourceforge.pmd.ant.internal;
import static net.sourceforge.pmd.lang.rule.InternalApiBridge.loadRuleSetsWithoutException;
import java.nio.charset.Charset;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -16,6 +19,7 @@ import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Resource;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -24,6 +28,7 @@ import org.slf4j.event.Level;
import net.sourceforge.pmd.PMDConfiguration;
import net.sourceforge.pmd.PmdAnalysis;
import net.sourceforge.pmd.ant.Formatter;
import net.sourceforge.pmd.ant.InternalApiBridge;
import net.sourceforge.pmd.ant.PMDTask;
import net.sourceforge.pmd.ant.SourceLanguage;
import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration;
@ -54,7 +59,7 @@ public class PMDTaskImpl {
private Project project;
public PMDTaskImpl(PMDTask task) {
configuration.addRelativizeRoots(task.getRelativizeRoots());
configuration.addRelativizeRoots(getRelativizeRoots(task));
if (task.getSuppressMarker() != null) {
configuration.setSuppressMarker(task.getSuppressMarker());
}
@ -96,6 +101,17 @@ public class PMDTaskImpl {
project = task.getProject();
}
private static List<java.nio.file.Path> getRelativizeRoots(PMDTask pmdTask) {
List<java.nio.file.Path> paths = new ArrayList<>();
for (Path path : pmdTask.getRelativizePathsWith()) {
for (Resource resource : path) {
paths.add(Paths.get(resource.toString()));
}
}
return paths;
}
private void doTask() {
setupClassLoader();
@ -111,7 +127,7 @@ public class PMDTaskImpl {
try (PmdAnalysis pmd = PmdAnalysis.create(configuration)) {
RuleSetLoader rulesetLoader =
pmd.newRuleSetLoader().loadResourcesWith(setupResourceLoader());
pmd.addRuleSets(rulesetLoader.loadRuleSetsWithoutException(ruleSetPaths));
pmd.addRuleSets(loadRuleSetsWithoutException(rulesetLoader, ruleSetPaths));
for (FileSet fileset : filesets) {
DirectoryScanner ds = fileset.getDirectoryScanner(project);
@ -160,7 +176,7 @@ public class PMDTaskImpl {
renderers.add(reportSizeListener);
for (Formatter formatter : formatters) {
project.log("Sending a report to " + formatter, Project.MSG_VERBOSE);
renderers.add(formatter.newListener(project));
renderers.add(InternalApiBridge.newListener(formatter, project));
}
return GlobalAnalysisListener.tee(renderers);
} catch (Exception e) {

View File

@ -8,6 +8,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.lang.LanguageVersionHandler;
import net.sourceforge.pmd.lang.apex.multifile.ApexMultifileAnalysis;
import net.sourceforge.pmd.lang.apex.multifile.InternalApiBridge;
import net.sourceforge.pmd.lang.impl.BatchLanguageProcessor;
public class ApexLanguageProcessor
@ -18,7 +19,7 @@ public class ApexLanguageProcessor
ApexLanguageProcessor(ApexLanguageProperties bundle) {
super(bundle);
this.multifileAnalysis = new ApexMultifileAnalysis(bundle);
this.multifileAnalysis = InternalApiBridge.createApexMultiFileAnalysis(bundle);
this.services = new ApexLanguageHandler();
}

View File

@ -42,6 +42,6 @@ public final class ASTBlockStatement extends AbstractApexNode<BlockStatement> {
@Override
public boolean hasRealLoc() {
return super.hasRealLoc() && !Objects.equals(node.getLoc(), getParent().getNode().getLoc());
return super.hasRealLoc() && !Objects.equals(node.getLoc(), ((AbstractApexNode<?>) getParent()).getNode().getLoc());
}
}

View File

@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.apex.ast;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.AstVisitor;
import net.sourceforge.pmd.lang.ast.FileAnalysisException;
import net.sourceforge.pmd.lang.ast.impl.AbstractNode;
@ -89,10 +88,7 @@ abstract class AbstractApexNode<T extends AstNode> extends AbstractNode<Abstract
this.region = region;
}
@Deprecated
@InternalApi
@Override
public T getNode() {
T getNode() {
return node;
}

View File

@ -14,8 +14,7 @@ import apex.jorje.semantic.ast.AstNode;
/**
* Root interface implemented by all Apex nodes. Apex nodes wrap a tree
* obtained from an external parser (Jorje). The underlying AST node is
* available with {@link #getNode()}.
* obtained from an external parser (Jorje).
*
* @param <T> Type of the underlying Jorje node
*/
@ -33,16 +32,6 @@ public interface ApexNode<T extends AstNode> extends GenericNode<ApexNode<?>> {
}
/**
* Get the underlying AST node.
* @deprecated the underlying AST node should not be available outside of the AST node.
* If information is needed from the underlying node, then PMD's AST node need to expose
* this information.
*/
@Deprecated
T getNode();
boolean hasRealLoc();

View File

@ -4,7 +4,6 @@
package net.sourceforge.pmd.lang.apex.ast;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.apex.ApexJorjeLogging;
import net.sourceforge.pmd.lang.apex.ApexLanguageProcessor;
import net.sourceforge.pmd.lang.ast.ParseException;
@ -14,7 +13,6 @@ import net.sourceforge.pmd.lang.document.FileLocation;
import apex.jorje.data.Locations;
import apex.jorje.semantic.ast.compilation.Compilation;
@InternalApi
public final class ApexParser implements Parser {
public ApexParser() {

View File

@ -328,7 +328,7 @@ final class ApexTreeBuilder extends AstVisitor<AdditionalPassScope> {
}
}
private boolean containsComments(ASTCommentContainer<?> commentContainer) {
private boolean containsComments(AbstractApexCommentContainerNode<?> commentContainer) {
Location loc = commentContainer.getNode().getLoc();
if (!Locations.isReal(loc)) {
// Synthetic nodes don't have a location and can't have comments

View File

@ -16,7 +16,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.sourceforge.pmd.annotation.Experimental;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.apex.ApexLanguageProcessor;
import net.sourceforge.pmd.lang.apex.ApexLanguageProperties;
@ -52,8 +51,7 @@ public final class ApexMultifileAnalysis {
}
@InternalApi
public ApexMultifileAnalysis(ApexLanguageProperties properties) {
ApexMultifileAnalysis(ApexLanguageProperties properties) {
String rootDir = properties.getProperty(ApexLanguageProperties.MULTIFILE_DIRECTORY);
LOG.debug("MultiFile Analysis created for {}", rootDir);

View File

@ -0,0 +1,28 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.multifile;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.apex.ApexLanguageProperties;
/**
* Internal API.
*
* <p>Acts as a bridge between outer parts of PMD and the restricted access
* internal API of this package.
*
* <p><b>None of this is published API, and compatibility can be broken anytime!</b>
* Use this only at your own risk.
*
* @apiNote Internal API
*/
@InternalApi
public final class InternalApiBridge {
private InternalApiBridge() {}
public static ApexMultifileAnalysis createApexMultiFileAnalysis(ApexLanguageProperties properties) {
return new ApexMultifileAnalysis(properties);
}
}

View File

@ -2,22 +2,19 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.rule;
package net.sourceforge.pmd.lang.apex.rule.bestpractices;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.apex.ast.ASTModifierNode;
import net.sourceforge.pmd.lang.apex.ast.ASTUserClass;
import net.sourceforge.pmd.lang.apex.ast.ApexNode;
import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule;
/**
* Do special checks for apex unit test classes and methods
*
* @author a.subramanian
* @deprecated Internal API
*/
@Deprecated
@InternalApi
public abstract class AbstractApexUnitTestRule extends AbstractApexRule {
abstract class AbstractApexUnitTestRule extends AbstractApexRule {
/**
* Don't bother visiting this class if it's not a class with @isTest and

View File

@ -5,7 +5,6 @@
package net.sourceforge.pmd.lang.apex.rule.bestpractices;
import net.sourceforge.pmd.lang.apex.ast.ASTMethodCallExpression;
import net.sourceforge.pmd.lang.apex.rule.AbstractApexUnitTestRule;
public class ApexAssertionsShouldIncludeMessageRule extends AbstractApexUnitTestRule {

View File

@ -21,7 +21,6 @@ import net.sourceforge.pmd.lang.apex.ast.ASTMethod;
import net.sourceforge.pmd.lang.apex.ast.ASTMethodCallExpression;
import net.sourceforge.pmd.lang.apex.ast.ASTStatement;
import net.sourceforge.pmd.lang.apex.ast.ApexNode;
import net.sourceforge.pmd.lang.apex.rule.AbstractApexUnitTestRule;
import net.sourceforge.pmd.properties.PropertyDescriptor;
/**

View File

@ -9,7 +9,6 @@ import java.util.List;
import net.sourceforge.pmd.lang.apex.ast.ASTMethod;
import net.sourceforge.pmd.lang.apex.ast.ASTRunAsBlockStatement;
import net.sourceforge.pmd.lang.apex.ast.ApexNode;
import net.sourceforge.pmd.lang.apex.rule.AbstractApexUnitTestRule;
/**
* Apex unit tests should have System.runAs methods in them

View File

@ -9,7 +9,6 @@ import net.sourceforge.pmd.lang.apex.ast.ASTMethod;
import net.sourceforge.pmd.lang.apex.ast.ASTModifierNode;
import net.sourceforge.pmd.lang.apex.ast.ASTUserClass;
import net.sourceforge.pmd.lang.apex.ast.ApexNode;
import net.sourceforge.pmd.lang.apex.rule.AbstractApexUnitTestRule;
/**
* <p>

View File

@ -4,7 +4,6 @@
package net.sourceforge.pmd.lang.apex.rule.design;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.apex.ast.ASTBreakStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTContinueStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTDoLoopStatement;
@ -33,11 +32,8 @@ import net.sourceforge.pmd.lang.ast.Node;
* <a href="http://www.kclee.de/clemens/java/javancss/">JavaNCSS rules</a>.
*
* @author ported from Java original of Jason Bennett
* @deprecated Internal API
*/
@Deprecated
@InternalApi
public abstract class AbstractNcssCountRule<T extends ApexNode<?>> extends AbstractCounterCheckRule<T> {
abstract class AbstractNcssCountRule<T extends ApexNode<?>> extends AbstractCounterCheckRule<T> {
/**

View File

@ -8,7 +8,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.apex.ast.ASTDmlDeleteStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTDmlInsertStatement;
import net.sourceforge.pmd.lang.apex.ast.ASTDmlMergeStatement;
@ -36,7 +35,6 @@ import net.sourceforge.pmd.lang.apex.ast.ApexNode;
* @author sergey.gorbaty
*
*/
@InternalApi
public final class Helper {
public static final String ANY_METHOD = "*";
private static final String DATABASE_CLASS_NAME = "Database";

View File

@ -38,7 +38,7 @@ import net.sourceforge.pmd.renderers.Renderer;
import net.sourceforge.pmd.renderers.RendererFactory;
import net.sourceforge.pmd.reporting.ReportStats;
import net.sourceforge.pmd.util.StringUtil;
import net.sourceforge.pmd.util.log.MessageReporter;
import net.sourceforge.pmd.util.log.PmdReporter;
import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter;
import picocli.CommandLine.Command;
@ -302,7 +302,7 @@ public class PmdCommand extends AbstractAnalysisPmdSubcommand<PMDConfiguration>
TimeTracker.startGlobalTracking();
}
final MessageReporter pmdReporter = configuration.getReporter();
final PmdReporter pmdReporter = configuration.getReporter();
try {
PmdAnalysis pmd = null;
@ -350,14 +350,14 @@ public class PmdCommand extends AbstractAnalysisPmdSubcommand<PMDConfiguration>
}
}
private void printErrorDetected(MessageReporter reporter, int errors) {
private void printErrorDetected(PmdReporter reporter, int errors) {
String msg = LogMessages.errorDetectedMessage(errors, "pmd");
// note: using error level here increments the error count of the reporter,
// which we don't want.
reporter.info(StringUtil.quoteMessageFormat(msg));
}
private void finishBenchmarker(final MessageReporter pmdReporter) {
private void finishBenchmarker(final PmdReporter pmdReporter) {
if (benchmark) {
final TimingReport timingReport = TimeTracker.stopGlobalTracking();

Some files were not shown because too many files have changed in this diff Show More