repo stringlengths 1 191 ⌀ | file stringlengths 23 351 | code stringlengths 0 5.32M | file_length int64 0 5.32M | avg_line_length float64 0 2.9k | max_line_length int64 0 288k | extension_type stringclasses 1 value |
|---|---|---|---|---|---|---|
pmd | pmd-master/pmd-cli/src/test/java/net/sourceforge/pmd/cli/ForceLanguageCliTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli;
import static net.sourceforge.pmd.cli.internal.CliExitCode.OK;
import static net.sourceforge.pmd.cli.internal.CliExitCode.VIOLATIONS_FOUND;
import static net.sourceforge.pmd.util.CollectionUtil.listOf;
import java.util.List;
import org.junit.jupiter.api.Test;
class ForceLanguageCliTest extends BaseCliTest {
private static final String BASE_DIR = "src/test/resources/net/sourceforge/pmd/cli/forceLanguage/";
private static final String RULE_MESSAGE = "Violation from ReportAllRootNodes";
@Override
protected List<String> cliStandardArgs() {
return listOf(
"check",
"--no-cache",
"-f", "text",
"-R", PmdCliTest.RULESET_WITH_VIOLATION
);
}
@Test
void analyzeSingleXmlWithoutForceLanguage() throws Exception {
runCli(OK, "-d", BASE_DIR + "src/file1.ext")
.verify(r -> r.checkStdOut(containsStringNTimes(0, RULE_MESSAGE)));
}
@Test
void analyzeSingleXmlWithForceLanguage() throws Exception {
runCli(VIOLATIONS_FOUND, "-d", BASE_DIR + "src/file1.ext", "--force-language", "dummy")
.verify(r -> r.checkStdOut(containsStringNTimes(1, RULE_MESSAGE)));
}
@Test
void analyzeDirectoryWithForceLanguage() throws Exception {
runCli(VIOLATIONS_FOUND, "-d", BASE_DIR + "src/", "--force-language", "dummy")
.verify(r -> r.checkStdOut(containsStringNTimes(3, RULE_MESSAGE)));
}
}
| 1,576 | 30.54 | 103 | java |
pmd | pmd-master/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/BaseCommandTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.internal;
import static org.hamcrest.MatcherAssert.assertThat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.hamcrest.Matchers;
import picocli.CommandLine;
import picocli.CommandLine.ParseResult;
abstract class BaseCommandTest<T> {
protected abstract T createCommand();
protected abstract void addStandardParams(List<String> argList);
protected void assertError(final String... params) {
final T cmd = createCommand();
final ParseResult parseResult = parseCommand(cmd, params);
assertThat(parseResult.errors(), Matchers.not(Matchers.empty()));
}
protected T setupAndParse(final String... params) {
final T cmd = createCommand();
final ParseResult parseResult = parseCommand(cmd, params);
assertThat(parseResult.errors(), Matchers.empty());
return cmd;
}
private ParseResult parseCommand(final Object cmd, final String... params) {
final List<String> argList = new ArrayList<>();
argList.addAll(Arrays.asList(params));
addStandardParams(argList);
final CommandLine commandLine = new CommandLine(cmd)
.setCaseInsensitiveEnumValuesAllowed(true);
// Collect errors instead of simply throwing during parsing
commandLine.getCommandSpec().parser().collectErrors(true);
return commandLine.parseArgs(argList.toArray(new String[0]));
}
}
| 1,600 | 28.109091 | 80 | java |
pmd | pmd-master/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/PmdCommandTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.internal;
import static net.sourceforge.pmd.util.CollectionUtil.listOf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.nio.file.Path;
import java.util.List;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.PMDConfiguration;
import net.sourceforge.pmd.lang.DummyLanguageModule;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.util.CollectionUtil;
class PmdCommandTest extends BaseCommandTest<PmdCommand> {
@Test
void testVersionGiven() throws Exception {
final PmdCommand cmd = setupAndParse("--use-version", "dummy-1.2", "-d", "a", "-R", "x.xml");
final LanguageVersion dummyLatest = cmd.toConfiguration().getLanguageVersionOfFile("foo.dummy");
// LanguageVersion do not implement equals, but we can check their string representations
assertEquals(DummyLanguageModule.getInstance().getVersion("1.2").toString(), dummyLatest.toString());
}
@Test
void testMultipleDirsAndRuleSets() {
final PmdCommand cmd = setupAndParse(
"-d", "a", "b", "-R", "x.xml", "y.xml"
);
assertMultipleDirsAndRulesets(cmd);
}
@Test
void testMultipleDirsAndRuleSetsWithCommas() {
final PmdCommand cmd = setupAndParse(
"-d", "a,b", "-R", "x.xml,y.xml"
);
assertMultipleDirsAndRulesets(cmd);
}
@Test
void testMultipleDirsAndRuleSetsWithRepeatedOption() {
final PmdCommand cmd = setupAndParse(
"-d", "a", "-d", "b", "-R", "x.xml", "-R", "y.xml"
);
assertMultipleDirsAndRulesets(cmd);
}
@Test
void testNoPositionalParametersAllowed() {
final PmdCommand cmd = setupAndParse(
"-R", "x.xml", "-R", "y.xml", "-d", "a", "--", "b"
);
assertMultipleDirsAndRulesets(cmd);
}
@Test
void testEmptyDirOption() {
assertError("-d", "-R", "y.xml");
}
@Test
void testEmptyRulesetOption() {
assertError("-R", "-d", "something");
}
private void assertMultipleDirsAndRulesets(final PmdCommand result) {
final PMDConfiguration config = result.toConfiguration();
assertEquals(listOf("a", "b"), CollectionUtil.map(config.getInputPathList(), Path::toString));
assertEquals(listOf("x.xml", "y.xml"), config.getRuleSetPaths());
}
@Override
protected PmdCommand createCommand() {
return new PmdCommand();
}
@Override
protected void addStandardParams(final List<String> argList) {
// If no language provided, set dummy latest
if (!argList.contains("--use-version")) {
argList.add(0, "--use-version");
argList.add(1, "dummy-1.0");
}
}
}
| 2,887 | 30.053763 | 109 | java |
pmd | pmd-master/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/CpdCommandTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.internal;
import static net.sourceforge.pmd.util.CollectionUtil.listOf;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.cpd.CPDConfiguration;
class CpdCommandTest extends BaseCommandTest<CpdCommand> {
@Test
void testMultipleDirs() {
final CpdCommand cmd = setupAndParse(
"-d", "a", "b"
);
assertMultipleDirs(cmd);
}
@Test
void testMultipleDirsWithCommas() {
final CpdCommand cmd = setupAndParse(
"-d", "a,b"
);
assertMultipleDirs(cmd);
}
@Test
void testMultipleDirsWithRepeatedOption() {
final CpdCommand cmd = setupAndParse(
"-d", "a", "-d", "b"
);
assertMultipleDirs(cmd);
}
@Test
void testNoPositionalParametersAllowed() {
final CpdCommand cmd = setupAndParse(
"-d", "a", "--", "b"
);
assertMultipleDirs(cmd);
}
@Test
void testEmptyDirOption() {
assertError("-d", "-f", "text");
}
private void assertMultipleDirs(final CpdCommand result) {
final CPDConfiguration config = result.toConfiguration();
assertEquals(listOf("a", "b"), config.getFiles().stream().map(File::toString).collect(Collectors.toList()));
}
@Override
protected CpdCommand createCommand() {
return new CpdCommand();
}
@Override
protected void addStandardParams(final List<String> argList) {
// If no minimum tokens provided, set default value
if (!argList.contains("--minimum-tokens")) {
argList.add(0, "--minimum-tokens");
argList.add(1, "100");
}
}
}
| 1,937 | 24.5 | 116 | java |
pmd | pmd-master/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/cpd/encodingTest/File2.java | public class File2 {
public void dup() {
for (int j = 0; j < 10; j++) {
System.out.println(j + "ä");
}
}
} | 142 | 19.428571 | 40 | java |
pmd | pmd-master/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/cpd/encodingTest/File1.java | public class File1 {
public void dup() {
for (int i = 0; i < 10; i++) {
System.out.println(i + "ä");
}
}
} | 142 | 19.428571 | 40 | java |
pmd | pmd-master/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/cpd/badandgood/GoodFile2.java | public class GoodFile2 {
public void foo() {
int abc = 1;
}
} | 77 | 14.6 | 24 | java |
pmd | pmd-master/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/cpd/badandgood/BadFile.java | public class BadFile {
public void foo() {
// this is a bad character � it's U+FFFD REPLACEMENT CHARACTER
int a�b = 1;
}
} | 146 | 23.5 | 70 | java |
pmd | pmd-master/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/cpd/badandgood/GoodFile.java | public class GoodFile {
public void foo() {
int abc = 1;
}
} | 76 | 14.4 | 23 | java |
pmd | pmd-master/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/cpd/files/dup1.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
public class dup1 {
public static void main(String[] args) {
System.out.println("Test1");
System.out.println("Test2");
System.out.println("Test3");
System.out.println("Test4");
System.out.println("Test5");
System.out.println("Test6");
System.out.println("Test7");
System.out.println("Test8");
System.out.println("Test9");
}
} | 495 | 26.555556 | 79 | java |
pmd | pmd-master/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/cpd/files/file_with_ISO-8859-1_encoding.java | /**
* This file is using ISO-8859-1 (Latin-1) encoding.
*
* (this is an a-umlaut U+00E4)
*/
public class FileWith_ISO8859-1_Encoding {
}
| 143 | 15 | 52 | java |
pmd | pmd-master/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/cpd/files/file_with_utf8_bom.java | /**
* This file is using UTF-8 with BOM encoding.
*
* ä (this is an a-umlaut U+00E4)
*/
public class FileWith_UTF-8-BOM_Encoding {
}
| 139 | 14.555556 | 46 | java |
pmd | pmd-master/pmd-cli/src/test/resources/net/sourceforge/pmd/cli/cpd/files/dup2.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
public class dup2 {
public static void main(String[] args) {
System.out.println("Test1");
System.out.println("Test2");
System.out.println("Test3");
System.out.println("Test4");
System.out.println("Test5");
System.out.println("Test6");
System.out.println("Test7");
System.out.println("Test8");
System.out.println("Test9");
}
} | 495 | 26.555556 | 79 | java |
pmd | pmd-master/pmd-cli/src/main/java/me/tongfei/progressbar/PmdProgressBarFriend.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package me.tongfei.progressbar;
import static me.tongfei.progressbar.TerminalUtils.CARRIAGE_RETURN;
import java.io.PrintStream;
/**
* This is a friend class for me.tongfei.progressbar, as TerminalUtils is package-private.
*/
public final class PmdProgressBarFriend {
private PmdProgressBarFriend() {
throw new AssertionError("Can't instantiate utility classes");
}
public static ConsoleProgressBarConsumer createConsoleConsumer(PrintStream ps) {
return TerminalUtils.hasCursorMovementSupport()
? new InteractiveConsoleProgressBarConsumer(ps)
: new PostCarriageReturnConsoleProgressBarConsumer(ps);
}
private static class PostCarriageReturnConsoleProgressBarConsumer extends ConsoleProgressBarConsumer {
PostCarriageReturnConsoleProgressBarConsumer(PrintStream out) {
super(out);
}
@Override
public void accept(String str) {
// Set the carriage return at the end instead of at the beginning
out.print(StringDisplayUtils.trimDisplayLength(str, getMaxRenderedLength()) + CARRIAGE_RETURN);
}
@Override
public void clear() {
// do nothing (prints an empty line otherwise)
}
}
}
| 1,365 | 30.045455 | 107 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/PmdCli.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli;
import net.sourceforge.pmd.cli.commands.internal.PmdRootCommand;
import picocli.CommandLine;
public final class PmdCli {
private PmdCli() { }
public static void main(String[] args) {
final int exitCode = new CommandLine(new PmdRootCommand())
.setCaseInsensitiveEnumValuesAllowed(true)
.execute(args);
System.exit(exitCode);
}
}
| 515 | 22.454545 | 79 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/PmdLanguageTypeSupport.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.typesupport.internal;
import java.util.Iterator;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageRegistry;
import picocli.CommandLine.ITypeConverter;
import picocli.CommandLine.TypeConversionException;
/**
* Provider of candidates / conversion support for supported PMD languages.
*
* Beware, the help will report this on runtime, and be accurate to available
* modules in the classpath, but autocomplete will include all available at build time.
*/
public class PmdLanguageTypeSupport implements ITypeConverter<Language>, Iterable<String> {
@Override
public Language convert(final String value) throws Exception {
return LanguageRegistry.PMD.getLanguages().stream()
.filter(l -> l.getTerseName().equals(value)).findFirst()
.orElseThrow(() -> new TypeConversionException("Unknown language: " + value));
}
@Override
public Iterator<String> iterator() {
return LanguageRegistry.PMD.getLanguages().stream().map(Language::getTerseName).iterator();
}
}
| 1,196 | 33.2 | 99 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/CpdLanguageTypeSupport.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.typesupport.internal;
import java.util.Arrays;
import java.util.Iterator;
import net.sourceforge.pmd.cpd.Language;
import net.sourceforge.pmd.cpd.LanguageFactory;
import picocli.CommandLine.ITypeConverter;
/**
* Provider of candidates / conversion support for supported CPD languages.
*
* Beware, the help will report this on runtime, and be accurate to available
* modules in the classpath, but autocomplete will include all available at build time.
*/
public class CpdLanguageTypeSupport implements ITypeConverter<Language>, Iterable<String> {
@Override
public Iterator<String> iterator() {
return Arrays.stream(LanguageFactory.supportedLanguages).iterator();
}
@Override
public Language convert(final String languageString) {
// TODO : If an unknown value is passed, AnyLanguage is returned silently…
return LanguageFactory.createLanguage(languageString);
}
}
| 1,057 | 30.117647 | 91 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.typesupport.internal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.sourceforge.pmd.RulePriority;
import picocli.CommandLine.ITypeConverter;
import picocli.CommandLine.TypeConversionException;
public class RulePriorityTypeSupport implements ITypeConverter<RulePriority>, Iterable<String> {
@Override
public RulePriority convert(String value) {
for (RulePriority rulePriority : RulePriority.values()) {
String descriptiveName = rulePriority.getName();
String name = rulePriority.name();
String priority = String.valueOf(rulePriority.getPriority());
if (descriptiveName.equalsIgnoreCase(value) || name.equalsIgnoreCase(value) || priority.equalsIgnoreCase(value)) {
return rulePriority;
}
}
throw new TypeConversionException("Invalid priority: " + value);
}
@Override
public Iterator<String> iterator() {
List<String> completionValues = new ArrayList<>();
for (RulePriority rulePriority : RulePriority.values()) {
completionValues.add(rulePriority.name());
}
return completionValues.iterator();
}
}
| 1,341 | 33.410256 | 126 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/PmdLanguageVersionTypeSupport.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.typesupport.internal;
import java.util.Iterator;
import java.util.Objects;
import java.util.TreeSet;
import java.util.stream.Collectors;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.LanguageVersion;
import picocli.CommandLine.ITypeConverter;
import picocli.CommandLine.TypeConversionException;
/**
* Provider of candidates for valid language-version combinations.
*
* Beware, the help will report this on runtime, and be accurate to available
* modules in the classpath, but autocomplete will include all available at build time.
*/
public class PmdLanguageVersionTypeSupport implements ITypeConverter<LanguageVersion>, Iterable<String> {
@Override
public Iterator<String> iterator() {
// Explicit language-version pairs, such as "java-18" or "apex-54".
// We build these directly to retain aliases. "java-8" works, but the canonical name for the LanguageVersion is java-1.8
return LanguageRegistry.PMD.getLanguages().stream()
.flatMap(l -> l.getVersionNamesAndAliases().stream().map(v -> l.getTerseName() + "-" + v))
.collect(Collectors.toCollection(TreeSet::new)).iterator();
}
@Override
public LanguageVersion convert(final String value) throws Exception {
return LanguageRegistry.PMD.getLanguages().stream()
.filter(l -> value.startsWith(l.getTerseName() + "-"))
.map(l -> l.getVersion(value.substring(l.getTerseName().length() + 1)))
.filter(Objects::nonNull)
.findFirst()
.orElseThrow(() -> new TypeConversionException("Unknown language version: " + value));
}
}
| 1,796 | 38.933333 | 128 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/mixins/internal/EncodingMixin.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.mixins.internal;
import java.nio.charset.Charset;
import picocli.CommandLine.Option;
/**
* A mixin for source code encoding. Used to ensure consistency among commands.
*/
public class EncodingMixin {
@Option(names = { "--encoding", "-e" }, description = "Specifies the character set encoding of the source code files",
defaultValue = "UTF-8")
private Charset encoding;
public Charset getEncoding() {
return encoding;
}
}
| 594 | 23.791667 | 122 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdCommand.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.internal;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.sourceforge.pmd.PMDConfiguration;
import net.sourceforge.pmd.PmdAnalysis;
import net.sourceforge.pmd.RulePriority;
import net.sourceforge.pmd.benchmark.TextTimingReportRenderer;
import net.sourceforge.pmd.benchmark.TimeTracker;
import net.sourceforge.pmd.benchmark.TimingReport;
import net.sourceforge.pmd.benchmark.TimingReportRenderer;
import net.sourceforge.pmd.cli.commands.typesupport.internal.PmdLanguageTypeSupport;
import net.sourceforge.pmd.cli.commands.typesupport.internal.PmdLanguageVersionTypeSupport;
import net.sourceforge.pmd.cli.commands.typesupport.internal.RulePriorityTypeSupport;
import net.sourceforge.pmd.cli.internal.CliExitCode;
import net.sourceforge.pmd.cli.internal.ProgressBarListener;
import net.sourceforge.pmd.internal.LogMessages;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.properties.PropertyDescriptor;
import net.sourceforge.pmd.renderers.Renderer;
import net.sourceforge.pmd.renderers.RendererFactory;
import net.sourceforge.pmd.reporting.ReportStats;
import net.sourceforge.pmd.util.StringUtil;
import net.sourceforge.pmd.util.log.MessageReporter;
import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.ParameterException;
@Command(name = "check", showDefaultValues = true,
description = "The PMD standard source code analyzer")
public class PmdCommand extends AbstractAnalysisPmdSubcommand {
private static final Logger LOG = LoggerFactory.getLogger(PmdCommand.class);
static {
final Properties emptyProps = new Properties();
final StringBuilder reportPropertiesHelp = new StringBuilder();
final String lineSeparator = System.lineSeparator();
for (final String rendererName : RendererFactory.supportedRenderers()) {
final Renderer renderer = RendererFactory.createRenderer(rendererName, emptyProps);
if (!renderer.getPropertyDescriptors().isEmpty()) {
reportPropertiesHelp.append(rendererName + ":" + lineSeparator);
for (final PropertyDescriptor<?> property : renderer.getPropertyDescriptors()) {
reportPropertiesHelp.append(" ").append(property.name()).append(" - ")
.append(property.description()).append(lineSeparator);
final Object deflt = property.defaultValue();
if (deflt != null && !"".equals(deflt)) {
reportPropertiesHelp.append(" Default: ").append(deflt)
.append(lineSeparator);
}
}
}
}
// System Properties are the easier way to inject dynamically computed values into the help of an option
System.setProperty("pmd-cli.pmd.report.properties.help", reportPropertiesHelp.toString());
}
private List<String> rulesets;
private Path ignoreListPath;
private String format;
private int threads;
private boolean benchmark;
private List<Path> relativizeRootPaths;
private boolean showSuppressed;
private String suppressMarker;
private RulePriority minimumPriority;
private Properties properties = new Properties();
private Path reportFile;
private List<LanguageVersion> languageVersion;
private Language forceLanguage;
private String auxClasspath;
private boolean noRuleSetCompatibility;
private Path cacheLocation;
private boolean noCache;
private boolean showProgressBar;
@Option(names = { "--rulesets", "-R" },
description = "Path to a ruleset xml file. "
+ "The path may reference a resource on the classpath of the application, be a local file system path, or a URL. "
+ "The option can be repeated, and multiple arguments separated by comma can be provided to a single occurrence of the option.",
required = true, split = ",", arity = "1..*")
public void setRulesets(final List<String> rulesets) {
this.rulesets = rulesets;
}
@Option(names = "--ignore-list",
description = "Path to a file containing a list of files to exclude from the analysis, one path per line. "
+ "This option can be combined with --dir, --file-list and --uri.")
public void setIgnoreListPath(final Path ignoreListPath) {
this.ignoreListPath = ignoreListPath;
}
@Option(names = { "--format", "-f" },
description = "Report format.%nValid values: ${COMPLETION-CANDIDATES}%n"
+ "Alternatively, you can provide the fully qualified name of a custom Renderer in the classpath.",
defaultValue = "text", completionCandidates = PmdSupportedReportFormatsCandidates.class)
public void setFormat(final String format) {
this.format = format;
}
@Option(names = { "--benchmark", "-b" },
description = "Benchmark mode - output a benchmark report upon completion; default to System.err.")
public void setBenchmark(final boolean benchmark) {
this.benchmark = benchmark;
}
@Option(names = { "--relativize-paths-with", "-z"}, description = "Path relative to which directories are rendered in the report. "
+ "This option allows shortening directories in the report; "
+ "without it, paths are rendered as mentioned in the source directory (option \"--dir\"). "
+ "The option can be repeated, in which case the shortest relative path will be used. "
+ "If the root path is mentioned (e.g. \"/\" or \"C:\\\"), then the paths will be rendered as absolute.",
arity = "1..*", split = ",")
public void setRelativizePathsWith(List<Path> rootPaths) {
this.relativizeRootPaths = rootPaths;
for (Path path : this.relativizeRootPaths) {
if (Files.isRegularFile(path)) {
throw new ParameterException(spec.commandLine(),
"Expected a directory path for option '--relativize-paths-with', found a file: " + path);
}
}
}
@Option(names = "--show-suppressed", description = "Report should show suppressed rule violations.")
public void setShowSuppressed(final boolean showSuppressed) {
this.showSuppressed = showSuppressed;
}
@Option(names = "--suppress-marker",
description = "Specifies the string that marks a line which PMD should ignore.",
defaultValue = "NOPMD")
public void setSuppressMarker(final String suppressMarker) {
this.suppressMarker = suppressMarker;
}
@Option(names = "--minimum-priority",
description = "Rule priority threshold; rules with lower priority than configured here won't be used.%n"
+ "Valid values (case insensitive): ${COMPLETION-CANDIDATES}",
defaultValue = "Low",
completionCandidates = RulePriorityTypeSupport.class, converter = RulePriorityTypeSupport.class)
public void setMinimumPriority(final RulePriority priority) {
this.minimumPriority = priority;
}
@Option(names = { "--property", "-P" }, description = "Key-value pair defining a property for the report format.%n"
+ "Supported values for each report format:%n${sys:pmd-cli.pmd.report.properties.help}",
completionCandidates = PmdReportPropertiesCandidates.class)
public void setProperties(final Properties properties) {
this.properties = properties;
}
@Option(names = { "--report-file", "-r" },
description = "Path to a file to which report output is written. "
+ "The file is created if it does not exist. "
+ "If this option is not specified, the report is rendered to standard output.")
public void setReportFile(final Path reportFile) {
this.reportFile = reportFile;
}
@Option(names = "--use-version",
description = "The language version PMD should use when parsing source code.%nValid values: ${COMPLETION-CANDIDATES}",
completionCandidates = PmdLanguageVersionTypeSupport.class, converter = PmdLanguageVersionTypeSupport.class)
public void setLanguageVersion(final List<LanguageVersion> languageVersion) {
// Make sure we only set 1 version per language
languageVersion.stream().collect(Collectors.groupingBy(LanguageVersion::getLanguage))
.forEach((l, list) -> {
if (list.size() > 1) {
throw new ParameterException(spec.commandLine(), "Can only set one version per language, "
+ "but for language " + l.getName() + " multiple versions were provided "
+ list.stream().map(LanguageVersion::getTerseName).collect(Collectors.joining("', '", "'", "'")));
}
});
this.languageVersion = languageVersion;
}
@Option(names = "--force-language",
description = "Force a language to be used for all input files, irrespective of file names. "
+ "When using this option, the automatic language selection by extension is disabled, and PMD "
+ "tries to parse all input files with the given language's parser. "
+ "Parsing errors are ignored.%nValid values: ${COMPLETION-CANDIDATES}",
completionCandidates = PmdLanguageTypeSupport.class, converter = PmdLanguageTypeSupport.class)
public void setForceLanguage(final Language forceLanguage) {
this.forceLanguage = forceLanguage;
}
@Option(names = "--aux-classpath",
description = "Specifies the classpath for libraries used by the source code. "
+ "This is used to resolve types in Java source files. The platform specific path delimiter "
+ "(\":\" on Linux, \";\" on Windows) is used to separate the entries. "
+ "Alternatively, a single 'file:' URL to a text file containing path elements on consecutive lines "
+ "can be specified.")
public void setAuxClasspath(final String auxClasspath) {
this.auxClasspath = auxClasspath;
}
@Option(names = "--no-ruleset-compatibility",
description = "Disable the ruleset compatibility filter. The filter is active by default and tries automatically 'fix' old ruleset files with old rule names")
public void setNoRuleSetCompatibility(final boolean noRuleSetCompatibility) {
this.noRuleSetCompatibility = noRuleSetCompatibility;
}
@Option(names = "--cache",
description = "Specify the location of the cache file for incremental analysis. "
+ "This should be the full path to the file, including the desired file name (not just the parent directory). "
+ "If the file doesn't exist, it will be created on the first run. The file will be overwritten on each run "
+ "with the most up-to-date rule violations.")
public void setCacheLocation(final Path cacheLocation) {
this.cacheLocation = cacheLocation;
}
@Option(names = "--no-cache", description = "Explicitly disable incremental analysis. The '-cache' option is ignored if this switch is present in the command line.")
public void setNoCache(final boolean noCache) {
this.noCache = noCache;
}
@Option(names = { "--threads", "-t" }, description = "Sets the number of threads used by PMD.",
defaultValue = "1")
public void setThreads(final int threads) {
if (threads < 0) {
throw new ParameterException(spec.commandLine(), "Thread count should be a positive number or zero, found " + threads + " instead.");
}
this.threads = threads;
}
@Option(names = "--no-progress", negatable = true, defaultValue = "true",
description = "Enables / disables progress bar indicator of live analysis progress.")
public void setShowProgressBar(final boolean showProgressBar) {
this.showProgressBar = showProgressBar;
}
/**
* Converts these parameters into a configuration.
*
* @return A new PMDConfiguration corresponding to these parameters
*
* @throws ParameterException if the parameters are inconsistent or incomplete
*/
public PMDConfiguration toConfiguration() {
final PMDConfiguration configuration = new PMDConfiguration();
if (inputPaths != null) {
configuration.setInputPathList(inputPaths);
}
configuration.setInputFilePath(fileListPath);
configuration.setIgnoreFilePath(ignoreListPath);
configuration.setInputUri(uri);
configuration.setReportFormat(format);
configuration.setSourceEncoding(encoding.getEncoding().name());
configuration.setMinimumPriority(minimumPriority);
configuration.setReportFile(reportFile);
configuration.setReportProperties(properties);
if (relativizeRootPaths != null) {
configuration.addRelativizeRoots(relativizeRootPaths);
}
configuration.setRuleSets(rulesets);
configuration.setRuleSetFactoryCompatibilityEnabled(!this.noRuleSetCompatibility);
configuration.setShowSuppressedViolations(showSuppressed);
configuration.setSuppressMarker(suppressMarker);
configuration.setThreads(threads);
configuration.setFailOnViolation(failOnViolation);
configuration.setAnalysisCacheLocation(cacheLocation != null ? cacheLocation.toString() : null);
configuration.setIgnoreIncrementalAnalysis(noCache);
if (languageVersion != null) {
configuration.setDefaultLanguageVersions(languageVersion);
}
// Important: do this after setting default versions, so we can pick them up
if (forceLanguage != null) {
final LanguageVersion forcedLangVer = configuration.getLanguageVersionDiscoverer()
.getDefaultLanguageVersion(forceLanguage);
configuration.setForceLanguageVersion(forcedLangVer);
}
// Setup CLI message reporter
configuration.setReporter(new SimpleMessageReporter(LoggerFactory.getLogger(PmdCommand.class)));
try {
configuration.prependAuxClasspath(auxClasspath);
} catch (IllegalArgumentException e) {
throw new ParameterException(spec.commandLine(), "Invalid auxiliary classpath: " + e.getMessage(), e);
}
return configuration;
}
@Override
protected CliExitCode execute() {
if (benchmark) {
TimeTracker.startGlobalTracking();
}
final PMDConfiguration configuration = toConfiguration();
final MessageReporter pmdReporter = configuration.getReporter();
try {
PmdAnalysis pmd = null;
try {
try {
pmd = PmdAnalysis.create(configuration);
} catch (final Exception e) {
pmdReporter.errorEx("Could not initialize analysis", e);
return CliExitCode.ERROR;
}
LOG.debug("Current classpath:\n{}", System.getProperty("java.class.path"));
if (showProgressBar) {
if (reportFile == null) {
pmdReporter.warn("Progressbar rendering conflicts with reporting to STDOUT. "
+ "No progressbar will be shown. Try running with argument '-r <file>' to output the report to a file instead.");
} else {
pmd.addListener(new ProgressBarListener());
}
}
final ReportStats stats = pmd.runAndReturnStats();
if (pmdReporter.numErrors() > 0) {
// processing errors are ignored
return CliExitCode.ERROR;
} else if (stats.getNumViolations() > 0 && configuration.isFailOnViolation()) {
return CliExitCode.VIOLATIONS_FOUND;
} else {
return CliExitCode.OK;
}
} finally {
if (pmd != null) {
pmd.close();
}
}
} catch (final Exception e) {
pmdReporter.errorEx("Exception while running PMD.", e);
printErrorDetected(pmdReporter, 1);
return CliExitCode.ERROR;
} finally {
finishBenchmarker(pmdReporter);
}
}
private void printErrorDetected(MessageReporter reporter, int errors) {
String msg = LogMessages.errorDetectedMessage(errors, "pmd");
// note: using error level here increments the error count of the reporter,
// which we don't want.
reporter.info(StringUtil.quoteMessageFormat(msg));
}
private void finishBenchmarker(final MessageReporter pmdReporter) {
if (benchmark) {
final TimingReport timingReport = TimeTracker.stopGlobalTracking();
// TODO get specified report format from config
final TimingReportRenderer renderer = new TextTimingReportRenderer();
try {
// No try-with-resources, do not want to close STDERR
@SuppressWarnings("PMD.CloseResource")
final Writer writer = new OutputStreamWriter(System.err);
renderer.render(timingReport, writer);
} catch (final IOException e) {
pmdReporter.errorEx("Error producing benchmark report", e);
}
}
}
/**
* Provider of candidates for valid report formats.
*/
private static final class PmdSupportedReportFormatsCandidates implements Iterable<String> {
@Override
public Iterator<String> iterator() {
return RendererFactory.supportedRenderers().iterator();
}
}
/**
* Provider of candidates for valid report properties.
*
* Check the help for which ones are supported by each report format and possible values.
*/
private static final class PmdReportPropertiesCandidates implements Iterable<String> {
@Override
public Iterator<String> iterator() {
final List<String> propertyNames = new ArrayList<>();
final Properties emptyProps = new Properties();
for (final String rendererName : RendererFactory.supportedRenderers()) {
final Renderer renderer = RendererFactory.createRenderer(rendererName, emptyProps);
for (final PropertyDescriptor<?> property : renderer.getPropertyDescriptors()) {
propertyNames.add(property.name());
}
}
return propertyNames.iterator();
}
}
}
| 19,575 | 43.796339 | 170 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdRootCommand.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.internal;
import net.sourceforge.pmd.PMDVersion;
import picocli.CommandLine.Command;
import picocli.CommandLine.IVersionProvider;
@Command(name = "pmd", mixinStandardHelpOptions = true,
versionProvider = PMDVersionProvider.class,
exitCodeListHeading = "Exit Codes:%n",
exitCodeList = { "0:Successful analysis, no violations found", "1:An unexpected error occurred during execution",
"2:Usage error, please refer to the command help", "4:Successful analysis, at least 1 violation found" },
subcommands = { PmdCommand.class, CpdCommand.class, DesignerCommand.class, CpdGuiCommand.class, TreeExportCommand.class })
public class PmdRootCommand {
}
class PMDVersionProvider implements IVersionProvider {
@Override
public String[] getVersion() throws Exception {
return new String[] { "PMD " + PMDVersion.VERSION };
}
}
| 994 | 33.310345 | 126 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/TreeExportCommand.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.internal;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import org.slf4j.LoggerFactory;
import net.sourceforge.pmd.cli.commands.mixins.internal.EncodingMixin;
import net.sourceforge.pmd.cli.commands.typesupport.internal.PmdLanguageTypeSupport;
import net.sourceforge.pmd.cli.internal.CliExitCode;
import net.sourceforge.pmd.internal.LogMessages;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.properties.PropertyDescriptor;
import net.sourceforge.pmd.properties.PropertySource;
import net.sourceforge.pmd.util.StringUtil;
import net.sourceforge.pmd.util.log.internal.SimpleMessageReporter;
import net.sourceforge.pmd.util.treeexport.TreeExportConfiguration;
import net.sourceforge.pmd.util.treeexport.TreeExporter;
import net.sourceforge.pmd.util.treeexport.TreeRendererDescriptor;
import net.sourceforge.pmd.util.treeexport.TreeRenderers;
import picocli.CommandLine.Command;
import picocli.CommandLine.Mixin;
import picocli.CommandLine.Option;
import picocli.CommandLine.ParameterException;
@Command(name = "ast-dump", description = "Experimental: dumps the AST of parsing source code")
public class TreeExportCommand extends AbstractPmdSubcommand {
static {
final StringBuilder reportPropertiesHelp = new StringBuilder();
final String lineSeparator = System.lineSeparator();
for (final TreeRendererDescriptor renderer : TreeRenderers.registeredRenderers()) {
final PropertySource propertyBundle = renderer.newPropertyBundle();
if (!propertyBundle.getPropertyDescriptors().isEmpty()) {
reportPropertiesHelp.append(renderer.id() + ":" + lineSeparator);
for (final PropertyDescriptor<?> property : propertyBundle.getPropertyDescriptors()) {
reportPropertiesHelp.append(" ").append(property.name()).append(" - ")
.append(property.description()).append(lineSeparator);
final Object deflt = property.defaultValue();
if (deflt != null && !"".equals(deflt)) {
reportPropertiesHelp.append(" Default: ").append(StringUtil.escapeWhitespace(deflt))
.append(lineSeparator);
}
}
}
}
// System Properties are the easier way to inject dynamically computed values into the help of an option
System.setProperty("pmd-cli.tree-export.report.properties.help", reportPropertiesHelp.toString());
}
@Mixin
private EncodingMixin encoding;
@Option(names = { "--format", "-f" }, defaultValue = "xml",
description = "The output format.%nValid values: ${COMPLETION-CANDIDATES}",
completionCandidates = TreeRenderersCandidates.class)
private String format;
@Option(names = { "--language", "-l" }, defaultValue = "java",
description = "The source code language.%nValid values: ${COMPLETION-CANDIDATES}",
completionCandidates = PmdLanguageTypeSupport.class, converter = PmdLanguageTypeSupport.class)
private Language language;
@Option(names = "-P", description = "Key-value pair defining a property for the report format.%n"
+ "Supported values for each report format:%n${sys:pmd-cli.tree-export.report.properties.help}",
completionCandidates = TreeExportReportPropertiesCandidates.class)
private Properties properties = new Properties();
@Option(names = "--file", description = "The file to parse and dump.")
private Path file;
@Option(names = { "--read-stdin", "-i" }, description = "Read source from standard input.")
private boolean readStdin;
public TreeExportConfiguration toConfiguration() {
final TreeExportConfiguration configuration = new TreeExportConfiguration();
configuration.setFile(file);
configuration.setFormat(format);
configuration.setLanguage(language);
configuration.setProperties(properties);
configuration.setReadStdin(readStdin);
configuration.setSourceEncoding(encoding.getEncoding().name());
return configuration;
}
@Override
protected void validate() throws ParameterException {
super.validate();
if (file == null && !readStdin) {
throw new ParameterException(spec.commandLine(), "One of --file or --read-stdin must be used.");
}
}
@Override
protected CliExitCode execute() {
final TreeExporter exporter = new TreeExporter(toConfiguration());
try {
exporter.export();
return CliExitCode.OK;
} catch (final IOException e) {
final SimpleMessageReporter reporter = new SimpleMessageReporter(LoggerFactory.getLogger(TreeExportCommand.class));
reporter.error(e, LogMessages.errorDetectedMessage(1, "ast-dump"));
return CliExitCode.ERROR;
}
}
/**
* Provides completion candidates for the report format.
*/
private static final class TreeRenderersCandidates implements Iterable<String> {
@Override
public Iterator<String> iterator() {
return TreeRenderers.registeredRenderers().stream().map(TreeRendererDescriptor::id).iterator();
}
}
/**
* Provider of candidates for valid report properties.
*
* Check the help for which ones are supported by each report format and possible values.
*/
private static final class TreeExportReportPropertiesCandidates implements Iterable<String> {
@Override
public Iterator<String> iterator() {
final List<String> propertyNames = new ArrayList<>();
for (final TreeRendererDescriptor renderer : TreeRenderers.registeredRenderers()) {
final PropertySource propertyBundle = renderer.newPropertyBundle();
for (final PropertyDescriptor<?> property : propertyBundle.getPropertyDescriptors()) {
propertyNames.add(property.name());
}
}
return propertyNames.iterator();
}
}
}
| 6,439 | 41.091503 | 127 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdGuiCommand.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.internal;
import net.sourceforge.pmd.cpd.GUI;
import picocli.CommandLine.Command;
@Command(name = "cpd-gui",
description = "GUI for the Copy/Paste Detector%n Warning: May not support the full CPD feature set")
public class CpdGuiCommand implements Runnable {
@Override
public void run() {
new GUI();
}
}
| 464 | 21.142857 | 105 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/AbstractPmdSubcommand.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.internal;
import java.util.concurrent.Callable;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;
import net.sourceforge.pmd.cli.internal.CliExitCode;
import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Option;
import picocli.CommandLine.ParameterException;
import picocli.CommandLine.Spec;
public abstract class AbstractPmdSubcommand implements Callable<Integer> {
@Spec
protected CommandSpec spec; // injected by PicoCli, needed for validations
@Option(names = { "-h", "--help" }, usageHelp = true, description = "Show this help message and exit.")
protected boolean helpRequested;
@Option(names = { "--debug", "--verbose", "-D", "-v" }, description = "Debug mode.")
protected boolean debug;
@Override
public final Integer call() throws Exception {
setupCliLogger();
validate();
return execute().getExitCode();
}
/**
* Extension point to validate provided configuration.
*
* Implementations must throw {@code ParameterException} upon a violation.
*
* @throws ParameterException
*/
protected void validate() throws ParameterException {
// no-op, children may override
}
protected abstract CliExitCode execute();
private void setupCliLogger() {
// only reconfigure logging, if debug flag was used on command line
// otherwise just use whatever is in conf/simplelogger.properties which happens automatically
if (debug) {
Slf4jSimpleConfiguration.reconfigureDefaultLogLevel(Level.TRACE);
}
// always install java.util.logging to slf4j bridge
Slf4jSimpleConfiguration.installJulBridge();
// log the current log level. This is used in unit tests to verify that --debug actually works
Level defaultLogLevel = Slf4jSimpleConfiguration.getDefaultLogLevel();
LoggerFactory.getLogger(AbstractPmdSubcommand.class).info("Log level is at {}", defaultLogLevel);
}
}
| 2,200 | 32.348485 | 107 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/DesignerCommand.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.internal;
import net.sourceforge.pmd.cli.internal.CliExitCode;
import net.sourceforge.pmd.util.fxdesigner.DesignerStarter;
import net.sourceforge.pmd.util.fxdesigner.DesignerStarter.ExitStatus;
import net.sourceforge.pmd.util.fxdesigner.DesignerVersion;
import picocli.CommandLine.Command;
import picocli.CommandLine.IVersionProvider;
import picocli.CommandLine.Option;
@Command(name = "designer", showDefaultValues = true,
versionProvider = DesignerVersionProvider.class,
description = "The PMD visual rule designer")
public class DesignerCommand extends AbstractPmdSubcommand {
@SuppressWarnings("unused")
@Option(names = {"-V", "--version"}, versionHelp = true, description = "Print version information and exit.")
private boolean versionRequested;
@Override
protected CliExitCode execute() {
final String[] rawArgs = spec.commandLine().getParseResult().expandedArgs().toArray(new String[0]);
final ExitStatus status = DesignerStarter.launchGui(rawArgs);
return status == ExitStatus.OK ? CliExitCode.OK : CliExitCode.ERROR;
}
}
class DesignerVersionProvider implements IVersionProvider {
@Override
public String[] getVersion() throws Exception {
return new String[] { "PMD Rule Designer " + DesignerVersion.getCurrentVersion() };
}
}
| 1,456 | 33.690476 | 113 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.internal;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.sourceforge.pmd.cli.commands.typesupport.internal.CpdLanguageTypeSupport;
import net.sourceforge.pmd.cli.internal.CliExitCode;
import net.sourceforge.pmd.cpd.CPD;
import net.sourceforge.pmd.cpd.CPDConfiguration;
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.internal.util.IOUtil;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.ParameterException;
@Command(name = "cpd", showDefaultValues = true,
description = "Copy/Paste Detector - find duplicate code")
public class CpdCommand extends AbstractAnalysisPmdSubcommand {
@Option(names = { "--language", "-l" }, description = "The source code language.%nValid values: ${COMPLETION-CANDIDATES}",
defaultValue = CPDConfiguration.DEFAULT_LANGUAGE, converter = CpdLanguageTypeSupport.class, completionCandidates = CpdLanguageTypeSupport.class)
private Language language;
@Option(names = "--minimum-tokens",
description = "The minimum token length which should be reported as a duplicate.", required = true)
private int minimumTokens;
@Option(names = "--skip-duplicate-files",
description = "Ignore multiple copies of files of the same name and length in comparison.")
private boolean skipDuplicates;
@Option(names = { "--format", "-f" },
description = "Report format.%nValid values: ${COMPLETION-CANDIDATES}%n"
+ "Alternatively, you can provide the fully qualified name of a custom CpdRenderer in the classpath.",
defaultValue = CPDConfiguration.DEFAULT_RENDERER, completionCandidates = CpdSupportedReportFormatsCandidates.class)
private String rendererName;
@Option(names = "--ignore-literals",
description = "Ignore literal values such as numbers and strings when comparing text.")
private boolean ignoreLiterals;
@Option(names = "--ignore-identifiers",
description = "Ignore names of classes, methods, variables, constants, etc. when comparing text.")
private boolean ignoreIdentifiers;
@Option(names = "--ignore-annotations", description = "Ignore language annotations when comparing text.")
private boolean ignoreAnnotations;
@Option(names = "--ignore-usings", description = "Ignore using directives in C#")
private boolean ignoreUsings;
@Option(names = "--ignore-literal-sequences", description = "Ignore sequences of literals such as list initializers.")
private boolean ignoreLiteralSequences;
@Option(names = "--ignore-sequences", description = "Ignore sequences of identifiers and literals")
private boolean ignoreIdentifierAndLiteralSequences;
@Option(names = "--skip-lexical-errors",
description = "Skip files which can't be tokenized due to invalid characters, instead of aborting with an error.")
private boolean skipLexicalErrors;
@Option(names = "--no-skip-blocks",
description = "Do not skip code blocks marked with --skip-blocks-pattern (e.g. #if 0 until #endif).")
private boolean noSkipBlocks;
@Option(names = "--skip-blocks-pattern",
description = "Pattern to find the blocks to skip. Start and End pattern separated by |.",
defaultValue = Tokenizer.DEFAULT_SKIP_BLOCKS_PATTERN)
private String skipBlocksPattern;
@Option(names = "--exclude", arity = "1..*", description = "Files to be excluded from the analysis")
private List<File> excludes;
@Option(names = "--non-recursive", description = "Don't scan subdirectiories.")
private boolean nonRecursive;
/**
* Converts these parameters into a configuration.
*
* @return A new CPDConfiguration corresponding to these parameters
*
* @throws ParameterException if the parameters are inconsistent or incomplete
*/
public CPDConfiguration toConfiguration() {
final CPDConfiguration configuration = new CPDConfiguration();
configuration.setExcludes(excludes);
configuration.setFailOnViolation(failOnViolation);
configuration.setFileListPath(fileListPath == null ? null : fileListPath.toString());
configuration.setFiles(inputPaths == null ? null : inputPaths.stream().map(Path::toFile).collect(Collectors.toList()));
configuration.setIgnoreAnnotations(ignoreAnnotations);
configuration.setIgnoreIdentifiers(ignoreIdentifiers);
configuration.setIgnoreLiterals(ignoreLiterals);
configuration.setIgnoreLiteralSequences(ignoreLiteralSequences);
configuration.setIgnoreUsings(ignoreUsings);
configuration.setLanguage(language);
configuration.setMinimumTileSize(minimumTokens);
configuration.setNonRecursive(nonRecursive);
configuration.setNoSkipBlocks(noSkipBlocks);
configuration.setRendererName(rendererName);
configuration.setSkipBlocksPattern(skipBlocksPattern);
configuration.setSkipDuplicates(skipDuplicates);
configuration.setSkipLexicalErrors(skipLexicalErrors);
configuration.setSourceEncoding(encoding.getEncoding().name());
configuration.setURI(uri == null ? null : uri.toString());
configuration.postContruct();
// Pass extra parameters as System properties to allow language
// implementation to retrieve their associate values...
CPDConfiguration.setSystemProperties(configuration);
return configuration;
}
@Override
protected CliExitCode execute() {
final Logger logger = LoggerFactory.getLogger(CpdCommand.class);
// TODO : Create a new CpdAnalysis to match PmdAnalysis
final CPDConfiguration configuration = toConfiguration();
final CPD cpd = new CPD(configuration);
try {
cpd.go();
final CPDReport report = cpd.toReport();
configuration.getCPDReportRenderer().render(report, IOUtil.createWriter(Charset.defaultCharset(), null));
if (cpd.getMatches().hasNext() && configuration.isFailOnViolation()) {
return CliExitCode.VIOLATIONS_FOUND;
}
} catch (IOException | RuntimeException e) {
logger.debug(e.toString(), e);
logger.error(LogMessages.errorDetectedMessage(1, "cpd"));
return CliExitCode.ERROR;
}
return CliExitCode.OK;
}
/**
* Provider of candidates for valid report formats.
*/
private static final class CpdSupportedReportFormatsCandidates implements Iterable<String> {
@Override
public Iterator<String> iterator() {
return Arrays.stream(CPDConfiguration.getRenderers()).iterator();
}
}
}
| 7,257 | 42.202381 | 156 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/AbstractAnalysisPmdSubcommand.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.commands.internal;
import java.net.URI;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import net.sourceforge.pmd.cli.commands.mixins.internal.EncodingMixin;
import picocli.CommandLine.Mixin;
import picocli.CommandLine.Option;
import picocli.CommandLine.ParameterException;
import picocli.CommandLine.Parameters;
public abstract class AbstractAnalysisPmdSubcommand extends AbstractPmdSubcommand {
@Mixin
protected EncodingMixin encoding;
@Option(names = { "--dir", "-d" },
description = "Path to a source file, or directory containing source files to analyze. "
+ "Zip and Jar files are also supported, if they are specified directly "
+ "(archive files found while exploring a directory are not recursively expanded). "
+ "This option can be repeated, and multiple arguments can be provided to a single occurrence of the option. "
+ "One of --dir, --file-list or --uri must be provided.",
arity = "1..*", split = ",")
protected List<Path> inputPaths;
@Option(names = "--file-list",
description =
"Path to a file containing a list of files to analyze, one path per line. "
+ "One of --dir, --file-list or --uri must be provided.")
protected Path fileListPath;
@Option(names = { "--uri", "-u" },
description = "Database URI for sources. "
+ "One of --dir, --file-list or --uri must be provided.")
protected URI uri;
@Option(names = "--no-fail-on-violation",
description = "By default PMD exits with status 4 if violations are found. "
+ "Disable this option with '--no-fail-on-violation' to exit with 0 instead and just write the report.",
defaultValue = "true", negatable = true)
protected boolean failOnViolation;
@Parameters(arity = "*", description = "Path to a source file, or directory containing source files to analyze. "
+ "Equivalent to using --dir.")
public void setInputPaths(final List<Path> inputPaths) {
if (this.inputPaths == null) {
this.inputPaths = new ArrayList<>();
}
this.inputPaths.addAll(inputPaths);
}
@Override
protected final void validate() throws ParameterException {
super.validate();
if ((inputPaths == null || inputPaths.isEmpty()) && uri == null && fileListPath == null) {
throw new ParameterException(spec.commandLine(),
"Please provide a parameter for source root directory (--dir or -d), "
+ "database URI (--uri or -u), or file list path (--file-list)");
}
}
}
| 2,936 | 40.366197 | 136 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/ProgressBarListener.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.internal;
import java.util.concurrent.atomic.AtomicInteger;
import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.lang.document.TextFile;
import net.sourceforge.pmd.reporting.FileAnalysisListener;
import net.sourceforge.pmd.reporting.GlobalAnalysisListener;
import net.sourceforge.pmd.reporting.ListenerInitializer;
import me.tongfei.progressbar.PmdProgressBarFriend;
import me.tongfei.progressbar.ProgressBar;
import me.tongfei.progressbar.ProgressBarBuilder;
import me.tongfei.progressbar.ProgressBarStyle;
/**
* Collects runtime analysis statistics and displays them live on command line output.
* Toggled off through --no-progress command line argument.
*/
public final class ProgressBarListener implements GlobalAnalysisListener {
private ProgressBar progressBar;
private final AtomicInteger numErrors = new AtomicInteger(0);
private final AtomicInteger numViolations = new AtomicInteger(0);
@Override
public ListenerInitializer initializer() {
return new ListenerInitializer() {
@Override
public void setNumberOfFilesToAnalyze(int totalFiles) {
// We need to delay initialization until we know how many files there are to avoid a first bogus render
progressBar = new ProgressBarBuilder()
.setTaskName("Processing files")
.setStyle(ProgressBarStyle.ASCII)
.hideEta()
.continuousUpdate()
.setInitialMax(totalFiles)
.setConsumer(PmdProgressBarFriend.createConsoleConsumer(System.out))
.clearDisplayOnFinish()
.build();
progressBar.setExtraMessage(extraMessage());
}
};
}
/**
* Updates progress bar string and forces it to be output regardless of its update interval.
*/
private void refreshProgressBar() {
progressBar.setExtraMessage(extraMessage());
progressBar.refresh();
}
private String extraMessage() {
return String.format("Violations:%d, Errors:%d", numViolations.get(), numErrors.get());
}
@Override
public FileAnalysisListener startFileAnalysis(TextFile file) {
return new FileAnalysisListener() {
@Override
public void onRuleViolation(RuleViolation violation) {
ProgressBarListener.this.numViolations.addAndGet(1);
}
@Override
public void onSuppressedRuleViolation(Report.SuppressedViolation violation) {
/*Not handled*/
}
@Override
public void onError(Report.ProcessingError error) {
ProgressBarListener.this.numErrors.addAndGet(1);
}
@Override
public void close() {
// Refresh progress bar on file analysis end (or file was in cache)
progressBar.step();
refreshProgressBar();
}
};
}
@Override
public void close() throws Exception {
progressBar.close();
}
}
| 3,315 | 34.276596 | 119 | java |
pmd | pmd-master/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/CliExitCode.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cli.internal;
import net.sourceforge.pmd.PMDConfiguration;
/**
* The execution result of any given command.
*/
public enum CliExitCode {
/** No errors, no violations. This is exit code {@code 0}. */
OK(0),
/**
* Errors were detected, PMD may have not run to the end.
* This is exit code {@code 1}.
*/
ERROR(1),
/**
* Indicates a problem with the CLI parameters: either a required
* parameter is missing or an invalid parameter was provided.
*/
USAGE_ERROR(2),
/**
* No errors, but PMD found violations. This is exit code {@code 4}.
* This is only returned if {@link PMDConfiguration#isFailOnViolation()}
* is set (CLI flag {@code --failOnViolation}).
*/
VIOLATIONS_FOUND(4);
private final int exitCode;
CliExitCode(int exitCode) {
this.exitCode = exitCode;
}
public int getExitCode() {
return exitCode;
}
public static CliExitCode fromInt(int i) {
switch (i) {
case 0: return OK;
case 1: return ERROR;
case 2: return USAGE_ERROR;
case 4: return VIOLATIONS_FOUND;
default:
throw new IllegalArgumentException("Not a known exit code: " + i);
}
}
}
| 1,364 | 24.754717 | 79 | java |
pmd | pmd-master/pmd-lua/src/test/java/net/sourceforge/pmd/cpd/LuaTokenizerTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.util.Properties;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
class LuaTokenizerTest extends CpdTextComparisonTest {
LuaTokenizerTest() {
super(".lua");
}
@Override
protected String getResourcePrefix() {
return "../lang/lua/cpd/testdata";
}
@Override
public Tokenizer newTokenizer(Properties properties) {
return new LuaTokenizer();
}
@Test
void testSimple() {
doTest("helloworld");
}
@Test
void testFactorial() {
doTest("factorial");
}
@Test
void testTabWidth() {
doTest("tabWidth");
}
@Test
void testLuauTypes() {
doTest("luauTypes");
}
@Test
void testComment() {
doTest("comment");
}
}
| 939 | 16.735849 | 79 | java |
pmd | pmd-master/pmd-lua/src/main/java/net/sourceforge/pmd/cpd/LuaTokenizer.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.util.Properties;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Lexer;
import net.sourceforge.pmd.cpd.impl.AntlrTokenizer;
import net.sourceforge.pmd.cpd.token.AntlrTokenFilter;
import net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrToken;
import net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrTokenManager;
import net.sourceforge.pmd.lang.lua.ast.LuaLexer;
/**
* The Lua Tokenizer
*/
public class LuaTokenizer extends AntlrTokenizer {
private boolean ignoreLiteralSequences = false;
/**
* Sets the possible options for the Lua tokenizer.
*
* @param properties the properties
* @see #OPTION_IGNORE_LITERAL_SEQUENCES
*/
public void setProperties(Properties properties) {
ignoreLiteralSequences = getBooleanProperty(properties, OPTION_IGNORE_LITERAL_SEQUENCES);
}
private boolean getBooleanProperty(final Properties properties, final String property) {
return Boolean.parseBoolean(properties.getProperty(property, Boolean.FALSE.toString()));
}
@Override
protected Lexer getLexerForSource(CharStream charStream) {
return new LuaLexer(charStream);
}
@Override
protected AntlrTokenFilter getTokenFilter(final AntlrTokenManager tokenManager) {
return new LuaTokenFilter(tokenManager, ignoreLiteralSequences);
}
/**
* The {@link LuaTokenFilter} extends the {@link AntlrTokenFilter} to discard
* Lua-specific tokens.
* <p>
* By default, it discards semicolons, require statements, and
* enables annotation-based CPD suppression.
* </p>
*/
private static class LuaTokenFilter extends AntlrTokenFilter {
private final boolean ignoreLiteralSequences;
private boolean discardingRequires = false;
private boolean discardingNL = false;
private AntlrToken discardingLiteralsUntil = null;
private boolean discardCurrent = false;
LuaTokenFilter(final AntlrTokenManager tokenManager, boolean ignoreLiteralSequences) {
super(tokenManager);
this.ignoreLiteralSequences = ignoreLiteralSequences;
}
@Override
protected void analyzeToken(final AntlrToken currentToken) {
skipNewLines(currentToken);
}
@Override
protected void analyzeTokens(final AntlrToken currentToken, final Iterable<AntlrToken> remainingTokens) {
discardCurrent = false;
skipRequires(currentToken);
skipLiteralSequences(currentToken, remainingTokens);
}
private void skipRequires(final AntlrToken currentToken) {
final int type = currentToken.getKind();
if (type == LuaLexer.REQUIRE) {
discardingRequires = true;
} else if (type == LuaLexer.CLOSE_PARENS && discardingRequires) {
discardingRequires = false;
discardCurrent = true;
}
}
private void skipNewLines(final AntlrToken currentToken) {
discardingNL = currentToken.getKind() == LuaLexer.NL;
}
private void skipLiteralSequences(final AntlrToken currentToken, final Iterable<AntlrToken> remainingTokens) {
if (ignoreLiteralSequences) {
final int type = currentToken.getKind();
if (isDiscardingLiterals()) {
if (currentToken == discardingLiteralsUntil) { // NOPMD - intentional check for reference equality
discardingLiteralsUntil = null;
discardCurrent = true;
}
} else if (type == LuaLexer.OPEN_BRACE
|| type == LuaLexer.OPEN_BRACKET
|| type == LuaLexer.OPEN_PARENS) {
final AntlrToken finalToken = findEndOfSequenceOfLiterals(remainingTokens);
discardingLiteralsUntil = finalToken;
}
}
}
private AntlrToken findEndOfSequenceOfLiterals(final Iterable<AntlrToken> remainingTokens) {
boolean seenLiteral = false;
int braceCount = 0;
int bracketCount = 0;
int parenCount = 0;
for (final AntlrToken token : remainingTokens) {
switch (token.getKind()) {
case LuaLexer.INT:
case LuaLexer.NORMAL_STRING:
case LuaLexer.INTERPOLATED_STRING:
case LuaLexer.LONG_STRING:
case LuaLexer.HEX_FLOAT:
case LuaLexer.HEX:
case LuaLexer.FLOAT:
case LuaLexer.NIL:
case LuaLexer.BOOLEAN:
seenLiteral = true;
break; // can be skipped; continue to the next token
case LuaLexer.COMMA:
break; // can be skipped; continue to the next token
case LuaLexer.NL:
// this helps skip large multi-line data table sequences in Lua
break; // can be skipped; continue to the next token
case LuaLexer.ASSIGNMENT:
// this helps skip large data table sequences in Lua: { ["bob"] = "uncle", ["alice"] = "enby" }
break; // can be skipped; continue to the next token
case LuaLexer.OPEN_BRACE:
braceCount++;
break; // curly braces are allowed, as long as they're balanced
case LuaLexer.CLOSE_BRACE:
braceCount--;
if (braceCount < 0) {
// end of the list in the braces; skip all contents
return seenLiteral ? token : null;
} else {
// curly braces are not yet balanced; continue to the next token
break;
}
case LuaLexer.OPEN_BRACKET:
bracketCount++;
break; // brackets are allowed, as long as they're balanced
case LuaLexer.CLOSE_BRACKET:
bracketCount--;
if (bracketCount < 0) {
// end of the list in the brackets; skip all contents
return seenLiteral ? token : null;
} else {
// brackets are not yet balanced; continue to the next token
break;
}
case LuaLexer.OPEN_PARENS:
parenCount++;
break; // parens are allowed, as long as they're balanced
case LuaLexer.CLOSE_PARENS:
parenCount--;
if (parenCount < 0) {
// end of the list in the parens; skip all contents
return seenLiteral ? token : null;
} else {
// parens are not yet balanced; continue to the next token
break;
}
default:
// some other token than the expected ones; this is not a sequence of literals
return null;
}
}
return null;
}
public boolean isDiscardingLiterals() {
return discardingLiteralsUntil != null;
}
@Override
protected boolean isLanguageSpecificDiscarding() {
return discardingRequires || discardingNL || isDiscardingLiterals() || discardCurrent;
}
}
}
| 7,729 | 38.845361 | 118 | java |
pmd | pmd-master/pmd-lua/src/main/java/net/sourceforge/pmd/cpd/LuaLanguage.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.util.Properties;
/**
* Language implementation for Lua
*/
public class LuaLanguage extends AbstractLanguage {
public LuaLanguage() {
this(System.getProperties());
}
/**
* Creates a new Lua Language instance.
*/
public LuaLanguage(Properties properties) {
super("Lua", "lua", new LuaTokenizer(), ".lua");
setProperties(properties);
}
@Override
public final void setProperties(Properties properties) {
LuaTokenizer tokenizer = (LuaTokenizer) getTokenizer();
tokenizer.setProperties(properties);
}
}
| 720 | 21.53125 | 79 | java |
pmd | pmd-master/pmd-objectivec/src/test/java/net/sourceforge/pmd/cpd/ObjectiveCTokenizerTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.util.Properties;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
class ObjectiveCTokenizerTest extends CpdTextComparisonTest {
ObjectiveCTokenizerTest() {
super(".m");
}
@Override
protected String getResourcePrefix() {
return "../lang/objc/cpd/testdata";
}
@Override
public Tokenizer newTokenizer(Properties properties) {
return new ObjectiveCTokenizer();
}
@Test
void testLongSample() {
doTest("big_sample");
}
@Test
void testUnicodeEscape() {
doTest("unicodeEscapeInString");
}
@Test
void testUnicodeCharInIdent() {
doTest("unicodeCharInIdent");
}
@Test
void testTabWidth() {
doTest("tabWidth");
}
}
| 930 | 17.62 | 79 | java |
pmd | pmd-master/pmd-objectivec/src/main/java/net/sourceforge/pmd/cpd/ObjectiveCLanguage.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
/**
* Defines the Language module for Objective-C
*/
public class ObjectiveCLanguage extends AbstractLanguage {
/**
* Creates a new instance of {@link ObjectiveCLanguage} with the default
* extensions for Objective-C files.
*/
public ObjectiveCLanguage() {
super("Objective-C", "objectivec", new ObjectiveCTokenizer(), ".h", ".m");
}
}
| 496 | 23.85 | 82 | java |
pmd | pmd-master/pmd-objectivec/src/main/java/net/sourceforge/pmd/cpd/ObjectiveCTokenizer.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import net.sourceforge.pmd.cpd.impl.JavaCCTokenizer;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
import net.sourceforge.pmd.lang.objectivec.ast.ObjectiveCTokenKinds;
/**
* The Objective-C Tokenizer
*/
public class ObjectiveCTokenizer extends JavaCCTokenizer {
@Override
protected TokenManager<JavaccToken> makeLexerImpl(CharStream sourceCode) {
return ObjectiveCTokenKinds.newTokenManager(sourceCode);
}
}
| 675 | 28.391304 | 79 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/LanguageVersionTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala;
import java.util.Arrays;
import java.util.Collection;
import net.sourceforge.pmd.AbstractLanguageVersionTest;
class LanguageVersionTest extends AbstractLanguageVersionTest {
static Collection<TestDescriptor> data() {
return Arrays.asList(
new TestDescriptor(ScalaLanguageModule.NAME, ScalaLanguageModule.TERSE_NAME, "2.13",
getLanguage(ScalaLanguageModule.NAME).getVersion("2.13")),
new TestDescriptor(ScalaLanguageModule.NAME, ScalaLanguageModule.TERSE_NAME, "2.12",
getLanguage(ScalaLanguageModule.NAME).getVersion("2.12")),
new TestDescriptor(ScalaLanguageModule.NAME, ScalaLanguageModule.TERSE_NAME, "2.11",
getLanguage(ScalaLanguageModule.NAME).getVersion("2.11")),
new TestDescriptor(ScalaLanguageModule.NAME, ScalaLanguageModule.TERSE_NAME, "2.10",
getLanguage(ScalaLanguageModule.NAME).getVersion("2.10")));
}
}
| 1,113 | 41.846154 | 100 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/RulesetFactoryTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala;
import net.sourceforge.pmd.AbstractRuleSetFactoryTest;
/**
* Test scala rulesets
*/
class RulesetFactoryTest extends AbstractRuleSetFactoryTest {
// no rulesets yet
}
| 304 | 19.333333 | 79 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/ast/ScalaParsingHelper.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import net.sourceforge.pmd.lang.ast.test.BaseParsingHelper;
import net.sourceforge.pmd.lang.scala.ScalaLanguageModule;
public final class ScalaParsingHelper extends BaseParsingHelper<ScalaParsingHelper, ASTSource> {
public static final ScalaParsingHelper DEFAULT = new ScalaParsingHelper(Params.getDefault());
private ScalaParsingHelper(Params params) {
super(ScalaLanguageModule.NAME, ASTSource.class, params);
}
@Override
protected ScalaParsingHelper clone(Params params) {
return new ScalaParsingHelper(params);
}
}
| 697 | 28.083333 | 97 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/ast/BaseScalaTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
/**
* @author Clément Fournier
*/
public abstract class BaseScalaTest {
protected final ScalaParsingHelper scala = ScalaParsingHelper.DEFAULT.withResourceContext(getClass());
}
| 318 | 20.266667 | 106 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.rule;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.lang.rule.XPathRule;
import net.sourceforge.pmd.lang.scala.ast.BaseScalaTest;
class XPathRuleTest extends BaseScalaTest {
private static final String SCALA_TEST = "/parserFiles/helloworld.scala";
@Test
void testPrintHelloWorld() {
Report report = evaluate(SCALA_TEST, "//TermApply/TermName[@Image=\"println\"]");
RuleViolation rv = report.getViolations().get(0);
assertEquals(2, rv.getBeginLine());
}
private Report evaluate(String testSource, String xpath) {
XPathRule rule = scala.newXpathRule(xpath);
return scala.executeRuleOnResource(rule, testSource);
}
}
| 966 | 29.21875 | 89 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleTest.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.rule;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.lang.scala.ast.ASTSource;
import net.sourceforge.pmd.lang.scala.ast.ASTTermApply;
import net.sourceforge.pmd.lang.scala.ast.ASTTermName;
import net.sourceforge.pmd.lang.scala.ast.BaseScalaTest;
import net.sourceforge.pmd.lang.scala.ast.ScalaNode;
class ScalaRuleTest extends BaseScalaTest {
private static final String SCALA_TEST = "/parserFiles/helloworld.scala";
@Test
void testRuleVisits() {
final AtomicInteger visited = new AtomicInteger();
ScalaRule rule = new ScalaRule() {
@Override
public RuleContext visit(ScalaNode<?> node, RuleContext data) {
visited.incrementAndGet();
return super.visit(node, data);
}
};
ASTSource root = scala.parseResource(SCALA_TEST);
rule.apply(root, null);
assertEquals(12, visited.get());
}
@Test
void testDummyRule() {
ScalaRule rule = new ScalaRule() {
@Override
public String getMessage() {
return "a message";
}
@Override
public RuleContext visit(ASTTermApply node, RuleContext data) {
ASTTermName child = node.getFirstChildOfType(ASTTermName.class);
if (child != null && child.hasImageEqualTo("println")) {
addViolation(data, node);
}
return data;
}
};
Report report = scala.executeRuleOnResource(rule, SCALA_TEST);
assertEquals(1, report.getViolations().size());
}
}
| 1,950 | 29.968254 | 80 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/cpd/ScalaTokenizerTest.java | /**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.Properties;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
class ScalaTokenizerTest extends CpdTextComparisonTest {
ScalaTokenizerTest() {
super(".scala");
}
@Override
protected String getResourcePrefix() {
return "../lang/scala/cpd/testdata";
}
@Override
public Tokenizer newTokenizer(Properties properties) {
return new ScalaTokenizer();
}
@Test
void testSample() {
doTest("sample-LiftActor");
}
@Test
void testSuppressionComments() {
doTest("special_comments");
}
@Test
void tokenizeFailTest() {
assertThrows(TokenMgrError.class, () -> doTest("unlexable_sample"));
}
@Test
void testTabWidth() {
doTest("tabWidth");
}
}
| 1,068 | 19.557692 | 79 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ScalaLanguageHandler.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala;
import net.sourceforge.pmd.lang.AbstractPmdLanguageVersionHandler;
import net.sourceforge.pmd.lang.scala.ast.ScalaParser;
/**
* The Scala Language Handler implementation.
*/
public class ScalaLanguageHandler extends AbstractPmdLanguageVersionHandler {
@Override
public ScalaParser getParser() {
return new ScalaParser();
}
}
| 478 | 22.95 | 79 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ScalaLanguageModule.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala;
import static net.sourceforge.pmd.util.CollectionUtil.listOf;
import java.util.List;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.lang.impl.SimpleLanguageModuleBase;
import scala.meta.Dialect;
/**
* Language Module for Scala.
*/
public class ScalaLanguageModule extends SimpleLanguageModuleBase {
/** The name. */
public static final String NAME = "Scala";
/** The terse name. */
public static final String TERSE_NAME = "scala";
@InternalApi
public static final List<String> EXTENSIONS = listOf("scala");
/**
* Create a new instance of Scala Language Module.
*/
public ScalaLanguageModule() {
super(LanguageMetadata.withId(TERSE_NAME).name(NAME)
.extensions(EXTENSIONS)
.addVersion("2.10")
.addVersion("2.11")
.addVersion("2.12")
.addDefaultVersion("2.13"),
new ScalaLanguageHandler());
}
@InternalApi
public static @NonNull Dialect dialectOf(LanguageVersion v) {
switch (v.getVersion()) {
case "2.10": return scala.meta.dialects.package$.MODULE$.Scala210();
case "2.11": return scala.meta.dialects.package$.MODULE$.Scala211();
case "2.12": return scala.meta.dialects.package$.MODULE$.Scala212();
case "2.13": return scala.meta.dialects.package$.MODULE$.Scala213();
default:
throw new IllegalArgumentException(v.getVersion());
}
}
public static ScalaLanguageModule getInstance() {
return (ScalaLanguageModule) LanguageRegistry.PMD.getLanguageByFullName(NAME);
}
}
| 2,011 | 30.936508 | 86 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTModLazy.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Mod;
/**
* The ASTModLazy node implementation.
*/
public final class ASTModLazy extends AbstractScalaNode<Mod.Lazy> {
ASTModLazy(Mod.Lazy scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 506 | 21.043478 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTypeParam.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Type;
/**
* The ASTTypeParam node implementation.
*/
public final class ASTTypeParam extends AbstractScalaNode<Type.Param> {
ASTTypeParam(Type.Param scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 517 | 21.521739 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTDefnVar.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Defn;
/**
* The ASTDefnVar node implementation.
*/
public final class ASTDefnVar extends AbstractScalaNode<Defn.Var> {
ASTDefnVar(Defn.Var scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 507 | 21.086957 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTypeByName.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Type;
/**
* The ASTTypeByName node implementation.
*/
public final class ASTTypeByName extends AbstractScalaNode<Type.ByName> {
ASTTypeByName(Type.ByName scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 522 | 21.73913 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTDefnTrait.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Defn;
/**
* The ASTDefnTrait node implementation.
*/
public final class ASTDefnTrait extends AbstractScalaNode<Defn.Trait> {
ASTDefnTrait(Defn.Trait scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 517 | 21.521739 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermParam.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermParam node implementation.
*/
public final class ASTTermParam extends AbstractScalaNode<Term.Param> {
ASTTermParam(Term.Param scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 517 | 21.521739 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTModSealed.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Mod;
/**
* The ASTModSealed node implementation.
*/
public final class ASTModSealed extends AbstractScalaNode<Mod.Sealed> {
ASTModSealed(Mod.Sealed scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 516 | 21.478261 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermThrow.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermThrow node implementation.
*/
public final class ASTTermThrow extends AbstractScalaNode<Term.Throw> {
ASTTermThrow(Term.Throw scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 517 | 21.521739 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTModProtected.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Mod;
/**
* The ASTModProtected node implementation.
*/
public final class ASTModProtected extends AbstractScalaNode<Mod.Protected> {
ASTModProtected(Mod.Protected scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 531 | 22.130435 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTPkg.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Pkg;
/**
* The ASTPkg node implementation.
*/
public final class ASTPkg extends AbstractScalaNode<Pkg> {
ASTPkg(Pkg scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 484 | 20.086957 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermNewAnonymous.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermNewAnonymous node implementation.
*/
public final class ASTTermNewAnonymous extends AbstractScalaNode<Term.NewAnonymous> {
ASTTermNewAnonymous(Term.NewAnonymous scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 552 | 23.043478 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTCtorPrimary.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Ctor;
/**
* The ASTCtorPrimary node implementation.
*/
public final class ASTCtorPrimary extends AbstractScalaNode<Ctor.Primary> {
ASTCtorPrimary(Ctor.Primary scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 527 | 21.956522 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermForYield.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermForYield node implementation.
*/
public final class ASTTermForYield extends AbstractScalaNode<Term.ForYield> {
ASTTermForYield(Term.ForYield scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 532 | 22.173913 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitChar.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Lit;
/**
* The ASTLitChar node implementation.
*/
public final class ASTLitChar extends AbstractScalaNode<Lit.Char> {
ASTLitChar(Lit.Char scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public String getImage() {
return String.valueOf(node.value());
}
}
| 603 | 20.571429 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTImport.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Import;
/**
* The ASTImport node implementation.
*/
public final class ASTImport extends AbstractScalaNode<Import> {
ASTImport(Import scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 502 | 20.869565 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTDeclType.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Decl;
/**
* The ASTDeclType node implementation.
*/
public final class ASTDeclType extends AbstractScalaNode<Decl.Type> {
ASTDeclType(Decl.Type scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 512 | 21.304348 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTImporteeUnimport.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Importee;
/**
* The ASTImporteeUnimport node implementation.
*/
public final class ASTImporteeUnimport extends AbstractScalaNode<Importee.Unimport> {
ASTImporteeUnimport(Importee.Unimport scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 556 | 23.217391 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitSymbol.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Lit;
/**
* The ASTLitSymbol node implementation.
*/
public final class ASTLitSymbol extends AbstractScalaNode<Lit.Symbol> {
ASTLitSymbol(Lit.Symbol scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public String getImage() {
return String.valueOf(node.value());
}
}
| 613 | 20.928571 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermNew.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermNew node implementation.
*/
public final class ASTTermNew extends AbstractScalaNode<Term.New> {
ASTTermNew(Term.New scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 507 | 21.086957 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermSelect.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermSelect node implementation.
*/
public final class ASTTermSelect extends AbstractScalaNode<Term.Select> {
ASTTermSelect(Term.Select scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 522 | 21.73913 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermBlock.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermBlock node implementation.
*/
public final class ASTTermBlock extends AbstractScalaNode<Term.Block> {
ASTTermBlock(Term.Block scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 517 | 21.521739 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTEnumeratorGenerator.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Enumerator;
/**
* The ASTEnumeratorGenerator node implementation.
*/
public final class ASTEnumeratorGenerator extends AbstractScalaNode<Enumerator.Generator> {
ASTEnumeratorGenerator(Enumerator.Generator scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 573 | 23.956522 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTModContravariant.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Mod;
/**
* The ASTModContravariant node implementation.
*/
public final class ASTModContravariant extends AbstractScalaNode<Mod.Contravariant> {
ASTModContravariant(Mod.Contravariant scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 551 | 23 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTypeSelect.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Type;
/**
* The ASTTypeSelect node implementation.
*/
public final class ASTTypeSelect extends AbstractScalaNode<Type.Select> {
ASTTypeSelect(Type.Select scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 522 | 21.73913 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTPatTuple.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Pat;
/**
* The ASTPatTuple node implementation.
*/
public final class ASTPatTuple extends AbstractScalaNode<Pat.Tuple> {
ASTPatTuple(Pat.Tuple scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 511 | 21.26087 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTNameIndeterminate.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Name;
/**
* The ASTNameIndeterminate node implementation.
*/
public final class ASTNameIndeterminate extends AbstractScalaNode<Name.Indeterminate> {
ASTNameIndeterminate(Name.Indeterminate scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public String getImage() {
return node.value();
}
}
| 638 | 21.821429 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermTuple.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermTuple node implementation.
*/
public final class ASTTermTuple extends AbstractScalaNode<Term.Tuple> {
ASTTermTuple(Term.Tuple scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 517 | 21.521739 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTModCovariant.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Mod;
/**
* The ASTModCovariant node implementation.
*/
public final class ASTModCovariant extends AbstractScalaNode<Mod.Covariant> {
ASTModCovariant(Mod.Covariant scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 531 | 22.130435 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTDeclVar.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Decl;
/**
* The ASTDeclVar node implementation.
*/
public final class ASTDeclVar extends AbstractScalaNode<Decl.Var> {
ASTDeclVar(Decl.Var scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 507 | 21.086957 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitByte.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Lit;
/**
* The ASTLitByte node implementation.
*/
public final class ASTLitByte extends AbstractScalaNode<Lit.Byte> {
ASTLitByte(Lit.Byte scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public String getImage() {
return String.valueOf(node.value());
}
}
| 603 | 20.571429 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermApplyInfix.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermApplyInfix node implementation.
*/
public final class ASTTermApplyInfix extends AbstractScalaNode<Term.ApplyInfix> {
ASTTermApplyInfix(Term.ApplyInfix scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 542 | 22.608696 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermApply.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermApply node implementation.
*/
public final class ASTTermApply extends AbstractScalaNode<Term.Apply> {
ASTTermApply(Term.Apply scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 517 | 21.521739 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTPatInterpolate.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Pat;
/**
* The ASTPatInterpolate node implementation.
*/
public final class ASTPatInterpolate extends AbstractScalaNode<Pat.Interpolate> {
ASTPatInterpolate(Pat.Interpolate scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 541 | 22.565217 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermName.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermName node implementation.
*/
public final class ASTTermName extends AbstractScalaNode<Term.Name> {
ASTTermName(Term.Name scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public String getImage() {
return node.value();
}
}
| 593 | 20.214286 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTPkgObject.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Pkg;
/**
* The ASTPkgObject node implementation.
*/
public final class ASTPkgObject extends AbstractScalaNode<Pkg.Object> {
ASTPkgObject(Pkg.Object scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 516 | 21.478261 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermReturn.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermReturn node implementation.
*/
public final class ASTTermReturn extends AbstractScalaNode<Term.Return> {
ASTTermReturn(Term.Return scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 522 | 21.73913 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermXml.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermXml node implementation.
*/
public final class ASTTermXml extends AbstractScalaNode<Term.Xml> {
ASTTermXml(Term.Xml scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 507 | 21.086957 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTypeWith.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Type;
/**
* The ASTTypeWith node implementation.
*/
public final class ASTTypeWith extends AbstractScalaNode<Type.With> {
ASTTypeWith(Type.With scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 512 | 21.304348 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermTryWithHandler.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermTryWithHandler node implementation.
*/
public final class ASTTermTryWithHandler extends AbstractScalaNode<Term.TryWithHandler> {
ASTTermTryWithHandler(Term.TryWithHandler scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 562 | 23.478261 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTCtorSecondary.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Ctor;
/**
* The ASTCtorSecondary node implementation.
*/
public final class ASTCtorSecondary extends AbstractScalaNode<Ctor.Secondary> {
ASTCtorSecondary(Ctor.Secondary scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 537 | 22.391304 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTPatVar.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Pat;
/**
* The ASTPatVar node implementation.
*/
public final class ASTPatVar extends AbstractScalaNode<Pat.Var> {
ASTPatVar(Pat.Var scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 501 | 20.826087 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTypeLambda.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Type;
/**
* The ASTTypeLambda node implementation.
*/
public final class ASTTypeLambda extends AbstractScalaNode<Type.Lambda> {
ASTTypeLambda(Type.Lambda scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 522 | 21.73913 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTypeName.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Type;
/**
* The ASTTypeName node implementation.
*/
public final class ASTTypeName extends AbstractScalaNode<Type.Name> {
ASTTypeName(Type.Name scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public String getImage() {
return node.value();
}
}
| 593 | 20.214286 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTermFunction.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Term;
/**
* The ASTTermFunction node implementation.
*/
public final class ASTTermFunction extends AbstractScalaNode<Term.Function> {
ASTTermFunction(Term.Function scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 532 | 22.173913 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ScalaParserVisitor.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import net.sourceforge.pmd.lang.ast.AstVisitor;
/**
* A Visitor Pattern Interface for the Scala AST.
*
* @param <D> The type of the data input to each visit method
* @param <R> the type of the returned data from each visit method
*/
public interface ScalaParserVisitor<D, R> extends AstVisitor<D, R> {
/**
* Visit an arbitrary Scala Node (any node in the tree).
*
* @param node the node of the tree
* @param data context-specific data
*
* @return context-specific data
*/
default R visit(ScalaNode<?> node, D data) {
return visitNode(node, data);
}
/**
* Visit the Source Node (the root node of the tree).
*
* @param node the root node of the tree
* @param data context-specific data
*
* @return context-specific data
*/
default R visit(ASTSource node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTCase node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTCtorPrimary node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTCtorSecondary node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTDeclDef node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTDeclType node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTDeclVal node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTDeclVar node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTDefnClass node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTDefnDef node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTDefnMacro node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTDefnObject node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTDefnTrait node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTDefnType node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTDefnVal node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTDefnVar node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTEnumeratorGenerator node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTEnumeratorGuard node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTEnumeratorVal node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTImport node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTImporteeName node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTImporteeRename node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTImporteeUnimport node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTImporteeWildcard node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTImporter node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTInit node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTLitBoolean node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTLitByte node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTLitChar node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTLitDouble node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTLitFloat node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTLitInt node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTLitLong node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTLitNull node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTLitShort node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTLitString node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTLitSymbol node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTLitUnit node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModAbstract node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModAnnot node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModCase node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModContravariant node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModCovariant node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModFinal node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModImplicit node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModInline node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModLazy node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModOverride node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModPrivate node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModProtected node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModSealed node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModValParam node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTModVarParam node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTNameAnonymous node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTNameIndeterminate node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPatAlternative node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPatBind node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPatExtract node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPatExtractInfix node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPatInterpolate node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPatSeqWildcard node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPatTuple node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPatTyped node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPatVar node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPatWildcard node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPatXml node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPkg node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTPkgObject node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTQuasi node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTSelf node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTemplate node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermAnnotate node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermApply node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermApplyInfix node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermApplyType node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermApplyUnary node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermAscribe node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermAssign node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermBlock node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermDo node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermEta node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermFor node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermForYield node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermFunction node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermIf node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermInterpolate node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermMatch node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermName node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermNewAnonymous node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermNew node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermParam node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermPartialFunction node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermPlaceholder node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermRepeated node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermReturn node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermSelect node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermSuper node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermThis node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermThrow node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermTry node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermTryWithHandler node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermTuple node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermWhile node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTermXml node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeAnd node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeAnnotate node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeApply node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeApplyInfix node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeBounds node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeByName node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeExistential node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeFunction node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeImplicitFunction node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeLambda node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeMethod node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeName node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeOr node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeParam node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypePlaceholder node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeProject node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeRefine node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeRepeated node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeSelect node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeSingleton node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeTuple node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeVar node, D data) {
return visit((ScalaNode<?>) node, data);
}
default R visit(ASTTypeWith node, D data) {
return visit((ScalaNode<?>) node, data);
}
}
| 14,543 | 20.610698 | 79 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTemplate.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Template;
/**
* The ASTTemplate node implementation.
*/
public final class ASTTemplate extends AbstractScalaNode<Template> {
ASTTemplate(Template scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 514 | 21.391304 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTImporteeRename.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Importee;
/**
* The ASTImporteeRename node implementation.
*/
public final class ASTImporteeRename extends AbstractScalaNode<Importee.Rename> {
ASTImporteeRename(Importee.Rename scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 546 | 22.782609 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTModPrivate.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Mod;
/**
* The ASTModPrivate node implementation.
*/
public final class ASTModPrivate extends AbstractScalaNode<Mod.Private> {
ASTModPrivate(Mod.Private scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 521 | 21.695652 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTPatBind.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Pat;
/**
* The ASTPatBind node implementation.
*/
public final class ASTPatBind extends AbstractScalaNode<Pat.Bind> {
ASTPatBind(Pat.Bind scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 506 | 21.043478 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTypeProject.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Type;
/**
* The ASTTypeProject node implementation.
*/
public final class ASTTypeProject extends AbstractScalaNode<Type.Project> {
ASTTypeProject(Type.Project scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 527 | 21.956522 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTypeSingleton.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Type;
/**
* The ASTTypeSingleton node implementation.
*/
public final class ASTTypeSingleton extends AbstractScalaNode<Type.Singleton> {
ASTTypeSingleton(Type.Singleton scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 537 | 22.391304 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTModImplicit.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Mod;
/**
* The ASTModImplicit node implementation.
*/
public final class ASTModImplicit extends AbstractScalaNode<Mod.Implicit> {
ASTModImplicit(Mod.Implicit scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 526 | 21.913043 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitShort.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Lit;
/**
* The ASTLitShort node implementation.
*/
public final class ASTLitShort extends AbstractScalaNode<Lit.Short> {
ASTLitShort(Lit.Short scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
@Override
public String getImage() {
return String.valueOf(node.value());
}
}
| 608 | 20.75 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTPatExtract.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Pat;
/**
* The ASTPatExtract node implementation.
*/
public final class ASTPatExtract extends AbstractScalaNode<Pat.Extract> {
ASTPatExtract(Pat.Extract scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 521 | 21.695652 | 98 | java |
pmd | pmd-master/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTImporteeName.java | /*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.scala.ast;
import scala.meta.Importee;
/**
* The ASTImporteeName node implementation.
*/
public final class ASTImporteeName extends AbstractScalaNode<Importee.Name> {
ASTImporteeName(Importee.Name scalaNode) {
super(scalaNode);
}
@Override
protected <P, R> R acceptVisitor(ScalaParserVisitor<? super P, ? extends R> visitor, P data) {
return visitor.visit(this, data);
}
}
| 536 | 22.347826 | 98 | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.