diff --git a/docs/pages/7_0_0_release_notes.md b/docs/pages/7_0_0_release_notes.md index 9ef91f07b4..fcca1fc63d 100644 --- a/docs/pages/7_0_0_release_notes.md +++ b/docs/pages/7_0_0_release_notes.md @@ -247,6 +247,7 @@ The following previously deprecated rules have been finally removed: * [#4080](https://github.com/pmd/pmd/issues/4080): \[ant] Split off Ant integration into a new submodule * core * [#2234](https://github.com/pmd/pmd/issues/2234): \[core] Consolidate PMD CLI into a single command + * [#2873](https://github.com/pmd/pmd/issues/2873): \[core] Utility classes in pmd 7 * [#3203](https://github.com/pmd/pmd/issues/3203): \[core] Replace RuleViolationFactory implementations with ViolationDecorator * [#3902](https://github.com/pmd/pmd/issues/3902): \[core] Violation decorators * [#4035](https://github.com/pmd/pmd/issues/4035): \[core] ConcurrentModificationException in DefaultRuleViolationFactory @@ -354,6 +355,19 @@ The following previously deprecated rules have been finally removed: has been moved into the same package {% jdoc_package ant::ant %}. You'll need to update your taskdef entries in your build.xml files with the FQCN {% jdoc !!ant::ant.CPDTask %} if you use it anywhere. +* Utility classes in {% jdoc_package core::util %}, that have previously marked as `@InternalApi` have been finally + moved to {% jdoc_package core::internal.util %}. This includes ClasspathClassLoader, FileFinder, FileUtil, and + IOUtil. + +* The following utility classes in {% jdoc_package core::util %} are now considered public API: + * {% jdoc core::util.AssertionUtil %} + * {% jdoc core::util.CollectionUtil %} + * {% jdoc core::util.ContextedAssertionError %} + * {% jdoc core::util.ContextedStackOverflowError %} + * {% jdoc core::util.GraphUtil %} + * {% jdoc core::util.IteratorUtil %} + * {% jdoc core::util.StringUtil %} + #### Metrics framework The metrics framework has been made simpler and more general. diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java index 6099351996..6c14fd7356 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java @@ -27,12 +27,12 @@ import org.apache.tools.ant.types.Parameter; import net.sourceforge.pmd.Report; 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; import net.sourceforge.pmd.renderers.RendererFactory; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.util.IOUtil; @InternalApi public class Formatter { diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java index a39fd1abfd..f3d2d5e17b 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java @@ -28,6 +28,8 @@ import net.sourceforge.pmd.ant.Formatter; import net.sourceforge.pmd.ant.PMDTask; import net.sourceforge.pmd.ant.SourceLanguage; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; +import net.sourceforge.pmd.internal.util.ClasspathClassLoader; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; @@ -36,8 +38,6 @@ import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; import net.sourceforge.pmd.reporting.ReportStats; import net.sourceforge.pmd.reporting.ReportStatsListener; -import net.sourceforge.pmd.util.ClasspathClassLoader; -import net.sourceforge.pmd.util.IOUtil; public class PMDTaskImpl { diff --git a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java index 7b8d822486..1a671f4fcd 100644 --- a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java +++ b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java @@ -19,7 +19,7 @@ import org.apache.tools.ant.ProjectHelper; import org.junit.jupiter.api.AfterAll; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; class AbstractAntTest { protected Project project; diff --git a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java index d3ea8f2072..819aebf084 100644 --- a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java +++ b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java @@ -20,7 +20,7 @@ import org.apache.tools.ant.BuildException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; class PMDTaskTest extends AbstractAntTest { diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java index 7ce83fcfcb..c966e5a330 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/cpd/ApexCpdTest.java @@ -14,8 +14,8 @@ import java.util.Iterator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.apex.ApexLanguageModule; -import net.sourceforge.pmd.util.IOUtil; class ApexCpdTest { private File testdir; diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java index 935f362cf3..965167dfd9 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java @@ -20,9 +20,9 @@ import java.util.List; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.document.FileLocation; -import net.sourceforge.pmd.util.IOUtil; class ApexParserTest extends ApexParserTestBase { @@ -182,7 +182,7 @@ class ApexParserTest extends ApexParserTestBase { @Test void stackOverflowDuringClassParsing() throws Exception { String source = IOUtil.readToString(ApexParserTest.class.getResourceAsStream("StackOverflowClass.cls"), - StandardCharsets.UTF_8); + StandardCharsets.UTF_8); ASTUserClassOrInterface rootNode = parse(source); assertNotNull(rootNode); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java index c88133f447..6ff741235b 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java @@ -19,7 +19,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java index 68614cec2e..da3fdacdc0 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java @@ -24,7 +24,7 @@ import net.sourceforge.pmd.cpd.CPDReport; import net.sourceforge.pmd.cpd.Language; import net.sourceforge.pmd.cpd.Tokenizer; import net.sourceforge.pmd.internal.LogMessages; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import picocli.CommandLine.Command; import picocli.CommandLine.Option; diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java index f95c39afc7..87ec854b7a 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java @@ -42,9 +42,9 @@ import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.cli.internal.CliExitCode; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.MockRule; -import net.sourceforge.pmd.util.IOUtil; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java index 1c8549fed6..616759b737 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java @@ -26,13 +26,13 @@ import net.sourceforge.pmd.cache.AnalysisCache; import net.sourceforge.pmd.cache.FileAnalysisCache; import net.sourceforge.pmd.cache.NoopAnalysisCache; import net.sourceforge.pmd.cli.PmdParametersParseResult; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.internal.util.ClasspathClassLoader; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; import net.sourceforge.pmd.renderers.Renderer; import net.sourceforge.pmd.renderers.RendererFactory; -import net.sourceforge.pmd.util.ClasspathClassLoader; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.log.MessageReporter; import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java index f9a42d0b88..0033109c7d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java @@ -26,8 +26,9 @@ import net.sourceforge.pmd.benchmark.TimedOperationCategory; import net.sourceforge.pmd.cache.AnalysisCacheListener; import net.sourceforge.pmd.cache.NoopAnalysisCache; import net.sourceforge.pmd.internal.LogMessages; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.internal.util.ClasspathClassLoader; import net.sourceforge.pmd.internal.util.FileCollectionUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; @@ -39,8 +40,7 @@ import net.sourceforge.pmd.reporting.GlobalAnalysisListener; import net.sourceforge.pmd.reporting.ListenerInitializer; import net.sourceforge.pmd.reporting.ReportStats; import net.sourceforge.pmd.reporting.ReportStatsListener; -import net.sourceforge.pmd.util.ClasspathClassLoader; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; import net.sourceforge.pmd.util.log.MessageReporter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java index ff3e3510f8..41f95f2759 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java @@ -29,6 +29,7 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.rule.RuleReference; @@ -36,7 +37,6 @@ import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyDescriptorField; import net.sourceforge.pmd.properties.PropertyTypeId; -import net.sourceforge.pmd.util.IOUtil; /** * This class represents a way to serialize a RuleSet to an XML configuration diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java index 74af13c400..c10effe5f3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/AbstractAnalysisCache.java @@ -33,9 +33,9 @@ import net.sourceforge.pmd.benchmark.TimeTracker; import net.sourceforge.pmd.benchmark.TimedOperation; import net.sourceforge.pmd.benchmark.TimedOperationCategory; import net.sourceforge.pmd.cache.internal.ClasspathFingerprinter; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.TextDocument; import net.sourceforge.pmd.reporting.FileAnalysisListener; -import net.sourceforge.pmd.util.IOUtil; /** * Abstract implementation of the analysis cache. Handles all operations, except for persistence. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinter.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinter.java index 29e6457efe..7b31dac6f0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinter.java @@ -16,7 +16,7 @@ import java.util.zip.Checksum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * Base fingerprinter for raw files. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPD.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPD.java index 42875f9079..a4bf7e24c2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPD.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPD.java @@ -23,10 +23,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import net.sourceforge.pmd.annotation.Experimental; +import net.sourceforge.pmd.internal.util.FileFinder; +import net.sourceforge.pmd.internal.util.FileUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.ast.TokenMgrError; -import net.sourceforge.pmd.util.FileFinder; -import net.sourceforge.pmd.util.FileUtil; -import net.sourceforge.pmd.util.IOUtil; import net.sourceforge.pmd.util.database.DBMSMetadata; import net.sourceforge.pmd.util.database.DBURI; import net.sourceforge.pmd.util.database.SourceObject; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java index 9def103844..efe6550261 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java @@ -22,8 +22,8 @@ import java.util.Set; import net.sourceforge.pmd.AbstractConfiguration; import net.sourceforge.pmd.cpd.renderer.CPDReportRenderer; -import net.sourceforge.pmd.util.FileFinder; -import net.sourceforge.pmd.util.FileUtil; +import net.sourceforge.pmd.internal.util.FileFinder; +import net.sourceforge.pmd.internal.util.FileUtil; /** * diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java index 20529bdea6..bd93023de7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SourceCode.java @@ -14,7 +14,7 @@ import java.nio.file.Files; import java.util.ArrayList; import java.util.List; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; public class SourceCode { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/token/internal/BaseTokenFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/token/internal/BaseTokenFilter.java index 692fc2462d..6d980ea41e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/token/internal/BaseTokenFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/token/internal/BaseTokenFilter.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.cpd.token.internal; -import static net.sourceforge.pmd.internal.util.IteratorUtil.AbstractIterator; +import static net.sourceforge.pmd.util.IteratorUtil.AbstractIterator; import java.util.ConcurrentModificationException; import java.util.Iterator; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java similarity index 90% rename from pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java rename to pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java index 0266574901..92056007f8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java @@ -1,8 +1,8 @@ -/** +/* * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.util; +package net.sourceforge.pmd.internal.util; import java.io.BufferedReader; import java.io.File; @@ -19,8 +19,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * Create a ClassLoader which loads classes using a CLASSPATH like String. If @@ -28,10 +27,7 @@ import net.sourceforge.pmd.internal.util.AssertionUtil; * the file will be read with each line representing an path on the classpath. * * @author Edwin Chan - * @deprecated Is internal API */ -@InternalApi -@Deprecated public class ClasspathClassLoader extends URLClassLoader { private static final Logger LOG = LoggerFactory.getLogger(ClasspathClassLoader.class); @@ -105,10 +101,10 @@ public class ClasspathClassLoader extends URLClassLoader { @Override public String toString() { - return new StringBuilder(getClass().getSimpleName()) - .append("[[") - .append(StringUtils.join(getURLs(), ":")) - .append("] parent: ").append(getParent()).append(']').toString(); + return getClass().getSimpleName() + + "[[" + + StringUtils.join(getURLs(), ":") + + "] parent: " + getParent() + ']'; } @Override diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java index f06a227c31..efa42a1df1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java @@ -17,8 +17,6 @@ import org.slf4j.LoggerFactory; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.lang.document.FileCollector; -import net.sourceforge.pmd.util.FileUtil; -import net.sourceforge.pmd.util.IOUtil; import net.sourceforge.pmd.util.database.DBMSMetadata; import net.sourceforge.pmd.util.database.DBURI; import net.sourceforge.pmd.util.database.SourceObject; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/FileFinder.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileFinder.java similarity index 92% rename from pmd-core/src/main/java/net/sourceforge/pmd/util/FileFinder.java rename to pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileFinder.java index c632997409..36a8dec0d7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/FileFinder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileFinder.java @@ -1,8 +1,8 @@ -/** +/* * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.util; +package net.sourceforge.pmd.internal.util; import java.io.File; import java.io.FilenameFilter; @@ -11,14 +11,9 @@ import java.util.Arrays; import java.util.Comparator; import java.util.List; -import net.sourceforge.pmd.annotation.InternalApi; - /** * A utility class for finding files within a directory. - * @deprecated Is internal API */ -@Deprecated -@InternalApi public class FileFinder { private FilenameFilter filter; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/FileUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileUtil.java similarity index 96% rename from pmd-core/src/main/java/net/sourceforge/pmd/util/FileUtil.java rename to pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileUtil.java index a37740c32e..b7b3fe94fd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/FileUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileUtil.java @@ -1,8 +1,8 @@ -/** +/* * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.util; +package net.sourceforge.pmd.internal.util; import java.io.File; import java.io.FileNotFoundException; @@ -21,15 +21,9 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.annotation.InternalApi; - /** * This is a utility class for working with Files. - * - * @deprecated Is internal API */ -@Deprecated -@InternalApi public final class FileUtil { private FileUtil() { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/IOUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IOUtil.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/util/IOUtil.java rename to pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IOUtil.java index b017770b80..1fce3ef4c4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/IOUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IOUtil.java @@ -1,8 +1,8 @@ -/** +/* * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.util; +package net.sourceforge.pmd.internal.util; import java.io.Closeable; import java.io.File; @@ -34,15 +34,10 @@ import java.util.Objects; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.annotation.InternalApi; - /** * * @author Brian Remedios - * @deprecated Is internal API */ -@InternalApi -@Deprecated public final class IOUtil { /** * Unicode BOM character. Replaces commons io ByteOrderMark. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/PredicateUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/PredicateUtil.java index cb002d3f34..92984b94e9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/PredicateUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/PredicateUtil.java @@ -5,8 +5,8 @@ package net.sourceforge.pmd.internal.util; -import static net.sourceforge.pmd.internal.util.AssertionUtil.requireOver1; -import static net.sourceforge.pmd.internal.util.AssertionUtil.requireParamNotNull; +import static net.sourceforge.pmd.util.AssertionUtil.requireOver1; +import static net.sourceforge.pmd.util.AssertionUtil.requireParamNotNull; import java.util.Collection; import java.util.function.Predicate; @@ -14,6 +14,8 @@ import java.util.regex.Pattern; import org.checkerframework.checker.nullness.qual.NonNull; +import net.sourceforge.pmd.util.AssertionUtil; + /** * Utility class for working with {@link Predicate}. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java index 927e6572d3..6e7b1f3f94 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java @@ -15,7 +15,7 @@ import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.annotation.DeprecatedUntil700; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * This class can discover the LanguageVersion of a source file. Further, every diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstInfo.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstInfo.java index 1e70b8549d..4cfaeccdac 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstInfo.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstInfo.java @@ -10,9 +10,9 @@ import java.util.Map; import org.checkerframework.checker.nullness.qual.NonNull; import net.sourceforge.pmd.annotation.Experimental; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.Parser.ParserTask; import net.sourceforge.pmd.lang.document.TextDocument; +import net.sourceforge.pmd.util.AssertionUtil; /** * The output of {@link Parser#parse(ParserTask)}. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java index eded4cdb3c..bc9e09a608 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java @@ -9,10 +9,10 @@ import java.util.stream.Stream; import org.apache.commons.lang3.StringUtils; import net.sourceforge.pmd.annotation.Experimental; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.document.TextRegion; import net.sourceforge.pmd.reporting.Reportable; +import net.sourceforge.pmd.util.IteratorUtil; /** * Represents a token, part of a token chain in a source file. Tokens diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/EscapeTranslator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/EscapeTranslator.java index 30431d995d..f2852d8c45 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/EscapeTranslator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/EscapeTranslator.java @@ -6,11 +6,11 @@ package net.sourceforge.pmd.lang.ast.impl.javacc; import static java.lang.Integer.min; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.FragmentedDocBuilder; import net.sourceforge.pmd.lang.document.TextDocument; +import net.sourceforge.pmd.util.AssertionUtil; /** * An object that can translate an input document into an output document, diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AxisStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AxisStream.java index 31ef6efd37..fd1eecb465 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AxisStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AxisStream.java @@ -18,10 +18,10 @@ import java.util.function.Predicate; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.NodeStream; +import net.sourceforge.pmd.util.AssertionUtil; +import net.sourceforge.pmd.util.IteratorUtil; /** * Stream that iterates over one axis of the tree. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/Filtermap.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/Filtermap.java index 0ab3923adc..68ca382e9b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/Filtermap.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/Filtermap.java @@ -13,8 +13,8 @@ import java.util.function.Predicate; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.util.IteratorUtil; /** * Combined filter/map predicate. Cannot accept null values. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/GreedyNStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/GreedyNStream.java index aa17ef5290..98f7eee936 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/GreedyNStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/GreedyNStream.java @@ -13,11 +13,11 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.NodeStream; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; +import net.sourceforge.pmd.util.IteratorUtil; /** * A greedy stream evaluates all axis operations, except for descendants, diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/IteratorBasedNStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/IteratorBasedNStream.java index cd322ac924..0319e8e974 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/IteratorBasedNStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/IteratorBasedNStream.java @@ -22,11 +22,11 @@ import java.util.stream.StreamSupport; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.NodeStream; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; +import net.sourceforge.pmd.util.IteratorUtil; /** * Implementations are based on the iterator rather than the stream. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/SingletonNodeStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/SingletonNodeStream.java index 269574254e..ff1f4acca8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/SingletonNodeStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/SingletonNodeStream.java @@ -15,11 +15,11 @@ import java.util.stream.Stream; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.ast.NodeStream.DescendantNodeStream; +import net.sourceforge.pmd.util.AssertionUtil; +import net.sourceforge.pmd.util.IteratorUtil; /** * Optimised node stream implementation for a single element. Streams diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/StreamImpl.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/StreamImpl.java index ffaa189452..893413d435 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/StreamImpl.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/StreamImpl.java @@ -16,7 +16,6 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.ast.NodeStream.DescendantNodeStream; @@ -28,6 +27,7 @@ import net.sourceforge.pmd.lang.ast.internal.AxisStream.FilteredAncestorOrSelfSt import net.sourceforge.pmd.lang.ast.internal.AxisStream.FilteredChildrenStream; import net.sourceforge.pmd.lang.ast.internal.AxisStream.FilteredDescendantStream; import net.sourceforge.pmd.lang.ast.internal.GreedyNStream.GreedyKnownNStream; +import net.sourceforge.pmd.util.IteratorUtil; public final class StreamImpl { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/Chars.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/Chars.java index f39978c265..f07f905fca 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/Chars.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/Chars.java @@ -21,7 +21,7 @@ import java.util.stream.StreamSupport; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.internal.util.IteratorUtil.AbstractIterator; +import net.sourceforge.pmd.util.IteratorUtil.AbstractIterator; /** * View on a string which doesn't copy the array for subsequence operations. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java index e3ca07677a..516851b167 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java @@ -38,11 +38,11 @@ import org.slf4j.LoggerFactory; import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.log.MessageReporter; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java index 6cdf18785c..57768ac833 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java @@ -10,10 +10,10 @@ import java.util.Objects; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.GenericToken; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.reporting.Reportable; +import net.sourceforge.pmd.util.AssertionUtil; /** * Represents the coordinates of a text region, used for reporting. This provides access diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java index 1b51bd59bb..0520f907da 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java @@ -13,9 +13,9 @@ import java.nio.file.Path; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.internal.util.BaseCloseable; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.util.AssertionUtil; /** * A {@link TextFile} backed by a file in some {@link FileSystem}. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/ReaderTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/ReaderTextFile.java index dcb36819db..d23ae6494e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/ReaderTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/ReaderTextFile.java @@ -9,8 +9,8 @@ import java.io.Reader; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.util.AssertionUtil; /** * Read-only view on a string. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/SourceCodePositioner.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/SourceCodePositioner.java index cf8caab34c..0e098aacb5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/SourceCodePositioner.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/SourceCodePositioner.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.document; import java.util.Arrays; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * Wraps a piece of text, and converts absolute offsets to line/column diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java index cfa7273a8e..7c288ff04b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java @@ -6,8 +6,8 @@ package net.sourceforge.pmd.lang.document; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFile.java index 6e0af1e1b4..a4c2bfacdf 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFile.java @@ -21,11 +21,11 @@ import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.annotation.DeprecatedUntil700; import net.sourceforge.pmd.cpd.SourceCode; import net.sourceforge.pmd.internal.util.BaseCloseable; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.document.TextFileBuilder.ForCharSeq; import net.sourceforge.pmd.lang.document.TextFileBuilder.ForNio; import net.sourceforge.pmd.lang.document.TextFileBuilder.ForReader; -import net.sourceforge.pmd.util.IOUtil; import net.sourceforge.pmd.util.datasource.DataSource; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileBuilder.java index e23f3264b5..b8e146a91a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileBuilder.java @@ -10,8 +10,8 @@ import java.nio.file.Path; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.LanguageVersion; +import net.sourceforge.pmd.util.AssertionUtil; /** * A builder for a new text file. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileContent.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileContent.java index 0219448387..b973f91d89 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileContent.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileContent.java @@ -23,7 +23,7 @@ import java.util.zip.Checksum; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * Contents of a text file. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/Metric.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/Metric.java index 92d4f1796d..f9576c38d8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/Metric.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/Metric.java @@ -13,8 +13,8 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.DataMap.DataKey; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java index 9b5241a897..aeca48672b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/ParametricRuleViolation.java @@ -10,9 +10,9 @@ import java.util.Map; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.reporting.Reportable; +import net.sourceforge.pmd.util.AssertionUtil; /** * @deprecated This is internal. Clients should exclusively use {@link RuleViolation}. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelation.java index 7c2398c8d8..91ac6c5a77 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelation.java @@ -5,11 +5,11 @@ package net.sourceforge.pmd.lang.rule.internal; import static java.util.stream.Collectors.toSet; -import static net.sourceforge.pmd.internal.GraphUtils.DotColor; import static net.sourceforge.pmd.util.CollectionUtil.any; import static net.sourceforge.pmd.util.CollectionUtil.finish; import static net.sourceforge.pmd.util.CollectionUtil.map; import static net.sourceforge.pmd.util.CollectionUtil.toMutableList; +import static net.sourceforge.pmd.util.GraphUtil.DotColor; import java.util.ArrayDeque; import java.util.Collections; @@ -26,8 +26,8 @@ import java.util.stream.Collector; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.GraphUtils; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; +import net.sourceforge.pmd.util.GraphUtil; /** * Indexes data of type {@code } with keys of type {@code }, where @@ -218,7 +218,7 @@ class LatticeRelation { public String toString() { // generates a DOT representation of the lattice // Visualize eg at http://webgraphviz.com/ - return GraphUtils.toDot( + return GraphUtil.toDot( nodes.values(), n -> n.transitiveSuccs, n -> n.getClass() == QueryNode.class ? DotColor.GREEN : DotColor.BLACK, diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java index fa16d8dbdc..67a0d35408 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java @@ -19,10 +19,10 @@ import net.sourceforge.pmd.benchmark.TimeTracker; import net.sourceforge.pmd.benchmark.TimedOperation; import net.sourceforge.pmd.benchmark.TimedOperationCategory; import net.sourceforge.pmd.internal.SystemProps; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.reporting.FileAnalysisListener; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; /** Applies a set of rules to a set of ASTs. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/TreeIndex.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/TreeIndex.java index 420b4afcf7..d7ba9652fc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/TreeIndex.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/TreeIndex.java @@ -14,8 +14,8 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.util.IteratorUtil; /** * Index of an AST, for use by the {@link RuleApplicator}. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java index dabd3a99ae..f1bd734934 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java @@ -10,8 +10,8 @@ import java.io.Writer; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.annotation.Experimental; import net.sourceforge.pmd.cli.PMDParameters; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.properties.AbstractPropertySource; -import net.sourceforge.pmd.util.IOUtil; /** * Abstract base class for {@link Renderer} implementations. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java index 5bf6c47ac8..66750cb5e5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java @@ -16,8 +16,8 @@ import java.util.TreeMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.util.AssertionUtil; /** * This class handles the creation of Renderers. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java index 135858d80b..f4052818d0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java @@ -10,9 +10,9 @@ import java.util.Iterator; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.renderers.internal.sarif.SarifLog; import net.sourceforge.pmd.renderers.internal.sarif.SarifLogBuilder; -import net.sourceforge.pmd.util.IOUtil; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java index e75ae3a25b..6fa8f6ff9a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java @@ -27,9 +27,9 @@ import org.apache.commons.lang3.StringUtils; import net.sourceforge.pmd.PMDVersion; import net.sourceforge.pmd.Report; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; -import net.sourceforge.pmd.util.IOUtil; import net.sourceforge.pmd.util.StringUtil; /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java index b59c401d07..f882ac7632 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java @@ -11,8 +11,8 @@ import java.util.List; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.Report.SuppressedViolation; import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * A handler for events occuring during analysis of a single file. Instances diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java index 1abe5accac..55008fa997 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java @@ -15,13 +15,13 @@ import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.GlobalReportBuilderListener; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.ast.FileAnalysisException; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.renderers.Renderer; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.BaseResultProducingCloseable; import net.sourceforge.pmd.util.CollectionUtil; -import net.sourceforge.pmd.util.IOUtil; /** * Listens to an analysis. This object produces new {@link FileAnalysisListener} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ListenerInitializer.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ListenerInitializer.java index bf1f740cf1..2ae8547c8e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ListenerInitializer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ListenerInitializer.java @@ -8,8 +8,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * An initializer for {@link GlobalAnalysisListener} that gets notified of diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/AssertionUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/AssertionUtil.java similarity index 97% rename from pmd-core/src/main/java/net/sourceforge/pmd/internal/util/AssertionUtil.java rename to pmd-core/src/main/java/net/sourceforge/pmd/util/AssertionUtil.java index 9ac28a1e7c..303ec3c3e7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/AssertionUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/AssertionUtil.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.internal.util; +package net.sourceforge.pmd.util; import java.util.Collection; @@ -24,7 +24,7 @@ public final class AssertionUtil { } - /** @throws NullPointerException if $name */ + /** @throws NullPointerException if any item is null */ public static void requireContainsNoNullValue(String name, Collection c) { int i = 0; for (Object o : c) { @@ -65,7 +65,7 @@ public final class AssertionUtil { } } - public static boolean isJavaBinaryName(CharSequence name) { + private static boolean isJavaBinaryName(CharSequence name) { return name.length() > 0 && BINARY_NAME_PATTERN.matcher(name).matches(); } @@ -78,6 +78,7 @@ public final class AssertionUtil { } + /** Throws {@link IllegalStateException} if the condition is false. */ public static void validateState(boolean condition, String failed) { if (!condition) { throw new IllegalStateException(failed); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/BaseResultProducingCloseable.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/BaseResultProducingCloseable.java index ea978cc9bd..d28e7180df 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/BaseResultProducingCloseable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/BaseResultProducingCloseable.java @@ -18,9 +18,7 @@ public abstract class BaseResultProducingCloseable implements AutoCloseable { private boolean closed; protected final void ensureOpen() { - if (closed) { - throw new IllegalStateException("Listener closed"); - } + AssertionUtil.validateState(!closed, "Listener has been closed"); } /** @@ -29,9 +27,7 @@ public abstract class BaseResultProducingCloseable implements AutoCloseable { * @throws IllegalStateException If this instance has not been closed yet */ public final T getResult() { - if (!closed) { - throw new IllegalStateException("Cannot get result before listener is closed"); - } + AssertionUtil.validateState(closed, "Cannot get result before listener is closed"); return getResultImpl(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java index 2ad062ee21..d470b6c7eb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java @@ -14,7 +14,6 @@ import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -40,68 +39,21 @@ import org.pcollections.PMap; import org.pcollections.PSequence; import org.pcollections.PSet; -import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.AssertionUtil; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.document.Chars; /** - * Generic collection and array-related utility functions for java.util types. - * See ClassUtil for comparable facilities for short name lookup. + * Generic collection-related utility functions for java.util types. * * @author Brian Remedios - * @version $Revision$ - * @deprecated Is internal API + * @author Clément Fournier */ -@Deprecated -@InternalApi public final class CollectionUtil { private static final int UNKNOWN_SIZE = -1; - @SuppressWarnings("PMD.UnnecessaryFullyQualifiedName") - public static final Set COLLECTION_INTERFACES_BY_NAMES = collectionTypes(List.class, Collection.class, Map.class, Set.class); - - @SuppressWarnings({"PMD.LooseCoupling", "PMD.UnnecessaryFullyQualifiedName"}) - public static final Set COLLECTION_CLASSES_BY_NAMES - = collectionTypes(ArrayList.class, java.util.LinkedList.class, java.util.Vector.class, HashMap.class, - java.util.LinkedHashMap.class, java.util.TreeMap.class, java.util.TreeSet.class, - HashSet.class, java.util.LinkedHashSet.class, java.util.Hashtable.class); - - private CollectionUtil() { } - private static Set collectionTypes(Class... types) { - Set set = new HashSet<>(); - - for (Class type : types) { - if (!set.add(type.getSimpleName()) || !set.add(type.getName())) { - throw new IllegalArgumentException("Duplicate or name collision for " + type); - } - } - - return set; - } - - /** - * Return whether we can identify the typeName as a java.util collection - * class or interface as specified. - * - * @param typeName - * String - * @param includeInterfaces - * boolean - * @return boolean - * - * @deprecated Will be replaced with type resolution - */ - @Deprecated - public static boolean isCollectionType(String typeName, boolean includeInterfaces) { - return COLLECTION_CLASSES_BY_NAMES.contains(typeName) - || includeInterfaces && COLLECTION_INTERFACES_BY_NAMES.contains(typeName); - } - /** * Creates and returns a map populated with the keyValuesSets where the * value held by the tuples are they key and value in that order. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ConsList.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ConsList.java index 3c3a40f4e0..66fdfcfe73 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ConsList.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ConsList.java @@ -10,8 +10,6 @@ import java.util.List; import org.apache.commons.lang3.Validate; -import net.sourceforge.pmd.internal.util.IteratorUtil; - final class ConsList extends AbstractList { private final List head; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ContextedAssertionError.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedAssertionError.java similarity index 92% rename from pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ContextedAssertionError.java rename to pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedAssertionError.java index e4ab1a5bdf..a6cb0615eb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ContextedAssertionError.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedAssertionError.java @@ -2,10 +2,12 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.internal.util; +package net.sourceforge.pmd.util; import org.apache.commons.lang3.exception.DefaultExceptionContext; +import net.sourceforge.pmd.internal.util.ExceptionContextDefaultImpl; + /** * An {@link AssertionError} with nice messages. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ContextedStackOverflowError.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedStackOverflowError.java similarity index 92% rename from pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ContextedStackOverflowError.java rename to pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedStackOverflowError.java index e2fa9b2fe0..854f3a6b8e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ContextedStackOverflowError.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedStackOverflowError.java @@ -2,10 +2,12 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.internal.util; +package net.sourceforge.pmd.util; import org.apache.commons.lang3.exception.DefaultExceptionContext; +import net.sourceforge.pmd.internal.util.ExceptionContextDefaultImpl; + /** * A {@link StackOverflowError} with nice messages. */ diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/GraphUtils.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/GraphUtil.java similarity index 96% rename from pmd-core/src/main/java/net/sourceforge/pmd/internal/GraphUtils.java rename to pmd-core/src/main/java/net/sourceforge/pmd/util/GraphUtil.java index 1748dfff42..bdd43e6525 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/GraphUtils.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/GraphUtil.java @@ -3,7 +3,7 @@ */ -package net.sourceforge.pmd.internal; +package net.sourceforge.pmd.util; import java.util.ArrayList; import java.util.Collection; @@ -16,9 +16,9 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; -public final class GraphUtils { +public final class GraphUtil { - private GraphUtils() { + private GraphUtil() { } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IteratorUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/IteratorUtil.java similarity index 99% rename from pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IteratorUtil.java rename to pmd-core/src/main/java/net/sourceforge/pmd/util/IteratorUtil.java index 25c27dbe5e..4e10d396bb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IteratorUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/IteratorUtil.java @@ -1,8 +1,8 @@ -/** +/* * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.internal.util; +package net.sourceforge.pmd.util; import java.util.ArrayList; import java.util.Arrays; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java index fc4ecca0a6..1913a713ff 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java @@ -15,22 +15,16 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.document.Chars; /** - * A number of String-specific utility methods for use by PMD or its IDE - * plugins. + * String-related utility functions. See also {@link StringUtils}. * * @author BrianRemedios - * @deprecated Is internal API + * @author Clément Fournier */ -@Deprecated -@InternalApi public final class StringUtil { - private static final String[] EMPTY_STRINGS = new String[0]; private static final Pattern XML_10_INVALID_CHARS = Pattern.compile( "\\x00|\\x01|\\x02|\\x03|\\x04|\\x05|\\x06|\\x07|\\x08|" @@ -225,47 +219,6 @@ public final class StringUtil { return text; } - - /** - * @param supportUTF8 override the default setting, whether special characters should be replaced with entities ( - * false) or should be included as is ( true). - * @deprecated for removal. Use Java's XML implementations, that do the escaping, - * use {@link #removedInvalidXml10Characters(String)} for fixing invalid characters in XML 1.0 - * documents or use {@code StringEscapeUtils#escapeXml10(String)} from apache commons-text instead. - */ - @Deprecated - public static void appendXmlEscaped(StringBuilder buf, String src, boolean supportUTF8) { - char c; - int i = 0; - while (i < src.length()) { - c = src.charAt(i++); - if (c > '~') { - // 126 - if (!supportUTF8) { - int codepoint = c; - // surrogate characters are not allowed in XML - if (Character.isHighSurrogate(c)) { - char low = src.charAt(i++); - codepoint = Character.toCodePoint(c, low); - } - buf.append("&#x").append(Integer.toHexString(codepoint)).append(';'); - } else { - buf.append(c); - } - } else if (c == '&') { - buf.append("&"); - } else if (c == '"') { - buf.append("""); - } else if (c == '<') { - buf.append("<"); - } else if (c == '>') { - buf.append(">"); - } else { - buf.append(c); - } - } - } - /** * Remove characters, that are not allowed in XML 1.0 documents. * @@ -489,15 +442,6 @@ public final class StringUtil { return truncated + ellipsis; } - /** - * Returns an empty array of string - * - * @return String - */ - public static String[] getEmptyStrings() { - return EMPTY_STRINGS; - } - /** * Replaces unprintable characters by their escaped (or unicode escaped) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ReaderDataSource.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ReaderDataSource.java index 6edb9e6553..149382ea09 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ReaderDataSource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/datasource/ReaderDataSource.java @@ -8,7 +8,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.Reader; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.util.datasource.internal.AbstractDataSource; /** diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java index 127fea8da0..7fdc4933f6 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java @@ -32,9 +32,9 @@ import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.cache.FileAnalysisCache; import net.sourceforge.pmd.cache.NoopAnalysisCache; +import net.sourceforge.pmd.internal.util.ClasspathClassLoader; import net.sourceforge.pmd.renderers.CSVRenderer; import net.sourceforge.pmd.renderers.Renderer; -import net.sourceforge.pmd.util.ClasspathClassLoader; class PmdConfigurationTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java index 1e75e37584..4e271dbbba 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetReferenceIdTest.java @@ -25,7 +25,7 @@ import java.util.List; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.util.ResourceLoader; import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java index 81396be626..8ecbdd6377 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetTest.java @@ -40,6 +40,7 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.RuleSet.RuleSetBuilder; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode; import net.sourceforge.pmd.lang.ast.Node; @@ -47,7 +48,6 @@ import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.RuleTargetSelector; -import net.sourceforge.pmd.util.IOUtil; class RuleSetTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java index ddce7c5cf2..6a1c855246 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cli/PMDFilelistTest.java @@ -18,11 +18,11 @@ import org.junit.jupiter.api.Test; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; import net.sourceforge.pmd.internal.util.FileCollectionUtil; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.LanguageVersionDiscoverer; import net.sourceforge.pmd.lang.document.FileCollector; import net.sourceforge.pmd.lang.document.TextFile; -import net.sourceforge.pmd.util.IOUtil; import net.sourceforge.pmd.util.log.internal.NoopReporter; class PMDFilelistTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cli/ZipFileTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cli/ZipFileTest.java index e260f65f9d..cbf9ab007d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cli/ZipFileTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cli/ZipFileTest.java @@ -16,8 +16,8 @@ import org.junit.Test; import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.PmdAnalysis; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.TextFile; -import net.sourceforge.pmd.util.IOUtil; public class ZipFileTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdXsltTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdXsltTest.java index ea2cffa619..49f135e4d4 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdXsltTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdXsltTest.java @@ -22,7 +22,7 @@ import javax.xml.transform.stream.StreamSource; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; class CpdXsltTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java index e0681d607e..a62bfba125 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java @@ -24,8 +24,8 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.util.CollectionUtil; +import net.sourceforge.pmd.util.IteratorUtil; /** * diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java index 08e3edab7a..1e4aa3ded1 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java @@ -15,9 +15,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageVersion; -import net.sourceforge.pmd.util.IOUtil; class TextDocumentTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/NoAttributeTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/NoAttributeTest.java index d035f6f961..d06ad5e6f7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/NoAttributeTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/NoAttributeTest.java @@ -12,10 +12,10 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.DummyNode; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.xpath.NoAttribute.NoAttrScope; +import net.sourceforge.pmd.util.IteratorUtil; /** * @author Clément Fournier diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/processor/PmdRunnableTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/processor/PmdRunnableTest.java index 415a7f2845..334da77a7b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/processor/PmdRunnableTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/processor/PmdRunnableTest.java @@ -34,7 +34,6 @@ import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSets; import net.sourceforge.pmd.internal.SystemProps; -import net.sourceforge.pmd.internal.util.ContextedAssertionError; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.DummyLanguageModule.Handler; import net.sourceforge.pmd.lang.Language; @@ -45,6 +44,7 @@ import net.sourceforge.pmd.lang.ast.RootNode; import net.sourceforge.pmd.lang.document.TextFile; import net.sourceforge.pmd.lang.rule.AbstractRule; import net.sourceforge.pmd.processor.MonoThreadProcessor.MonothreadRunnable; +import net.sourceforge.pmd.util.ContextedAssertionError; import net.sourceforge.pmd.util.log.MessageReporter; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java index 84570db95d..78ba7dd755 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java @@ -27,6 +27,7 @@ import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RulePriority; import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.RuleWithProperties; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.DummyLanguageModule; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.document.FileLocation; @@ -35,7 +36,6 @@ import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.reporting.FileAnalysisListener; import net.sourceforge.pmd.reporting.GlobalAnalysisListener; -import net.sourceforge.pmd.util.IOUtil; abstract class AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java index c2c13b7c83..00173d2f5d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/XMLRendererTest.java @@ -30,10 +30,10 @@ import net.sourceforge.pmd.Report; import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.document.TextRange2d; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; -import net.sourceforge.pmd.util.IOUtil; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java index 88667ee62c..12d78fae60 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/YAHTMLRendererTest.java @@ -26,10 +26,10 @@ import net.sourceforge.pmd.Report.ConfigurationError; import net.sourceforge.pmd.Report.ProcessingError; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleViolation; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.rule.ParametricRuleViolation; import net.sourceforge.pmd.util.CollectionUtil; -import net.sourceforge.pmd.util.IOUtil; class YAHTMLRendererTest extends AbstractRendererTest { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/IOUtilTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/IOUtilTest.java index 7d149e886a..9b558684b2 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/IOUtilTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/IOUtilTest.java @@ -33,6 +33,8 @@ import java.nio.file.Path; import org.apache.commons.lang3.SystemUtils; import org.junit.jupiter.api.Test; +import net.sourceforge.pmd.internal.util.IOUtil; + class IOUtilTest { @Test diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/internal/util/IteratorUtilTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/IteratorUtilTest.java similarity index 99% rename from pmd-core/src/test/java/net/sourceforge/pmd/internal/util/IteratorUtilTest.java rename to pmd-core/src/test/java/net/sourceforge/pmd/util/IteratorUtilTest.java index e306fcfc0c..c58f39afc0 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/internal/util/IteratorUtilTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/IteratorUtilTest.java @@ -2,7 +2,7 @@ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html */ -package net.sourceforge.pmd.internal.util; +package net.sourceforge.pmd.util; import static java.util.Collections.emptyIterator; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/StringUtilTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/StringUtilTest.java index 052244bf84..189040c97b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/StringUtilTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/StringUtilTest.java @@ -51,31 +51,6 @@ class StringUtilTest { assertEquals(-1, StringUtil.columnNumberAt("", 1)); } - @Test - void testUTF8NotSupported() { - StringBuilder sb = new StringBuilder(); - String test = "é"; - StringUtil.appendXmlEscaped(sb, test, false); - assertEquals("é", sb.toString()); - } - - @Test - void testUTF8NotSupportedSurrogates() { - // D8 34 DD 1E -> U+1D11E - StringBuilder sb = new StringBuilder(); - String test = new String(new char[] {0xd834, 0xdd1e}); - StringUtil.appendXmlEscaped(sb, test, false); - assertEquals("𝄞", sb.toString()); - } - - @Test - void testUTF8Supported() { - StringBuilder sb = new StringBuilder(); - String test = "é"; - StringUtil.appendXmlEscaped(sb, test, true); - assertEquals("é", sb.toString()); - } - @Test void testRemoveSurrounding() { assertThat(StringUtil.removeSurrounding("", 'q'), equalTo("")); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/util/datasource/internal/PathDataSourceTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/util/datasource/internal/PathDataSourceTest.java index 0acbbbf255..195e78e1e0 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/util/datasource/internal/PathDataSourceTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/util/datasource/internal/PathDataSourceTest.java @@ -19,7 +19,7 @@ import java.util.zip.ZipOutputStream; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; class PathDataSourceTest { @TempDir diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/AntIT.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/AntIT.java index 78114cb84e..f28e430273 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/AntIT.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/AntIT.java @@ -20,7 +20,7 @@ import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.condition.OS; import net.sourceforge.pmd.PMDVersion; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * This test calls ant in a fake terminal to make sure we have a {@link java.io.Console} connected. diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/PMDExecutor.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/PMDExecutor.java index 7998ae0652..d4d601789b 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/PMDExecutor.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/PMDExecutor.java @@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.lang3.SystemUtils; import net.sourceforge.pmd.PMDVersion; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * Executes PMD from command line. Deals with the differences, when PMD is run on Windows or on Linux. diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/ZipFileExtractor.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/ZipFileExtractor.java index 609dde0e44..053e84db70 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/ZipFileExtractor.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/ZipFileExtractor.java @@ -18,7 +18,7 @@ import java.util.List; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipFile; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * Extracts a zip file with preserving the unix file permissions. diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/DeadLinksChecker.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/DeadLinksChecker.java index 499b7b67e3..9188ebef0d 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/DeadLinksChecker.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/DeadLinksChecker.java @@ -39,7 +39,7 @@ import java.util.stream.Stream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; /** * Checks links to local pages for non-existing link-targets. diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java index 56cdad1a81..ebe55f4abd 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/GenerateRuleDocsCmd.java @@ -19,7 +19,7 @@ import java.util.regex.Pattern; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSetLoader; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; public final class GenerateRuleDocsCmd { diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java index d6a82e1a06..0e4e886329 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleDocGenerator.java @@ -37,13 +37,13 @@ import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSetLoadException; import net.sourceforge.pmd.RuleSetLoader; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.MultiValuePropertyDescriptor; import net.sourceforge.pmd.properties.PropertyDescriptor; -import net.sourceforge.pmd.util.IOUtil; public class RuleDocGenerator { private static final Logger LOG = LoggerFactory.getLogger(RuleDocGenerator.class); diff --git a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java index 0ab05a68bc..f581ae6776 100644 --- a/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java +++ b/pmd-doc/src/main/java/net/sourceforge/pmd/docs/RuleSetUtils.java @@ -12,8 +12,8 @@ import org.apache.commons.lang3.SystemUtils; import net.sourceforge.pmd.Rule; import net.sourceforge.pmd.RuleSet; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.rule.RuleReference; -import net.sourceforge.pmd.util.IOUtil; public final class RuleSetUtils { diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java index d7d5f2162e..69665c54b5 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleDocGeneratorTest.java @@ -22,7 +22,7 @@ import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.RuleSet; import net.sourceforge.pmd.RuleSetLoader; import net.sourceforge.pmd.docs.MockedFileWriter.FileEntry; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; class RuleDocGeneratorTest { diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java index 8d476217a3..f5baf81b34 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/RuleSetResolverTest.java @@ -15,7 +15,7 @@ import java.util.List; import org.junit.jupiter.api.Test; import net.sourceforge.pmd.RuleSetLoader; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; class RuleSetResolverTest { diff --git a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java index 0ac2a3dbc1..8fe3a7d5ef 100644 --- a/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java +++ b/pmd-doc/src/test/java/net/sourceforge/pmd/docs/SidebarGeneratorTest.java @@ -27,9 +27,9 @@ import org.yaml.snakeyaml.constructor.SafeConstructor; import org.yaml.snakeyaml.representer.Representer; import net.sourceforge.pmd.RuleSet; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; -import net.sourceforge.pmd.util.IOUtil; class SidebarGeneratorTest { private MockedFileWriter writer = new MockedFileWriter(); diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTClassOrInterfaceType.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTClassOrInterfaceType.java index 155e865e0c..3c780af67d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTClassOrInterfaceType.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTClassOrInterfaceType.java @@ -6,10 +6,10 @@ package net.sourceforge.pmd.lang.java.ast; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken; import net.sourceforge.pmd.lang.java.symbols.JTypeDeclSymbol; import net.sourceforge.pmd.lang.java.types.JClassType; +import net.sourceforge.pmd.util.AssertionUtil; // @formatter:off /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaTypeNode.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaTypeNode.java index 1954bb04bc..36208aef3a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaTypeNode.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaTypeNode.java @@ -6,10 +6,10 @@ package net.sourceforge.pmd.lang.java.ast; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.types.JTypeMirror; import net.sourceforge.pmd.lang.java.types.TypingContext; import net.sourceforge.pmd.lang.java.types.ast.LazyTypeResolver; +import net.sourceforge.pmd.util.AssertionUtil; /** * An extension of the SimpleJavaNode which implements the TypeNode interface. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ConstantFolder.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ConstantFolder.java index 663b31bb87..2e33a43d1c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ConstantFolder.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ConstantFolder.java @@ -9,13 +9,13 @@ import org.apache.commons.lang3.tuple.Pair; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; import net.sourceforge.pmd.lang.java.symbols.JFieldSymbol; import net.sourceforge.pmd.lang.java.symbols.JVariableSymbol; import net.sourceforge.pmd.lang.java.types.JPrimitiveType; import net.sourceforge.pmd.lang.java.types.JTypeMirror; import net.sourceforge.pmd.lang.java.types.TypeTestUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * Computes constant expression values. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalApiBridge.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalApiBridge.java index a5aa733418..d8f536eeaf 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalApiBridge.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalApiBridge.java @@ -8,7 +8,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccTokenDocument; import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr; @@ -33,6 +32,7 @@ import net.sourceforge.pmd.lang.java.types.ast.ExprContext; import net.sourceforge.pmd.lang.java.types.ast.LazyTypeResolver; import net.sourceforge.pmd.lang.java.types.internal.infer.Infer; import net.sourceforge.pmd.lang.java.types.internal.infer.TypeInferenceLogger; +import net.sourceforge.pmd.util.AssertionUtil; /** * Acts as a bridge between outer parts of PMD and the restricted access diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java index 3e19a5923c..d88681e3ab 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/JavaComment.java @@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.java.ast; import java.util.stream.Stream; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.GenericToken; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken; import net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode; @@ -14,6 +13,7 @@ import net.sourceforge.pmd.lang.document.Chars; import net.sourceforge.pmd.lang.document.FileLocation; import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; import net.sourceforge.pmd.reporting.Reportable; +import net.sourceforge.pmd.util.IteratorUtil; /** * Wraps a comment token to provide some utilities. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java index 7a2a31fa06..e5caff888e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/LanguageLevelChecker.java @@ -11,7 +11,6 @@ import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTAnnotation; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; @@ -53,6 +52,7 @@ import net.sourceforge.pmd.lang.java.ast.JModifier; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.ast.JavaTokenKinds; import net.sourceforge.pmd.lang.java.ast.JavaVisitorBase; +import net.sourceforge.pmd.util.IteratorUtil; /** * Checks that an AST conforms to some language level. The reporting diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/PrettyPrintingUtil.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/PrettyPrintingUtil.java index 0e1945919c..730a477e9d 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/PrettyPrintingUtil.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/PrettyPrintingUtil.java @@ -4,7 +4,7 @@ package net.sourceforge.pmd.lang.java.ast.internal; -import static net.sourceforge.pmd.internal.util.AssertionUtil.shouldNotReachHere; +import static net.sourceforge.pmd.util.AssertionUtil.shouldNotReachHere; import org.checkerframework.checker.nullness.qual.NonNull; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecorator.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecorator.java index d0691d7695..05900cd459 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecorator.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/internal/JavaViolationDecorator.java @@ -12,7 +12,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.RuleViolation; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTBodyDeclaration; @@ -26,6 +25,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclarator; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.reporting.ViolationDecorator; +import net.sourceforge.pmd.util.IteratorUtil; final class JavaViolationDecorator implements ViolationDecorator { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryFullyQualifiedNameRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryFullyQualifiedNameRule.java index 95407f525e..79ca132157 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryFullyQualifiedNameRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryFullyQualifiedNameRule.java @@ -13,7 +13,6 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType; import net.sourceforge.pmd.lang.java.ast.ASTFieldAccess; import net.sourceforge.pmd.lang.java.ast.ASTMethodCall; @@ -31,6 +30,7 @@ import net.sourceforge.pmd.lang.java.symbols.table.coreimpl.ShadowChain; import net.sourceforge.pmd.lang.java.symbols.table.coreimpl.ShadowChainIterator; import net.sourceforge.pmd.lang.java.types.JMethodSig; import net.sourceforge.pmd.properties.PropertyDescriptor; +import net.sourceforge.pmd.util.AssertionUtil; public class UnnecessaryFullyQualifiedNameRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UselessParenthesesRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UselessParenthesesRule.java index aeca43decc..6efdd0ef2a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UselessParenthesesRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UselessParenthesesRule.java @@ -11,7 +11,6 @@ import static net.sourceforge.pmd.lang.java.rule.codestyle.UselessParenthesesRul import static net.sourceforge.pmd.lang.java.rule.codestyle.UselessParenthesesRule.Necessity.definitely; import static net.sourceforge.pmd.lang.java.rule.codestyle.UselessParenthesesRule.Necessity.necessaryIf; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTAssignmentExpression; import net.sourceforge.pmd.lang.java.ast.ASTCastExpression; import net.sourceforge.pmd.lang.java.ast.ASTConditionalExpression; @@ -26,6 +25,7 @@ import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.util.AssertionUtil; public final class UselessParenthesesRule extends AbstractJavaRulechainRule { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java index 93d9c09b49..6bd257afa4 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/design/NcssCountRule.java @@ -11,7 +11,6 @@ import java.util.List; import java.util.Map; import net.sourceforge.pmd.RuleContext; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration; @@ -24,6 +23,7 @@ import net.sourceforge.pmd.lang.metrics.MetricOptions; import net.sourceforge.pmd.lang.metrics.MetricsUtil; import net.sourceforge.pmd.properties.PropertyDescriptor; import net.sourceforge.pmd.properties.PropertyFactory; +import net.sourceforge.pmd.util.AssertionUtil; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/AsmSymbolResolver.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/AsmSymbolResolver.java index 6e45e1dda0..31b06c9884 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/AsmSymbolResolver.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/AsmSymbolResolver.java @@ -13,12 +13,12 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.objectweb.asm.Opcodes; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.SymbolResolver; import net.sourceforge.pmd.lang.java.symbols.internal.asm.Loader.FailedLoader; import net.sourceforge.pmd.lang.java.symbols.internal.asm.Loader.UrlLoader; import net.sourceforge.pmd.lang.java.types.TypeSystem; +import net.sourceforge.pmd.util.AssertionUtil; /** * A {@link SymbolResolver} that reads class files to produce symbols. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/SignatureScanner.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/SignatureScanner.java index 029f2f6a9d..752e6b08d9 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/SignatureScanner.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/internal/asm/SignatureScanner.java @@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.java.symbols.internal.asm; import org.apache.commons.lang3.StringUtils; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * Base class to scan a type signature. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/MostlySingularMultimap.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/MostlySingularMultimap.java index 2a18b98237..d324eafa39 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/MostlySingularMultimap.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/MostlySingularMultimap.java @@ -17,7 +17,7 @@ import org.apache.commons.lang3.Validate; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; /** * An unmodifiable multimap type, efficient if the single-value case is the diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/ShadowChainIteratorImpl.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/ShadowChainIteratorImpl.java index fc234944b6..5d6a55f43a 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/ShadowChainIteratorImpl.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/coreimpl/ShadowChainIteratorImpl.java @@ -10,7 +10,7 @@ import java.util.List; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.IteratorUtil; +import net.sourceforge.pmd.util.IteratorUtil; import net.sourceforge.pmd.util.OptionalBool; class ShadowChainIteratorImpl diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/AbruptCompletionAnalysis.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/AbruptCompletionAnalysis.java index 6bd9eb3061..4b972c595c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/AbruptCompletionAnalysis.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/AbruptCompletionAnalysis.java @@ -12,7 +12,6 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.NodeStream; import net.sourceforge.pmd.lang.java.ast.ASTBlock; import net.sourceforge.pmd.lang.java.ast.ASTBreakStatement; @@ -41,6 +40,7 @@ import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.ast.JavaVisitorBase; import net.sourceforge.pmd.lang.java.ast.internal.JavaAstUtils; import net.sourceforge.pmd.lang.java.symbols.table.internal.AbruptCompletionAnalysis.ReachabilityVisitor.VisitResult; +import net.sourceforge.pmd.util.AssertionUtil; /** * Implementation of {@link #canCompleteNormally(ASTStatement)}, which diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/JavaResolvers.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/JavaResolvers.java index 00c5716d9f..ee8fb653b7 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/JavaResolvers.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/JavaResolvers.java @@ -25,7 +25,6 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.pcollections.HashTreePSet; import org.pcollections.PSet; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.symbols.JAccessibleElementSymbol; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.JElementSymbol; @@ -43,6 +42,7 @@ import net.sourceforge.pmd.lang.java.types.JVariableSig; import net.sourceforge.pmd.lang.java.types.JVariableSig.FieldSig; import net.sourceforge.pmd.lang.java.types.TypeOps; import net.sourceforge.pmd.lang.java.types.internal.infer.OverloadSet; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; public final class JavaResolvers { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/PatternBindingsUtil.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/PatternBindingsUtil.java index 4855b48ebb..311cb0d2e2 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/PatternBindingsUtil.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/PatternBindingsUtil.java @@ -7,7 +7,6 @@ package net.sourceforge.pmd.lang.java.symbols.table.internal; import org.pcollections.HashTreePSet; import org.pcollections.PSet; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTGuardedPattern; import net.sourceforge.pmd.lang.java.ast.ASTInfixExpression; @@ -19,6 +18,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTUnaryExpression; import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId; import net.sourceforge.pmd.lang.java.ast.BinaryOp; import net.sourceforge.pmd.lang.java.ast.UnaryOp; +import net.sourceforge.pmd.util.AssertionUtil; /** * Utilities to resolve scope of pattern binding variables. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SuperTypesEnumerator.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SuperTypesEnumerator.java index 3890162836..b05e5bda9c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SuperTypesEnumerator.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SuperTypesEnumerator.java @@ -18,9 +18,9 @@ import java.util.stream.StreamSupport; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.IteratorUtil; -import net.sourceforge.pmd.internal.util.IteratorUtil.AbstractIterator; import net.sourceforge.pmd.lang.java.types.JClassType; +import net.sourceforge.pmd.util.IteratorUtil; +import net.sourceforge.pmd.util.IteratorUtil.AbstractIterator; /** * Strategies to enumerate a type hierarchy. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SymTableFactory.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SymTableFactory.java index 46ffb2b987..fb93d4edb0 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SymTableFactory.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symbols/table/internal/SymTableFactory.java @@ -5,9 +5,9 @@ package net.sourceforge.pmd.lang.java.symbols.table.internal; -import static net.sourceforge.pmd.internal.util.AssertionUtil.isValidJavaPackageName; import static net.sourceforge.pmd.lang.java.symbols.table.ScopeInfo.FORMAL_PARAM; import static net.sourceforge.pmd.lang.java.symbols.table.ScopeInfo.SAME_FILE; +import static net.sourceforge.pmd.util.AssertionUtil.isValidJavaPackageName; import java.lang.reflect.Modifier; import java.util.ArrayList; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/InvocationMatcher.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/InvocationMatcher.java index 09224b77d1..59558c999c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/InvocationMatcher.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/InvocationMatcher.java @@ -13,13 +13,13 @@ import java.util.List; import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTList; import net.sourceforge.pmd.lang.java.ast.InvocationNode; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.ast.QualifiableExpression; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; import net.sourceforge.pmd.util.OptionalBool; import net.sourceforge.pmd.util.StringUtil; diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/JTypeMirror.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/JTypeMirror.java index a6eb81adad..03aace3844 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/JTypeMirror.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/JTypeMirror.java @@ -16,7 +16,6 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.pcollections.PSet; import net.sourceforge.pmd.annotation.Experimental; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.TypeNode; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.JExecutableSymbol; @@ -27,6 +26,7 @@ import net.sourceforge.pmd.lang.java.symbols.SymbolicValue.SymAnnot; import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind; import net.sourceforge.pmd.lang.java.types.TypeOps.Convertibility; import net.sourceforge.pmd.lang.java.types.internal.infer.InferenceVar; +import net.sourceforge.pmd.util.AssertionUtil; /** * Type mirrors represent Java types. They are created by a {@link TypeSystem} diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/Substitution.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/Substitution.java index 10892fd4eb..234833a1a2 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/Substitution.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/Substitution.java @@ -17,7 +17,7 @@ import java.util.function.Function; import org.checkerframework.checker.nullness.qual.NonNull; -import net.sourceforge.pmd.internal.util.AssertionUtil; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeOps.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeOps.java index e82adeb78f..5339bcb280 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeOps.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeOps.java @@ -29,7 +29,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.annotation.InternalApi; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.JConstructorSymbol; import net.sourceforge.pmd.lang.java.symbols.JExecutableSymbol; @@ -43,6 +42,7 @@ import net.sourceforge.pmd.lang.java.types.internal.infer.InferenceVar; import net.sourceforge.pmd.lang.java.types.internal.infer.InferenceVar.BoundKind; import net.sourceforge.pmd.lang.java.types.internal.infer.OverloadSet; import net.sourceforge.pmd.util.CollectionUtil; +import net.sourceforge.pmd.util.IteratorUtil; /** * Common operations on types. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeSystem.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeSystem.java index 06b044fdc7..788dc9ec94 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeSystem.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeSystem.java @@ -23,7 +23,6 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.pcollections.HashTreePSet; import org.pcollections.PSet; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.JavaNode; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.JExecutableSymbol; @@ -40,6 +39,7 @@ import net.sourceforge.pmd.lang.java.symbols.internal.asm.Classpath; import net.sourceforge.pmd.lang.java.types.BasePrimitiveSymbol.RealPrimitiveSymbol; import net.sourceforge.pmd.lang.java.types.BasePrimitiveSymbol.VoidSymbol; import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeTestUtil.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeTestUtil.java index 0eac183735..f9c5df63eb 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeTestUtil.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeTestUtil.java @@ -11,13 +11,13 @@ import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.InternalApiBridge; import net.sourceforge.pmd.lang.java.ast.TypeNode; import net.sourceforge.pmd.lang.java.symbols.JClassSymbol; import net.sourceforge.pmd.lang.java.symbols.JTypeDeclSymbol; import net.sourceforge.pmd.lang.java.symbols.JTypeParameterSymbol; import net.sourceforge.pmd.lang.java.symbols.internal.UnresolvedClassStore; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.OptionalBool; /** diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeVarImpl.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeVarImpl.java index 491b2d4270..e682425b6c 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeVarImpl.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypeVarImpl.java @@ -11,9 +11,9 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.pcollections.PSet; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.symbols.JTypeParameterSymbol; import net.sourceforge.pmd.lang.java.symbols.SymbolicValue.SymAnnot; +import net.sourceforge.pmd.util.AssertionUtil; @SuppressWarnings("PMD.CompareObjectsWithEquals") abstract class TypeVarImpl implements JTypeVar { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypingContext.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypingContext.java index bcd6813748..fc55e155a6 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypingContext.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/TypingContext.java @@ -11,8 +11,8 @@ import java.util.Map; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.symbols.JVariableSymbol; +import net.sourceforge.pmd.util.AssertionUtil; /** * A mapping of variables to types. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/ExprContext.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/ExprContext.java index 8f59b577cd..aa80538da1 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/ExprContext.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/ExprContext.java @@ -13,11 +13,11 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.annotation.Experimental; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.InvocationNode; import net.sourceforge.pmd.lang.java.types.JTypeMirror; import net.sourceforge.pmd.lang.java.types.OverloadSelectionResult; import net.sourceforge.pmd.lang.java.types.TypeConversion; +import net.sourceforge.pmd.util.AssertionUtil; /** * Context of an expression. This determines the target type of poly diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/PolyResolution.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/PolyResolution.java index 0baf61a9c0..a8f731c0c8 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/PolyResolution.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/PolyResolution.java @@ -7,8 +7,8 @@ package net.sourceforge.pmd.lang.java.types.ast; import static java.util.Arrays.asList; -import static net.sourceforge.pmd.internal.util.AssertionUtil.shouldNotReachHere; import static net.sourceforge.pmd.lang.java.types.TypeConversion.isConvertibleUsingBoxing; +import static net.sourceforge.pmd.util.AssertionUtil.shouldNotReachHere; import static net.sourceforge.pmd.util.CollectionUtil.all; import static net.sourceforge.pmd.util.CollectionUtil.map; @@ -17,7 +17,6 @@ import java.util.List; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration; import net.sourceforge.pmd.lang.java.ast.ASTArgumentList; @@ -71,6 +70,7 @@ import net.sourceforge.pmd.lang.java.types.internal.infer.Infer; import net.sourceforge.pmd.lang.java.types.internal.infer.MethodCallSite; import net.sourceforge.pmd.lang.java.types.internal.infer.PolySite; import net.sourceforge.pmd.lang.java.types.internal.infer.ast.JavaExprMirrors; +import net.sourceforge.pmd.util.AssertionUtil; /** * Routines to handle context around poly expressions. diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/Graph.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/Graph.java index ceddc46062..77db849273 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/Graph.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/Graph.java @@ -18,8 +18,8 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import net.sourceforge.pmd.internal.GraphUtils; -import net.sourceforge.pmd.internal.GraphUtils.DotColor; +import net.sourceforge.pmd.util.GraphUtil; +import net.sourceforge.pmd.util.GraphUtil.DotColor; /** * A graph to walk over ivar dependencies in an efficient way. @@ -157,7 +157,7 @@ class Graph { @Override public String toString() { - return GraphUtils.toDot( + return GraphUtil.toDot( vertices, this::successorsOf, v -> DotColor.BLACK, diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/VarWalkStrategy.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/VarWalkStrategy.java index 4f3291f909..2177a1cf92 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/VarWalkStrategy.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/VarWalkStrategy.java @@ -8,10 +8,10 @@ import java.util.Collections; import java.util.Iterator; import java.util.Set; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.java.types.internal.infer.Graph.UniqueGraph; import net.sourceforge.pmd.lang.java.types.internal.infer.Graph.Vertex; import net.sourceforge.pmd.lang.java.types.internal.infer.InferenceVar.BoundKind; +import net.sourceforge.pmd.util.IteratorUtil; /** * Strategy to walk the set of remaining free variables. Interdependent diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/BaseInvocMirror.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/BaseInvocMirror.java index 74a76ac4b0..3193ad0950 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/BaseInvocMirror.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/BaseInvocMirror.java @@ -10,7 +10,6 @@ import java.util.stream.Collectors; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTArgumentList; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; import net.sourceforge.pmd.lang.java.ast.ASTList; @@ -25,6 +24,7 @@ import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror.InvocationMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.MethodCallSite; import net.sourceforge.pmd.lang.java.types.internal.infer.ast.JavaExprMirrors.MirrorMaker; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; abstract class BaseInvocMirror extends BasePolyMirror implements InvocationMirror { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/CtorInvocMirror.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/CtorInvocMirror.java index 0b25ad842c..5aea093a0e 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/CtorInvocMirror.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/CtorInvocMirror.java @@ -13,7 +13,6 @@ import java.util.List; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; import net.sourceforge.pmd.lang.java.ast.ASTEnumConstant; import net.sourceforge.pmd.lang.java.ast.ASTExplicitConstructorInvocation; @@ -26,6 +25,7 @@ import net.sourceforge.pmd.lang.java.types.JTypeMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror.CtorInvocationMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ast.JavaExprMirrors.MirrorMaker; +import net.sourceforge.pmd.util.IteratorUtil; class CtorInvocMirror extends BaseInvocMirror implements CtorInvocationMirror { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/JavaExprMirrors.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/JavaExprMirrors.java index 890415436e..fbd113f641 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/JavaExprMirrors.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/JavaExprMirrors.java @@ -7,7 +7,6 @@ package net.sourceforge.pmd.lang.java.types.internal.infer.ast; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTConditionalExpression; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; import net.sourceforge.pmd.lang.java.ast.ASTEnumConstant; @@ -25,6 +24,7 @@ import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror.FunctionalE import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror.InvocationMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.Infer; import net.sourceforge.pmd.lang.java.types.internal.infer.ast.CtorInvocMirror.EnumCtorInvocMirror; +import net.sourceforge.pmd.util.AssertionUtil; /** Façade that creates {@link ExprMirror} instances. */ public final class JavaExprMirrors { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/LambdaMirrorImpl.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/LambdaMirrorImpl.java index 51a4663079..69f6fa1da2 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/LambdaMirrorImpl.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/LambdaMirrorImpl.java @@ -9,7 +9,6 @@ import java.util.List; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTAssignmentExpression; import net.sourceforge.pmd.lang.java.ast.ASTBlock; import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall; @@ -29,6 +28,7 @@ import net.sourceforge.pmd.lang.java.types.TypingContext; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror.LambdaExprMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ast.JavaExprMirrors.MirrorMaker; +import net.sourceforge.pmd.util.AssertionUtil; class LambdaMirrorImpl extends BaseFunctionalMirror implements LambdaExprMirror { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/MethodRefMirrorImpl.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/MethodRefMirrorImpl.java index 40933a3092..af9cded3d3 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/MethodRefMirrorImpl.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/internal/infer/ast/MethodRefMirrorImpl.java @@ -10,7 +10,6 @@ import java.util.List; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import net.sourceforge.pmd.internal.util.AssertionUtil; import net.sourceforge.pmd.lang.java.ast.ASTExpression; import net.sourceforge.pmd.lang.java.ast.ASTList; import net.sourceforge.pmd.lang.java.ast.ASTMethodReference; @@ -22,6 +21,7 @@ import net.sourceforge.pmd.lang.java.types.JTypeMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ExprMirror.MethodRefMirror; import net.sourceforge.pmd.lang.java.types.internal.infer.ast.JavaExprMirrors.MirrorMaker; +import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.CollectionUtil; final class MethodRefMirrorImpl extends BaseFunctionalMirror implements MethodRefMirror { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java index db07462b49..a9b9dbabaa 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java @@ -20,7 +20,7 @@ import org.junit.rules.ExternalResource; import org.junit.rules.TestRule; import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; -import net.sourceforge.pmd.util.IOUtil; +import net.sourceforge.pmd.internal.util.IOUtil; public class PMDTaskTest extends AbstractAntTestHelper { diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/coverage/PMDCoverageTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/coverage/PMDCoverageTest.java index a54b5989a9..f573e94f61 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/coverage/PMDCoverageTest.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/coverage/PMDCoverageTest.java @@ -22,9 +22,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import net.sourceforge.pmd.PMD; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.java.JavaLanguageModule; -import net.sourceforge.pmd.util.IOUtil; import com.github.stefanbirkner.systemlambda.SystemLambda; diff --git a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TestExtensions.kt b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TestExtensions.kt index b8ea9745bf..6e310638bc 100644 --- a/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TestExtensions.kt +++ b/pmd-java/src/test/kotlin/net/sourceforge/pmd/lang/java/ast/TestExtensions.kt @@ -11,7 +11,6 @@ import io.kotest.matchers.collections.shouldBeEmpty import io.kotest.matchers.shouldBe import io.kotest.matchers.shouldNotBe import io.kotest.matchers.types.shouldBeInstanceOf -import net.sourceforge.pmd.internal.util.IteratorUtil import net.sourceforge.pmd.lang.ast.Node import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken import net.sourceforge.pmd.lang.ast.test.NodeSpec @@ -19,6 +18,7 @@ import net.sourceforge.pmd.lang.ast.test.ValuedNodeSpec import net.sourceforge.pmd.lang.ast.test.shouldBe import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind import net.sourceforge.pmd.lang.java.types.JPrimitiveType.PrimitiveTypeKind.* +import net.sourceforge.pmd.util.IteratorUtil fun > C?.shouldContainAtMostOneOf(vararg expected: T) { this shouldNotBe null diff --git a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt index f3914a0e8b..6466448c66 100644 --- a/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt +++ b/pmd-lang-test/src/main/kotlin/net/sourceforge/pmd/lang/ast/test/BaseParsingHelper.kt @@ -4,18 +4,21 @@ package net.sourceforge.pmd.lang.ast.test import net.sourceforge.pmd.* +import net.sourceforge.pmd.internal.util.IOUtil import net.sourceforge.pmd.lang.Language import net.sourceforge.pmd.lang.LanguageRegistry import net.sourceforge.pmd.lang.LanguageVersion import net.sourceforge.pmd.lang.LanguageVersionHandler -import net.sourceforge.pmd.lang.ast.* +import net.sourceforge.pmd.lang.ast.Node +import net.sourceforge.pmd.lang.ast.Parser +import net.sourceforge.pmd.lang.ast.RootNode +import net.sourceforge.pmd.lang.ast.SemanticErrorReporter import net.sourceforge.pmd.lang.document.TextDocument import net.sourceforge.pmd.lang.document.TextFile import net.sourceforge.pmd.lang.rule.XPathRule import net.sourceforge.pmd.lang.rule.xpath.XPathVersion import net.sourceforge.pmd.processor.AbstractPMDProcessor import net.sourceforge.pmd.reporting.GlobalAnalysisListener -import net.sourceforge.pmd.util.IOUtil import java.io.InputStream import java.nio.charset.StandardCharsets import java.nio.file.Files diff --git a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java index 2825adbb4a..0012282d64 100644 --- a/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java +++ b/pmd-test/src/main/java/net/sourceforge/pmd/AbstractRuleSetFactoryTest.java @@ -39,12 +39,12 @@ import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; +import net.sourceforge.pmd.internal.util.IOUtil; import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageRegistry; import net.sourceforge.pmd.lang.rule.RuleReference; import net.sourceforge.pmd.lang.rule.XPathRule; import net.sourceforge.pmd.properties.PropertyDescriptor; -import net.sourceforge.pmd.util.IOUtil; /** * Base test class to verify the language's rulesets. This class should be diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/ast/internal/XmlNodeWrapper.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/ast/internal/XmlNodeWrapper.java index 306611f217..93817548fa 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/ast/internal/XmlNodeWrapper.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/ast/internal/XmlNodeWrapper.java @@ -18,7 +18,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; -import net.sourceforge.pmd.internal.util.IteratorUtil; import net.sourceforge.pmd.lang.document.TextDocument; import net.sourceforge.pmd.lang.document.TextRegion; import net.sourceforge.pmd.lang.rule.xpath.Attribute; @@ -26,6 +25,7 @@ import net.sourceforge.pmd.lang.rule.xpath.internal.CoordinateXPathFunction; import net.sourceforge.pmd.lang.xml.ast.XmlNode; import net.sourceforge.pmd.util.DataMap; import net.sourceforge.pmd.util.DataMap.DataKey; +import net.sourceforge.pmd.util.IteratorUtil; /**