diff --git a/.ci/files/project-list.xml b/.ci/files/project-list.xml index 98c2bf1c167..ce32708a358 100644 --- a/.ci/files/project-list.xml +++ b/.ci/files/project-list.xml @@ -4,33 +4,6 @@ xsi:noNamespaceSchemaLocation="projectlist_1_1_0.xsd"> Standard Projects - - checkstyle - git - https://github.com/checkstyle/checkstyle - checkstyle-9.1 - - .*/target/test-classes/com/puppycrawl/tools/checkstyle/.* - .*/target/generated-sources/.* - .*/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/javaparser/InputJavaParserNoFreezeOnDeeplyNestedLambdas.java - - - echo -n "$(pwd)/target/classes:$(pwd)/target/test-classes:"; cat classpath.txt - - spring-framework git diff --git a/.gitignore b/.gitignore index 95978b24728..6e834a5dc79 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ target/ bin/ .project .classpath -.checkstyle .pmd .pmdruleset.xml .ruleset diff --git a/docs/pages/pmd/devdocs/contributing/contributing.md b/docs/pages/pmd/devdocs/contributing/contributing.md index 881b5fd40f0..71a8e1cb322 100644 --- a/docs/pages/pmd/devdocs/contributing/contributing.md +++ b/docs/pages/pmd/devdocs/contributing/contributing.md @@ -83,11 +83,7 @@ There are various channels, on which you can ask questions: ## Code Style -PMD uses [Checkstyle](https://checkstyle.org/) to enforce a common code style. - -See [pmd-checkstyle-config.xml](https://github.com/pmd/build-tools/blob/main/src/main/resources/net/sourceforge/pmd/pmd-checkstyle-config.xml) for the configuration and -[the eclipse configuration files](https://github.com/pmd/build-tools/tree/main/eclipse) that can -be imported into a fresh workspace. +PMD uses Rewrite. ## Add yourself as contributor diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java index 86558b60480..3756bf54f82 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/CPDTask.java @@ -67,8 +67,7 @@ public class CPDTask extends Task { private static final String TEXT_FORMAT = "text"; private static final String XML_FORMAT = "xml"; - @Deprecated - private static final String XMLOLD_FORMAT = "xmlold"; + @Deprecated private static final String XMLOLD_FORMAT = "xmlold"; private static final String CSV_FORMAT = "csv"; private String format = TEXT_FORMAT; @@ -78,8 +77,7 @@ public class CPDTask extends Task { private boolean ignoreIdentifiers; private boolean ignoreAnnotations; private boolean ignoreUsings; - @Deprecated - private boolean skipLexicalErrors; + @Deprecated private boolean skipLexicalErrors; private boolean skipDuplicateFiles; private boolean skipBlocks = true; private String skipBlocksPattern; @@ -88,8 +86,7 @@ public class CPDTask extends Task { private List filesets = new ArrayList<>(); private boolean failOnError = true; - @Override - public void execute() throws BuildException { + @Override public void execute() throws BuildException { ClassLoader oldClassloader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(CPDTask.class.getClassLoader()); @@ -243,8 +240,7 @@ public void setIgnoreUsings(boolean value) { /** * @deprecated Use {@link #setFailOnError(boolean)} instead. */ - @Deprecated - public void setSkipLexicalErrors(boolean skipLexicalErrors) { + @Deprecated public void setSkipLexicalErrors(boolean skipLexicalErrors) { this.skipLexicalErrors = skipLexicalErrors; } @@ -286,10 +282,9 @@ public void setFailOnError(boolean failOnError) { } public static class FormatAttribute extends EnumeratedAttribute { - private static final String[] FORMATS = new String[] { XML_FORMAT, TEXT_FORMAT, CSV_FORMAT, XMLOLD_FORMAT }; + private static final String[] FORMATS = new String[]{XML_FORMAT, TEXT_FORMAT, CSV_FORMAT, XMLOLD_FORMAT}; - @Override - public String[] getValues() { + @Override public String[] getValues() { return FORMATS; } } diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java index 159f19d7e1a..547ec8301a0 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/Formatter.java @@ -130,8 +130,7 @@ boolean isNoOutputSupplied() { return toFile == null && !toConsole; } - @Override - public String toString() { + @Override public String toString() { return "file = " + toFile + "; renderer = " + type; } @@ -272,23 +271,19 @@ GlobalAnalysisListener newListener(Project project) throws IOException { return new GlobalAnalysisListener() { final GlobalAnalysisListener listener = renderer.newListener(); - @Override - public ListenerInitializer initializer() { + @Override public ListenerInitializer initializer() { return new ListenerInitializer() { - @Override - public void setFileNameRenderer(FileNameRenderer fileNameRenderer) { + @Override public void setFileNameRenderer(FileNameRenderer fileNameRenderer) { renderer.setFileNameRenderer(fileNameRenderer); } }; } - @Override - public FileAnalysisListener startFileAnalysis(TextFile file) { + @Override public FileAnalysisListener startFileAnalysis(TextFile file) { return listener.startFileAnalysis(file); } - @Override - public void close() throws Exception { + @Override public void close() throws Exception { listener.close(); if (!toConsole) { writer.close(); diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/InternalApiBridge.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/InternalApiBridge.java index 604e9c39971..89f18a1d439 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/InternalApiBridge.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/InternalApiBridge.java @@ -24,7 +24,8 @@ */ @InternalApi public final class InternalApiBridge { - private InternalApiBridge() {} + private InternalApiBridge() { + } public static GlobalAnalysisListener newListener(Formatter formatter, Project project) throws IOException { return formatter.newListener(project); diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java index a59a4c88359..f8dd634097e 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/PMDTask.java @@ -68,8 +68,7 @@ public class PMDTask extends Task { private boolean noCache; private final Collection nestedRules = new ArrayList<>(); - @Override - public void execute() throws BuildException { + @Override public void execute() throws BuildException { validate(); ClassLoader oldClassloader = Thread.currentThread().getContextClassLoader(); @@ -108,7 +107,7 @@ private void validate() throws BuildException { private String getNestedRuleSetFiles() { final StringBuilder sb = new StringBuilder(); - for (Iterator it = nestedRules.iterator(); it.hasNext();) { + for (Iterator it = nestedRules.iterator(); it.hasNext(); ) { RuleSetWrapper rs = it.next(); sb.append(rs.getFile()); if (it.hasNext()) { diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/SourceLanguage.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/SourceLanguage.java index c1c81aa12a8..480130b801c 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/SourceLanguage.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/SourceLanguage.java @@ -43,8 +43,7 @@ public void setName(String name) { this.name = name; } - @Override - public String toString() { + @Override public String toString() { return ""; } } diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java index 5f5e1f9bd91..9a2e14dc037 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/PMDTaskImpl.java @@ -126,7 +126,7 @@ private void doTask() { ReportStats stats; try (PmdAnalysis pmd = PmdAnalysis.create(configuration)) { RuleSetLoader rulesetLoader = - pmd.newRuleSetLoader().loadResourcesWith(setupResourceLoader()); + pmd.newRuleSetLoader().loadResourcesWith(setupResourceLoader()); pmd.addRuleSets(loadRuleSetsWithoutException(rulesetLoader, ruleSetPaths)); for (FileSet fileset : filesets) { @@ -137,8 +137,7 @@ private void doTask() { } - @SuppressWarnings("PMD.CloseResource") - ReportStatsListener reportStatsListener = new ReportStatsListener(); + @SuppressWarnings("PMD.CloseResource") ReportStatsListener reportStatsListener = new ReportStatsListener(); pmd.addListener(getListener(reportStatsListener)); pmd.performAnalysis(); @@ -192,15 +191,13 @@ private List expandRuleSetPaths(List ruleSetPaths) { private GlobalAnalysisListener makeLogListener() { return new GlobalAnalysisListener() { - @Override - public FileAnalysisListener startFileAnalysis(TextFile dataSource) { + @Override public FileAnalysisListener startFileAnalysis(TextFile dataSource) { String name = dataSource.getFileId().getUriString(); project.log("Processing file " + name, Project.MSG_VERBOSE); return FileAnalysisListener.noop(); } - @Override - public void close() { + @Override public void close() { // nothing to do } }; @@ -224,7 +221,7 @@ private ClassLoader setupResourceLoader() { // and exist in multiple class loaders final boolean parentFirst = true; return new AntClassLoader(Thread.currentThread().getContextClassLoader(), - project, classpath, parentFirst); + project, classpath, parentFirst); } private void setupClassLoader() { diff --git a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/Slf4jSimpleConfigurationForAnt.java b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/Slf4jSimpleConfigurationForAnt.java index d32579c64e1..3a52cec1397 100644 --- a/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/Slf4jSimpleConfigurationForAnt.java +++ b/pmd-ant/src/main/java/net/sourceforge/pmd/ant/internal/Slf4jSimpleConfigurationForAnt.java @@ -20,21 +20,21 @@ import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration; public final class Slf4jSimpleConfigurationForAnt { - private Slf4jSimpleConfigurationForAnt() { } + private Slf4jSimpleConfigurationForAnt() { + } private static final Level DEFAULT_LEVEL = Level.INFO; // Maps from ant's Project.MSG_* to org.slf4j.event.Level private static final Level[] LOG_LEVELS = { - Level.ERROR, // Project.MSG_ERR=0 - Level.WARN, // Project.MSG_WARN=1 - Level.INFO, // Project.MSG_INFO=2 - Level.DEBUG, // Project.MSG_VERBOSE=3 - Level.TRACE, // Project.MSG_DEBUG=4 + Level.ERROR, // Project.MSG_ERR=0 + Level.WARN, // Project.MSG_WARN=1 + Level.INFO, // Project.MSG_INFO=2 + Level.DEBUG, // Project.MSG_VERBOSE=3 + Level.TRACE, // Project.MSG_DEBUG=4 }; - @SuppressWarnings("PMD.CloseResource") - public static Level reconfigureLoggingForAnt(Project antProject) { + @SuppressWarnings("PMD.CloseResource") public static Level reconfigureLoggingForAnt(Project antProject) { if (!Slf4jSimpleConfiguration.isSimpleLogger()) { // do nothing, not even set system properties, if not Simple Logger is in use return DEFAULT_LEVEL; @@ -83,13 +83,11 @@ private static final class SimpleLoggerToAntBridge extends PrintStream { this.antProject = antProject; } - @Override - public void println(String x) { + @Override public void println(String x) { buffer.append(x).append(System.lineSeparator()); } - @Override - public void flush() { + @Override public void flush() { String logLevel = determineLogLevel(); int antLogLevel = ANT_LOG_LEVELS.getOrDefault(logLevel, Project.MSG_INFO); antProject.log(buffer.toString(), antLogLevel); @@ -162,13 +160,13 @@ private static Level determineGradleLogLevel(Project project, BuildListener l) { Object[] logLevels = gradleLogLevel.getEnumConstants(); // the log levels in gradle are declared in the order DEBUG, INFO, LIFECYCLE, WARN, QUIET, ERROR - Level[] mapping = new Level[] { - Level.TRACE, // DEBUG - Level.DEBUG, // INFO - Level.INFO, // LIFECYCLE - Level.WARN, // WARN - Level.ERROR, // QUIET - Level.ERROR, // ERROR + Level[] mapping = new Level[]{ + Level.TRACE, // DEBUG + Level.DEBUG, // INFO + Level.INFO, // LIFECYCLE + Level.WARN, // WARN + Level.ERROR, // QUIET + Level.ERROR, // ERROR }; for (int i = 0; i < Math.min(logLevels.length, mapping.length); i++) { diff --git a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java index 1a671f4fcd7..6293fc82ed7 100644 --- a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java +++ b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/AbstractAntTest.java @@ -38,8 +38,7 @@ protected void configureProject(String filename) { ProjectHelper.configureProject(project, antFile); } - @AfterAll - static void resetLogging() { + @AfterAll static void resetLogging() { Slf4jSimpleConfiguration.reconfigureDefaultLogLevel(null); } @@ -87,32 +86,25 @@ private AntBuildListener(int logLevel) { } - @Override - public void buildStarted(BuildEvent event) { + @Override public void buildStarted(BuildEvent event) { } - @Override - public void buildFinished(BuildEvent event) { + @Override public void buildFinished(BuildEvent event) { } - @Override - public void targetStarted(BuildEvent event) { + @Override public void targetStarted(BuildEvent event) { } - @Override - public void targetFinished(BuildEvent event) { + @Override public void targetFinished(BuildEvent event) { } - @Override - public void taskStarted(BuildEvent event) { + @Override public void taskStarted(BuildEvent event) { } - @Override - public void taskFinished(BuildEvent event) { + @Override public void taskFinished(BuildEvent event) { } - @Override - public void messageLogged(BuildEvent event) { + @Override public void messageLogged(BuildEvent event) { if (event.getPriority() > logLevel) { return; } diff --git a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java index 83b56f8781c..5899eab7809 100644 --- a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java +++ b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/CPDTaskTest.java @@ -28,26 +28,22 @@ */ class CPDTaskTest extends AbstractAntTest { - @BeforeEach - void setUp() { + @BeforeEach void setUp() { configureProject("src/test/resources/net/sourceforge/pmd/ant/xml/cpdtasktest.xml"); } - @Test - void testBasic() throws IOException { + @Test void testBasic() throws IOException { executeTarget("testBasic"); assertReport("target/cpd.ant.tests"); } - @Test - void failOnErrorDefault() throws IOException { + @Test void failOnErrorDefault() throws IOException { BuildException buildException = assertThrows(BuildException.class, () -> executeTarget("failOnErrorDefault")); assertThat(buildException.getMessage(), containsString("There were 1 recovered errors during analysis.")); assertReport("target/cpd.ant.tests"); } - @Test - void failOnErrorIgnore() throws IOException { + @Test void failOnErrorIgnore() throws IOException { executeTarget("failOnErrorIgnore"); assertReport("target/cpd.ant.tests"); assertThat(log.toString(), containsString("There were 1 recovered errors during analysis.")); diff --git a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/FormatterTest.java b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/FormatterTest.java index 0bb8b1f4f68..82505aabbf8 100644 --- a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/FormatterTest.java +++ b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/FormatterTest.java @@ -19,8 +19,7 @@ class FormatterTest { - @Test - void testType() { + @Test void testType() { Formatter f = new Formatter(); f.setType("xml"); assertTrue(f.createRenderer() instanceof XMLRenderer); @@ -39,8 +38,7 @@ void testType() { } } - @Test - void testNull() { + @Test void testNull() { Formatter f = new Formatter(); assertTrue(f.isNoOutputSupplied(), "Formatter toFile should start off null!"); f.setToFile(new File("foo")); diff --git a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java index 78217c1a17a..52105c03b88 100644 --- a/pmd-ant/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java +++ b/pmd-ant/src/test/java/net/sourceforge/pmd/ant/PMDTaskTest.java @@ -25,13 +25,11 @@ class PMDTaskTest extends AbstractAntTest { - @BeforeEach - void setUp() { + @BeforeEach void setUp() { configureProject("src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml"); } - @Test - void testFormatterWithNoToFileAttribute() { + @Test void testFormatterWithNoToFileAttribute() { try { executeTarget("testFormatterWithNoToFileAttribute"); fail("This should throw an exception"); @@ -40,8 +38,7 @@ void testFormatterWithNoToFileAttribute() { } } - @Test - void testNoRuleSets() { + @Test void testNoRuleSets() { try { executeTarget("testNoRuleSets"); fail("This should throw an exception"); @@ -50,13 +47,11 @@ void testNoRuleSets() { } } - @Test - void testBasic() { + @Test void testBasic() { executeTarget("testBasic"); } - @Test - void testInvalidLanguageVersion() { + @Test void testInvalidLanguageVersion() { try { executeTarget("testInvalidLanguageVersion"); assertEquals( @@ -70,8 +65,7 @@ void testInvalidLanguageVersion() { } } - @Test - void testRelativizeWith() throws IOException { + @Test void testRelativizeWith() throws IOException { executeTarget("testRelativizeWith"); try (InputStream in = Files.newInputStream(Paths.get("target/pmd-ant-test.txt"))) { @@ -82,8 +76,7 @@ void testRelativizeWith() throws IOException { } } - @Test - void testXmlFormatter() throws IOException { + @Test void testXmlFormatter() throws IOException { executeTarget("testXmlFormatter"); try (InputStream in = Files.newInputStream(Paths.get("target/pmd-ant-xml.xml")); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexAnnotationSuppressor.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexAnnotationSuppressor.java index ec727c48b10..c9f3cd477ac 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexAnnotationSuppressor.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexAnnotationSuppressor.java @@ -28,13 +28,11 @@ private ApexAnnotationSuppressor() { } - @Override - protected NodeStream getAnnotations(Node node) { + @Override protected NodeStream getAnnotations(Node node) { return node.children(ASTModifierNode.class).children(ASTAnnotation.class); } - @Override - protected boolean walkAnnotation(ASTAnnotation annot, AnnotationWalkCallbacks callbacks) { + @Override protected boolean walkAnnotation(ASTAnnotation annot, AnnotationWalkCallbacks callbacks) { if ("SuppressWarnings".equalsIgnoreCase(annot.getName())) { for (ASTAnnotationParameter param : annot.children(ASTAnnotationParameter.class)) { String image = param.getValue(); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageHandler.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageHandler.java index f2a3be5e5ae..4e7f9796941 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageHandler.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageHandler.java @@ -23,36 +23,31 @@ class ApexLanguageHandler implements LanguageVersionHandler { private final ApexMetricsProvider myMetricsProvider = new ApexMetricsProvider(); - @Override - public Parser getParser() { + @Override public Parser getParser() { return new ApexParser(); } - @Override - public List getExtraViolationSuppressors() { + @Override public List getExtraViolationSuppressors() { return ApexAnnotationSuppressor.ALL_APEX_SUPPRESSORS; } - @Override - public LanguageMetricsProvider getLanguageMetricsProvider() { + @Override public LanguageMetricsProvider getLanguageMetricsProvider() { return myMetricsProvider; } - @Override - public DesignerBindings getDesignerBindings() { + @Override public DesignerBindings getDesignerBindings() { return ApexDesignerBindings.INSTANCE; } private static final class ApexMetricsProvider implements LanguageMetricsProvider { private final Set> metrics = setOf( - ApexMetrics.COGNITIVE_COMPLEXITY, - ApexMetrics.CYCLO, - ApexMetrics.WEIGHED_METHOD_COUNT + ApexMetrics.COGNITIVE_COMPLEXITY, + ApexMetrics.CYCLO, + ApexMetrics.WEIGHED_METHOD_COUNT ); - @Override - public Set> getMetrics() { + @Override public Set> getMetrics() { return metrics; } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageModule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageModule.java index 66bb88c9340..9d71fe83b03 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageModule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageModule.java @@ -19,16 +19,16 @@ public class ApexLanguageModule extends LanguageModuleBase implements PmdCapable public ApexLanguageModule() { super(LanguageMetadata.withId(ID).name("Apex") - .extensions("cls", "trigger") - .addVersion("52") - .addVersion("53") - .addVersion("54") - .addVersion("55") - .addVersion("56") - .addVersion("57") - .addVersion("58") - .addVersion("59") - .addDefaultVersion("60")); + .extensions("cls", "trigger") + .addVersion("52") + .addVersion("53") + .addVersion("54") + .addVersion("55") + .addVersion("56") + .addVersion("57") + .addVersion("58") + .addVersion("59") + .addDefaultVersion("60")); } public static ApexLanguageModule getInstance() { @@ -37,18 +37,15 @@ public static ApexLanguageModule getInstance() { return INSTANCE; } - @Override - public ApexLanguageProperties newPropertyBundle() { + @Override public ApexLanguageProperties newPropertyBundle() { return new ApexLanguageProperties(); } - @Override - public LanguageProcessor createProcessor(LanguagePropertyBundle bundle) { + @Override public LanguageProcessor createProcessor(LanguagePropertyBundle bundle) { return new ApexLanguageProcessor((ApexLanguageProperties) bundle); } - @Override - public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { + @Override public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { return new ApexCpdLexer(); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageProcessor.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageProcessor.java index ca626f0976f..ba119226c05 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageProcessor.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageProcessor.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.impl.BatchLanguageProcessor; public class ApexLanguageProcessor - extends BatchLanguageProcessor { + extends BatchLanguageProcessor { private final ApexMultifileAnalysis multifileAnalysis; private final ApexLanguageHandler services; @@ -23,8 +23,7 @@ public class ApexLanguageProcessor this.services = new ApexLanguageHandler(); } - @Override - public @NonNull LanguageVersionHandler services() { + @Override public @NonNull LanguageVersionHandler services() { return services; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageProperties.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageProperties.java index 0ff84da9dcf..4e7bf4126dc 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageProperties.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageProperties.java @@ -16,11 +16,11 @@ public class ApexLanguageProperties extends LanguagePropertyBundle { public static final PropertyDescriptor> MULTIFILE_DIRECTORY = - PropertyFactory.stringProperty("rootDirectory") - .desc("The root directory of the Salesforce metadata, where `sfdx-project.json` resides.") - .defaultValue("") // is this ok? - .toOptional("") - .build(); + PropertyFactory.stringProperty("rootDirectory") + .desc("The root directory of the Salesforce metadata, where `sfdx-project.json` resides.") + .defaultValue("") // is this ok? + .toOptional("") + .build(); public ApexLanguageProperties() { super(ApexLanguageModule.getInstance()); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotation.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotation.java index 1828d56495d..53235ff0acc 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotation.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotation.java @@ -30,44 +30,43 @@ public final class ASTAnnotation extends AbstractApexNode.Single NORMALIZED_ANNOTATION_NAMES = - ImmutableSortedSet.orderedBy(String.CASE_INSENSITIVE_ORDER).add( - "AllowCertifiedApex", - "AuraEnabled", - "Deprecated", - "Future", - "HiddenFromDoc", - "HttpDelete", - "HttpGet", - "HttpPatch", - "HttpPost", - "HttpPut", - "InvocableMethod", - "InvocableVariable", - "IsTest", - "JsonAccess", - "NamespaceAccessible", - "NamespaceGuard", - "PermGuard", - "PrivateApi", - "ReadOnly", - "RemoteAction", - "RestResource", - "SfdcOnly", - "SuppressWarnings", - "TestSetup", - "TestVisible", - "UseConnectDeserializer", - "UseConnectSerializer", - "VisibleApiVersion" - ).build(); + ImmutableSortedSet.orderedBy(String.CASE_INSENSITIVE_ORDER).add( + "AllowCertifiedApex", + "AuraEnabled", + "Deprecated", + "Future", + "HiddenFromDoc", + "HttpDelete", + "HttpGet", + "HttpPatch", + "HttpPost", + "HttpPut", + "InvocableMethod", + "InvocableVariable", + "IsTest", + "JsonAccess", + "NamespaceAccessible", + "NamespaceGuard", + "PermGuard", + "PrivateApi", + "ReadOnly", + "RemoteAction", + "RestResource", + "SfdcOnly", + "SuppressWarnings", + "TestSetup", + "TestVisible", + "UseConnectDeserializer", + "UseConnectSerializer", + "VisibleApiVersion" + ).build(); ASTAnnotation(AnnotationModifier annotationModifier) { super(annotationModifier); } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } @@ -97,8 +96,7 @@ public String getRawName() { return node.getName().getString(); } - @Override - public String getImage() { + @Override public String getImage() { return getName(); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotationParameter.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotationParameter.java index 3782b2946ad..aca1c060a63 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotationParameter.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotationParameter.java @@ -19,8 +19,7 @@ public final class ASTAnnotationParameter extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } @@ -48,8 +47,7 @@ public Boolean getBooleanValue() { return false; } - @Override - public String getImage() { + @Override public String getImage() { return getValue(); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnonymousClass.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnonymousClass.java index e00149198ed..794eb4b1153 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnonymousClass.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAnonymousClass.java @@ -12,13 +12,11 @@ public final class ASTAnonymousClass extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - public String getImage() { + @Override public String getImage() { return node.getClass().getName(); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTApexFile.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTApexFile.java index a95d4d9b7a9..ac356f020d4 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTApexFile.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTApexFile.java @@ -27,17 +27,16 @@ public final class ASTApexFile extends AbstractApexNode.Single private final @NonNull ApexMultifileAnalysis multifileAnalysis; ASTApexFile(ParserTask task, - CompilationUnit compilationUnit, - Collection suppressMap, - @NonNull ApexLanguageProcessor apexLang) { + CompilationUnit compilationUnit, + Collection suppressMap, + @NonNull ApexLanguageProcessor apexLang) { super(compilationUnit); this.astInfo = new AstInfo<>(task, this).withSuppressionComments(suppressMap); this.multifileAnalysis = apexLang.getMultiFileState(); this.setRegion(TextRegion.fromOffsetLength(0, task.getTextDocument().getLength())); } - @Override - public AstInfo getAstInfo() { + @Override public AstInfo getAstInfo() { return astInfo; } @@ -45,14 +44,12 @@ public ASTUserClassOrInterface getMainNode() { return (ASTUserClassOrInterface) getChild(0); } - @Override - public @NonNull ASTApexFile getRoot() { + @Override public @NonNull ASTApexFile getRoot() { return this; } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } @@ -61,8 +58,7 @@ public List getGlobalIssues() { return multifileAnalysis.getFileIssues(fileId.getAbsolutePath()); } - @Override - public String getDefiningType() { + @Override public String getDefiningType() { // an apex file can contain only one top level type BaseApexClass baseApexClass = firstChild(BaseApexClass.class); if (baseApexClass != null) { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTArrayLoadExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTArrayLoadExpression.java index 3dd7d1bf0ac..d4543c260c5 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTArrayLoadExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTArrayLoadExpression.java @@ -13,8 +13,7 @@ public final class ASTArrayLoadExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTArrayStoreExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTArrayStoreExpression.java index 12f41f961a6..1398eca6777 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTArrayStoreExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTArrayStoreExpression.java @@ -13,8 +13,7 @@ public final class ASTArrayStoreExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java index ecb7936f284..9964e2485e3 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTAssignmentExpression.java @@ -13,8 +13,7 @@ public final class ASTAssignmentExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBinaryExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBinaryExpression.java index 4fb307fa963..2b8b165d4d1 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBinaryExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBinaryExpression.java @@ -13,8 +13,7 @@ public final class ASTBinaryExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBindExpressions.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBindExpressions.java index 1660bde57f2..cae182d6d99 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBindExpressions.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBindExpressions.java @@ -13,8 +13,7 @@ public final class ASTBindExpressions extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBlockStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBlockStatement.java index 8a1747dd160..052802a9591 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBlockStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBlockStatement.java @@ -16,8 +16,7 @@ public final class ASTBlockStatement extends AbstractApexNode.Single { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } @@ -25,8 +24,7 @@ public boolean hasCurlyBrace() { return curlyBrace; } - @Override - protected void calculateTextRegion(TextDocument sourceCode) { + @Override protected void calculateTextRegion(TextDocument sourceCode) { super.calculateTextRegion(sourceCode); if (!hasRealLoc()) { return; diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java index 2a18867572d..a7a69669237 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBooleanExpression.java @@ -12,8 +12,7 @@ public final class ASTBooleanExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBreakStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBreakStatement.java index 71194f5eb04..19dcd79b562 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBreakStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTBreakStatement.java @@ -13,8 +13,7 @@ public final class ASTBreakStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCastExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCastExpression.java index 4c706169518..c4ee1578110 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCastExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCastExpression.java @@ -13,8 +13,7 @@ public final class ASTCastExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCatchBlockStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCatchBlockStatement.java index d051b1743b1..c208700c045 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCatchBlockStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTCatchBlockStatement.java @@ -13,8 +13,7 @@ public final class ASTCatchBlockStatement extends AbstractApexCommentContainerNo } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTClassRefExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTClassRefExpression.java index 3379b2200f5..faa5377ef19 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTClassRefExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTClassRefExpression.java @@ -13,8 +13,7 @@ public final class ASTClassRefExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTConstructorPreamble.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTConstructorPreamble.java index c694646b9da..afe49e2f66a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTConstructorPreamble.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTConstructorPreamble.java @@ -13,8 +13,7 @@ public final class ASTConstructorPreamble extends AbstractApexNode.Single } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTConstructorPreambleStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTConstructorPreambleStatement.java index 7721d68bdb5..270603ea19d 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTConstructorPreambleStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTConstructorPreambleStatement.java @@ -13,8 +13,7 @@ public class ASTConstructorPreambleStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTContinueStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTContinueStatement.java index 7e5b010dff4..6f2bd3a730c 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTContinueStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTContinueStatement.java @@ -13,8 +13,7 @@ public final class ASTContinueStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlDeleteStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlDeleteStatement.java index 78fc81ac1d0..bbea3c1f5be 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlDeleteStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlDeleteStatement.java @@ -13,8 +13,7 @@ public final class ASTDmlDeleteStatement extends AbstractDmlStatement { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlInsertStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlInsertStatement.java index a4db16a355a..d8fbc8653a6 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlInsertStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlInsertStatement.java @@ -13,8 +13,7 @@ public final class ASTDmlInsertStatement extends AbstractDmlStatement { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlMergeStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlMergeStatement.java index 9d8f0e38064..fe62b689bf4 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlMergeStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlMergeStatement.java @@ -13,8 +13,7 @@ public final class ASTDmlMergeStatement extends AbstractDmlStatement { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUndeleteStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUndeleteStatement.java index f02742e51f9..84b43b9e9c3 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUndeleteStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUndeleteStatement.java @@ -13,8 +13,7 @@ public final class ASTDmlUndeleteStatement extends AbstractDmlStatement { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUpdateStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUpdateStatement.java index 14870926814..42fbce6660f 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUpdateStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUpdateStatement.java @@ -13,8 +13,7 @@ public final class ASTDmlUpdateStatement extends AbstractDmlStatement { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUpsertStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUpsertStatement.java index 5fbfc0dc3b8..5f08fb4dd66 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUpsertStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDmlUpsertStatement.java @@ -13,8 +13,7 @@ public final class ASTDmlUpsertStatement extends AbstractDmlStatement { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDoLoopStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDoLoopStatement.java index 0426a29e406..54c69ebc494 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDoLoopStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTDoLoopStatement.java @@ -13,8 +13,7 @@ public final class ASTDoLoopStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTElseWhenBlock.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTElseWhenBlock.java index 8e639fb84ea..8e8e3b22dd0 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTElseWhenBlock.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTElseWhenBlock.java @@ -13,8 +13,7 @@ public final class ASTElseWhenBlock extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTEmptyReferenceExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTEmptyReferenceExpression.java index 25c3514e899..d1d0a2b1eca 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTEmptyReferenceExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTEmptyReferenceExpression.java @@ -7,13 +7,11 @@ public final class ASTEmptyReferenceExpression extends AbstractApexNode.Empty { - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - public String getDefiningType() { + @Override public String getDefiningType() { return null; } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTExpression.java index 22f64ed7298..1e729845298 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTExpression.java @@ -13,8 +13,7 @@ public final class ASTExpression extends AbstractApexNode.Single { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTExpressionStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTExpressionStatement.java index 70641433b85..9369d261668 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTExpressionStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTExpressionStatement.java @@ -13,8 +13,7 @@ public final class ASTExpressionStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTField.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTField.java index 1198b3bf070..fa21f6df231 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTField.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTField.java @@ -27,8 +27,8 @@ public final class ASTField extends AbstractApexNode.Many { ASTField(TypeRef typeRef, Identifier name, Optional value) { super(value.isPresent() - ? Arrays.asList(typeRef, name, value.get()) - : Arrays.asList(typeRef, name)); + ? Arrays.asList(typeRef, name, value.get()) + : Arrays.asList(typeRef, name)); this.name = name; this.value = value; this.typeName = caseNormalizedTypeIfPrimitive(typeRef.asCodeString()); @@ -42,13 +42,11 @@ public final class ASTField extends AbstractApexNode.Many { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - public String getImage() { + @Override public String getImage() { return getName(); } @@ -80,8 +78,7 @@ public String getValue() { return null; } - @Override - public boolean hasRealLoc() { + @Override public boolean hasRealLoc() { if (!(nodes.get(0) instanceof TypeRef)) { return super.hasRealLoc(); } @@ -97,8 +94,7 @@ public boolean hasRealLoc() { return allHaveRealLoc; } - @Override - protected void calculateTextRegion(TextDocument sourceCode) { + @Override protected void calculateTextRegion(TextDocument sourceCode) { if (nodes.get(0) instanceof TypeRef) { super.calculateTextRegion(sourceCode); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclaration.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclaration.java index 295658ce4ba..39d16fdc239 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclaration.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclaration.java @@ -13,13 +13,11 @@ public final class ASTFieldDeclaration extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - public String getImage() { + @Override public String getImage() { return getName(); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclarationStatements.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclarationStatements.java index 89862a631d8..cff784bbef1 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclarationStatements.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclarationStatements.java @@ -18,8 +18,7 @@ public final class ASTFieldDeclarationStatements extends AbstractApexNode.Single } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTForEachStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTForEachStatement.java index 5c4d43ed55a..feb386ada87 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTForEachStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTForEachStatement.java @@ -13,8 +13,7 @@ public final class ASTForEachStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTForLoopStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTForLoopStatement.java index 36e98c10da8..c2a1f359e76 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTForLoopStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTForLoopStatement.java @@ -13,8 +13,7 @@ public final class ASTForLoopStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFormalComment.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFormalComment.java index 3243bf3d883..8b9461d6974 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFormalComment.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTFormalComment.java @@ -17,19 +17,16 @@ public final class ASTFormalComment extends AbstractApexNode.Empty { this.token = token; } - - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - public String getImage() { + @Override public String getImage() { return token.getText(); } - @Override - protected void calculateTextRegion(TextDocument sourceCode) { + @Override protected void calculateTextRegion(TextDocument sourceCode) { setRegion(TextRegion.fromBothOffsets(token.getStartIndex(), token.getStopIndex() + 1)); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIdentifierCase.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIdentifierCase.java index 6fd84c17a63..08426a4a53c 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIdentifierCase.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIdentifierCase.java @@ -13,8 +13,7 @@ public final class ASTIdentifierCase extends AbstractApexNode.Single { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIfBlockStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIfBlockStatement.java index 8f1243c5271..44bb2ba572c 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIfBlockStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIfBlockStatement.java @@ -13,8 +13,7 @@ public final class ASTIfBlockStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIfElseBlockStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIfElseBlockStatement.java index 6bd5d46e511..949367b12c5 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIfElseBlockStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIfElseBlockStatement.java @@ -16,8 +16,7 @@ public final class ASTIfElseBlockStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIllegalStoreExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIllegalStoreExpression.java index 3509e6f607b..6a2c97cb07f 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIllegalStoreExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTIllegalStoreExpression.java @@ -13,8 +13,7 @@ public final class ASTIllegalStoreExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTInstanceOfExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTInstanceOfExpression.java index e27dda72e93..3501f6bf7cc 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTInstanceOfExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTInstanceOfExpression.java @@ -13,8 +13,7 @@ public final class ASTInstanceOfExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTInvalidDependentCompilation.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTInvalidDependentCompilation.java index 1cf9540287b..4a24fd674e4 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTInvalidDependentCompilation.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTInvalidDependentCompilation.java @@ -13,14 +13,12 @@ public final class ASTInvalidDependentCompilation extends AbstractApexNode.Singl } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - public String getImage() { + @Override public String getImage() { String apexName = getDefiningType(); return apexName.substring(apexName.lastIndexOf('.') + 1); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTJavaMethodCallExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTJavaMethodCallExpression.java index a7bc0b9100e..d7cfa9031fe 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTJavaMethodCallExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTJavaMethodCallExpression.java @@ -13,8 +13,7 @@ public final class ASTJavaMethodCallExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTJavaVariableExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTJavaVariableExpression.java index 9927a3b0d7b..76961fb55e3 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTJavaVariableExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTJavaVariableExpression.java @@ -13,8 +13,7 @@ public final class ASTJavaVariableExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralCase.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralCase.java index 33d6a246cb7..ea54e55bd36 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralCase.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralCase.java @@ -13,8 +13,7 @@ public final class ASTLiteralCase extends AbstractApexNode.Single { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralExpression.java index 2be11d18274..ba469a48092 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralExpression.java @@ -14,8 +14,7 @@ public final class ASTLiteralExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } @@ -78,8 +77,7 @@ public boolean isNull() { return getLiteralType() == LiteralType.NULL; } - @Override - public String getImage() { + @Override public String getImage() { return literalToString(node); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMapEntryNode.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMapEntryNode.java index 6b5c2cb94f1..ce8f590fccf 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMapEntryNode.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMapEntryNode.java @@ -20,13 +20,11 @@ public final class ASTMapEntryNode extends AbstractApexNode.Many { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - public String getImage() { + @Override public String getImage() { return String.format("%s: %s", key, value); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethod.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethod.java index 3f44ef54307..800e916139c 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethod.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethod.java @@ -44,11 +44,11 @@ public final class ASTMethod extends AbstractApexNode implements ApexQualifiable private final SourceLocation sourceLocation; ASTMethod( - String name, - String internalName, - List parameterTypes, - String returnType, - SourceLocation sourceLocation) { + String name, + String internalName, + List parameterTypes, + String returnType, + SourceLocation sourceLocation) { this.name = name; this.internalName = internalName; @@ -68,23 +68,21 @@ static ASTMethod fromNode(MethodDeclaration node) { } return new ASTMethod( - name, - internalName, - node.getParameterDeclarations().stream() - .map(p -> caseNormalizedTypeIfPrimitive(p.getType().asCodeString())) - .collect(Collectors.toList()), - caseNormalizedTypeIfPrimitive(node.getReturnType().asCodeString()), - node.getSourceLocation()); + name, + internalName, + node.getParameterDeclarations().stream() + .map(p -> caseNormalizedTypeIfPrimitive(p.getType().asCodeString())) + .collect(Collectors.toList()), + caseNormalizedTypeIfPrimitive(node.getReturnType().asCodeString()), + node.getSourceLocation()); } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - void calculateTextRegion(TextDocument sourceCode) { + @Override void calculateTextRegion(TextDocument sourceCode) { if (sourceLocation.isUnknown()) { return; } @@ -97,13 +95,11 @@ void calculateTextRegion(TextDocument sourceCode) { )); } - @Override - public boolean hasRealLoc() { + @Override public boolean hasRealLoc() { return !sourceLocation.isUnknown(); } - @Override - public String getImage() { + @Override public String getImage() { if (isConstructor()) { BaseApexClass baseClassNode = ancestors(BaseApexClass.class).first(); if (baseClassNode != null) { @@ -127,8 +123,7 @@ public String getCanonicalName() { return name; } - @Override - public ApexQualifiedName getQualifiedName() { + @Override public ApexQualifiedName getQualifiedName() { return ApexQualifiedName.ofMethod(this); } @@ -163,8 +158,7 @@ public int getArity() { * @return true if this method is the synthetic trigger method * @since 7.5.0 */ - @NoAttribute - public boolean isTriggerBlock() { + @NoAttribute public boolean isTriggerBlock() { return TRIGGER_INVOKE_ID.equals(internalName); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodBlockStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodBlockStatement.java index d3256d2bfea..568a29ca595 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodBlockStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodBlockStatement.java @@ -13,8 +13,7 @@ public final class ASTMethodBlockStatement extends AbstractApexNode.Single } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodCallExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodCallExpression.java index b58b5bf6f69..6c60507b23f 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodCallExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodCallExpression.java @@ -25,8 +25,7 @@ public final class ASTMethodCallExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifier.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifier.java index 5f811c84a34..875618e090a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifier.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifier.java @@ -13,8 +13,7 @@ public final class ASTModifier extends AbstractApexNode.Single { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java index 2a95b5ca506..5ae397d254b 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierNode.java @@ -30,13 +30,11 @@ public final class ASTModifierNode extends AbstractApexNode.Many imple } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - public int getModifiers() { + @Override public int getModifiers() { int modifiers = nodes .stream() .filter(mod -> mod instanceof KeywordModifier) @@ -63,38 +61,31 @@ public int getModifiers() { return modifiers; } - @Override - public boolean isPublic() { + @Override public boolean isPublic() { return (getModifiers() & PUBLIC) == PUBLIC; } - @Override - public boolean isProtected() { + @Override public boolean isProtected() { return (getModifiers() & PROTECTED) == PROTECTED; } - @Override - public boolean isPrivate() { + @Override public boolean isPrivate() { return (getModifiers() & PRIVATE) == PRIVATE; } - @Override - public boolean isAbstract() { + @Override public boolean isAbstract() { return (getModifiers() & ABSTRACT) == ABSTRACT; } - @Override - public boolean isStatic() { + @Override public boolean isStatic() { return (getModifiers() & STATIC) == STATIC; } - @Override - public boolean isFinal() { + @Override public boolean isFinal() { return (getModifiers() & FINAL) == FINAL; } - @Override - public boolean isTransient() { + @Override public boolean isTransient() { return (getModifiers() & TRANSIENT) == TRANSIENT; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierOrAnnotation.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierOrAnnotation.java index bbe4d273cb5..f5f17cedd81 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierOrAnnotation.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTModifierOrAnnotation.java @@ -13,8 +13,7 @@ public final class ASTModifierOrAnnotation extends AbstractApexNode.Single } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMultiStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMultiStatement.java index 608d790f94c..4baf0960762 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMultiStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMultiStatement.java @@ -13,8 +13,7 @@ public final class ASTMultiStatement extends AbstractApexNode.Single { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNestedExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNestedExpression.java index b9e50e0facc..8d4ec26a905 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNestedExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNestedExpression.java @@ -13,8 +13,7 @@ public final class ASTNestedExpression extends AbstractApexNode.Single { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNestedStoreExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNestedStoreExpression.java index 69267154fd7..2b3db5238c1 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNestedStoreExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNestedStoreExpression.java @@ -13,8 +13,7 @@ public final class ASTNestedStoreExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpression.java index b298a048dc4..4fe95772fd8 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpression.java @@ -13,8 +13,7 @@ public final class ASTNewKeyValueObjectExpression extends AbstractApexNode.Singl } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewListInitExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewListInitExpression.java index f1fcf5f59b7..7936469e4d9 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewListInitExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewListInitExpression.java @@ -13,8 +13,7 @@ public final class ASTNewListInitExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewListLiteralExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewListLiteralExpression.java index 5963f2869c1..fd23bcbff50 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewListLiteralExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewListLiteralExpression.java @@ -13,8 +13,7 @@ public final class ASTNewListLiteralExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewMapInitExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewMapInitExpression.java index 1fb62440be8..d99c8ed8b37 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewMapInitExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewMapInitExpression.java @@ -13,8 +13,7 @@ public final class ASTNewMapInitExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewMapLiteralExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewMapLiteralExpression.java index ad0a775a613..788db4524eb 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewMapLiteralExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewMapLiteralExpression.java @@ -13,8 +13,7 @@ public final class ASTNewMapLiteralExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewObjectExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewObjectExpression.java index 686f11f79c8..150b77b53ad 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewObjectExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewObjectExpression.java @@ -13,8 +13,7 @@ public final class ASTNewObjectExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewSetInitExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewSetInitExpression.java index b2619789e52..094086153f9 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewSetInitExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewSetInitExpression.java @@ -13,8 +13,7 @@ public final class ASTNewSetInitExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewSetLiteralExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewSetLiteralExpression.java index 7418d03b4c3..b46c8984cbc 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewSetLiteralExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTNewSetLiteralExpression.java @@ -13,8 +13,7 @@ public final class ASTNewSetLiteralExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPackageVersionExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPackageVersionExpression.java index ef2705f85e9..dba82996ebe 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPackageVersionExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPackageVersionExpression.java @@ -13,8 +13,7 @@ public final class ASTPackageVersionExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTParameter.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTParameter.java index b5a24279a84..548f96860cd 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTParameter.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTParameter.java @@ -13,13 +13,11 @@ public final class ASTParameter extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - public String getImage() { + @Override public String getImage() { return node.getId().getString(); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java index 08296a6944b..0caff1bf870 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPostfixExpression.java @@ -13,8 +13,7 @@ public final class ASTPostfixExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java index 604afc32e7b..773f9110302 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTPrefixExpression.java @@ -12,8 +12,7 @@ public final class ASTPrefixExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTProperty.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTProperty.java index 15e8bddba65..087a6f0c709 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTProperty.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTProperty.java @@ -18,8 +18,7 @@ public final class ASTProperty extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpression.java index 22378be9853..89de6c69972 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpression.java @@ -23,8 +23,7 @@ public final class ASTReferenceExpression extends AbstractApexNode.Many R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } @@ -32,16 +31,14 @@ public ReferenceType getReferenceType() { return referenceType; } - @Override - public String getImage() { + @Override public String getImage() { if (!nodes.isEmpty()) { return nodes.get(0).getString(); } return ""; } - @NoAttribute - public List getNames() { + @NoAttribute public List getNames() { return nodes.stream().map(Identifier::getString).collect(Collectors.toList()); } @@ -53,8 +50,7 @@ public boolean isSObjectType() { return nodes.stream().anyMatch(id -> "sobjecttype".equalsIgnoreCase(id.getString())); } - @Override - public boolean hasRealLoc() { + @Override public boolean hasRealLoc() { return !nodes.isEmpty(); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReturnStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReturnStatement.java index 5aa54fd9833..836cc063574 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReturnStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTReturnStatement.java @@ -13,8 +13,7 @@ public final class ASTReturnStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTRunAsBlockStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTRunAsBlockStatement.java index e508ff78ad9..c654e94fdcd 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTRunAsBlockStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTRunAsBlockStatement.java @@ -13,8 +13,7 @@ public final class ASTRunAsBlockStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpression.java index 3b08de7d9bb..13a8724df47 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpression.java @@ -18,8 +18,7 @@ public final class ASTSoqlExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSoslExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSoslExpression.java index 8e7a4e33dbe..c9ee84a05a4 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSoslExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSoslExpression.java @@ -17,8 +17,7 @@ public final class ASTSoslExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStandardCondition.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStandardCondition.java index 6742140aaea..3604649a44a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStandardCondition.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStandardCondition.java @@ -13,8 +13,7 @@ public final class ASTStandardCondition extends AbstractApexNode.Single { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStatement.java index d0c7f78cbef..3089c60adcd 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStatement.java @@ -13,8 +13,7 @@ public final class ASTStatement extends AbstractApexNode.Single { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStatementExecuted.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStatementExecuted.java index 8fb82e4edbe..5fc3003e96e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStatementExecuted.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTStatementExecuted.java @@ -13,8 +13,7 @@ public final class ASTStatementExecuted extends AbstractApexNode.Single { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSuperMethodCallExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSuperMethodCallExpression.java index 00749591ffd..ecd93e5f661 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSuperMethodCallExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSuperMethodCallExpression.java @@ -13,8 +13,7 @@ public final class ASTSuperMethodCallExpression extends AbstractApexNode.Single< } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSuperVariableExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSuperVariableExpression.java index a30c4180d27..8b11dc28e23 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSuperVariableExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSuperVariableExpression.java @@ -13,8 +13,7 @@ public final class ASTSuperVariableExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSwitchStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSwitchStatement.java index 3c18e4f88b4..ae0cb37d0e7 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSwitchStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTSwitchStatement.java @@ -13,8 +13,7 @@ public final class ASTSwitchStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTernaryExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTernaryExpression.java index fcfc3ff3e61..ccd5a7a500d 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTernaryExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTernaryExpression.java @@ -13,8 +13,7 @@ public final class ASTTernaryExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThisMethodCallExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThisMethodCallExpression.java index 245db61e42c..35fcb7302d3 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThisMethodCallExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThisMethodCallExpression.java @@ -13,8 +13,7 @@ public final class ASTThisMethodCallExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThisVariableExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThisVariableExpression.java index 474eda0c0ac..9f04a3722c8 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThisVariableExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThisVariableExpression.java @@ -13,8 +13,7 @@ public final class ASTThisVariableExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThrowStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThrowStatement.java index 2710750279a..4f8755e836e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThrowStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTThrowStatement.java @@ -13,8 +13,7 @@ public class ASTThrowStatement extends AbstractApexNode.Single { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTriggerVariableExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTriggerVariableExpression.java index 215d15f42a5..82128d727fd 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTriggerVariableExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTriggerVariableExpression.java @@ -13,8 +13,7 @@ public final class ASTTriggerVariableExpression extends AbstractApexNode.Single< } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatement.java index 7ca5e80248a..3f10b00fc9b 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatement.java @@ -15,8 +15,7 @@ public final class ASTTryCatchFinallyBlockStatement extends AbstractApexNode.Sin } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTypeWhenBlock.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTypeWhenBlock.java index 3772aaae00d..33496abcad1 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTypeWhenBlock.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTTypeWhenBlock.java @@ -27,8 +27,7 @@ public String getName() { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClass.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClass.java index 15801c78753..4732fff7189 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClass.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClass.java @@ -16,8 +16,7 @@ public final class ASTUserClass extends BaseApexClass implemen super(userClass); } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } @@ -42,7 +41,7 @@ public String getSuperClassName() { */ public List getInterfaceNames() { return node.getImplementsTypes().stream() - .map(TypeRef::asTypeErasedString) - .collect(Collectors.toList()); + .map(TypeRef::asTypeErasedString) + .collect(Collectors.toList()); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassMethods.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassMethods.java index 424aef3776d..fba2b3fa5e4 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassMethods.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassMethods.java @@ -13,8 +13,7 @@ public final class ASTUserClassMethods extends AbstractApexNode.Single { } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnum.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnum.java index f8b5ebcf405..ee684b26d1f 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnum.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnum.java @@ -13,13 +13,11 @@ public final class ASTUserEnum extends BaseApexClass { super(enumDeclaration); } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - public ApexQualifiedName getQualifiedName() { + @Override public ApexQualifiedName getQualifiedName() { if (qname == null) { ASTUserClass parent = ancestors(ASTUserClass.class).first(); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserExceptionMethods.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserExceptionMethods.java index 931351c1d2d..ffbcb40dad8 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserExceptionMethods.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserExceptionMethods.java @@ -13,8 +13,7 @@ public final class ASTUserExceptionMethods extends AbstractApexNode.Single } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterface.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterface.java index 4618221aba8..173895f101a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterface.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterface.java @@ -13,8 +13,7 @@ public final class ASTUserInterface extends BaseApexClass super(userInterface); } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTrigger.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTrigger.java index 59855e084e2..6545b46054a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTrigger.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTrigger.java @@ -15,8 +15,7 @@ public final class ASTUserTrigger extends BaseApexClass { super(triggerDeclaration); } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTValueWhenBlock.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTValueWhenBlock.java index e30774d5371..0d74ae809a2 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTValueWhenBlock.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTValueWhenBlock.java @@ -13,8 +13,7 @@ public final class ASTValueWhenBlock extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableDeclaration.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableDeclaration.java index 869eed545e5..9dc9e1baa00 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableDeclaration.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableDeclaration.java @@ -13,13 +13,11 @@ public final class ASTVariableDeclaration extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - public String getImage() { + @Override public String getImage() { return node.getId().getString(); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableDeclarationStatements.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableDeclarationStatements.java index c96acdf94b4..100435548a0 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableDeclarationStatements.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableDeclarationStatements.java @@ -13,8 +13,7 @@ public final class ASTVariableDeclarationStatements extends AbstractApexNode.Sin } - @Override - protected R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableExpression.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableExpression.java index 2af69232289..98acc43618a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableExpression.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTVariableExpression.java @@ -13,13 +13,11 @@ public final class ASTVariableExpression extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } - @Override - public String getImage() { + @Override public String getImage() { return node.getString(); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTWhileLoopStatement.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTWhileLoopStatement.java index 57b2d4e95cd..bd9c5aa2b78 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTWhileLoopStatement.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTWhileLoopStatement.java @@ -13,8 +13,7 @@ public final class ASTWhileLoopStatement extends AbstractApexNode.Single R acceptApexVisitor(ApexVisitor visitor, P data) { + @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexCommentContainerNode.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexCommentContainerNode.java index 594d2f72443..4e7cfd05f84 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexCommentContainerNode.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexCommentContainerNode.java @@ -23,8 +23,7 @@ void setContainsComment(boolean containsComment) { this.containsComment = containsComment; } - @Override - public boolean getContainsComment() { + @Override public boolean getContainsComment() { return containsComment; } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexNode.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexNode.java index a86b7b0d34d..75faf78f710 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexNode.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AbstractApexNode.java @@ -37,21 +37,19 @@ protected Single(T node) { this.node = node; } - @Override - protected void calculateTextRegion(TextDocument sourceCode) { + @Override protected void calculateTextRegion(TextDocument sourceCode) { SourceLocation loc = node.getSourceLocation(); if (loc.isUnknown()) { return; } // Column+1 because Summit columns are 0-based and PMD are 1-based setRegion(TextRegion.fromBothOffsets( - sourceCode.offsetAtLineColumn(TextPos2d.pos2d(loc.getStartLine(), loc.getStartColumn() + 1)), - sourceCode.offsetAtLineColumn(TextPos2d.pos2d(loc.getEndLine(), loc.getEndColumn() + 1)) + sourceCode.offsetAtLineColumn(TextPos2d.pos2d(loc.getStartLine(), loc.getStartColumn() + 1)), + sourceCode.offsetAtLineColumn(TextPos2d.pos2d(loc.getEndLine(), loc.getEndColumn() + 1)) )); } - @Override - public boolean hasRealLoc() { + @Override public boolean hasRealLoc() { return !node.getSourceLocation().isUnknown(); } } @@ -67,8 +65,7 @@ protected Many(List nodes) { this.nodes = nodes; } - @Override - protected void calculateTextRegion(TextDocument sourceCode) { + @Override protected void calculateTextRegion(TextDocument sourceCode) { // from all nodes, use the earliest location and the latest location. // this assumes, that these nodes form a contiguous code snippet. @@ -92,14 +89,13 @@ protected void calculateTextRegion(TextDocument sourceCode) { if (!union.isUnknown()) { // Column+1 because Summit columns are 0-based and PMD are 1-based setRegion(TextRegion.fromBothOffsets( - sourceCode.offsetAtLineColumn(TextPos2d.pos2d(union.getStartLine(), union.getStartColumn() + 1)), - sourceCode.offsetAtLineColumn(TextPos2d.pos2d(union.getEndLine(), union.getEndColumn() + 1)) + sourceCode.offsetAtLineColumn(TextPos2d.pos2d(union.getStartLine(), union.getStartColumn() + 1)), + sourceCode.offsetAtLineColumn(TextPos2d.pos2d(union.getEndLine(), union.getEndColumn() + 1)) )); } } - @Override - public boolean hasRealLoc() { + @Override public boolean hasRealLoc() { return !nodes.isEmpty() && nodes.stream().noneMatch(n -> n.getSourceLocation().isUnknown()); } } @@ -109,36 +105,29 @@ public boolean hasRealLoc() { */ abstract static class Empty extends AbstractApexNode { - @Override - protected void calculateTextRegion(TextDocument sourceCode) { + @Override protected void calculateTextRegion(TextDocument sourceCode) { // no location } - @Override - public boolean hasRealLoc() { + @Override public boolean hasRealLoc() { return false; } } // overridden to make them visible - @Override - protected void addChild(AbstractApexNode child, int index) { + @Override protected void addChild(AbstractApexNode child, int index) { super.addChild(child, index); } - @Override - protected void insertChild(AbstractApexNode child, int index) { + @Override protected void insertChild(AbstractApexNode child, int index) { super.insertChild(child, index); } - @Override - protected void setChild(AbstractApexNode child, int index) { + @Override protected void setChild(AbstractApexNode child, int index) { super.setChild(child, index); } - @Override - @SuppressWarnings("unchecked") - public final R acceptVisitor(AstVisitor visitor, P data) { + @Override @SuppressWarnings("unchecked") public final R acceptVisitor(AstVisitor visitor, P data) { if (visitor instanceof ApexVisitor) { return this.acceptApexVisitor((ApexVisitor) visitor, data); } @@ -147,15 +136,13 @@ public final R acceptVisitor(AstVisitor visitor, protected abstract R acceptApexVisitor(ApexVisitor visitor, P data); - @Override - public @NonNull ASTApexFile getRoot() { + @Override public @NonNull ASTApexFile getRoot() { return getParent().getRoot(); } abstract void calculateTextRegion(TextDocument sourceCode); - @Override - public @NonNull TextRegion getTextRegion() { + @Override public @NonNull TextRegion getTextRegion() { if (region == null) { if (!hasRealLoc()) { AbstractApexNode parent = (AbstractApexNode) getParent(); @@ -170,20 +157,17 @@ public final R acceptVisitor(AstVisitor visitor, return region; } - @Override - public final String getXPathNodeName() { + @Override public final String getXPathNodeName() { return this.getClass().getSimpleName().replaceFirst("^AST", ""); } protected void setRegion(TextRegion region) { this.region = region; } - - @Override - public abstract boolean hasRealLoc(); - @Override - public String getDefiningType() { + @Override public abstract boolean hasRealLoc(); + + @Override public String getDefiningType() { BaseApexClass baseNode = this instanceof BaseApexClass ? (BaseApexClass) this : ancestors(BaseApexClass.class).first(); if (baseNode != null) { return baseNode.getQualifiedName().toString(); @@ -214,23 +198,23 @@ static String caseNormalizedTypeIfPrimitive(String name) { } private static NavigableSet caseNormalizedTypeNames = - new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + new TreeSet<>(String.CASE_INSENSITIVE_ORDER); static { caseNormalizedTypeNames.addAll(Arrays.asList( - "Blob", - "Boolean", - "Currency", - "Date", - "Datetime", - "Decimal", - "Double", - "Id", - "Integer", - "Long", - "Object", - "String", - "Time" + "Blob", + "Boolean", + "Currency", + "Date", + "Datetime", + "Decimal", + "Double", + "Id", + "Integer", + "Long", + "Object", + "String", + "Time" )); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentBuilder.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentBuilder.java index 38e4cac5ac1..f43b7023f46 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentBuilder.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentBuilder.java @@ -102,7 +102,7 @@ public void buildFormalComment(AbstractApexNode node) { } if (docToken.nearestNode == null - || nodeRegion.compareTo(docToken.nearestNode.getTextRegion()) < 0) { + || nodeRegion.compareTo(docToken.nearestNode.getTextRegion()) < 0) { docToken.nearestNode = node; } @@ -114,8 +114,7 @@ private static CommentInformation extractInformationFromComments(TextDocument so ApexLexer lexer = new ApexLexer(new CaseInsensitiveInputStream(CharStreams.fromString(source))); lexer.removeErrorListeners(); lexer.addErrorListener(new BaseErrorListener() { - @Override - public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { + @Override public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { throw new LexException(line, charPositionInLine, sourceCode.getFileId(), msg, e); } }); @@ -131,7 +130,7 @@ public void syntaxError(Recognizer recognizer, Object offendingSymbol, int // Keep track of all comment tokens if (token.getChannel() == ApexLexer.COMMENT_CHANNEL) { assert lastStartIndex < token.getStartIndex() - : "Comments should be sorted"; + : "Comments should be sorted"; allCommentTokens.add(token); } @@ -142,9 +141,9 @@ public void syntaxError(Recognizer recognizer, Object offendingSymbol, int if (trimmedCommentText.startsWith(suppressMarker)) { String userMessage = trimmedCommentText.substring(suppressMarker.length()).trim(); FileLocation loc = FileLocation.caret( - sourceCode.getFileId(), - token.getLine(), - token.getCharPositionInLine() + 1 + sourceCode.getFileId(), + token.getLine(), + token.getCharPositionInLine() + 1 ); suppressionComments.add(new SuppressionCommentImpl<>(() -> loc, userMessage)); } @@ -166,9 +165,9 @@ private static class CommentInformation { CommentInformation(Collection suppressMap, List allCommentTokens) { this.suppressionComments = suppressMap; this.docTokens = allCommentTokens.stream() - .filter(token -> token.getType() == ApexLexer.DOC_COMMENT) - .map(ApexDocToken::new) - .collect(toList()); + .filter(token -> token.getType() == ApexLexer.DOC_COMMENT) + .map(ApexDocToken::new) + .collect(toList()); this.allCommentsByStartIndex = new TokenListByStartIndex(new ArrayList<>(allCommentTokens)); } } @@ -188,13 +187,11 @@ & RandomAccess> TokenListByStartIndex(T tokens) { this.tokens = tokens; } - @Override - public Integer get(int index) { + @Override public Integer get(int index) { return tokens.get(index).getStartIndex(); } - @Override - public int size() { + @Override public int size() { return tokens.size(); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexNode.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexNode.java index cf398156e61..6529b0de1b4 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexNode.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexNode.java @@ -22,6 +22,5 @@ public interface ApexNode extends GenericNode> { String getDefiningType(); - @Override - @NonNull ASTApexFile getRoot(); + @Override @NonNull ASTApexFile getRoot(); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexParser.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexParser.java index 769315e3b25..2ad1c6db06d 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexParser.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexParser.java @@ -27,8 +27,7 @@ public final class ApexParser implements Parser { TRANSLATE_LOGGER.setLevel(Level.WARNING); } - @Override - public ASTApexFile parse(final ParserTask task) { + @Override public ASTApexFile parse(final ParserTask task) { CompilationUnit astRoot = null; try { astRoot = SummitAST.INSTANCE.parseAndTranslate(task.getFileId().getOriginalPath(), task.getTextDocument().getText().toString(), null); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java index 00ea17431fe..162e601baa4 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedName.java @@ -61,8 +61,7 @@ public boolean isOperation() { } - @Override - public String toString() { + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(classes[0]); @@ -93,19 +92,17 @@ public ApexQualifiedName getClassName() { } - @Override - public int hashCode() { + @Override public int hashCode() { int result = Arrays.hashCode(classes); result = 31 * result + (operation != null ? operation.hashCode() : 0); return result; } - @Override - public boolean equals(Object obj) { + @Override public boolean equals(Object obj) { return obj instanceof ApexQualifiedName - && Objects.deepEquals(classes, ((ApexQualifiedName) obj).classes) - && Objects.equals(operation, ((ApexQualifiedName) obj).operation); + && Objects.deepEquals(classes, ((ApexQualifiedName) obj).classes) + && Objects.equals(operation, ((ApexQualifiedName) obj).operation); } @@ -173,8 +170,8 @@ private static String getOperationString(ASTMethod node) { sb.append(node.getImage()).append('('); List paramTypes = node.children(ASTParameter.class).toStream() - .map(ASTParameter::getType) - .collect(Collectors.toList()); + .map(ASTParameter::getType) + .collect(Collectors.toList()); if (!paramTypes.isEmpty()) { for (int i = 0; i < paramTypes.size(); i++) { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexVisitorBase.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexVisitorBase.java index ff76e12b402..b508bb717e5 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexVisitorBase.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ApexVisitorBase.java @@ -8,13 +8,11 @@ public abstract class ApexVisitorBase extends AstVisitorBase implements ApexVisitor { - @Override - public R visit(ASTUserInterface node, P data) { + @Override public R visit(ASTUserInterface node, P data) { return visitTypeDecl(node, data); } - @Override - public R visit(ASTUserClass node, P data) { + @Override public R visit(ASTUserClass node, P data) { return visitTypeDecl(node, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AssignmentOperator.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AssignmentOperator.java index 1a7a5b71e04..84a7beed8b1 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AssignmentOperator.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/AssignmentOperator.java @@ -28,8 +28,7 @@ public enum AssignmentOperator { this.symbol = symbol; } - @Override - public String toString() { + @Override public String toString() { return this.symbol; } @@ -42,28 +41,28 @@ public static AssignmentOperator valueOf(BinaryExpression.Operator op) { return EQUALS; } switch (op) { - case ADDITION: - return ADDITION_EQUALS; - case SUBTRACTION: - return SUBTRACTION_EQUALS; - case MULTIPLICATION: - return MULTIPLICATION_EQUALS; - case DIVISION: - return DIVISION_EQUALS; - case LEFT_SHIFT: - return LEFT_SHIFT_EQUALS; - case RIGHT_SHIFT_SIGNED: - return RIGHT_SHIFT_SIGNED_EQUALS; - case RIGHT_SHIFT_UNSIGNED: - return RIGHT_SHIFT_UNSIGNED_EQUALS; - case BITWISE_AND: - return BITWISE_AND_EQUALS; - case BITWISE_OR: - return BITWISE_OR_EQUALS; - case BITWISE_XOR: - return BITWISE_XOR_EQUALS; - default: - throw new IllegalArgumentException("Invalid assignment operator " + op); + case ADDITION: + return ADDITION_EQUALS; + case SUBTRACTION: + return SUBTRACTION_EQUALS; + case MULTIPLICATION: + return MULTIPLICATION_EQUALS; + case DIVISION: + return DIVISION_EQUALS; + case LEFT_SHIFT: + return LEFT_SHIFT_EQUALS; + case RIGHT_SHIFT_SIGNED: + return RIGHT_SHIFT_SIGNED_EQUALS; + case RIGHT_SHIFT_UNSIGNED: + return RIGHT_SHIFT_UNSIGNED_EQUALS; + case BITWISE_AND: + return BITWISE_AND_EQUALS; + case BITWISE_OR: + return BITWISE_OR_EQUALS; + case BITWISE_XOR: + return BITWISE_XOR_EQUALS; + default: + throw new IllegalArgumentException("Invalid assignment operator " + op); } } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BaseApexClass.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BaseApexClass.java index 4188f544524..98522d2f87a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BaseApexClass.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BaseApexClass.java @@ -14,23 +14,19 @@ protected BaseApexClass(T node) { super(node); } - @Override - public boolean isFindBoundary() { + @Override public boolean isFindBoundary() { return true; } - @Override - public String getImage() { + @Override public String getImage() { return getSimpleName(); } - @Override - public String getSimpleName() { + @Override public String getSimpleName() { return node.getId().getString(); } - @Override - public ApexQualifiedName getQualifiedName() { + @Override public ApexQualifiedName getQualifiedName() { if (qname == null) { ASTUserClass parent = ancestors(ASTUserClass.class).first(); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BinaryOperator.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BinaryOperator.java index bc4b96cfa60..3fe4ef4bacf 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BinaryOperator.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BinaryOperator.java @@ -28,8 +28,7 @@ public enum BinaryOperator { this.symbol = symbol; } - @Override - public String toString() { + @Override public String toString() { return this.symbol; } @@ -39,30 +38,30 @@ public String toString() { */ public static BinaryOperator valueOf(BinaryExpression.Operator op) { switch (op) { - case ADDITION: - return ADDITION; - case SUBTRACTION: - return SUBTRACTION; - case MULTIPLICATION: - return MULTIPLICATION; - case DIVISION: - return DIVISION; - case LEFT_SHIFT: - return LEFT_SHIFT; - case RIGHT_SHIFT_SIGNED: - return RIGHT_SHIFT_SIGNED; - case RIGHT_SHIFT_UNSIGNED: - return RIGHT_SHIFT_UNSIGNED; - case BITWISE_AND: - return BITWISE_AND; - case BITWISE_OR: - return BITWISE_OR; - case BITWISE_XOR: - return BITWISE_XOR; - case NULL_COALESCING: - return NULL_COALESCING; - default: - throw new IllegalArgumentException("Invalid binary operator " + op); + case ADDITION: + return ADDITION; + case SUBTRACTION: + return SUBTRACTION; + case MULTIPLICATION: + return MULTIPLICATION; + case DIVISION: + return DIVISION; + case LEFT_SHIFT: + return LEFT_SHIFT; + case RIGHT_SHIFT_SIGNED: + return RIGHT_SHIFT_SIGNED; + case RIGHT_SHIFT_UNSIGNED: + return RIGHT_SHIFT_UNSIGNED; + case BITWISE_AND: + return BITWISE_AND; + case BITWISE_OR: + return BITWISE_OR; + case BITWISE_XOR: + return BITWISE_XOR; + case NULL_COALESCING: + return NULL_COALESCING; + default: + throw new IllegalArgumentException("Invalid binary operator " + op); } } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BooleanOperator.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BooleanOperator.java index fa5378b3de7..0da41f211b8 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BooleanOperator.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/BooleanOperator.java @@ -28,8 +28,7 @@ public enum BooleanOperator { this.symbol = symbol; } - @Override - public String toString() { + @Override public String toString() { return this.symbol; } @@ -39,30 +38,30 @@ public String toString() { */ public static BooleanOperator valueOf(BinaryExpression.Operator op) { switch (op) { - case EQUAL: - return EQUAL; - case NOT_EQUAL: - return NOT_EQUAL; - case ALTERNATIVE_NOT_EQUAL: - return ALT_NOT_EQUAL; - case EXACTLY_EQUAL: - return EXACTLY_EQUAL; - case EXACTLY_NOT_EQUAL: - return EXACTLY_NOT_EQUAL; - case LESS_THAN: - return LESS_THAN; - case GREATER_THAN: - return GREATER_THAN; - case LESS_THAN_OR_EQUAL: - return LESS_THAN_OR_EQUAL; - case GREATER_THAN_OR_EQUAL: - return GREATER_THAN_OR_EQUAL; - case LOGICAL_AND: - return LOGICAL_AND; - case LOGICAL_OR: - return LOGICAL_OR; - default: - throw new IllegalArgumentException("Invalid boolean operator " + op); + case EQUAL: + return EQUAL; + case NOT_EQUAL: + return NOT_EQUAL; + case ALTERNATIVE_NOT_EQUAL: + return ALT_NOT_EQUAL; + case EXACTLY_EQUAL: + return EXACTLY_EQUAL; + case EXACTLY_NOT_EQUAL: + return EXACTLY_NOT_EQUAL; + case LESS_THAN: + return LESS_THAN; + case GREATER_THAN: + return GREATER_THAN; + case LESS_THAN_OR_EQUAL: + return LESS_THAN_OR_EQUAL; + case GREATER_THAN_OR_EQUAL: + return GREATER_THAN_OR_EQUAL; + case LOGICAL_AND: + return LOGICAL_AND; + case LOGICAL_OR: + return LOGICAL_OR; + default: + throw new IllegalArgumentException("Invalid boolean operator " + op); } } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PostfixOperator.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PostfixOperator.java index 7582b17fa5c..f3e49cf1324 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PostfixOperator.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PostfixOperator.java @@ -19,8 +19,7 @@ public enum PostfixOperator { this.symbol = symbol; } - @Override - public String toString() { + @Override public String toString() { return this.symbol; } @@ -30,12 +29,12 @@ public String toString() { */ public static PostfixOperator valueOf(UnaryExpression.Operator op) { switch (op) { - case POST_INCREMENT: - return INCREMENT; - case POST_DECREMENT: - return DECREMENT; - default: - throw new IllegalArgumentException("Invalid postfix operator " + op); + case POST_INCREMENT: + return INCREMENT; + case POST_DECREMENT: + return DECREMENT; + default: + throw new IllegalArgumentException("Invalid postfix operator " + op); } } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PrefixOperator.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PrefixOperator.java index dbb92491e0c..81a08651644 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PrefixOperator.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/PrefixOperator.java @@ -23,8 +23,7 @@ public enum PrefixOperator { this.symbol = symbol; } - @Override - public String toString() { + @Override public String toString() { return this.symbol; } @@ -34,20 +33,20 @@ public String toString() { */ public static PrefixOperator valueOf(UnaryExpression.Operator op) { switch (op) { - case PLUS: - return POSITIVE; - case NEGATION: - return NEGATIVE; - case LOGICAL_COMPLEMENT: - return LOGICAL_NOT; - case BITWISE_NOT: - return BITWISE_NOT; - case PRE_INCREMENT: - return INCREMENT; - case PRE_DECREMENT: - return DECREMENT; - default: - throw new IllegalArgumentException("Invalid prefix operator " + op); + case PLUS: + return POSITIVE; + case NEGATION: + return NEGATIVE; + case LOGICAL_COMPLEMENT: + return LOGICAL_NOT; + case BITWISE_NOT: + return BITWISE_NOT; + case PRE_INCREMENT: + return INCREMENT; + case PRE_DECREMENT: + return DECREMENT; + default: + throw new IllegalArgumentException("Invalid prefix operator " + op); } } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/cpd/ApexCpdLexer.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/cpd/ApexCpdLexer.java index 2c22ce75fb4..eb54919eb97 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/cpd/ApexCpdLexer.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/cpd/ApexCpdLexer.java @@ -20,8 +20,7 @@ import io.github.apexdevtools.apexparser.CaseInsensitiveInputStream; public class ApexCpdLexer implements CpdLexer { - @Override - public void tokenize(TextDocument document, TokenFactory tokenEntries) throws IOException { + @Override public void tokenize(TextDocument document, TokenFactory tokenEntries) throws IOException { CharStream charStream = CharStreams.fromReader(document.newReader()); CaseInsensitiveInputStream caseInsensitiveInputStream = new CaseInsensitiveInputStream(charStream); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/internal/ApexDesignerBindings.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/internal/ApexDesignerBindings.java index 8f5e3d4ffe1..c095d458cde 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/internal/ApexDesignerBindings.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/internal/ApexDesignerBindings.java @@ -19,8 +19,7 @@ public class ApexDesignerBindings extends DefaultDesignerBindings { public static final ApexDesignerBindings INSTANCE = new ApexDesignerBindings(); - @Override - public Attribute getMainAttribute(Node node) { + @Override public Attribute getMainAttribute(Node node) { if (node instanceof ApexNode) { Attribute attr = (Attribute) node.acceptVisitor(MainAttrVisitor.INSTANCE, null); if (attr != null) { @@ -31,8 +30,7 @@ public Attribute getMainAttribute(Node node) { return super.getMainAttribute(node); } - @Override - public TreeIconId getIcon(Node node) { + @Override public TreeIconId getIcon(Node node) { if (node instanceof ASTFieldDeclaration) { return TreeIconId.FIELD; } else if (node instanceof ASTUserClass) { @@ -50,13 +48,11 @@ private static final class MainAttrVisitor extends ApexVisitorBase node, Object data) { + @Override public Object visitApexNode(ApexNode node, Object data) { return null; // don't recurse } - @Override - public Object visit(ASTMethodCallExpression node, Object data) { + @Override public Object visit(ASTMethodCallExpression node, Object data) { return new Attribute(node, "MethodName", node.getMethodName()); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/ApexMetrics.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/ApexMetrics.java index ddf1707119d..1698149d5f5 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/ApexMetrics.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/ApexMetrics.java @@ -26,9 +26,8 @@ * for usage doc. */ public final class ApexMetrics { - @SuppressWarnings({"unchecked", "rawtypes"}) - private static final Class> GENERIC_APEX_NODE_CLASS = - (Class) ApexNode.class; // this is a Class, the raw type + @SuppressWarnings({"unchecked", "rawtypes"}) private static final Class> GENERIC_APEX_NODE_CLASS = + (Class) ApexNode.class; // this is a Class, the raw type /** @@ -80,8 +79,8 @@ public final class ApexMetrics { * } */ public static final Metric, Integer> CYCLO = - Metric.of(ApexMetrics::computeCyclo, isRegularApexNode(), - "Cyclomatic Complexity", "Cyclo"); + Metric.of(ApexMetrics::computeCyclo, isRegularApexNode(), + "Cyclomatic Complexity", "Cyclo"); /** * See the corresponding Cognitive Complexity in pmd-java ({@code net.sourceforge.pmd.lang.java.metrics.JavaMetrics#COGNITIVE_COMPLEXITY}) @@ -93,8 +92,8 @@ public final class ApexMetrics { * These reported methods should be broken down into less complex components. */ public static final Metric, Integer> COGNITIVE_COMPLEXITY = - Metric.of(ApexMetrics::computeCognitiveComp, isRegularApexNode(), - "Cognitive Complexity"); + Metric.of(ApexMetrics::computeCognitiveComp, isRegularApexNode(), + "Cognitive Complexity"); /** @@ -103,15 +102,14 @@ public final class ApexMetrics { * */ public static final Metric, Integer> WEIGHED_METHOD_COUNT = - Metric.of(ApexMetrics::computeWmc, filterMapNode(ASTUserClass.class, PredicateUtil.always()), - "Weighed Method Count", "WMC"); + Metric.of(ApexMetrics::computeWmc, filterMapNode(ASTUserClass.class, PredicateUtil.always()), + "Weighed Method Count", "WMC"); private ApexMetrics() { // utility class } - private static Function> isRegularApexNode() { return filterMapNode(GENERIC_APEX_NODE_CLASS, PredicateUtil.always()); } @@ -134,7 +132,6 @@ private static int computeCognitiveComp(ApexNode node, MetricOptions ignored) } - private static int computeWmc(ASTUserClassOrInterface node, MetricOptions options) { return (int) MetricsUtil.computeStatistics(CYCLO, node.getMethods(), options).getSum(); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/internal/CognitiveComplexityVisitor.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/internal/CognitiveComplexityVisitor.java index 20867060b5d..52a5a9579aa 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/internal/CognitiveComplexityVisitor.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/internal/CognitiveComplexityVisitor.java @@ -86,8 +86,7 @@ void setMethodName(String name) { } } - @Override - public Void visit(ASTIfElseBlockStatement node, State state) { + @Override public Void visit(ASTIfElseBlockStatement node, State state) { boolean hasElseStatement = node.hasElseStatement(); for (ApexNode child : node.children()) { @@ -110,8 +109,7 @@ public Void visit(ASTIfElseBlockStatement node, State state) { return null; } - @Override - public Void visit(ASTForLoopStatement node, State state) { + @Override public Void visit(ASTForLoopStatement node, State state) { state.structureComplexity(); super.visit(node, state); @@ -120,8 +118,7 @@ public Void visit(ASTForLoopStatement node, State state) { return null; } - @Override - public Void visit(ASTForEachStatement node, State state) { + @Override public Void visit(ASTForEachStatement node, State state) { state.structureComplexity(); super.visit(node, state); state.decreaseNestingLevel(); @@ -129,8 +126,7 @@ public Void visit(ASTForEachStatement node, State state) { return null; } - @Override - public Void visit(ASTWhileLoopStatement node, State state) { + @Override public Void visit(ASTWhileLoopStatement node, State state) { state.structureComplexity(); super.visit(node, state); state.decreaseNestingLevel(); @@ -138,8 +134,7 @@ public Void visit(ASTWhileLoopStatement node, State state) { return null; } - @Override - public Void visit(ASTCatchBlockStatement node, State state) { + @Override public Void visit(ASTCatchBlockStatement node, State state) { state.structureComplexity(); super.visit(node, state); state.decreaseNestingLevel(); @@ -147,8 +142,7 @@ public Void visit(ASTCatchBlockStatement node, State state) { return null; } - @Override - public Void visit(ASTDoLoopStatement node, State state) { + @Override public Void visit(ASTDoLoopStatement node, State state) { state.structureComplexity(); super.visit(node, state); @@ -157,8 +151,7 @@ public Void visit(ASTDoLoopStatement node, State state) { return null; } - @Override - public Void visit(ASTTernaryExpression node, State state) { + @Override public Void visit(ASTTernaryExpression node, State state) { state.structureComplexity(); super.visit(node, state); @@ -167,8 +160,7 @@ public Void visit(ASTTernaryExpression node, State state) { return null; } - @Override - public Void visit(ASTBooleanExpression node, State state) { + @Override public Void visit(ASTBooleanExpression node, State state) { BooleanOperator op = node.getOp(); if (op == BooleanOperator.LOGICAL_AND || op == BooleanOperator.LOGICAL_OR) { @@ -178,8 +170,7 @@ public Void visit(ASTBooleanExpression node, State state) { return super.visit(node, state); } - @Override - public Void visit(ASTPrefixExpression node, State state) { + @Override public Void visit(ASTPrefixExpression node, State state) { PrefixOperator op = node.getOp(); if (op == PrefixOperator.LOGICAL_NOT) { @@ -189,8 +180,7 @@ public Void visit(ASTPrefixExpression node, State state) { return super.visit(node, state); } - @Override - public Void visit(ASTBlockStatement node, State state) { + @Override public Void visit(ASTBlockStatement node, State state) { for (ApexNode child : node.children()) { // This needs to happen because the current 'run' of boolean operations is terminated @@ -202,20 +192,17 @@ public Void visit(ASTBlockStatement node, State state) { return null; } - @Override - public Void visit(ASTMethod node, State state) { + @Override public Void visit(ASTMethod node, State state) { state.setMethodName(node.getCanonicalName()); return super.visit(node, state); } - @Override - public Void visit(ASTMethodCallExpression node, State state) { + @Override public Void visit(ASTMethodCallExpression node, State state) { state.methodCall(node.getMethodName()); return super.visit(node, state); } - @Override - public Void visit(ASTSwitchStatement node, State state) { + @Override public Void visit(ASTSwitchStatement node, State state) { state.structureComplexity(); super.visit(node, state); state.decreaseNestingLevel(); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/internal/StandardCycloVisitor.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/internal/StandardCycloVisitor.java index b6da5d861d7..862834d603f 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/internal/StandardCycloVisitor.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/metrics/internal/StandardCycloVisitor.java @@ -22,59 +22,51 @@ */ public class StandardCycloVisitor extends ApexVisitorBase { - @Override - public Void visit(ASTIfBlockStatement node, MutableInt data) { + @Override public Void visit(ASTIfBlockStatement node, MutableInt data) { data.add(1 + ApexMetricsHelper.booleanExpressionComplexity(node.descendants(ASTStandardCondition.class).first())); return super.visit(node, data); } - @Override - public Void visit(ASTCatchBlockStatement node, MutableInt data) { + @Override public Void visit(ASTCatchBlockStatement node, MutableInt data) { data.increment(); return super.visit(node, data); } - @Override - public Void visit(ASTForLoopStatement node, MutableInt data) { + @Override public Void visit(ASTForLoopStatement node, MutableInt data) { data.add( 1 + ApexMetricsHelper.booleanExpressionComplexity(node.descendants(ASTStandardCondition.class).first())); return super.visit(node, data); } - @Override - public Void visit(ASTForEachStatement node, MutableInt data) { + @Override public Void visit(ASTForEachStatement node, MutableInt data) { data.increment(); return super.visit(node, data); } - @Override - public Void visit(ASTThrowStatement node, MutableInt data) { + @Override public Void visit(ASTThrowStatement node, MutableInt data) { data.increment(); return super.visit(node, data); } - @Override - public Void visit(ASTWhileLoopStatement node, MutableInt data) { + @Override public Void visit(ASTWhileLoopStatement node, MutableInt data) { data.add( 1 + ApexMetricsHelper.booleanExpressionComplexity(node.descendants(ASTStandardCondition.class).first())); return super.visit(node, data); } - @Override - public Void visit(ASTDoLoopStatement node, MutableInt data) { + @Override public Void visit(ASTDoLoopStatement node, MutableInt data) { data.add( 1 + ApexMetricsHelper.booleanExpressionComplexity(node.descendants(ASTStandardCondition.class).first())); return super.visit(node, data); } - @Override - public Void visit(ASTTernaryExpression node, MutableInt data) { + @Override public Void visit(ASTTernaryExpression node, MutableInt data) { data.add( 1 + ApexMetricsHelper.booleanExpressionComplexity(node.descendants(ASTStandardCondition.class).first())); return super.visit(node, data); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysis.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysis.java index 4a7acb921b8..dae7ebd3fc6 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysis.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysis.java @@ -111,7 +111,7 @@ public boolean isFailed() { public List getFileIssues(String filename) { // Extract issues for a specific metadata file from the org return org == null ? Collections.emptyList() - : Collections.unmodifiableList(Arrays.asList(org.issues().issuesForFile(filename))); + : Collections.unmodifiableList(Arrays.asList(org.issues().issuesForFile(filename))); } /* @@ -119,18 +119,15 @@ public List getFileIssues(String filename) { */ private static final class AnalysisLogger implements com.nawforce.pkgforce.diagnostics.Logger { - @Override - public void info(String message) { + @Override public void info(String message) { LOG.info(message); } - @Override - public void debug(String message) { + @Override public void debug(String message) { LOG.debug(message); } - @Override - public void trace(String message) { + @Override public void trace(String message) { LOG.trace(message); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/multifile/InternalApiBridge.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/multifile/InternalApiBridge.java index beba36c4f7a..3888802cc89 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/multifile/InternalApiBridge.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/multifile/InternalApiBridge.java @@ -20,7 +20,8 @@ */ @InternalApi public final class InternalApiBridge { - private InternalApiBridge() {} + private InternalApiBridge() { + } public static ApexMultifileAnalysis createApexMultiFileAnalysis(ApexLanguageProperties properties) { return new ApexMultifileAnalysis(properties); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRule.java index 9bc00c47910..cf922b53c39 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRule.java @@ -11,13 +11,11 @@ public abstract class AbstractApexRule extends AbstractRule implements ApexVisitor { - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { target.acceptVisitor(this, ctx); } - @Override - public Object visitNode(Node node, Object param) { + @Override public Object visitNode(Node node, Object param) { node.children().forEach(n -> n.acceptVisitor(this, param)); return param; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AbstractApexUnitTestRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AbstractApexUnitTestRule.java index c627731c6b8..1f7948334c5 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AbstractApexUnitTestRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AbstractApexUnitTestRule.java @@ -20,8 +20,7 @@ abstract class AbstractApexUnitTestRule extends AbstractApexRule { * Don't bother visiting this class if it's not a class with @isTest and * newer than API v24 (V176 internal). */ - @Override - public Object visit(final ASTUserClass node, final Object data) { + @Override public Object visit(final ASTUserClass node, final Object data) { if (!isTestMethodOrClass(node)) { return data; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageRule.java index bed4a82a8fb..192529c9d38 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexAssertionsShouldIncludeMessageRule.java @@ -21,8 +21,7 @@ public class ApexAssertionsShouldIncludeMessageRule extends AbstractApexUnitTest private static final String IS_NULL = "Assert.isNull"; private static final String IS_TRUE = "Assert.isTrue"; - @Override - public Object visit(ASTMethodCallExpression node, Object data) { + @Override public Object visit(ASTMethodCallExpression node, Object data) { String methodName = node.getFullMethodName(); if (FAIL.equalsIgnoreCase(methodName) && node.getNumChildren() == 1) { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java index 7b95fc17e2a..df40131c10d 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveAssertsRule.java @@ -75,8 +75,7 @@ public ApexUnitTestClassShouldHaveAssertsRule() { definePropertyDescriptor(ADDITIONAL_ASSERT_METHOD_PATTERN_DESCRIPTOR); } - @Override - public Object visit(ASTMethod node, Object data) { + @Override public Object visit(ASTMethod node, Object data) { if (!isTestMethodOrClass(node)) { return data; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveRunAsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveRunAsRule.java index 2f2bfd1a51c..41d0e2da1a7 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveRunAsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestClassShouldHaveRunAsRule.java @@ -17,8 +17,7 @@ */ public class ApexUnitTestClassShouldHaveRunAsRule extends AbstractApexUnitTestRule { - @Override - public Object visit(ASTMethod node, Object data) { + @Override public Object visit(ASTMethod node, Object data) { if (!isTestMethodOrClass(node)) { return data; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestShouldNotUseSeeAllDataTrueRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestShouldNotUseSeeAllDataTrueRule.java index c5a5912a134..df02c776cd0 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestShouldNotUseSeeAllDataTrueRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/ApexUnitTestShouldNotUseSeeAllDataTrueRule.java @@ -21,8 +21,7 @@ */ public class ApexUnitTestShouldNotUseSeeAllDataTrueRule extends AbstractApexUnitTestRule { - @Override - public Object visit(final ASTUserClass node, final Object data) { + @Override public Object visit(final ASTUserClass node, final Object data) { if (!isTestMethodOrClass(node)) { return data; } @@ -31,8 +30,7 @@ public Object visit(final ASTUserClass node, final Object data) { return super.visit(node, data); } - @Override - public Object visit(ASTMethod node, Object data) { + @Override public Object visit(ASTMethod node, Object data) { if (!isTestMethodOrClass(node)) { return data; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidGlobalModifierRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidGlobalModifierRule.java index 59abdd90b34..da4a40a274a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidGlobalModifierRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidGlobalModifierRule.java @@ -14,13 +14,11 @@ public class AvoidGlobalModifierRule extends AbstractApexRule { - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { return checkForGlobal(node, data); } - @Override - public Object visit(ASTUserInterface node, Object data) { + @Override public Object visit(ASTUserInterface node, Object data) { return checkForGlobal(node, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidLogicInTriggerRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidLogicInTriggerRule.java index 6974d9f59ae..7914ef2b0e4 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidLogicInTriggerRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/AvoidLogicInTriggerRule.java @@ -15,13 +15,11 @@ public class AvoidLogicInTriggerRule extends AbstractApexRule { - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserTrigger.class); } - @Override - public Object visit(ASTUserTrigger node, Object data) { + @Override public Object visit(ASTUserTrigger node, Object data) { List blockStatements = node.descendants(ASTBlockStatement.class).toList(); if (!blockStatements.isEmpty()) { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/QueueableWithoutFinalizerRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/QueueableWithoutFinalizerRule.java index 9acb39e07d1..1e8485cb4b0 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/QueueableWithoutFinalizerRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/QueueableWithoutFinalizerRule.java @@ -30,8 +30,7 @@ public class QueueableWithoutFinalizerRule extends AbstractApexRule { private static final String QUEUEABLE_CONTEXT = "queueablecontext"; private static final String SYSTEM_ATTACH_FINALIZER = "system.attachfinalizer"; - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class); } @@ -40,8 +39,7 @@ public class QueueableWithoutFinalizerRule extends AbstractApexRule { * `execute(QueueableContext context)` does not call the * `System.attachFinalizer(Finalizer f)` method, then add a violation. */ - @Override - public Object visit(ASTUserClass theClass, Object data) { + @Override public Object visit(ASTUserClass theClass, Object data) { if (!implementsTheQueueableInterface(theClass)) { return data; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/UnusedLocalVariableRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/UnusedLocalVariableRule.java index f22a14eeb4a..97da36ad25e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/UnusedLocalVariableRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/bestpractices/UnusedLocalVariableRule.java @@ -39,13 +39,11 @@ public class UnusedLocalVariableRule extends AbstractApexRule { private static final Pattern BINDING_VARIABLE = Pattern.compile("(?i):\\s*+([_a-z0-9]+)"); - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTVariableDeclaration.class); } - @Override - public Object visit(ASTVariableDeclaration node, Object data) { + @Override public Object visit(ASTVariableDeclaration node, Object data) { String variableName = node.getImage(); ASTBlockStatement variableContext = node.ancestors(ASTBlockStatement.class).first(); @@ -96,8 +94,8 @@ private Collection findBindingsInSOSLQueries(ASTBlockStatement variableC private List findBindingsInSOQLStringLiterals(ASTBlockStatement variableContext) { List methodCalls = variableContext.descendants(ASTMethodCallExpression.class) - .filter(m -> DATABASE_QUERY_METHODS.contains(m.getFullMethodName().toLowerCase(Locale.ROOT))) - .collect(Collectors.toList()); + .filter(m -> DATABASE_QUERY_METHODS.contains(m.getFullMethodName().toLowerCase(Locale.ROOT))) + .collect(Collectors.toList()); List stringLiterals = new ArrayList<>(); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsRule.java index 508650adbcc..7de81a816a1 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/ClassNamingConventionsRule.java @@ -50,13 +50,11 @@ public ClassNamingConventionsRule() { definePropertyDescriptor(ENUM_REGEX); } - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class, ASTUserInterface.class, ASTUserEnum.class); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { if (node.isNested()) { checkMatches(INNER_CLASS_REGEX, node, data); } else if (node.getModifiers().isTest()) { @@ -70,8 +68,7 @@ public Object visit(ASTUserClass node, Object data) { return data; } - @Override - public Object visit(ASTUserInterface node, Object data) { + @Override public Object visit(ASTUserInterface node, Object data) { if (node.isNested()) { checkMatches(INNER_INTERFACE_REGEX, node, data); } else { @@ -81,14 +78,12 @@ public Object visit(ASTUserInterface node, Object data) { return data; } - @Override - public Object visit(ASTUserEnum node, Object data) { + @Override public Object visit(ASTUserEnum node, Object data) { checkMatches(ENUM_REGEX, node, data); return data; } - @Override - protected String displayName(String name) { + @Override protected String displayName(String name) { return DESCRIPTOR_TO_DISPLAY_NAME.get(name); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldDeclarationsShouldBeAtStartRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldDeclarationsShouldBeAtStartRule.java index d9d9e429166..fc7b705bb3e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldDeclarationsShouldBeAtStartRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldDeclarationsShouldBeAtStartRule.java @@ -23,23 +23,21 @@ public class FieldDeclarationsShouldBeAtStartRule extends AbstractApexRule { private static final Comparator> NODE_BY_SOURCE_LOCATION_COMPARATOR = - Comparator - .>comparingInt(ApexNode::getBeginLine) - .thenComparing(ApexNode::getBeginColumn); + Comparator + .>comparingInt(ApexNode::getBeginLine) + .thenComparing(ApexNode::getBeginColumn); - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { // Unfortunately the parser re-orders the AST to put field declarations before method declarations // so we have to rely on line numbers / positions to work out where the first non-field declaration starts // so we can check if the fields are in acceptable places. List fields = node.children(ASTFieldDeclarationStatements.class) - .children(ASTFieldDeclaration.class) - .toList(); + .children(ASTFieldDeclaration.class) + .toList(); List> nonFieldDeclarations = new ArrayList<>(); @@ -49,8 +47,8 @@ public Object visit(ASTUserClass node, Object data) { nonFieldDeclarations.addAll(node.children(ASTBlockStatement.class).toList()); Optional> firstNonFieldDeclaration = nonFieldDeclarations.stream() - .filter(ApexNode::hasRealLoc) - .min(NODE_BY_SOURCE_LOCATION_COMPARATOR); + .filter(ApexNode::hasRealLoc) + .min(NODE_BY_SOURCE_LOCATION_COMPARATOR); if (!firstNonFieldDeclaration.isPresent()) { // there is nothing except field declaration, so that has to come first diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldNamingConventionsRule.java index 01b77d87b21..d6cdeb7501e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FieldNamingConventionsRule.java @@ -45,13 +45,11 @@ public FieldNamingConventionsRule() { } - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTField.class); } - @Override - public Object visit(ASTField node, Object data) { + @Override public Object visit(ASTField node, Object data) { if (node.ancestors(ASTProperty.class).first() != null) { return data; } @@ -81,8 +79,7 @@ private ASTFieldDeclaration getFieldDeclaration(ASTField field) { return field.getParent().descendants(ASTFieldDeclaration.class).first(fieldDeclaration -> fieldDeclaration.getName().equals(field.getName())); } - @Override - protected String displayName(String name) { + @Override protected String displayName(String name) { return DESCRIPTOR_TO_DISPLAY_NAME.get(name); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterNamingConventionsRule.java index 10bc064bb4f..e2c651f1cbf 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/FormalParameterNamingConventionsRule.java @@ -28,13 +28,11 @@ public FormalParameterNamingConventionsRule() { definePropertyDescriptor(METHOD_PARAMETER_REGEX); } - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTParameter.class); } - @Override - public Object visit(ASTParameter node, Object data) { + @Override public Object visit(ASTParameter node, Object data) { // classes that extend Exception will contains methods that have parameters with null names if (node.getImage() == null) { return data; @@ -49,8 +47,7 @@ public Object visit(ASTParameter node, Object data) { return data; } - @Override - protected String displayName(String name) { + @Override protected String displayName(String name) { return DESCRIPTOR_TO_DISPLAY_NAME.get(name); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/LocalVariableNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/LocalVariableNamingConventionsRule.java index c3a85971d57..da720df848c 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/LocalVariableNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/LocalVariableNamingConventionsRule.java @@ -30,14 +30,12 @@ public LocalVariableNamingConventionsRule() { } - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTVariableDeclaration.class); } - @Override - public Object visit(ASTVariableDeclaration node, Object data) { + @Override public Object visit(ASTVariableDeclaration node, Object data) { if (node.ancestors(ASTVariableDeclarationStatements.class).first().getModifiers().isFinal()) { checkMatches(FINAL_REGEX, node, data); } else { @@ -47,8 +45,7 @@ public Object visit(ASTVariableDeclaration node, Object data) { return data; } - @Override - protected String displayName(String name) { + @Override protected String displayName(String name) { return DESCRIPTOR_TO_DISPLAY_NAME.get(name); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java index de3ae0a330e..9fe53e6d8f7 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/MethodNamingConventionsRule.java @@ -35,14 +35,12 @@ public MethodNamingConventionsRule() { } - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTMethod.class); } - @Override - public Object visit(ASTMethod node, Object data) { + @Override public Object visit(ASTMethod node, Object data) { if (isOverriddenMethod(node) || isPropertyAccessor(node) || isConstructor(node)) { return data; } @@ -66,8 +64,7 @@ public Object visit(ASTMethod node, Object data) { return data; } - @Override - protected String displayName(String name) { + @Override protected String displayName(String name) { return DESCRIPTOR_TO_DISPLAY_NAME.get(name); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/PropertyNamingConventionsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/PropertyNamingConventionsRule.java index b65850ae543..84ebf314335 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/PropertyNamingConventionsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/codestyle/PropertyNamingConventionsRule.java @@ -30,14 +30,12 @@ public PropertyNamingConventionsRule() { } - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTField.class); } - @Override - public Object visit(ASTField node, Object data) { + @Override public Object visit(ASTField node, Object data) { if (node.ancestors(ASTProperty.class).first() == null) { return data; } @@ -51,8 +49,7 @@ public Object visit(ASTField node, Object data) { return data; } - @Override - protected String displayName(String name) { + @Override protected String displayName(String name) { return DESCRIPTOR_TO_DISPLAY_NAME.get(name); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AbstractNcssCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AbstractNcssCountRule.java index adc52a8888f..e86721807d0 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AbstractNcssCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AbstractNcssCountRule.java @@ -46,8 +46,7 @@ protected AbstractNcssCountRule(Class nodeClass) { } - @Override - protected int getMetric(T node) { + @Override protected int getMetric(T node) { return node.acceptVisitor(NcssVisitor.INSTANCE, null) + 1; } @@ -56,13 +55,11 @@ private static final class NcssVisitor extends ApexVisitorBase { static final NcssVisitor INSTANCE = new NcssVisitor(); - @Override - public Integer visitApexNode(ApexNode node, Void data) { + @Override public Integer visitApexNode(ApexNode node, Void data) { return countNodeChildren(node, data); } - @Override - protected Integer visitChildren(Node node, Void data) { + @Override protected Integer visitChildren(Node node, Void data) { int v = 0; for (Node child : node.children()) { v += child.acceptVisitor(this, data); @@ -83,93 +80,75 @@ protected Integer countNodeChildren(ApexNode node, Void data) { return visitChildren(node, data); } - @Override - public Integer visit(ASTForLoopStatement node, Void data) { + @Override public Integer visit(ASTForLoopStatement node, Void data) { return countNodeChildren(node, data) + 1; } - @Override - public Integer visit(ASTForEachStatement node, Void data) { + @Override public Integer visit(ASTForEachStatement node, Void data) { return countNodeChildren(node, data) + 1; } - @Override - public Integer visit(ASTDoLoopStatement node, Void data) { + @Override public Integer visit(ASTDoLoopStatement node, Void data) { return countNodeChildren(node, data) + 1; } - @Override - public Integer visit(ASTIfBlockStatement node, Void data) { + @Override public Integer visit(ASTIfBlockStatement node, Void data) { return countNodeChildren(node, data) + 1; } - @Override - public Integer visit(ASTIfElseBlockStatement node, Void data) { + @Override public Integer visit(ASTIfElseBlockStatement node, Void data) { return countNodeChildren(node, data) + 2; } - @Override - public Integer visit(ASTWhileLoopStatement node, Void data) { + @Override public Integer visit(ASTWhileLoopStatement node, Void data) { return countNodeChildren(node, data) + 1; } - @Override - public Integer visit(ASTBreakStatement node, Void data) { + @Override public Integer visit(ASTBreakStatement node, Void data) { return 1; } - @Override - public Integer visit(ASTTryCatchFinallyBlockStatement node, Void data) { + @Override public Integer visit(ASTTryCatchFinallyBlockStatement node, Void data) { return countNodeChildren(node, data) + 1; } - @Override - public Integer visit(ASTContinueStatement node, Void data) { + @Override public Integer visit(ASTContinueStatement node, Void data) { return 1; } - @Override - public Integer visit(ASTReturnStatement node, Void data) { + @Override public Integer visit(ASTReturnStatement node, Void data) { return countNodeChildren(node, data) + 1; } - @Override - public Integer visit(ASTThrowStatement node, Void data) { + @Override public Integer visit(ASTThrowStatement node, Void data) { return countNodeChildren(node, data) + 1; } - @Override - public Integer visit(ASTStatement node, Void data) { + @Override public Integer visit(ASTStatement node, Void data) { return 1; } - @Override - public Integer visit(ASTMethodCallExpression node, Void data) { + @Override public Integer visit(ASTMethodCallExpression node, Void data) { return 1; } - @Override - public Integer visit(ASTMethod node, Void data) { + @Override public Integer visit(ASTMethod node, Void data) { return countNodeChildren(node, data); } - @Override - public Integer visit(ASTUserClass node, Void data) { + @Override public Integer visit(ASTUserClass node, Void data) { return countNodeChildren(node, data) + 1; } - @Override - public Integer visit(ASTUserEnum node, Void data) { + @Override public Integer visit(ASTUserEnum node, Void data) { return countNodeChildren(node, data) + 1; } - @Override - public Integer visit(ASTUserInterface node, Void data) { + @Override public Integer visit(ASTUserInterface node, Void data) { return countNodeChildren(node, data) + 1; } - @Override - public Integer visit(ASTFieldDeclaration node, Void data) { + @Override public Integer visit(ASTFieldDeclaration node, Void data) { return 1; } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidBooleanMethodParametersRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidBooleanMethodParametersRule.java index 6512bc8675e..73fea37863c 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidBooleanMethodParametersRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidBooleanMethodParametersRule.java @@ -45,8 +45,7 @@ public class AvoidBooleanMethodParametersRule extends AbstractApexRule { * the rule context data * @return the rule context data */ - @Override - public Object visit(ASTMethod theMethod, Object data) { + @Override public Object visit(ASTMethod theMethod, Object data) { if (!isPublicOrGlobal(theMethod)) { return data; } @@ -65,8 +64,7 @@ public Object visit(ASTMethod theMethod, Object data) { * * @return a rule target selector configured for ASTMethod nodes */ - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTMethod.class); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidDeeplyNestedIfStmtsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidDeeplyNestedIfStmtsRule.java index a462a6b387b..f64e433237c 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidDeeplyNestedIfStmtsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/AvoidDeeplyNestedIfStmtsRule.java @@ -20,21 +20,19 @@ public class AvoidDeeplyNestedIfStmtsRule extends AbstractApexRule { private static final PropertyDescriptor PROBLEM_DEPTH_DESCRIPTOR = PropertyFactory.intProperty("problemDepth") - .desc("The if statement depth reporting threshold") - .require(positive()).defaultValue(3).build(); + .desc("The if statement depth reporting threshold") + .require(positive()).defaultValue(3).build(); public AvoidDeeplyNestedIfStmtsRule() { definePropertyDescriptor(PROBLEM_DEPTH_DESCRIPTOR); } - @Override - public void start(RuleContext ctx) { + @Override public void start(RuleContext ctx) { depth = 0; depthLimit = getProperty(PROBLEM_DEPTH_DESCRIPTOR); } - @Override - public Object visit(ASTIfBlockStatement node, Object data) { + @Override public Object visit(ASTIfBlockStatement node, Object data) { depth++; super.visit(node, data); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityRule.java index 28a2110917d..4091dc934e5 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CognitiveComplexityRule.java @@ -44,8 +44,7 @@ public CognitiveComplexityRule() { } - @Override - public Object visit(ASTUserTrigger node, Object data) { + @Override public Object visit(ASTUserTrigger node, Object data) { inTrigger = true; super.visit(node, data); inTrigger = false; @@ -53,8 +52,7 @@ public Object visit(ASTUserTrigger node, Object data) { } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { classNames.push(node.getSimpleName()); super.visit(node, data); @@ -68,11 +66,11 @@ public Object visit(ASTUserClass node, Object data) { int classHighest = (int) MetricsUtil.computeStatistics(ApexMetrics.COGNITIVE_COMPLEXITY, node.getMethods()).getMax(); String[] messageParams = { - "class", - node.getSimpleName(), - " total", - classCognitive + " (highest " + classHighest + ")", - String.valueOf(classLevelThreshold), + "class", + node.getSimpleName(), + " total", + classCognitive + " (highest " + classHighest + ")", + String.valueOf(classLevelThreshold), }; asCtx(data).addViolation(node, (Object[]) messageParams); @@ -82,8 +80,7 @@ public Object visit(ASTUserClass node, Object data) { } - @Override - public final Object visit(ASTMethod node, Object data) { + @Override public final Object visit(ASTMethod node, Object data) { if (ApexMetrics.COGNITIVE_COMPLEXITY.supports(node)) { int cognitive = MetricsUtil.computeMetric(ApexMetrics.COGNITIVE_COMPLEXITY, node); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java index e1af8663df7..1c23f15fde5 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java @@ -28,18 +28,18 @@ public class CyclomaticComplexityRule extends AbstractApexRule { private static final PropertyDescriptor CLASS_LEVEL_DESCRIPTOR - = PropertyFactory.intProperty("classReportLevel") - .desc("Total class complexity reporting threshold") - .require(positive()) - .defaultValue(40) - .build(); + = PropertyFactory.intProperty("classReportLevel") + .desc("Total class complexity reporting threshold") + .require(positive()) + .defaultValue(40) + .build(); private static final PropertyDescriptor METHOD_LEVEL_DESCRIPTOR - = PropertyFactory.intProperty("methodReportLevel") - .desc("Cyclomatic complexity reporting threshold") - .require(positive()) - .defaultValue(10) - .build(); + = PropertyFactory.intProperty("methodReportLevel") + .desc("Cyclomatic complexity reporting threshold") + .require(positive()) + .defaultValue(10) + .build(); private Deque classNames = new ArrayDeque<>(); private boolean inTrigger; @@ -51,8 +51,7 @@ public CyclomaticComplexityRule() { } - @Override - public Object visit(ASTUserTrigger node, Object data) { + @Override public Object visit(ASTUserTrigger node, Object data) { inTrigger = true; super.visit(node, data); inTrigger = false; @@ -60,8 +59,7 @@ public Object visit(ASTUserTrigger node, Object data) { } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { classNames.push(node.getSimpleName()); super.visit(node, data); @@ -74,9 +72,9 @@ public Object visit(ASTUserClass node, Object data) { int classHighest = (int) MetricsUtil.computeStatistics(ApexMetrics.CYCLO, node.getMethods()).getMax(); String[] messageParams = {"class", - node.getSimpleName(), - " total", - classWmc + " (highest " + classHighest + ")", }; + node.getSimpleName(), + " total", + classWmc + " (highest " + classHighest + ")", }; asCtx(data).addViolation(node, (Object[]) messageParams); } @@ -85,15 +83,14 @@ public Object visit(ASTUserClass node, Object data) { } - @Override - public final Object visit(ASTMethod node, Object data) { + @Override public final Object visit(ASTMethod node, Object data) { if (ApexMetrics.CYCLO.supports(node)) { int cyclo = MetricsUtil.computeMetric(ApexMetrics.CYCLO, node); if (cyclo >= getProperty(METHOD_LEVEL_DESCRIPTOR)) { String opType = inTrigger ? "trigger" - : node.getImage().equals(classNames.peek()) ? "constructor" - : "method"; + : node.getImage().equals(classNames.peek()) ? "constructor" + : "method"; asCtx(data).addViolation(node, opType, node.getQualifiedName().getOperation(), diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveClassLengthRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveClassLengthRule.java index 73d6e06c922..62059b6af6c 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveClassLengthRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveClassLengthRule.java @@ -17,13 +17,11 @@ public ExcessiveClassLengthRule() { super(ASTUserClass.class); } - @Override - protected int defaultReportLevel() { + @Override protected int defaultReportLevel() { return 1000; } - @Override - protected boolean isIgnored(ASTUserClass node) { + @Override protected boolean isIgnored(ASTUserClass node) { return node.getModifiers().isTest(); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveParameterListRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveParameterListRule.java index fa5220151d4..7d3d8afe1fc 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveParameterListRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessiveParameterListRule.java @@ -21,13 +21,11 @@ public ExcessiveParameterListRule() { super(ASTMethod.class); } - @Override - protected int defaultReportLevel() { + @Override protected int defaultReportLevel() { return 4; } - @Override - protected FileLocation getReportLocation(ASTMethod node) { + @Override protected FileLocation getReportLocation(ASTMethod node) { ApexNode lastParameter = node.children(ASTParameter.class).last(); if (lastParameter == null) { lastParameter = node; @@ -38,8 +36,7 @@ protected FileLocation getReportLocation(ASTMethod node) { return FileLocation.range(node.getAstInfo().getTextDocument().getFileId(), textRange); } - @Override - protected int getMetric(ASTMethod node) { + @Override protected int getMetric(ASTMethod node) { return node.getArity(); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessivePublicCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessivePublicCountRule.java index 5be01a62c67..1c21c4e1c09 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessivePublicCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/ExcessivePublicCountRule.java @@ -30,13 +30,11 @@ public ExcessivePublicCountRule() { super(ASTUserClass.class); } - @Override - protected int defaultReportLevel() { + @Override protected int defaultReportLevel() { return 20; } - @Override - protected int getMetric(ASTUserClass node) { + @Override protected int getMetric(ASTUserClass node) { int publicMethods = node.children(ASTMethod.class) .filter(it -> it.getModifiers().isPublic()) @@ -54,8 +52,7 @@ protected int getMetric(ASTUserClass node) { return publicFields + publicMethods + publicProperties; } - @Override - protected Object[] getViolationParameters(ASTUserClass node, int metric, int limit) { - return new Object[] { node.getSimpleName(), metric, limit }; + @Override protected Object[] getViolationParameters(ASTUserClass node, int metric, int limit) { + return new Object[]{node.getSimpleName(), metric, limit}; } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountRule.java index 44cbc9c3814..5a5560cd66a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssConstructorCountRule.java @@ -20,13 +20,11 @@ public NcssConstructorCountRule() { super(ASTMethod.class); } - @Override - protected int defaultReportLevel() { + @Override protected int defaultReportLevel() { return 20; } - @Override - protected boolean isIgnored(ASTMethod node) { + @Override protected boolean isIgnored(ASTMethod node) { return !node.isConstructor(); } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountRule.java index 2891dc92353..5f323249441 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssMethodCountRule.java @@ -20,18 +20,15 @@ public NcssMethodCountRule() { super(ASTMethod.class); } - @Override - protected int defaultReportLevel() { + @Override protected int defaultReportLevel() { return 40; } - @Override - protected boolean isIgnored(ASTMethod node) { + @Override protected boolean isIgnored(ASTMethod node) { return node.isConstructor(); } - @Override - protected Object[] getViolationParameters(ASTMethod node, int metric, int limit) { - return new Object[]{ node.getImage(), metric, limit }; + @Override protected Object[] getViolationParameters(ASTMethod node, int metric, int limit) { + return new Object[]{node.getImage(), metric, limit}; } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountRule.java index f534a140fed..b98b5cb3e22 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/NcssTypeCountRule.java @@ -21,8 +21,7 @@ public NcssTypeCountRule() { super(ASTUserClass.class); } - @Override - protected int defaultReportLevel() { + @Override protected int defaultReportLevel() { return 500; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java index 076ba77a0a1..acbbcb39dc7 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/StdCyclomaticComplexityRule.java @@ -44,10 +44,10 @@ public class StdCyclomaticComplexityRule extends AbstractApexRule { public static final PropertyDescriptor REPORT_LEVEL_DESCRIPTOR = PropertyFactory.intProperty("reportLevel") - .desc("Cyclomatic Complexity reporting threshold") - .require(inRange(1, 30)) - .defaultValue(10) - .build(); + .desc("Cyclomatic Complexity reporting threshold") + .require(inRange(1, 30)) + .defaultValue(10) + .build(); public static final PropertyDescriptor SHOW_CLASSES_COMPLEXITY_DESCRIPTOR = booleanProperty("showClassesComplexity").desc("Add class average violations to the report").defaultValue(true).build(); @@ -86,53 +86,47 @@ public StdCyclomaticComplexityRule() { definePropertyDescriptor(SHOW_METHODS_COMPLEXITY_DESCRIPTOR); } - @Override - public void start(RuleContext ctx) { + @Override public void start(RuleContext ctx) { reportLevel = getProperty(REPORT_LEVEL_DESCRIPTOR); showClassesComplexity = getProperty(SHOW_CLASSES_COMPLEXITY_DESCRIPTOR); showMethodsComplexity = getProperty(SHOW_METHODS_COMPLEXITY_DESCRIPTOR); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { entryStack.push(new Entry()); super.visit(node, data); Entry classEntry = entryStack.pop(); if (showClassesComplexity) { if (classEntry.getComplexityAverage() >= reportLevel || classEntry.highestDecisionPoints >= reportLevel) { asCtx(data).addViolation(node, "class", node.getSimpleName(), - classEntry.getComplexityAverage() + " (Highest = " + classEntry.highestDecisionPoints + ')'); + classEntry.getComplexityAverage() + " (Highest = " + classEntry.highestDecisionPoints + ')'); } } return data; } - @Override - public Object visit(ASTUserTrigger node, Object data) { + @Override public Object visit(ASTUserTrigger node, Object data) { entryStack.push(new Entry()); super.visit(node, data); Entry classEntry = entryStack.pop(); if (showClassesComplexity) { if (classEntry.getComplexityAverage() >= reportLevel || classEntry.highestDecisionPoints >= reportLevel) { asCtx(data).addViolation(node, "trigger", node.getSimpleName(), - classEntry.getComplexityAverage() + " (Highest = " + classEntry.highestDecisionPoints + ')'); + classEntry.getComplexityAverage() + " (Highest = " + classEntry.highestDecisionPoints + ')'); } } return data; } - @Override - public Object visit(ASTUserInterface node, Object data) { + @Override public Object visit(ASTUserInterface node, Object data) { return data; } - @Override - public Object visit(ASTUserEnum node, Object data) { + @Override public Object visit(ASTUserEnum node, Object data) { return data; } - @Override - public Object visit(ASTMethod node, Object data) { + @Override public Object visit(ASTMethod node, Object data) { entryStack.push(new Entry()); super.visit(node, data); Entry methodEntry = entryStack.pop(); @@ -153,57 +147,49 @@ public Object visit(ASTMethod node, Object data) { return data; } - @Override - public Object visit(ASTIfBlockStatement node, Object data) { + @Override public Object visit(ASTIfBlockStatement node, Object data) { entryStack.peek().bumpDecisionPoints(); super.visit(node, data); return data; } - @Override - public Object visit(ASTTryCatchFinallyBlockStatement node, Object data) { + @Override public Object visit(ASTTryCatchFinallyBlockStatement node, Object data) { entryStack.peek().bumpDecisionPoints(); super.visit(node, data); return data; } - @Override - public Object visit(ASTForLoopStatement node, Object data) { + @Override public Object visit(ASTForLoopStatement node, Object data) { entryStack.peek().bumpDecisionPoints(); super.visit(node, data); return data; } - @Override - public Object visit(ASTForEachStatement node, Object data) { + @Override public Object visit(ASTForEachStatement node, Object data) { entryStack.peek().bumpDecisionPoints(); super.visit(node, data); return data; } - @Override - public Object visit(ASTWhileLoopStatement node, Object data) { + @Override public Object visit(ASTWhileLoopStatement node, Object data) { entryStack.peek().bumpDecisionPoints(); super.visit(node, data); return data; } - @Override - public Object visit(ASTDoLoopStatement node, Object data) { + @Override public Object visit(ASTDoLoopStatement node, Object data) { entryStack.peek().bumpDecisionPoints(); super.visit(node, data); return data; } - @Override - public Object visit(ASTTernaryExpression node, Object data) { + @Override public Object visit(ASTTernaryExpression node, Object data) { entryStack.peek().bumpDecisionPoints(); super.visit(node, data); return data; } - @Override - public Object visit(ASTBooleanExpression node, Object data) { + @Override public Object visit(ASTBooleanExpression node, Object data) { return data; } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/TooManyFieldsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/TooManyFieldsRule.java index 8500fa22e11..3d40c495759 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/TooManyFieldsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/TooManyFieldsRule.java @@ -23,10 +23,10 @@ public class TooManyFieldsRule extends AbstractApexRule { private static final PropertyDescriptor MAX_FIELDS_DESCRIPTOR = PropertyFactory.intProperty("maxfields") - .desc("Max allowable fields") - .defaultValue(DEFAULT_MAXFIELDS) - .require(positive()) - .build(); + .desc("Max allowable fields") + .defaultValue(DEFAULT_MAXFIELDS) + .require(positive()) + .build(); public TooManyFieldsRule() { @@ -34,14 +34,12 @@ public TooManyFieldsRule() { } - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { List fields = node.children(ASTField.class).toList(); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodRule.java index e912f343f6e..67e0a5f90a1 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodRule.java @@ -11,14 +11,13 @@ public class UnusedMethodRule extends AbstractApexRule { - @Override - public Object visit(ASTMethod node, Object data) { + @Override public Object visit(ASTMethod node, Object data) { // Check if any 'Unused' Issues align with this method node.getRoot().getGlobalIssues().stream() - .filter(issue -> issue.rule().name().equals(UNUSED_CATEGORY.name())) - .filter(issue -> issue.fileLocation().startLineNumber() == node.getBeginLine()) - .filter(issue -> issue.fileLocation().endLineNumber() <= node.getBeginLine()) - .forEach(issue -> asCtx(data).addViolation(node)); + .filter(issue -> issue.rule().name().equals(UNUSED_CATEGORY.name())) + .filter(issue -> issue.fileLocation().startLineNumber() == node.getBeginLine()) + .filter(issue -> issue.fileLocation().endLineNumber() <= node.getBeginLine()) + .forEach(issue -> asCtx(data).addViolation(node)); return data; } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/documentation/ApexDocRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/documentation/ApexDocRule.java index dc926065f8c..72c2553430d 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/documentation/ApexDocRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/documentation/ApexDocRule.java @@ -49,11 +49,11 @@ public class ApexDocRule extends AbstractApexRule { private static final PropertyDescriptor REPORT_MISSING_DESCRIPTION_DESCRIPTOR = booleanProperty("reportMissingDescription") - .desc("Report missing @description").defaultValue(true).build(); + .desc("Report missing @description").defaultValue(true).build(); private static final PropertyDescriptor REPORT_PROPERTY_DESCRIPTOR = booleanProperty("reportProperty") - .desc("Report properties without comments").defaultValue(true).build(); + .desc("Report properties without comments").defaultValue(true).build(); public ApexDocRule() { definePropertyDescriptor(REPORT_PRIVATE_DESCRIPTOR); @@ -62,25 +62,21 @@ public ApexDocRule() { definePropertyDescriptor(REPORT_PROPERTY_DESCRIPTOR); } - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class, ASTUserInterface.class, ASTMethod.class, ASTProperty.class); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { handleClassOrInterface(node, data); return data; } - @Override - public Object visit(ASTUserInterface node, Object data) { + @Override public Object visit(ASTUserInterface node, Object data) { handleClassOrInterface(node, data); return data; } - @Override - public Object visit(ASTMethod node, Object data) { + @Override public Object visit(ASTMethod node, Object data) { if (node.getParent() instanceof ASTProperty) { // Skip property methods, doc is required on the property itself return data; @@ -118,8 +114,7 @@ public Object visit(ASTMethod node, Object data) { return data; } - @Override - public Object visit(ASTProperty node, Object data) { + @Override public Object visit(ASTProperty node, Object data) { ApexDocComment comment = getApexDocComment(node); if (comment == null) { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/ApexCSRFRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/ApexCSRFRule.java index cb8d095fc11..0391e0c32b1 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/ApexCSRFRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/ApexCSRFRule.java @@ -20,8 +20,7 @@ public class ApexCSRFRule extends AbstractApexRule { public static final String INIT = "init"; - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { if (Helper.isTestMethodOrClass(node) || Helper.isSystemLevelClass(node)) { return data; // stops all the rules } @@ -29,16 +28,14 @@ public Object visit(ASTUserClass node, Object data) { return super.visit(node, data); } - @Override - public Object visit(ASTMethod node, Object data) { + @Override public Object visit(ASTMethod node, Object data) { if (!Helper.isTestMethodOrClass(node)) { checkForCSRF(node, data); } return data; } - @Override - public Object visit(ASTBlockStatement node, Object data) { + @Override public Object visit(ASTBlockStatement node, Object data) { if (node.getParent() instanceof ASTUserClass && Helper.foundAnyDML(node)) { asCtx(data).addViolation(node); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdRule.java index 38062083476..1e6c45dddad 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidHardcodingIdRule.java @@ -30,14 +30,12 @@ public class AvoidHardcodingIdRule extends AbstractApexRule { CHECKSUM_LOOKUP = Collections.unmodifiableMap(lookup); } - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTLiteralExpression.class); } - @Override - public Object visit(ASTLiteralExpression node, Object data) { + @Override public Object visit(ASTLiteralExpression node, Object data) { if (node.isString()) { String literal = node.getImage(); if (PATTERN.matcher(literal).matches()) { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidNonExistentAnnotationsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidNonExistentAnnotationsRule.java index dbd3be2e707..eb1ddda8d3f 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidNonExistentAnnotationsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidNonExistentAnnotationsRule.java @@ -24,37 +24,31 @@ * @author a.subramanian */ public class AvoidNonExistentAnnotationsRule extends AbstractApexRule { - @Override - public Object visit(final ASTUserClass node, final Object data) { + @Override public Object visit(final ASTUserClass node, final Object data) { checkForNonExistentAnnotation(node, node.getModifiers(), data); return super.visit(node, data); } - @Override - public Object visit(final ASTUserInterface node, final Object data) { + @Override public Object visit(final ASTUserInterface node, final Object data) { checkForNonExistentAnnotation(node, node.getModifiers(), data); return super.visit(node, data); } - @Override - public Object visit(final ASTUserEnum node, final Object data) { + @Override public Object visit(final ASTUserEnum node, final Object data) { checkForNonExistentAnnotation(node, node.getModifiers(), data); return super.visit(node, data); } - @Override - public Object visit(final ASTMethod node, final Object data) { + @Override public Object visit(final ASTMethod node, final Object data) { return checkForNonExistentAnnotation(node, node.getModifiers(), data); } - @Override - public Object visit(final ASTProperty node, final Object data) { + @Override public Object visit(final ASTProperty node, final Object data) { // may have nested methods, don't visit children return checkForNonExistentAnnotation(node, node.getModifiers(), data); } - @Override - public Object visit(final ASTField node, final Object data) { + @Override public Object visit(final ASTField node, final Object data) { return checkForNonExistentAnnotation(node, node.getModifiers(), data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidStatefulDatabaseResultRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidStatefulDatabaseResultRule.java index 64a083b16b1..023bae418ee 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidStatefulDatabaseResultRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/AvoidStatefulDatabaseResultRule.java @@ -32,13 +32,11 @@ public final class AvoidStatefulDatabaseResultRule extends AbstractApexRule { "database.deleteresult", "database.emptyrecyclebinresult", "database.mergeresult", "database.saveresult", "database.undeleteresult", "database.upsertresult"); - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class); } - @Override - public Object visit(ASTUserClass theClass, Object data) { + @Override public Object visit(ASTUserClass theClass, Object data) { if (!implementsDatabaseStateful(theClass)) { return data; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/InaccessibleAuraEnabledGetterRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/InaccessibleAuraEnabledGetterRule.java index d6978f66190..1565f79f75f 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/InaccessibleAuraEnabledGetterRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/InaccessibleAuraEnabledGetterRule.java @@ -23,13 +23,11 @@ */ public class InaccessibleAuraEnabledGetterRule extends AbstractApexRule { - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTProperty.class); } - @Override - public Object visit(ASTProperty node, Object data) { + @Override public Object visit(ASTProperty node, Object data) { // Find @AuraEnabled property ASTModifierNode propModifiers = node.getModifiers(); if (hasAuraEnabledAnnotation(propModifiers)) { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/MethodWithSameNameAsEnclosingClassRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/MethodWithSameNameAsEnclosingClassRule.java index aa30b268bef..9b0248a1c8e 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/MethodWithSameNameAsEnclosingClassRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/MethodWithSameNameAsEnclosingClassRule.java @@ -13,14 +13,12 @@ public class MethodWithSameNameAsEnclosingClassRule extends AbstractApexRule { - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { String className = node.getSimpleName(); for (ASTMethod m : node.descendants(ASTMethod.class)) { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/OverrideBothEqualsAndHashcodeRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/OverrideBothEqualsAndHashcodeRule.java index e4375a5013b..166804d1c25 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/OverrideBothEqualsAndHashcodeRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/OverrideBothEqualsAndHashcodeRule.java @@ -15,13 +15,11 @@ public class OverrideBothEqualsAndHashcodeRule extends AbstractApexRule { - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { ApexNode equalsNode = null; ApexNode hashNode = null; for (ASTMethod method : node.children(ASTMethod.class)) { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/TypeShadowsBuiltInNamespaceRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/TypeShadowsBuiltInNamespaceRule.java index 79e37dcfa5a..72f1c069533 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/TypeShadowsBuiltInNamespaceRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/errorprone/TypeShadowsBuiltInNamespaceRule.java @@ -36,13 +36,11 @@ public class TypeShadowsBuiltInNamespaceRule extends AbstractRule { private static final ApexVisitor VISITOR = new Visitor(); - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class, ASTUserEnum.class, ASTUserInterface.class); } - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { target.acceptVisitor(VISITOR, ctx); } @@ -86,26 +84,22 @@ private void checkNode(ApexNode node, RuleContext ruleContext) { } } - @Override - public Void visit(ASTUserClass node, RuleContext data) { + @Override public Void visit(ASTUserClass node, RuleContext data) { checkNode(node, data); return null; } - @Override - public Void visit(ASTUserEnum node, RuleContext data) { + @Override public Void visit(ASTUserEnum node, RuleContext data) { checkNode(node, data); return null; } - @Override - public Void visit(ASTUserInterface node, RuleContext data) { + @Override public Void visit(ASTUserInterface node, RuleContext data) { checkNode(node, data); return null; } - @Override - public Void visitNode(Node node, RuleContext param) { + @Override public Void visitNode(Node node, RuleContext param) { return null; } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/internal/AbstractCounterCheckRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/internal/AbstractCounterCheckRule.java index 753527d029f..9298fc12e1b 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/internal/AbstractCounterCheckRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/internal/AbstractCounterCheckRule.java @@ -29,10 +29,10 @@ public abstract class AbstractCounterCheckRule> extends Ab private final PropertyDescriptor reportLevel = - CommonPropertyDescriptors.reportLevelProperty() - .desc("Threshold above which a node is reported") - .require(positive()) - .defaultValue(defaultReportLevel()).build(); + CommonPropertyDescriptors.reportLevelProperty() + .desc("Threshold above which a node is reported") + .require(positive()) + .defaultValue(defaultReportLevel()).build(); private final Class nodeType; @@ -41,8 +41,7 @@ public AbstractCounterCheckRule(Class nodeType) { definePropertyDescriptor(reportLevel); } - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(nodeType); } @@ -50,7 +49,7 @@ public AbstractCounterCheckRule(Class nodeType) { protected abstract int defaultReportLevel(); protected Object[] getViolationParameters(T node, int metric, int limit) { - return new Object[] {metric, limit}; + return new Object[]{metric, limit}; } @@ -65,10 +64,8 @@ protected FileLocation getReportLocation(T node) { return node.getReportLocation(); } - @Override - public Object visitApexNode(ApexNode node, Object data) { - @SuppressWarnings("unchecked") - T t = (T) node; + @Override public Object visitApexNode(ApexNode node, Object data) { + @SuppressWarnings("unchecked") T t = (T) node; // since we only visit this node, it's ok if (!isIgnored(t)) { @@ -88,8 +85,7 @@ public AbstractLineLengthCheckRule(Class nodeType) { super(nodeType); } - @Override - protected int getMetric(T node) { + @Override protected int getMetric(T node) { Node measured = node; if (node instanceof ASTUserClass && node.getParent() instanceof ASTApexFile) { measured = node.getParent(); diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/internal/Helper.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/internal/Helper.java index de284ef7502..c96a37ff068 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/internal/Helper.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/internal/Helper.java @@ -173,12 +173,12 @@ public static boolean isSystemLevelClass(ASTUserClass node) { private static boolean isAllowed(String identifier) { switch (identifier.toLowerCase(Locale.ROOT)) { - case "queueable": - case "database.batchable": - case "installhandler": - return true; - default: - break; + case "queueable": + case "database.batchable": + case "installhandler": + return true; + default: + break; } return false; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidNonRestrictiveQueriesRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidNonRestrictiveQueriesRule.java index fd3c5bf392d..9c2e4d4dbb6 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidNonRestrictiveQueriesRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/AvoidNonRestrictiveQueriesRule.java @@ -28,19 +28,16 @@ public class AvoidNonRestrictiveQueriesRule extends AbstractApexRule { private static final Pattern SELECT_OR_FIND_PATTERN = Pattern.compile("(select\\s+|find\\s+)", Pattern.CASE_INSENSITIVE); private static final Pattern SUB_QUERY_PATTERN = Pattern.compile("(?i)\\(\\s*select\\s+[^)]+\\)"); - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTSoqlExpression.class, ASTSoslExpression.class); } - @Override - public Object visit(ASTSoqlExpression node, Object data) { + @Override public Object visit(ASTSoqlExpression node, Object data) { visitSoqlOrSosl(node, "SOQL", node.getQuery(), asCtx(data)); return data; } - @Override - public Object visit(ASTSoslExpression node, Object data) { + @Override public Object visit(ASTSoslExpression node, Object data) { visitSoqlOrSosl(node, "SOSL", node.getQuery(), asCtx(data)); return data; } @@ -66,9 +63,9 @@ private void visitSoqlOrSosl(ApexNode node, String type, String query, RuleCo .firstOpt() .map(ASTAnnotationParameter::getBooleanValue)); boolean classSeeAllData = classAnnotation.flatMap(m -> m.children(ASTAnnotationParameter.class) - .filter(p -> p.hasName(ASTAnnotationParameter.SEE_ALL_DATA)) - .firstOpt() - .map(ASTAnnotationParameter::getBooleanValue)) + .filter(p -> p.hasName(ASTAnnotationParameter.SEE_ALL_DATA)) + .firstOpt() + .map(ASTAnnotationParameter::getBooleanValue)) .orElse(false); if (methodSeeAllData.isPresent()) { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithHighCostInLoopRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithHighCostInLoopRule.java index ee2a7ef06cc..53e30525269 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithHighCostInLoopRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithHighCostInLoopRule.java @@ -21,22 +21,20 @@ public class OperationWithHighCostInLoopRule extends AbstractAvoidNodeInLoopsRule { private static final Set SCHEMA_PERFORMANCE_METHODS = CollectionUtil.setOf( - "System.Schema.getGlobalDescribe", - "Schema.getGlobalDescribe", - "System.Schema.describeSObjects", - "Schema.describeSObjects") + "System.Schema.getGlobalDescribe", + "Schema.getGlobalDescribe", + "System.Schema.describeSObjects", + "Schema.describeSObjects") .stream().map(s -> s.toLowerCase(Locale.ROOT)).collect(Collectors.toSet()); - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes( // performance consuming methods ASTMethodCallExpression.class); } // Begin general method invocations - @Override - public Object visit(ASTMethodCallExpression node, Object data) { + @Override public Object visit(ASTMethodCallExpression node, Object data) { if (checkHighCostClassMethods(node)) { return checkForViolation(node, data); } else { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithLimitsInLoopRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithLimitsInLoopRule.java index bd440e4013a..636f0b3532b 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithLimitsInLoopRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/performance/OperationWithLimitsInLoopRule.java @@ -28,89 +28,81 @@ public class OperationWithLimitsInLoopRule extends AbstractAvoidNodeInLoopsRule private static final String MESSAGING_CLASS_NAME = "Messaging"; private static final String SYSTEM_CLASS_NAME = "System"; - private static final String[] MESSAGING_LIMIT_METHODS = new String[] { "renderEmailTemplate", "renderStoredEmailTemplate", "sendEmail" }; - private static final String[] SYSTEM_LIMIT_METHODS = new String[] { "enqueueJob", "schedule", "scheduleBatch" }; + private static final String[] MESSAGING_LIMIT_METHODS = new String[]{"renderEmailTemplate", "renderStoredEmailTemplate", "sendEmail"}; + private static final String[] SYSTEM_LIMIT_METHODS = new String[]{"enqueueJob", "schedule", "scheduleBatch"}; - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes( - // DML - ASTDmlDeleteStatement.class, - ASTDmlInsertStatement.class, - ASTDmlMergeStatement.class, - ASTDmlUndeleteStatement.class, - ASTDmlUpdateStatement.class, - ASTDmlUpsertStatement.class, - // SOQL - ASTSoqlExpression.class, - // SOSL - ASTSoslExpression.class, - // Other limit consuming methods - ASTMethodCallExpression.class, - ASTRunAsBlockStatement.class + // DML + ASTDmlDeleteStatement.class, + ASTDmlInsertStatement.class, + ASTDmlMergeStatement.class, + ASTDmlUndeleteStatement.class, + ASTDmlUpdateStatement.class, + ASTDmlUpsertStatement.class, + // SOQL + ASTSoqlExpression.class, + // SOSL + ASTSoslExpression.class, + // Other limit consuming methods + ASTMethodCallExpression.class, + ASTRunAsBlockStatement.class ); } // Begin DML Statements - @Override - public Object visit(ASTDmlDeleteStatement node, Object data) { + @Override public Object visit(ASTDmlDeleteStatement node, Object data) { return checkForViolation(node, data); } - @Override - public Object visit(ASTDmlInsertStatement node, Object data) { + @Override public Object visit(ASTDmlInsertStatement node, Object data) { return checkForViolation(node, data); } - @Override - public Object visit(ASTDmlMergeStatement node, Object data) { + @Override public Object visit(ASTDmlMergeStatement node, Object data) { return checkForViolation(node, data); } - @Override - public Object visit(ASTDmlUndeleteStatement node, Object data) { + @Override public Object visit(ASTDmlUndeleteStatement node, Object data) { return checkForViolation(node, data); } - @Override - public Object visit(ASTDmlUpdateStatement node, Object data) { + @Override public Object visit(ASTDmlUpdateStatement node, Object data) { return checkForViolation(node, data); } - @Override - public Object visit(ASTDmlUpsertStatement node, Object data) { + @Override public Object visit(ASTDmlUpsertStatement node, Object data) { return checkForViolation(node, data); } + // End DML Statements // Begin SOQL method invocations - @Override - public Object visit(ASTSoqlExpression node, Object data) { + @Override public Object visit(ASTSoqlExpression node, Object data) { return checkForViolation(node, data); } + // End SOQL method invocations // Begin SOSL method invocations - @Override - public Object visit(ASTSoslExpression node, Object data) { + @Override public Object visit(ASTSoslExpression node, Object data) { return checkForViolation(node, data); } + // End SOSL method invocations // Begin general method invocations - @Override - public Object visit(ASTRunAsBlockStatement node, Object data) { + @Override public Object visit(ASTRunAsBlockStatement node, Object data) { return checkForViolation(node, data); } - @Override - public Object visit(ASTMethodCallExpression node, Object data) { + @Override public Object visit(ASTMethodCallExpression node, Object data) { if (Helper.isAnyDatabaseMethodCall(node) - || Helper.isMethodName(node, APPROVAL_CLASS_NAME, Helper.ANY_METHOD) - || checkLimitClassMethods(node, MESSAGING_CLASS_NAME, MESSAGING_LIMIT_METHODS) - || checkLimitClassMethods(node, SYSTEM_CLASS_NAME, SYSTEM_LIMIT_METHODS)) { + || Helper.isMethodName(node, APPROVAL_CLASS_NAME, Helper.ANY_METHOD) + || checkLimitClassMethods(node, MESSAGING_CLASS_NAME, MESSAGING_LIMIT_METHODS) + || checkLimitClassMethods(node, SYSTEM_CLASS_NAME, SYSTEM_LIMIT_METHODS)) { return checkForViolation(node, data); } else { diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexBadCryptoRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexBadCryptoRule.java index a3ffbaa4808..d09fd3f8507 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexBadCryptoRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexBadCryptoRule.java @@ -38,13 +38,11 @@ public class ApexBadCryptoRule extends AbstractApexRule { private final Set potentiallyStaticBlob = new HashSet<>(); - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { if (Helper.isTestMethodOrClass(node)) { return data; } @@ -88,22 +86,22 @@ private void validateStaticIVorKey(ASTMethodCallExpression methodCall, Object da // .encrypt('AES128', key, exampleIv, data); int numberOfChildren = methodCall.getNumChildren(); switch (numberOfChildren) { - // matching signature to encrypt( - case 5: - Object potentialIV = methodCall.getChild(3); - reportIfHardCoded(data, potentialIV); - Object potentialKey = methodCall.getChild(2); - reportIfHardCoded(data, potentialKey); - break; - - // matching signature to encryptWithManagedIV( - case 4: - Object key = methodCall.getChild(2); - reportIfHardCoded(data, key); - break; - - default: - break; + // matching signature to encrypt( + case 5: + Object potentialIV = methodCall.getChild(3); + reportIfHardCoded(data, potentialIV); + Object potentialKey = methodCall.getChild(2); + reportIfHardCoded(data, potentialKey); + break; + + // matching signature to encryptWithManagedIV( + case 4: + Object key = methodCall.getChild(2); + reportIfHardCoded(data, key); + break; + + default: + break; } } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java index 8b39e0d7ca2..f737081e2af 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexCRUDViolationRule.java @@ -86,17 +86,17 @@ public class ApexCRUDViolationRule extends AbstractApexRule { private static final String ACCESS_LEVEL = "AccessLevel"; // ESAPI.accessController().isAuthorizedToView(Lead.sObject, fields) - private static final String[] ESAPI_ISAUTHORIZED_TO_VIEW = new String[] { "ESAPI", "accessController", - "isAuthorizedToView", }; - private static final String[] ESAPI_ISAUTHORIZED_TO_CREATE = new String[] { "ESAPI", "accessController", - "isAuthorizedToCreate", }; - private static final String[] ESAPI_ISAUTHORIZED_TO_UPDATE = new String[] { "ESAPI", "accessController", - "isAuthorizedToUpdate", }; - private static final String[] ESAPI_ISAUTHORIZED_TO_DELETE = new String[] { "ESAPI", "accessController", - "isAuthorizedToDelete", }; + private static final String[] ESAPI_ISAUTHORIZED_TO_VIEW = new String[]{"ESAPI", "accessController", + "isAuthorizedToView", }; + private static final String[] ESAPI_ISAUTHORIZED_TO_CREATE = new String[]{"ESAPI", "accessController", + "isAuthorizedToCreate", }; + private static final String[] ESAPI_ISAUTHORIZED_TO_UPDATE = new String[]{"ESAPI", "accessController", + "isAuthorizedToUpdate", }; + private static final String[] ESAPI_ISAUTHORIZED_TO_DELETE = new String[]{"ESAPI", "accessController", + "isAuthorizedToDelete", }; // ESAPI doesn't provide support for undelete or merge - private static final String[] RESERVED_KEYS_FLS = new String[] { "Schema", S_OBJECT_TYPE, }; + private static final String[] RESERVED_KEYS_FLS = new String[]{"Schema", S_OBJECT_TYPE, }; private static final Pattern WITH_SECURITY_ENFORCED = Pattern.compile("(?is).*[^']\\s*WITH\\s+SECURITY_ENFORCED\\s*[^']*"); @@ -163,8 +163,7 @@ public ApexCRUDViolationRule() { } } - @Override - public void start(RuleContext ctx) { + @Override public void start(RuleContext ctx) { // At the start of each rule execution, these member variables need to be fresh. So they're initialized in the // .start() method instead of the constructor, since .start() is called before every execution. varToTypeMapping = new HashMap<>(); @@ -175,8 +174,7 @@ public void start(RuleContext ctx) { super.start(ctx); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { if (Helper.isTestMethodOrClass(node) || Helper.isSystemLevelClass(node)) { return data; // stops all the rules } @@ -191,8 +189,7 @@ public Object visit(ASTUserClass node, Object data) { return super.visit(node, data); } - @Override - public Object visit(ASTMethodCallExpression node, Object data) { + @Override public Object visit(ASTMethodCallExpression node, Object data) { if (Helper.isAnyDatabaseMethodCall(node)) { if (hasAccessLevelArgument(node)) { @@ -200,33 +197,33 @@ public Object visit(ASTMethodCallExpression node, Object data) { } switch (node.getMethodName().toLowerCase(Locale.ROOT)) { - case "insert": - case "insertasync": - case "insertimmediate": - checkForCRUD(node, data, IS_CREATEABLE); - break; - case "update": - case "updateasync": - case "updateimmediate": - checkForCRUD(node, data, IS_UPDATEABLE); - break; - case "delete": - case "deleteasync": - case "deleteimmediate": - checkForCRUD(node, data, IS_DELETABLE); - break; - case "undelete": - checkForCRUD(node, data, IS_UNDELETABLE); - break; - case "upsert": - checkForCRUD(node, data, IS_CREATEABLE); - checkForCRUD(node, data, IS_UPDATEABLE); - break; - case "merge": - checkForCRUD(node, data, IS_MERGEABLE); - break; - default: - break; + case "insert": + case "insertasync": + case "insertimmediate": + checkForCRUD(node, data, IS_CREATEABLE); + break; + case "update": + case "updateasync": + case "updateimmediate": + checkForCRUD(node, data, IS_UPDATEABLE); + break; + case "delete": + case "deleteasync": + case "deleteimmediate": + checkForCRUD(node, data, IS_DELETABLE); + break; + case "undelete": + checkForCRUD(node, data, IS_UNDELETABLE); + break; + case "upsert": + checkForCRUD(node, data, IS_CREATEABLE); + checkForCRUD(node, data, IS_UPDATEABLE); + break; + case "merge": + checkForCRUD(node, data, IS_MERGEABLE); + break; + default: + break; } } else { @@ -264,8 +261,7 @@ private boolean hasRunAsMode(AbstractDmlStatement node) { return node.getRunAsMode().isPresent(); } - @Override - public Object visit(ASTDmlInsertStatement node, Object data) { + @Override public Object visit(ASTDmlInsertStatement node, Object data) { if (hasRunAsMode(node)) { return data; } @@ -274,8 +270,7 @@ public Object visit(ASTDmlInsertStatement node, Object data) { return data; } - @Override - public Object visit(ASTDmlDeleteStatement node, Object data) { + @Override public Object visit(ASTDmlDeleteStatement node, Object data) { if (hasRunAsMode(node)) { return data; } @@ -284,8 +279,7 @@ public Object visit(ASTDmlDeleteStatement node, Object data) { return data; } - @Override - public Object visit(ASTDmlUndeleteStatement node, Object data) { + @Override public Object visit(ASTDmlUndeleteStatement node, Object data) { if (hasRunAsMode(node)) { return data; } @@ -294,8 +288,7 @@ public Object visit(ASTDmlUndeleteStatement node, Object data) { return data; } - @Override - public Object visit(ASTDmlUpdateStatement node, Object data) { + @Override public Object visit(ASTDmlUpdateStatement node, Object data) { if (hasRunAsMode(node)) { return data; } @@ -304,8 +297,7 @@ public Object visit(ASTDmlUpdateStatement node, Object data) { return data; } - @Override - public Object visit(ASTDmlUpsertStatement node, Object data) { + @Override public Object visit(ASTDmlUpsertStatement node, Object data) { if (hasRunAsMode(node)) { return data; } @@ -315,8 +307,7 @@ public Object visit(ASTDmlUpsertStatement node, Object data) { return data; } - @Override - public Object visit(ASTDmlMergeStatement node, Object data) { + @Override public Object visit(ASTDmlMergeStatement node, Object data) { if (hasRunAsMode(node)) { return data; } @@ -325,8 +316,7 @@ public Object visit(ASTDmlMergeStatement node, Object data) { return data; } - @Override - public Object visit(final ASTAssignmentExpression node, Object data) { + @Override public Object visit(final ASTAssignmentExpression node, Object data) { final ASTSoqlExpression soql = node.descendants(ASTSoqlExpression.class).first(); if (soql != null) { checkForAccessibility(soql, data); @@ -335,8 +325,7 @@ public Object visit(final ASTAssignmentExpression node, Object data) { return data; } - @Override - public Object visit(final ASTVariableDeclaration node, Object data) { + @Override public Object visit(final ASTVariableDeclaration node, Object data) { String type = node.getType(); addVariableToMapping(Helper.getFQVariableName(node), type); @@ -349,15 +338,13 @@ public Object visit(final ASTVariableDeclaration node, Object data) { } - @Override - public Object visit(ASTParameter node, Object data) { + @Override public Object visit(ASTParameter node, Object data) { String type = node.getType(); addVariableToMapping(Helper.getFQVariableName(node), type); return data; } - @Override - public Object visit(final ASTFieldDeclaration node, Object data) { + @Override public Object visit(final ASTFieldDeclaration node, Object data) { ASTFieldDeclarationStatements field = node.ancestors(ASTFieldDeclarationStatements.class).first(); if (field != null) { String namesString = field.getTypeName(); @@ -371,8 +358,7 @@ public Object visit(final ASTFieldDeclaration node, Object data) { return data; } - @Override - public Object visit(final ASTReturnStatement node, Object data) { + @Override public Object visit(final ASTReturnStatement node, Object data) { final ASTSoqlExpression soql = node.descendants(ASTSoqlExpression.class).first(); if (soql != null) { checkForAccessibility(soql, data); @@ -381,8 +367,7 @@ public Object visit(final ASTReturnStatement node, Object data) { return data; } - @Override - public Object visit(final ASTForEachStatement node, Object data) { + @Override public Object visit(final ASTForEachStatement node, Object data) { final ASTSoqlExpression soql = node.firstChild(ASTSoqlExpression.class); if (soql != null) { checkForAccessibility(soql, data); @@ -411,8 +396,7 @@ private String getSimpleType(final String type) { return typeToUse; } - @Override - public Object visit(final ASTProperty node, Object data) { + @Override public Object visit(final ASTProperty node, Object data) { ASTField field = node.firstChild(ASTField.class); if (field != null) { String fieldType = field.getType(); @@ -493,13 +477,13 @@ private boolean isWithSecurityEnforced(final ApexNode node) { //For USER_MODE private boolean isWithUserMode(final ApexNode node) { return node instanceof ASTSoqlExpression - && WITH_USER_MODE.matcher(((ASTSoqlExpression) node).getQuery()).matches(); + && WITH_USER_MODE.matcher(((ASTSoqlExpression) node).getQuery()).matches(); } //For System Mode private boolean isWithSystemMode(final ApexNode node) { return node instanceof ASTSoqlExpression - && WITH_SYSTEM_MODE.matcher(((ASTSoqlExpression) node).getQuery()).matches(); + && WITH_SYSTEM_MODE.matcher(((ASTSoqlExpression) node).getQuery()).matches(); } private String getType(final ASTMethodCallExpression methodNode) { @@ -743,7 +727,7 @@ private void checkForAccessibility(final ASTSoqlExpression node, Object data) { final ASTUserClass wrappingClass = node.ancestors(ASTUserClass.class).first(); if (wrappingClass != null && Helper.isTestMethodOrClass(wrappingClass) - || wrappingMethod != null && Helper.isTestMethodOrClass(wrappingMethod)) { + || wrappingMethod != null && Helper.isTestMethodOrClass(wrappingMethod)) { return; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexDangerousMethodsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexDangerousMethodsRule.java index 5fdba1d5c81..f72b4ea28f2 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexDangerousMethodsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexDangerousMethodsRule.java @@ -42,14 +42,12 @@ public class ApexDangerousMethodsRule extends AbstractApexRule { private final Set whiteListedVariables = new HashSet<>(); - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { if (Helper.isTestMethodOrClass(node)) { return data; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointRule.java index f107bce6fcc..52166018154 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexInsecureEndpointRule.java @@ -32,20 +32,17 @@ public class ApexInsecureEndpointRule extends AbstractApexRule { private final Set httpEndpointStrings = new HashSet<>(); - @Override - public Object visit(ASTAssignmentExpression node, Object data) { + @Override public Object visit(ASTAssignmentExpression node, Object data) { findInsecureEndpoints(node); return data; } - @Override - public Object visit(ASTVariableDeclaration node, Object data) { + @Override public Object visit(ASTVariableDeclaration node, Object data) { findInsecureEndpoints(node); return data; } - @Override - public Object visit(ASTFieldDeclaration node, Object data) { + @Override public Object visit(ASTFieldDeclaration node, Object data) { findInsecureEndpoints(node); return data; } @@ -74,8 +71,7 @@ private void findInnerInsecureEndpoints(ApexNode node, ASTVariableExpression } } - @Override - public Object visit(ASTMethodCallExpression node, Object data) { + @Override public Object visit(ASTMethodCallExpression node, Object data) { processInsecureEndpoint(node, data); return data; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexOpenRedirectRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexOpenRedirectRule.java index 25a1872bda8..e9e87d9a81b 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexOpenRedirectRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexOpenRedirectRule.java @@ -33,13 +33,11 @@ public class ApexOpenRedirectRule extends AbstractApexRule { private final Set listOfStringLiteralVariables = new HashSet<>(); - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { if (Helper.isTestMethodOrClass(node) || Helper.isSystemLevelClass(node)) { return data; // stops all the rules } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionRule.java index e7de58c97e9..a9ef2fe050a 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSOQLInjectionRule.java @@ -41,12 +41,12 @@ * */ public class ApexSOQLInjectionRule extends AbstractApexRule { - private static final Set SAFE_VARIABLE_TYPES = - Collections.unmodifiableSet(Stream.of( - "double", "long", "decimal", "boolean", "id", "integer", - "sobjecttype", "schema.sobjecttype", "sobjectfield", "schema.sobjectfield" - ).collect(Collectors.toSet())); - + private static final Set SAFE_VARIABLE_TYPES = + Collections.unmodifiableSet(Stream.of( + "double", "long", "decimal", "boolean", "id", "integer", + "sobjecttype", "schema.sobjecttype", "sobjectfield", "schema.sobjectfield" + ).collect(Collectors.toSet())); + private static final String JOIN = "join"; private static final String ESCAPE_SINGLE_QUOTES = "escapeSingleQuotes"; private static final String STRING = "String"; @@ -57,13 +57,11 @@ public class ApexSOQLInjectionRule extends AbstractApexRule { private final Set safeVariables = new HashSet<>(); private final Map selectContainingVariables = new HashMap<>(); - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { if (Helper.isTestMethodOrClass(node) || Helper.isSystemLevelClass(node)) { return data; // stops all the rules diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java index a4bb420ef41..84621ccc256 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsRule.java @@ -39,8 +39,7 @@ public class ApexSharingViolationsRule extends AbstractApexRule { */ private Map, Object> localCacheOfReportedNodes = new WeakHashMap<>(); - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes( ASTDmlDeleteStatement.class, ASTDmlInsertStatement.class, @@ -53,62 +52,52 @@ public class ApexSharingViolationsRule extends AbstractApexRule { ASTSoslExpression.class); } - @Override - public void start(RuleContext ctx) { + @Override public void start(RuleContext ctx) { super.start(ctx); localCacheOfReportedNodes.clear(); } - @Override - public Object visit(ASTSoqlExpression node, Object data) { + @Override public Object visit(ASTSoqlExpression node, Object data) { checkForViolation(node, data); return data; } - @Override - public Object visit(ASTSoslExpression node, Object data) { + @Override public Object visit(ASTSoslExpression node, Object data) { checkForViolation(node, data); return data; } - @Override - public Object visit(ASTDmlUpsertStatement node, Object data) { + @Override public Object visit(ASTDmlUpsertStatement node, Object data) { checkForViolation(node, data); return data; } - @Override - public Object visit(ASTDmlUpdateStatement node, Object data) { + @Override public Object visit(ASTDmlUpdateStatement node, Object data) { checkForViolation(node, data); return data; } - @Override - public Object visit(ASTDmlUndeleteStatement node, Object data) { + @Override public Object visit(ASTDmlUndeleteStatement node, Object data) { checkForViolation(node, data); return data; } - @Override - public Object visit(ASTDmlMergeStatement node, Object data) { + @Override public Object visit(ASTDmlMergeStatement node, Object data) { checkForViolation(node, data); return data; } - @Override - public Object visit(ASTDmlInsertStatement node, Object data) { + @Override public Object visit(ASTDmlInsertStatement node, Object data) { checkForViolation(node, data); return data; } - @Override - public Object visit(ASTDmlDeleteStatement node, Object data) { + @Override public Object visit(ASTDmlDeleteStatement node, Object data) { checkForViolation(node, data); return data; } - @Override - public Object visit(ASTMethodCallExpression node, Object data) { + @Override public Object visit(ASTMethodCallExpression node, Object data) { if (Helper.isAnyDatabaseMethodCall(node)) { checkForViolation(node, data); } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredRule.java index f2af171e819..2027871f560 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSuggestUsingNamedCredRule.java @@ -37,13 +37,11 @@ public class ApexSuggestUsingNamedCredRule extends AbstractApexRule { private final Set listOfAuthorizationVariables = new HashSet<>(); private final Set listOfCredentialVariables = new HashSet<>(); - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { if (Helper.isTestMethodOrClass(node)) { return data; } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromEscapeFalseRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromEscapeFalseRule.java index 1002bc08fdf..210510dd07d 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromEscapeFalseRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromEscapeFalseRule.java @@ -23,13 +23,11 @@ public class ApexXSSFromEscapeFalseRule extends AbstractApexRule { private static final String ADD_ERROR = "addError"; - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forTypes(ASTUserClass.class); } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { if (Helper.isTestMethodOrClass(node) || Helper.isSystemLevelClass(node)) { return data; // stops all the rules } diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamRule.java index 1fdb805a26f..6cc33da5220 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamRule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/security/ApexXSSFromURLParamRule.java @@ -29,28 +29,27 @@ * */ public class ApexXSSFromURLParamRule extends AbstractApexRule { - private static final String[] URL_PARAMETER_METHOD = new String[] { "ApexPages", "currentPage", "getParameters", - "get", }; - private static final String[] HTML_ESCAPING = new String[] { "ESAPI", "encoder", "SFDC_HTMLENCODE" }; - private static final String[] JS_ESCAPING = new String[] { "ESAPI", "encoder", "SFDC_JSENCODE" }; - private static final String[] JSINHTML_ESCAPING = new String[] { "ESAPI", "encoder", "SFDC_JSINHTMLENCODE" }; - private static final String[] URL_ESCAPING = new String[] { "ESAPI", "encoder", "SFDC_URLENCODE" }; - private static final String[] STRING_HTML3 = new String[] { "String", "escapeHtml3" }; - private static final String[] STRING_HTML4 = new String[] { "String", "escapeHtml4" }; - private static final String[] STRING_XML = new String[] { "String", "escapeXml" }; - private static final String[] STRING_ECMASCRIPT = new String[] { "String", "escapeEcmaScript" }; - private static final String[] INTEGER_VALUEOF = new String[] { "Integer", "valueOf" }; - private static final String[] ID_VALUEOF = new String[] { "ID", "valueOf" }; - private static final String[] DOUBLE_VALUEOF = new String[] { "Double", "valueOf" }; - private static final String[] BOOLEAN_VALUEOF = new String[] { "Boolean", "valueOf" }; - private static final String[] STRING_ISEMPTY = new String[] { "String", "isEmpty" }; - private static final String[] STRING_ISBLANK = new String[] { "String", "isBlank" }; - private static final String[] STRING_ISNOTBLANK = new String[] { "String", "isNotBlank" }; + private static final String[] URL_PARAMETER_METHOD = new String[]{"ApexPages", "currentPage", "getParameters", + "get", }; + private static final String[] HTML_ESCAPING = new String[]{"ESAPI", "encoder", "SFDC_HTMLENCODE"}; + private static final String[] JS_ESCAPING = new String[]{"ESAPI", "encoder", "SFDC_JSENCODE"}; + private static final String[] JSINHTML_ESCAPING = new String[]{"ESAPI", "encoder", "SFDC_JSINHTMLENCODE"}; + private static final String[] URL_ESCAPING = new String[]{"ESAPI", "encoder", "SFDC_URLENCODE"}; + private static final String[] STRING_HTML3 = new String[]{"String", "escapeHtml3"}; + private static final String[] STRING_HTML4 = new String[]{"String", "escapeHtml4"}; + private static final String[] STRING_XML = new String[]{"String", "escapeXml"}; + private static final String[] STRING_ECMASCRIPT = new String[]{"String", "escapeEcmaScript"}; + private static final String[] INTEGER_VALUEOF = new String[]{"Integer", "valueOf"}; + private static final String[] ID_VALUEOF = new String[]{"ID", "valueOf"}; + private static final String[] DOUBLE_VALUEOF = new String[]{"Double", "valueOf"}; + private static final String[] BOOLEAN_VALUEOF = new String[]{"Boolean", "valueOf"}; + private static final String[] STRING_ISEMPTY = new String[]{"String", "isEmpty"}; + private static final String[] STRING_ISBLANK = new String[]{"String", "isBlank"}; + private static final String[] STRING_ISNOTBLANK = new String[]{"String", "isNotBlank"}; private final Set urlParameterStrings = new HashSet<>(); - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { if (Helper.isTestMethodOrClass(node) || Helper.isSystemLevelClass(node)) { return data; // stops all the rules } @@ -58,36 +57,31 @@ public Object visit(ASTUserClass node, Object data) { return super.visit(node, data); } - @Override - public Object visit(ASTAssignmentExpression node, Object data) { + @Override public Object visit(ASTAssignmentExpression node, Object data) { findTaintedVariables(node, data); processVariableAssignments(node, data, false); return data; } - @Override - public Object visit(ASTVariableDeclaration node, Object data) { + @Override public Object visit(ASTVariableDeclaration node, Object data) { findTaintedVariables(node, data); processVariableAssignments(node, data, true); return data; } - @Override - public Object visit(ASTFieldDeclaration node, Object data) { + @Override public Object visit(ASTFieldDeclaration node, Object data) { findTaintedVariables(node, data); processVariableAssignments(node, data, true); return data; } - @Override - public Object visit(ASTMethodCallExpression node, Object data) { + @Override public Object visit(ASTMethodCallExpression node, Object data) { processEscapingMethodCalls(node, data); processInlineMethodCalls(node, data, false); return data; } - @Override - public Object visit(ASTReturnStatement node, Object data) { + @Override public Object visit(ASTReturnStatement node, Object data) { ASTBinaryExpression binaryExpression = node.firstChild(ASTBinaryExpression.class); if (binaryExpression != null) { processBinaryExpression(binaryExpression, data); @@ -220,28 +214,28 @@ private void processVariableAssignments(ApexNode node, Object data, final boo List nodes = node.children(ASTVariableExpression.class).toList(); switch (nodes.size()) { - case 1: { - // Look for: foo + bar - final List ops = node.children(ASTBinaryExpression.class).toList(); - if (!ops.isEmpty()) { - for (ASTBinaryExpression o : ops) { - processBinaryExpression(o, data); + case 1: { + // Look for: foo + bar + final List ops = node.children(ASTBinaryExpression.class).toList(); + if (!ops.isEmpty()) { + for (ASTBinaryExpression o : ops) { + processBinaryExpression(o, data); + } } - } - } - break; - case 2: { - // Look for: foo = bar; - final ASTVariableExpression right = reverseOrder ? nodes.get(0) : nodes.get(1); + } + break; + case 2: { + // Look for: foo = bar; + final ASTVariableExpression right = reverseOrder ? nodes.get(0) : nodes.get(1); - if (urlParameterStrings.contains(Helper.getFQVariableName(right))) { - asCtx(data).addViolation(right); + if (urlParameterStrings.contains(Helper.getFQVariableName(right))) { + asCtx(data).addViolation(right); + } } - } - break; - default: - break; + break; + default: + break; } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/AntlrVersionTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/AntlrVersionTest.java index f55f98f4f4b..2cea7562683 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/AntlrVersionTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/AntlrVersionTest.java @@ -41,18 +41,15 @@ class AntlrVersionTest { * * @see [apex] Warning messages about ANTLR version mismatch #4678 */ - @Test - void antlrVersionIsCompatible() throws IOException { + @Test void antlrVersionIsCompatible() throws IOException { ClassReader classReader = new ClassReader(ApexParser.class.getName()); classReader.accept(new ClassVisitor(Opcodes.ASM9) { - @Override - public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { + @Override public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { if ("".equals(name)) { return new MethodVisitor(Opcodes.ASM9) { private final Deque versions = new LinkedList<>(); - @Override - public void visitLdcInsn(Object value) { + @Override public void visitLdcInsn(Object value) { if (value instanceof String) { versions.addLast((String) value); if (versions.size() > 2) { @@ -61,8 +58,7 @@ public void visitLdcInsn(Object value) { } } - @Override - public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) { + @Override public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) { if ("org/antlr/v4/runtime/RuntimeMetaData".equals(owner) && "checkVersion".equals(name)) { assertEquals(2, versions.size()); String checkResult = executeCheckVersion(versions.getFirst(), versions.getLast()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/FooRule.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/FooRule.java index 8729f901345..7645b032287 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/FooRule.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/FooRule.java @@ -19,40 +19,35 @@ public FooRule() { setMessage("No Foo allowed"); } - @Override - public Object visit(ASTUserClass c, Object ctx) { + @Override public Object visit(ASTUserClass c, Object ctx) { if ("Foo".equalsIgnoreCase(c.getSimpleName())) { asCtx(ctx).addViolation(c); } return super.visit(c, ctx); } - @Override - public Object visit(ASTVariableDeclaration c, Object ctx) { + @Override public Object visit(ASTVariableDeclaration c, Object ctx) { if ("Foo".equalsIgnoreCase(c.getImage())) { asCtx(ctx).addViolation(c); } return super.visit(c, ctx); } - @Override - public Object visit(ASTField c, Object ctx) { + @Override public Object visit(ASTField c, Object ctx) { if ("Foo".equalsIgnoreCase(c.getImage())) { asCtx(ctx).addViolation(c); } return super.visit(c, ctx); } - @Override - public Object visit(ASTParameter c, Object ctx) { + @Override public Object visit(ASTParameter c, Object ctx) { if ("Foo".equalsIgnoreCase(c.getImage())) { asCtx(ctx).addViolation(c); } return super.visit(c, ctx); } - @Override - public String getName() { + @Override public String getName() { return "NoFoo"; } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/LanguageVersionTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/LanguageVersionTest.java index 622f358037f..d65cec2bdd4 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/LanguageVersionTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/LanguageVersionTest.java @@ -13,7 +13,7 @@ class LanguageVersionTest extends AbstractLanguageVersionTest { static Collection data() { return Arrays.asList( - TestDescriptor.defaultVersionIs(ApexLanguageModule.getInstance(), "60") + TestDescriptor.defaultVersionIs(ApexLanguageModule.getInstance(), "60") ); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/QuickstartRulesetTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/QuickstartRulesetTest.java index dcde511529d..06dc0e69f3d 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/QuickstartRulesetTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/QuickstartRulesetTest.java @@ -18,8 +18,7 @@ class QuickstartRulesetTest { private static final String QUICKSTART_RULESET = "rulesets/apex/quickstart.xml"; - @Test - void loadQuickstartRuleset() throws Exception { + @Test void loadQuickstartRuleset() throws Exception { String log = SystemLambda.tapSystemErr(() -> { RuleSet ruleset = rulesetLoader().loadFromResource(QUICKSTART_RULESET); assertNotNull(ruleset); @@ -27,8 +26,7 @@ void loadQuickstartRuleset() throws Exception { assertTrue(log.isEmpty(), "No Logging expected"); } - @Test - void correctEncoding() throws Exception { + @Test void correctEncoding() throws Exception { assertTrue(AbstractRuleSetFactoryTest.hasCorrectEncoding(QUICKSTART_RULESET)); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java index a569c39b94d..716b17e388e 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/SuppressWarningsTest.java @@ -24,135 +24,121 @@ class SuppressWarningsTest extends ApexParserTestBase { private static class BarRule extends AbstractApexRule { - @Override - public String getMessage() { + @Override public String getMessage() { return "a message"; } - @Override - public Object visit(ASTUserClass clazz, Object ctx) { + @Override public Object visit(ASTUserClass clazz, Object ctx) { if ("bar".equalsIgnoreCase(clazz.getSimpleName())) { asCtx(ctx).addViolation(clazz); } return super.visit(clazz, ctx); } - @Override - public String getName() { + @Override public String getName() { return "NoBar"; } } - @Test - void testClassLevelSuppression() { + @Test void testClassLevelSuppression() { assertNoWarningsWithFoo("@SuppressWarnings('PMD')\n" - + "public class Foo {}"); + + "public class Foo {}"); } private void assertNoWarningsWithFoo(String code) { assertWarningsWithFoo(0, code); } - @Test - void testClassLevelSuppression2() { + @Test void testClassLevelSuppression2() { assertNoWarningsWithFoo("@SuppressWarnings('PMD')\n" - + "public class Foo {" + "\n" - + " void bar() {\n" - + " Integer foo;\n" - + " }\n" - + "}"); + + "public class Foo {" + "\n" + + " void bar() {\n" + + " Integer foo;\n" + + " }\n" + + "}"); } - @Test - void testInheritedSuppression() { + @Test void testInheritedSuppression() { assertNoWarningsWithFoo("public class Baz {\n" - + " @SuppressWarnings('PMD')" + "\n" - + " public class Bar {\n" - + " void bar() {\n" - + " Integer foo;\n" - + " }" + "\n" - + " }\n" - + "}"); + + " @SuppressWarnings('PMD')" + "\n" + + " public class Bar {\n" + + " void bar() {\n" + + " Integer foo;\n" + + " }" + "\n" + + " }\n" + + "}"); } - @Test - void testMethodLevelSuppression() { + @Test void testMethodLevelSuppression() { assertWarningsWithFoo(1, "public class Foo {\n" - + " @SuppressWarnings('PMD')\n" - + " void bar() {\n" - + " Integer foo;\n" - + " }\n" - + "}"); + + " @SuppressWarnings('PMD')\n" + + " void bar() {\n" + + " Integer foo;\n" + + " }\n" + + "}"); } - @Test - void testConstructorLevelSuppression() { + @Test void testConstructorLevelSuppression() { assertNoWarningsWithFoo("public class Bar {\n" - + " @SuppressWarnings('PMD')" + "\n" - + " public Bar() {\n" - + " Integer foo;\n" - + " }\n" - + "}"); + + " @SuppressWarnings('PMD')" + "\n" + + " public Bar() {\n" + + " Integer foo;\n" + + " }\n" + + "}"); } - @Test - void testFieldLevelSuppression() { + @Test void testFieldLevelSuppression() { assertWarningsWithFoo(1, "public class Bar {\n" - + " @SuppressWarnings('PMD')" + "\n" - + " Integer foo;\n" - + " void bar() {\n" - + " Integer foo;\n" - + " }\n" - + "}"); + + " @SuppressWarnings('PMD')" + "\n" + + " Integer foo;\n" + + " void bar() {\n" + + " Integer foo;\n" + + " }\n" + + "}"); } - @Test - void testParameterLevelSuppression() { + @Test void testParameterLevelSuppression() { assertWarningsWithFoo(1, "public class Bar {\n" - + " Integer foo;" + "\n" - + " void bar(@SuppressWarnings('PMD') Integer foo) {}\n" - + "}"); + + " Integer foo;" + "\n" + + " void bar(@SuppressWarnings('PMD') Integer foo) {}\n" + + "}"); } - @Test - void testLocalVariableLevelSuppression() { + @Test void testLocalVariableLevelSuppression() { assertWarningsWithFoo(1, "public class Bar {\n" - + " Integer foo;\n" - + " void bar() {" - + "\n" + " @SuppressWarnings('PMD') Integer foo;\n" - + " }\n" - + "}"); + + " Integer foo;\n" + + " void bar() {" + + "\n" + " @SuppressWarnings('PMD') Integer foo;\n" + + " }\n" + + "}"); } - @Test - void testSpecificSuppression() { + @Test void testSpecificSuppression() { assertWarningsWithFoo(1, "public class Bar {\n" - + " Integer foo;\n" - + " void bar() {" - + "\n" + " @SuppressWarnings('PMD.NoFoo') Integer foo;\n" - + " }\n" - + "}"); + + " Integer foo;\n" + + " void bar() {" + + "\n" + " @SuppressWarnings('PMD.NoFoo') Integer foo;\n" + + " }\n" + + "}"); } - @Test - void testSpecificSuppressionMulitpleValues() { + @Test void testSpecificSuppressionMulitpleValues() { assertNoWarningsWithFoo("@SuppressWarnings('PMD.NoFoo, PMD.NoBar')" - + "\n" + "public class Bar {\n" - + " Integer foo;\n" - + " void bar() {" + "\n" - + " Integer foo;\n" - + " }\n" - + "}"); + + "\n" + "public class Bar {\n" + + " Integer foo;\n" + + " void bar() {" + "\n" + + " Integer foo;\n" + + " }\n" + + "}"); } - @Test - void testNoSuppressionBlank() { + @Test void testNoSuppressionBlank() { assertWarningsWithFoo(2, "public class Bar {\n" - + " Integer foo;\n" - + " void bar() {" - + "\n" + " @SuppressWarnings('') Integer foo;\n" - + " }\n" - + "}"); + + " Integer foo;\n" + + " void bar() {" + + "\n" + " @SuppressWarnings('') Integer foo;\n" + + " }\n" + + "}"); } private void assertWarningsWithFoo(int size, String code) { @@ -160,45 +146,40 @@ private void assertWarningsWithFoo(int size, String code) { assertSize(rpt, size); } - @Test - void testNoSuppressionSomethingElseS() { + @Test void testNoSuppressionSomethingElseS() { assertWarningsWithFoo(2, "public class Bar {\n" - + " Integer foo;\n" - + " void bar() {" - + "\n" + " @SuppressWarnings('SomethingElse') Integer foo;\n" - + " }\n" - + "}"); + + " Integer foo;\n" + + " void bar() {" + + "\n" + " @SuppressWarnings('SomethingElse') Integer foo;\n" + + " }\n" + + "}"); } - @Test - void testSuppressAll() { + @Test void testSuppressAll() { assertNoWarningsWithFoo("public class Bar {\n" - + " @SuppressWarnings('all') Integer foo;" - + "\n" + "}"); + + " @SuppressWarnings('all') Integer foo;" + + "\n" + "}"); } - @Test - void testSpecificSuppressionAtTopLevel() { + @Test void testSpecificSuppressionAtTopLevel() { Report rpt = apex.executeRule(new BarRule(), "@SuppressWarnings('PMD.NoBar')\n" - + "public class Bar {" + "\n" - + "}"); + + "public class Bar {" + "\n" + + "}"); assertSize(rpt, 0); } - @Test - void testCommentSuppression() { + @Test void testCommentSuppression() { Report rpt = apex.executeRule(new FooRule(), "public class Bar {\n" - + "Integer foo; // NOPMD\n" - + "}"); + + "Integer foo; // NOPMD\n" + + "}"); assertSize(rpt, 0); assertSuppressed(rpt, 1); } - @Test - void testMessageWithCommentSuppression() { + @Test void testMessageWithCommentSuppression() { Report rpt = apex.executeRule(new FooRule(), "public class Bar {\n" - + "Integer foo; //NOPMD We allow foo here\n" - + "}"); + + "Integer foo; //NOPMD We allow foo here\n" + + "}"); assertSize(rpt, 0); List suppressions = assertSuppressed(rpt, 1); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotationTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotationTest.java index c94b167a53b..6f51af6ff7a 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotationTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTAnnotationTest.java @@ -11,8 +11,7 @@ import net.sourceforge.pmd.lang.document.Chars; class ASTAnnotationTest extends ApexParserTestBase { - @Test - void caseSensitiveName() { + @Test void caseSensitiveName() { ASTUserClassOrInterface parsed = parse("public with sharing class Example {\n" + "\n" + " @istest\n" diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTBlockStatementTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTBlockStatementTest.java index f6d52a209f6..cab8ef5f20c 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTBlockStatementTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTBlockStatementTest.java @@ -10,8 +10,7 @@ import org.junit.jupiter.api.Test; class ASTBlockStatementTest extends ApexParserTestBase { - @Test - void noCurlyBraces() { + @Test void noCurlyBraces() { ASTBlockStatement blockStatement = parse("class Foo { { if (true) methodCall(); } }") .descendants(ASTIfBlockStatement.class) .firstChild(ASTBlockStatement.class) @@ -19,8 +18,7 @@ void noCurlyBraces() { assertFalse(blockStatement.hasCurlyBrace()); } - @Test - void withCurlyBraces() { + @Test void withCurlyBraces() { ASTBlockStatement blockStatement = parse("class Foo { { if (true) { methodCall(); } } }") .descendants(ASTIfBlockStatement.class) .firstChild(ASTBlockStatement.class) diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclarationStatementsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclarationStatementsTest.java index c83f1511aa8..bf5d950d840 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclarationStatementsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldDeclarationStatementsTest.java @@ -11,39 +11,34 @@ class ASTFieldDeclarationStatementsTest extends ApexParserTestBase { - @Test - void getSimpleTypeName() { + @Test void getSimpleTypeName() { ASTFieldDeclarationStatements fields = parse("class Foo { String field; }").descendants(ASTFieldDeclarationStatements.class).first(); assertEquals("String", fields.getTypeName()); assertTrue(fields.getTypeArguments().isEmpty()); } - @Test - void getListTypeName() { + @Test void getListTypeName() { ASTFieldDeclarationStatements fields = parse("class Foo { List field; }").descendants(ASTFieldDeclarationStatements.class).first(); assertEquals("List", fields.getTypeName()); assertEquals(1, fields.getTypeArguments().size()); assertEquals("String", fields.getTypeArguments().get(0)); } - @Test - void getListTypeNameComponents() { + @Test void getListTypeNameComponents() { ASTFieldDeclarationStatements fields = parse("class Foo { my.List field; }").descendants(ASTFieldDeclarationStatements.class).first(); assertEquals("my.List", fields.getTypeName()); assertEquals(1, fields.getTypeArguments().size()); assertEquals("my.String", fields.getTypeArguments().get(0)); } - @Test - void getNestedListTypeName() { + @Test void getNestedListTypeName() { ASTFieldDeclarationStatements fields = parse("class Foo { List> field; }").descendants(ASTFieldDeclarationStatements.class).first(); assertEquals("List>", fields.getTypeName()); assertEquals(1, fields.getTypeArguments().size()); assertEquals("List", fields.getTypeArguments().get(0)); } - @Test - void getMapTypeName() { + @Test void getMapTypeName() { ASTFieldDeclarationStatements fields = parse("class Foo { Map field; }").descendants(ASTFieldDeclarationStatements.class).first(); assertEquals("Map", fields.getTypeName()); assertEquals(2, fields.getTypeArguments().size()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldTest.java index 6c4797a7b68..65e47af2b58 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTFieldTest.java @@ -11,28 +11,25 @@ class ASTFieldTest extends ApexParserTestBase { - @Test - void testGetType() { + @Test void testGetType() { ASTField field = parse("public class Foo { private String myField = 'a'; }") - .descendants(ASTField.class).firstOrThrow(); + .descendants(ASTField.class).firstOrThrow(); assertEquals("myField", field.getImage()); assertEquals("String", field.getType()); assertEquals("a", field.getValue()); } - @Test - void testGetValue() { + @Test void testGetValue() { ASTField field = parse("public class Foo { private String myField = 'a'; }") - .descendants(ASTField.class).firstOrThrow(); + .descendants(ASTField.class).firstOrThrow(); assertEquals("a", field.getValue()); } - @Test - void testGetNoValue() { + @Test void testGetNoValue() { ASTField field = parse("public class Foo { private String myField; }") - .descendants(ASTField.class).firstOrThrow(); + .descendants(ASTField.class).firstOrThrow(); assertNull(field.getValue()); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralExpressionTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralExpressionTest.java index c249c8df5a5..f62fc520ef4 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralExpressionTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTLiteralExpressionTest.java @@ -11,8 +11,7 @@ class ASTLiteralExpressionTest extends ApexParserTestBase { - @Test - void doubleLiteral() { + @Test void doubleLiteral() { ASTLiteralExpression literal = createLiteral("1.2d"); assertTrue(literal.isDouble()); assertEquals(ASTLiteralExpression.LiteralType.DOUBLE, literal.getLiteralType()); @@ -23,16 +22,14 @@ void doubleLiteral() { assertEquals(ASTLiteralExpression.LiteralType.DOUBLE, literal.getLiteralType()); } - @Test - void decimalLiteral() { + @Test void decimalLiteral() { ASTLiteralExpression literal = createLiteral("1.2"); assertTrue(literal.isDecimal()); assertEquals(ASTLiteralExpression.LiteralType.DECIMAL, literal.getLiteralType()); assertEquals("1.2", literal.getImage()); } - @Test - void stringLiteral() { + @Test void stringLiteral() { ASTLiteralExpression literal = createLiteral("'foo'"); assertTrue(literal.isString()); assertEquals(ASTLiteralExpression.LiteralType.STRING, literal.getLiteralType()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodTest.java index bfe90c1b5d6..bc74d836666 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTMethodTest.java @@ -12,8 +12,7 @@ class ASTMethodTest extends ApexParserTestBase { - @Test - void testConstructorName() { + @Test void testConstructorName() { ASTUserClass node = (ASTUserClass) parse("public class Foo { public Foo() {} public void bar() {} }"); List methods = node.children(ASTMethod.class).toList(); assertEquals("Foo", methods.get(0).getImage()); // constructor @@ -21,8 +20,7 @@ void testConstructorName() { assertEquals("bar", methods.get(1).getImage()); // normal method } - @Test - void qualifiedNameWithGenerics() { + @Test void qualifiedNameWithGenerics() { ASTUserClass node = (ASTUserClass) parse("public class Foo { public void bar(List mylist, Map oldMap) {}}"); ApexQualifiedName qualifiedName = node.getMethods().first().getQualifiedName(); assertEquals("bar(List, Map)", qualifiedName.getOperation()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpressionTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpressionTest.java index 83751e6648d..794b4b9b86c 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpressionTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTNewKeyValueObjectExpressionTest.java @@ -12,8 +12,7 @@ class ASTNewKeyValueObjectExpressionTest extends ApexParserTestBase { - @Test - void testParameterName() { + @Test void testParameterName() { ASTUserClassOrInterface node = parse("public class Foo { \n" + " public void foo(String newName, String tempID) { \n" + " if (Contact.sObjectType.getDescribe().isCreateable() && Contact.sObjectType.getDescribe().isUpdateable()) {\n" diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpressionTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpressionTest.java index 64c766de417..a8527acbfca 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpressionTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTReferenceExpressionTest.java @@ -11,8 +11,7 @@ import org.junit.jupiter.api.Test; class ASTReferenceExpressionTest extends ApexParserTestBase { - @Test - void referenceTypeMethodWithSafeNav() { + @Test void referenceTypeMethodWithSafeNav() { ASTReferenceExpression reference = parse("class Foo { static void bar() { Foo?.staticMethod(); } }") .descendants(ASTReferenceExpression.class) .first(); @@ -20,8 +19,7 @@ void referenceTypeMethodWithSafeNav() { assertTrue(reference.isSafeNav()); } - @Test - void referenceTypeMethodWithoutSafeNav() { + @Test void referenceTypeMethodWithoutSafeNav() { ASTReferenceExpression reference = parse("class Foo { static void bar() { Foo.staticMethod(); } }") .descendants(ASTReferenceExpression.class) .first(); @@ -29,8 +27,7 @@ void referenceTypeMethodWithoutSafeNav() { assertFalse(reference.isSafeNav()); } - @Test - void referenceTypeLoad() { + @Test void referenceTypeLoad() { ASTReferenceExpression reference = parse("class Foo { static void bar() { Foo x = Foo?.INSTANCE; } }") .descendants(ASTReferenceExpression.class) .first(); @@ -38,8 +35,7 @@ void referenceTypeLoad() { assertTrue(reference.isSafeNav()); } - @Test - void referenceTypeStore() { + @Test void referenceTypeStore() { ASTReferenceExpression reference = parse("class Foo { static void bar() { Foo.INSTANCE = x; } }") .descendants(ASTReferenceExpression.class) .first(); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpressionTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpressionTest.java index 236f7a32c49..d81bb799eb0 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpressionTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTSoqlExpressionTest.java @@ -10,24 +10,21 @@ class ASTSoqlExpressionTest extends ApexParserTestBase { - @Test - void testQuery1() { + @Test void testQuery1() { ApexNode root = parse("class Foo { void test1() { Account acc = [SeLeCt cOl fRoM Account where a = 1]; } }"); ASTSoqlExpression soqlExpression = root.descendants(ASTSoqlExpression.class).firstOrThrow(); assertEquals("SeLeCt cOl fRoM Account where a = 1", soqlExpression.getQuery()); assertEquals("SELECT cOl FROM Account WHERE a = 1", soqlExpression.getCanonicalQuery()); } - @Test - void testQuery2() { + @Test void testQuery2() { ApexNode root = parse("class Foo { void test1() { Integer i = [select count() from Account]; } }"); ASTSoqlExpression soqlExpression = root.descendants(ASTSoqlExpression.class).firstOrThrow(); assertEquals("select count() from Account", soqlExpression.getQuery()); assertEquals("SELECT COUNT() FROM Account", soqlExpression.getCanonicalQuery()); } - @Test - void testQuery3() { + @Test void testQuery3() { ApexNode root = parse("class Foo { void test1() { String name = [SELECT Name FROM Account WHERE Id = :accId and Name = :myName]; } }"); ASTSoqlExpression soqlExpression = root.descendants(ASTSoqlExpression.class).firstOrThrow(); assertEquals("SELECT Name FROM Account WHERE Id = :accId and Name = :myName", soqlExpression.getQuery()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatementTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatementTest.java index edb48cd1f67..14ebd23ce67 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatementTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTTryCatchFinallyBlockStatementTest.java @@ -12,8 +12,7 @@ class ASTTryCatchFinallyBlockStatementTest extends ApexParserTestBase { - @Test - void testTryFinally() { + @Test void testTryFinally() { ApexNode node = parse("class Foo { void bar() { try { methodCall(); } finally { methodCall(); } } }"); ASTTryCatchFinallyBlockStatement statement = node.descendants(ASTTryCatchFinallyBlockStatement.class).first(); assertNotNull(statement.getTryBlock()); @@ -23,8 +22,7 @@ void testTryFinally() { assertEquals(0, statement.getCatchClauses().size()); } - @Test - void testTryCatch() { + @Test void testTryCatch() { ApexNode node = parse("class Foo { void bar() { try { methodCall(); } catch (Exception e) { methodCall(); } } }"); ASTTryCatchFinallyBlockStatement statement = node.descendants(ASTTryCatchFinallyBlockStatement.class).first(); assertNotNull(statement.getTryBlock()); @@ -35,8 +33,7 @@ void testTryCatch() { assertEquals(1, statement.getCatchClauses().get(0).getIndexInParent()); } - @Test - void testTryCatchFinally() { + @Test void testTryCatchFinally() { ApexNode node = parse("class Foo { void bar() { try { methodCall(); } catch (Exception e) { methodCall(); } finally { } } }"); ASTTryCatchFinallyBlockStatement statement = node.descendants(ASTTryCatchFinallyBlockStatement.class).first(); assertNotNull(statement.getTryBlock()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassTest.java index 97120ce364b..4b425773e65 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserClassTest.java @@ -12,33 +12,28 @@ class ASTUserClassTest extends ApexParserTestBase { - @Test - void testClassName() { + @Test void testClassName() { ASTUserClass node = (ASTUserClass) parse("class Foo { }"); assertEquals("Foo", node.getSimpleName()); } - @Test - void testInnerClassName() { + @Test void testInnerClassName() { ASTUserClass foo = (ASTUserClass) parse("class Foo { class Bar { } }"); ASTUserClass innerNode = foo.descendants(ASTUserClass.class).firstOrThrow(); assertEquals("Bar", innerNode.getSimpleName()); } - @Test - void testSuperClassName() { + @Test void testSuperClassName() { ASTUserClass toplevel = (ASTUserClass) parse("public class AccountTriggerHandler extends TriggerHandler {}"); assertEquals("TriggerHandler", toplevel.getSuperClassName()); } - @Test - void testSuperClassName2() { + @Test void testSuperClassName2() { ASTUserClass toplevel = (ASTUserClass) parse("public class AccountTriggerHandler extends Other.TriggerHandler {}"); assertEquals("Other.TriggerHandler", toplevel.getSuperClassName()); } - @Test - void testInterfaces() { + @Test void testInterfaces() { ASTUserClass toplevel = (ASTUserClass) parse("public class AccountTriggerHandler implements TriggerHandler, Other.Interface2 {}"); assertEquals(Arrays.asList("TriggerHandler", "Other.Interface2"), toplevel.getInterfaceNames()); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnumTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnumTest.java index 406177cc707..26f0313efc3 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnumTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserEnumTest.java @@ -10,8 +10,7 @@ class ASTUserEnumTest extends ApexParserTestBase { - @Test - void testEnumName() { + @Test void testEnumName() { ASTUserClass node = (ASTUserClass) parse("class Foo { enum Bar { } }"); ASTUserEnum enumNode = node.descendants(ASTUserEnum.class).firstOrThrow(); assertEquals("Bar", enumNode.getSimpleName()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterfaceTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterfaceTest.java index 1786022e8aa..fc8621b106f 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterfaceTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserInterfaceTest.java @@ -10,27 +10,23 @@ class ASTUserInterfaceTest extends ApexParserTestBase { - @Test - void testInterfaceName() { + @Test void testInterfaceName() { ASTUserInterface node = (ASTUserInterface) parse("interface Foo { }"); assertEquals("Foo", node.getSimpleName()); } - @Test - void testInnerInterfaceName() { + @Test void testInnerInterfaceName() { ASTUserClass node = (ASTUserClass) parse("class Foo { interface Bar { } }"); ASTUserInterface innerNode = node.descendants(ASTUserInterface.class).firstOrThrow(); assertEquals("Bar", innerNode.getSimpleName()); } - @Test - void testSuperInterface() { + @Test void testSuperInterface() { ASTUserInterface toplevel = (ASTUserInterface) parse("public interface CustomInterface extends A {}"); assertEquals("A", toplevel.getSuperInterfaceName()); } - @Test - void testSuperInterface2() { + @Test void testSuperInterface2() { ASTUserInterface toplevel = (ASTUserInterface) parse("public interface CustomInterface extends Other.A {}"); assertEquals("Other.A", toplevel.getSuperInterfaceName()); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTriggerTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTriggerTest.java index f995c95e8bd..fe3d9994643 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTriggerTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ASTUserTriggerTest.java @@ -13,8 +13,7 @@ class ASTUserTriggerTest extends ApexParserTestBase { - @Test - void testTriggerName() { + @Test void testTriggerName() { ApexNode node = parse("trigger HelloWorldTrigger on Book__c (before insert, after update) {\n" + " Book__c[] books = Trigger.new;\n" + " MyHelloWorld.applyDiscount(books);\n" + "}\n"); assertSame(ASTUserTrigger.class, node.getClass()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentTest.java index 6e847170bfe..4da0314f517 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCommentTest.java @@ -12,19 +12,17 @@ class ApexCommentTest extends ApexParserTestBase { private static final String FORMAL_COMMENT_CONTENT = "/** formal comment */"; - @Test - void testContainsComment1() { + @Test void testContainsComment1() { ASTApexFile file = apex.parse("class Foo {void foo(){try {\n" - + "} catch (Exception e) {\n" - + " /* OK: block comment inside of empty catch block; should not be reported */\n" - + "}}}"); + + "} catch (Exception e) {\n" + + " /* OK: block comment inside of empty catch block; should not be reported */\n" + + "}}}"); ASTCatchBlockStatement catchBlock = file.descendants(ASTCatchBlockStatement.class).crossFindBoundaries().firstOrThrow(); assertTrue(catchBlock.getContainsComment()); } - @Test - void fieldDeclarationHasFormalComment() { + @Test void fieldDeclarationHasFormalComment() { ASTApexFile file = apex.parse("class MyClass {\n" + " " + FORMAL_COMMENT_CONTENT + "\n" + " Integer field;\n" @@ -36,19 +34,17 @@ void fieldDeclarationHasFormalComment() { assertEquals(FORMAL_COMMENT_CONTENT, comment.getImage()); } - @Test - void methodHasFormalComment() { + @Test void methodHasFormalComment() { ASTApexFile file = apex.parse(FORMAL_COMMENT_CONTENT + "\n" - + "class MyClass {\n" - + " " + FORMAL_COMMENT_CONTENT + "\n" - + " public void bar() {}\n" - + "}"); + + "class MyClass {\n" + + " " + FORMAL_COMMENT_CONTENT + "\n" + + " public void bar() {}\n" + + "}"); ASTFormalComment comment = file.descendants(ASTUserClass.class).children(ASTMethod.class).children(ASTFormalComment.class).first(); assertEquals(FORMAL_COMMENT_CONTENT, comment.getImage()); } - @Test - void methodHasFormalCommentAnnotatedClass() { + @Test void methodHasFormalCommentAnnotatedClass() { ASTApexFile file = apex.parse(FORMAL_COMMENT_CONTENT + "\n" + "@RestResource(urlMapping='/api/v1/get/*')\n" + "class MyClass {\n" @@ -59,16 +55,14 @@ void methodHasFormalCommentAnnotatedClass() { assertEquals(FORMAL_COMMENT_CONTENT, comment.getImage()); } - @Test - void classHasFormalComment() { + @Test void classHasFormalComment() { ASTApexFile file = apex.parse(FORMAL_COMMENT_CONTENT + "\n" + "class MyClass {}"); ASTFormalComment comment = file.descendants(ASTUserClass.class).children(ASTFormalComment.class).first(); assertEquals(FORMAL_COMMENT_CONTENT, comment.getImage()); } - @Test - void fileWithUnicodeEscapes() { + @Test void fileWithUnicodeEscapes() { ASTApexFile file = apex.parse(FORMAL_COMMENT_CONTENT + "\n" + "class MyClass { String s = 'Fran\\u00E7ois'; }"); ASTFormalComment comment = file.descendants(ASTUserClass.class).children(ASTFormalComment.class).first(); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerSoqlTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerSoqlTest.java index e585078d7fd..5d81dea51a5 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerSoqlTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerSoqlTest.java @@ -9,13 +9,12 @@ class ApexCompilerSoqlTest extends ApexParserTestBase { private static final String CODE = "public class Foo {\n" - + " public List test1() {\n" - + " return Database.query(\'Select Id from Account LIMIT 100\');\n" - + " }\n" - + "}\n"; + + " public List test1() {\n" + + " return Database.query(\'Select Id from Account LIMIT 100\');\n" + + " }\n" + + "}\n"; - @Test - void testSoqlCompilation() { + @Test void testSoqlCompilation() { apex.parse(CODE); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerTest.java index 107da7d444e..6dbe69fa12f 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexCompilerTest.java @@ -12,8 +12,7 @@ class ApexCompilerTest extends ApexParserTestBase { - @Test - void compileShouldFail() { + @Test void compileShouldFail() { assertThrows(ParseException.class, () -> apex.parse("public class Foo { private String myField = \"a\"; }")); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexLexerTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexLexerTest.java index 0d456d29559..75c7bfcc153 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexLexerTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexLexerTest.java @@ -31,8 +31,7 @@ class ApexLexerTest { + " }\n" + "}\n"; - @Test - void testLexer() { + @Test void testLexer() { CharStream in = CharStreams.fromString(CODE); ApexLexer lexer = new ApexLexer(in); @@ -45,8 +44,7 @@ void testLexer() { assertEquals(35, tokenCount); } - @Test - void testParser() { + @Test void testParser() { CharStream in = CharStreams.fromString(CODE); ApexLexer lexer = new ApexLexer(in); ApexParser parser = new ApexParser(new CommonTokenStream(lexer)); @@ -54,8 +52,7 @@ void testParser() { assertNotNull(compilationUnit); } - @Test - void testLexerUnicodeEscapes() { + @Test void testLexerUnicodeEscapes() { String s = "'Fran\\u00E7ois'"; // note: with apex-parser 4.3.1, no errors are reported anymore assertEquals(0, getLexingErrors(CharStreams.fromString(s))); @@ -75,9 +72,8 @@ private int getLexingErrors(CharStream stream) { private static class ErrorListener extends BaseErrorListener { private int errorCount = 0; - @Override - public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, - int charPositionInLine, String msg, RecognitionException e) { + @Override public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, + int charPositionInLine, String msg, RecognitionException e) { ++errorCount; } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java index ede06c79afe..3a892f25183 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserTest.java @@ -28,16 +28,15 @@ class ApexParserTest extends ApexParserTestBase { - @Test - void understandsSimpleFile() { + @Test void understandsSimpleFile() { // Setup String code = "@isTest\n" - + " public class SimpleClass {\n" - + " @isTest\n public static void testAnything() {\n" - + " \n" - + " }\n" - + "}"; + + " public class SimpleClass {\n" + + " @isTest\n public static void testAnything() {\n" + + " \n" + + " }\n" + + "}"; // Exercise ASTUserClassOrInterface rootNode = parse(code); @@ -47,35 +46,32 @@ void understandsSimpleFile() { assertEquals(1, methods.size()); } - @Test - void parseErrors() { + @Test void parseErrors() { ParseException exception = assertThrows(ParseException.class, () -> parse("public class SimpleClass { String x = \"a\"; }")); assertThat(exception.getMessage(), containsString("Syntax error at 1:38: token recognition error at: '\"'")); } private final String testCodeForLineNumbers = - "public class SimpleClass {\n" // line 1 - + " public void method1() {\n" // line 2 - + " System.out.println('abc');\n" // line 3 - + " // this is a comment\n" // line 4 - + " }\n" // line 5 - + "}"; // line 6 - - @Test - void verifyLineColumnNumbers() { + "public class SimpleClass {\n" // line 1 + + " public void method1() {\n" // line 2 + + " System.out.println('abc');\n" // line 3 + + " // this is a comment\n" // line 4 + + " }\n" // line 5 + + "}"; // line 6 + + @Test void verifyLineColumnNumbers() { ASTUserClassOrInterface rootNode = parse(testCodeForLineNumbers); assertLineNumbersForTestCode(rootNode); } - @Test - void verifyLineColumnNumbersWithWindowsLineEndings() { + @Test void verifyLineColumnNumbersWithWindowsLineEndings() { String windowsLineEndings = testCodeForLineNumbers.replaceAll(" \n", "\r\n"); ASTUserClassOrInterface rootNode = parse(windowsLineEndings); assertLineNumbersForTestCode(rootNode); } private void assertLineNumbersForTestCode(ASTUserClassOrInterface classNode) { - + // identifier: "SimpleClass" assertEquals("SimpleClass", classNode.getSimpleName()); // Class location starts at the "class" keyword. (It excludes modifiers.) @@ -102,8 +98,7 @@ private void assertLineNumbersForTestCode(ASTUserClassOrInterface classNode) assertTextEquals("System.out.println('abc');", expressionStatement); } - @Test - void verifyEndLine() { + @Test void verifyEndLine() { String code = "public class SimpleClass {\n" // line 1 + " public void method1() {\n" // line 2 @@ -122,16 +117,15 @@ void verifyEndLine() { assertPosition(method2, 4, 12, 5, 6); } - @Test - void checkComments() { + @Test void checkComments() { String code = "public /** Comment on Class */ class SimpleClass {\n" // line 1 - + " /** Comment on m1 */" - + " public void method1() {\n" // line 2 - + " }\n" // line 3 - + " public void method2() {\n" // line 4 - + " }\n" // line 5 - + "}\n"; // line 6 + + " /** Comment on m1 */" + + " public void method1() {\n" // line 2 + + " }\n" // line 3 + + " public void method2() {\n" // line 4 + + " }\n" // line 5 + + "}\n"; // line 6 ASTUserClassOrInterface root = parse(code); @@ -150,8 +144,7 @@ void checkComments() { assertEquals("/** Comment on m1 */", ((ASTFormalComment) comment2).getImage()); } - @Test - void parsesRealWorldClasses() throws Exception { + @Test void parsesRealWorldClasses() throws Exception { File directory = new File("src/test/resources"); File[] fList = directory.listFiles(); @@ -167,8 +160,7 @@ void parsesRealWorldClasses() throws Exception { * See github issue #1546 * @see [apex] PMD parsing exception for Apex classes using 'inherited sharing' keyword */ - @Test - void parseInheritedSharingClass() throws IOException { + @Test void parseInheritedSharingClass() throws IOException { String source = IOUtil.readToString(ApexParserTest.class.getResourceAsStream("InheritedSharing.cls"), StandardCharsets.UTF_8); assertNotNull(parse(source)); @@ -179,10 +171,9 @@ void parseInheritedSharingClass() throws IOException { * * @see #1485 [apex] Analysis of some apex classes cause a stackoverflow error */ - @Test - void stackOverflowDuringClassParsing() throws Exception { + @Test void stackOverflowDuringClassParsing() throws Exception { String source = IOUtil.readToString(ApexParserTest.class.getResourceAsStream("StackOverflowClass.cls"), - StandardCharsets.UTF_8); + StandardCharsets.UTF_8); ASTUserClassOrInterface rootNode = parse(source); assertNotNull(rootNode); @@ -190,8 +181,7 @@ void stackOverflowDuringClassParsing() throws Exception { assertEquals(471, count); } - @Test - void verifyLineColumnNumbersInnerClasses() { + @Test void verifyLineColumnNumbersInnerClasses() { ASTApexFile rootNode = apex.parseResource("InnerClassLocations.cls"); assertNotNull(rootNode); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParsingHelper.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParsingHelper.java index 5761140413c..0e83b3885c8 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParsingHelper.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParsingHelper.java @@ -16,8 +16,7 @@ private ApexParsingHelper(Params p) { super(ApexLanguageModule.getInstance(), ASTApexFile.class, p); } - @Override - protected ApexParsingHelper clone(Params params) { + @Override protected ApexParsingHelper clone(Params params) { return new ApexParsingHelper(params); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java index bfe0af7510b..6a813398e3c 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexQualifiedNameTest.java @@ -20,8 +20,7 @@ */ class ApexQualifiedNameTest extends ApexParserTestBase { - @Test - void testClass() { + @Test void testClass() { ASTUserClass root = (ASTUserClass) parse("public class Foo {}"); ApexQualifiedName qname = root.getQualifiedName(); @@ -31,8 +30,7 @@ void testClass() { } - @Test - void testNestedClass() { + @Test void testNestedClass() { ASTUserClass root = (ASTUserClass) parse("public class Foo { class Bar {}}"); ASTUserClass inner = root.descendants(ASTUserClass.class).firstOrThrow(); @@ -43,8 +41,7 @@ void testNestedClass() { } - @Test - void testSimpleMethod() { + @Test void testSimpleMethod() { ASTUserClass root = (ASTUserClass) parse("public class Foo { String foo() {}}"); ApexQualifiedName qname = root.descendants(ASTMethod.class).firstOrThrow().getQualifiedName(); assertEquals("Foo#foo()", qname.toString()); @@ -53,8 +50,7 @@ void testSimpleMethod() { } - @Test - void testMethodWithArguments() { + @Test void testMethodWithArguments() { ASTUserClass root = (ASTUserClass) parse("public class Foo { String foo(String h, Foo g) {}}"); ApexQualifiedName qname = root.descendants(ASTMethod.class).firstOrThrow().getQualifiedName(); assertEquals("Foo#foo(String, Foo)", qname.toString()); @@ -63,12 +59,11 @@ void testMethodWithArguments() { } - @Test - void testOverLoads() { + @Test void testOverLoads() { ASTUserClass root = (ASTUserClass) parse("public class Foo { " - + "String foo(String h) {} " - + "String foo(int c) {}" - + "String foo(Foo c) {}}"); + + "String foo(String h) {} " + + "String foo(int c) {}" + + "String foo(Foo c) {}}"); for (ASTMethod m1 : root.descendants(ASTMethod.class)) { for (ASTMethod m2 : root.descendants(ASTMethod.class)) { @@ -80,8 +75,7 @@ void testOverLoads() { } - @Test - void testTrigger() { + @Test void testTrigger() { ASTUserTrigger root = (ASTUserTrigger) parse("trigger myAccountTrigger on Account (before insert, before update) {}"); @@ -90,8 +84,7 @@ void testTrigger() { } - @Test - void testUnqualifiedEnum() { + @Test void testUnqualifiedEnum() { ASTUserEnum root = (ASTUserEnum) parse("public enum primaryColor { RED, YELLOW, BLUE }"); ApexQualifiedName enumQName = root.getQualifiedName(); @@ -103,8 +96,7 @@ void testUnqualifiedEnum() { } } - @Test - void testQualifiedEnum() { + @Test void testQualifiedEnum() { ASTUserClass root = (ASTUserClass) parse("public class Outer { public enum Inner { OK } }"); ASTUserEnum enumNode = root.descendants(ASTUserEnum.class).firstOrThrow(); @@ -117,11 +109,10 @@ void testQualifiedEnum() { } } - @Test - void testOfString() { - assertQualifiedName(new String[] { "MyClass" }, true, null, ApexQualifiedName.ofString("MyClass")); - assertQualifiedName(new String[] { "Outer", "MyClass" }, true, null, ApexQualifiedName.ofString("Outer.MyClass")); - assertQualifiedName(new String[] { "Foo" }, false, "foo(String, Foo)", ApexQualifiedName.ofString("Foo#foo(String, Foo)")); + @Test void testOfString() { + assertQualifiedName(new String[]{"MyClass"}, true, null, ApexQualifiedName.ofString("MyClass")); + assertQualifiedName(new String[]{"Outer", "MyClass"}, true, null, ApexQualifiedName.ofString("Outer.MyClass")); + assertQualifiedName(new String[]{"Foo"}, false, "foo(String, Foo)", ApexQualifiedName.ofString("Foo#foo(String, Foo)")); } private static void assertQualifiedName(String[] expectedClasses, boolean isClass, String expectedOperation, ApexQualifiedName name) { diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeDumpTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeDumpTest.java index a09432bf062..89d2390f5db 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeDumpTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexTreeDumpTest.java @@ -17,113 +17,97 @@ class ApexTreeDumpTest extends BaseTreeDumpTest { super(new RelevantAttributePrinter(), ".cls"); } - @Override - public BaseParsingHelper getParser() { + @Override public BaseParsingHelper getParser() { return ApexParsingHelper.DEFAULT; } - @Test - void safeNavigationOperator() { + @Test void safeNavigationOperator() { doTest("SafeNavigationOperator"); } - @Test - void userEnumType() { + @Test void userEnumType() { doTest("UserEnumType"); } - @Test - void innerClassLocations() { + @Test void innerClassLocations() { doTest("InnerClassLocations"); } - @Test - void nullCoalescingOperator() { + @Test void nullCoalescingOperator() { doTest("NullCoalescingOperator"); } /** * @see [apex] TYPEOF in sub-query throws error #4922 */ - @Test - void typeOfSubQuery() { + @Test void typeOfSubQuery() { doTest("TypeofTest"); } /** * @see Fail to parses SOSL with WITH USER_MODE or WITH SYSTEM_MODE #53 */ - @Test - void soslWithUsermode() { + @Test void soslWithUsermode() { doTest("SoslWithUsermode"); } /** * @see [apex] "No adapter exists for type" error message printed to stdout instead of stderr */ - @Test - void switchStatements() { + @Test void switchStatements() { doTest("SwitchStatements"); } - @Test - void trigger() { + @Test void trigger() { doTest("AccountTrigger"); } /** * @see [apex] Parser error when using toLabel in SOSL query */ - @Test - void toLabelInSosl() { + @Test void toLabelInSosl() { doTest("ToLabelInSosl"); } /** * @see [apex] Parser error when using GROUPING in a SOQL query */ - @Test - void groupingInSoql() { + @Test void groupingInSoql() { doTest("GroupingInSoql"); } /** * @see [apex] Seeing false-negatives on PMD 7.3.0 that were not there with 7.2.0 */ - @Test - void triggersWithMethods() { + @Test void triggersWithMethods() { doTest("TriggerWithMethod"); } /** * @see [apex] Parser error when using nested subqueries in SOQL */ - @Test - void nestedSubqueries() { + @Test void nestedSubqueries() { doTest("NestedSubqueries"); } /** * @see [apex] Parse error with time literal in SOQL query */ - @Test - void timeLiteralsInSoql() { + @Test void timeLiteralsInSoql() { doTest("TimeLiteralsInSoql"); } /** * @see [apex] Provide type information for CastExpression */ - @Test - void castExpressionTypeInfo() { + @Test void castExpressionTypeInfo() { doTest("CastExpressionTypeInfo"); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/cpd/ApexCpdLexerTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/cpd/ApexCpdLexerTest.java index 7210cbfed76..d2024bf2dc3 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/cpd/ApexCpdLexerTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/cpd/ApexCpdLexerTest.java @@ -15,31 +15,26 @@ class ApexCpdLexerTest extends CpdTextComparisonTest { super(ApexLanguageModule.getInstance(), ".cls"); } - @Test - void testTokenize() { + @Test void testTokenize() { doTest("Simple"); } /** * Comments are ignored since using ApexLexer. */ - @Test - void testTokenizeWithComments() { + @Test void testTokenizeWithComments() { doTest("comments"); } - @Test - void testTabWidth() { + @Test void testTabWidth() { doTest("tabWidth"); } - @Test - void lexExceptionExpected() { + @Test void lexExceptionExpected() { expectLexException("class Foo { String s = \"not a string literal\"; }"); } - @Test - void caseInsensitiveStringLiterals() { + @Test void caseInsensitiveStringLiterals() { doTest("StringLiterals5053"); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/cpd/ApexCpdTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/cpd/ApexCpdTest.java index c934a1f76a0..7b873e4eae7 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/cpd/ApexCpdTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/cpd/ApexCpdTest.java @@ -23,14 +23,12 @@ class ApexCpdTest { private Path testdir; - @BeforeEach - void setUp() { + @BeforeEach void setUp() { String path = IOUtil.normalizePath("src/test/resources/net/sourceforge/pmd/lang/apex/cpd/issue427"); testdir = Paths.get(path); } - @Test - void testIssue427() throws Exception { + @Test void testIssue427() throws Exception { CPDConfiguration configuration = new CPDConfiguration(); configuration.setMinimumTileSize(10); configuration.setOnlyRecognizeLanguage(ApexLanguageModule.getInstance()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/AllMetricsTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/AllMetricsTest.java index f3d9d791edd..c23745b0bfc 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/AllMetricsTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/AllMetricsTest.java @@ -18,8 +18,7 @@ class AllMetricsTest extends SimpleAggregatorTst { private static final String RULESET = "rulesets/apex/metrics_test.xml"; - @Override - public void setUp() { + @Override public void setUp() { addRule(RULESET, "CycloTest"); addRule(RULESET, "WmcTest"); addRule(RULESET, "CognitiveComplexityTest"); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/CognitiveComplexityTestRule.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/CognitiveComplexityTestRule.java index dcfd7fb034b..1ad80c1737d 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/CognitiveComplexityTestRule.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/CognitiveComplexityTestRule.java @@ -18,13 +18,11 @@ public CognitiveComplexityTestRule() { super(ApexMetrics.COGNITIVE_COMPLEXITY); } - @Override - protected boolean reportOn(Node node) { + @Override protected boolean reportOn(Node node) { return node instanceof ASTMethod; } - @Override - protected String violationMessage(Node node, Integer result) { + @Override protected String violationMessage(Node node, Integer result) { return AllMetricsTest.formatApexMessage(node, result, super.violationMessage(node, result)); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/CycloTestRule.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/CycloTestRule.java index 447ff4dfb3c..ece406ec547 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/CycloTestRule.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/CycloTestRule.java @@ -22,15 +22,12 @@ public CycloTestRule() { } - @Override - protected boolean reportOn(Node node) { + @Override protected boolean reportOn(Node node) { return node instanceof ASTUserClassOrInterface || node instanceof ASTMethod; } - - @Override - protected String violationMessage(Node node, Integer result) { + @Override protected String violationMessage(Node node, Integer result) { return AllMetricsTest.formatApexMessage(node, result, super.violationMessage(node, result)); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/WmcTestRule.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/WmcTestRule.java index ebda680adc5..514190c8599 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/WmcTestRule.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/metrics/internal/WmcTestRule.java @@ -18,8 +18,7 @@ public WmcTestRule() { } - @Override - protected String violationMessage(Node node, Integer result) { + @Override protected String violationMessage(Node node, Integer result) { return AllMetricsTest.formatApexMessage(node, result, super.violationMessage(node, result)); } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java index 4f8a22df34a..487e6eb03ae 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/multifile/ApexMultifileAnalysisTest.java @@ -27,11 +27,9 @@ class ApexMultifileAnalysisTest { - @TempDir - private Path tempFolder; + @TempDir private Path tempFolder; - @Test - void testNoSfdxProjectJsonProducesFailedAnalysis() throws Exception { + @Test void testNoSfdxProjectJsonProducesFailedAnalysis() throws Exception { String log = SystemLambda.tapSystemErr(() -> { ApexMultifileAnalysis analysisInstance = getAnalysisForTempFolder(); @@ -41,8 +39,7 @@ void testNoSfdxProjectJsonProducesFailedAnalysis() throws Exception { assertThat(log, containsStringIgnoringCase("Missing project file")); } - @Test - void testMalformedSfdxProjectJsonProducesFailedAnalysis() throws Exception { + @Test void testMalformedSfdxProjectJsonProducesFailedAnalysis() throws Exception { copyResource("malformedSfdxFile.json", "sfdx-project.json"); String log = SystemLambda.tapSystemErr(() -> { @@ -55,8 +52,7 @@ void testMalformedSfdxProjectJsonProducesFailedAnalysis() throws Exception { containsStringIgnoringCase("Error: line 3 at 4: 'path' is required")); } - @Test - void testWellFormedSfdxProjectJsonProducesFunctionalAnalysis() throws Exception { + @Test void testWellFormedSfdxProjectJsonProducesFunctionalAnalysis() throws Exception { copyResource("correctSfdxFile.json", "sfdx-project.json"); String log = SystemLambda.tapSystemErr(() -> { diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java index 724859e818a..16599005118 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/AbstractApexRuleTest.java @@ -17,23 +17,19 @@ class AbstractApexRuleTest extends ApexParserTestBase { - @Test - void shouldVisitTopLevelClass() { + @Test void shouldVisitTopLevelClass() { run("class Foo { }"); } - @Test - void shouldVisitTopLevelInterface() { + @Test void shouldVisitTopLevelInterface() { run("interface Foo { }"); } - @Test - void shouldVisitTopLevelTrigger() { + @Test void shouldVisitTopLevelTrigger() { run("trigger Foo on Account (before insert, before update) { }"); } - @Test - void shouldVisitTopLevelEnum() { + @Test void shouldVisitTopLevelEnum() { run("enum Foo { }"); } @@ -46,37 +42,31 @@ private void run(String code) { private static class TopLevelRule extends AbstractApexRule { - @Override - public String getMessage() { + @Override public String getMessage() { return "a message"; } - @Override - public Object visit(ASTUserClass node, Object data) { + @Override public Object visit(ASTUserClass node, Object data) { asCtx(data).addViolation(node); return data; } - @Override - public Object visit(ASTUserInterface node, Object data) { + @Override public Object visit(ASTUserInterface node, Object data) { asCtx(data).addViolation(node); return data; } - @Override - public Object visit(ASTUserTrigger node, Object data) { + @Override public Object visit(ASTUserTrigger node, Object data) { asCtx(data).addViolation(node); return data; } - @Override - public Object visit(ASTUserEnum node, Object data) { + @Override public Object visit(ASTUserEnum node, Object data) { asCtx(data).addViolation(node); return data; } - @Override - public Object visit(ASTAnonymousClass node, Object data) { + @Override public Object visit(ASTAnonymousClass node, Object data) { asCtx(data).addViolation(node); return data; } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java index 380aa836e3e..269814d4716 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/ApexXPathRuleTest.java @@ -23,19 +23,17 @@ private XPathRule makeXPath(String expression) { } - @Test - void testFileNameInXpath() { + @Test void testFileNameInXpath() { Report report = apex.executeRule(makeXPath("/UserClass[pmd:fileName() = 'Foo.cls']"), - "class Foo {}", - FileId.fromPathLikeString("src/Foo.cls")); + "class Foo {}", + FileId.fromPathLikeString("src/Foo.cls")); assertSize(report, 1); } - @Test - void testBooleanExpressions() { + @Test void testBooleanExpressions() { Report report = apex.executeRuleOnResource(makeXPath("//BooleanExpression[@Op='&&']"), - "BooleanExpressions.cls"); + "BooleanExpressions.cls"); assertSize(report, 1); } } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java index 63a42bcbfd4..2ef75bbc64c 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethodTest.java @@ -32,11 +32,9 @@ import scala.Option; class UnusedMethodTest { - @TempDir - private Path tempDir; + @TempDir private Path tempDir; - @Test - void findUnusedMethodsWithSfdxProject() throws Exception { + @Test void findUnusedMethodsWithSfdxProject() throws Exception { Path testProjectDir = Paths.get("src/test/resources/net/sourceforge/pmd/lang/apex/rule/design/UnusedMethod/project1"); Report report = runRule(testProjectDir); assertEquals(1, report.getViolations().size()); diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsNestedClassTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsNestedClassTest.java index 05c95696c69..34c4b60d545 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsNestedClassTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/rule/security/ApexSharingViolationsNestedClassTest.java @@ -54,11 +54,9 @@ private enum Operation { /** * The permutations used for class generation. See {@link #generateClass(boolean, Operation, boolean, Operation)} */ - @ParameterizedTest - @MethodSource("data") - void testSharingPermutation(boolean outerSharingDeclared, Operation outerOperation, - boolean innerSharingDeclared, Operation innerOperation, - int expectedViolations, List expectedLineNumbers) { + @ParameterizedTest @MethodSource("data") void testSharingPermutation(boolean outerSharingDeclared, Operation outerOperation, + boolean innerSharingDeclared, Operation innerOperation, + int expectedViolations, List expectedLineNumbers) { String apexClass = generateClass(outerSharingDeclared, outerOperation, innerSharingDeclared, innerOperation); ApexSharingViolationsRule rule = new ApexSharingViolationsRule(); rule.setMessage("a message"); @@ -96,7 +94,7 @@ static Collection data() { expectedLineNumbers.add(outerOperation.requiresSharingDeclaration ? 3 : 2); } data.add(new Object[]{outerSharingDeclared, outerOperation, innerSharingDeclared, innerOperation, - expectedViolations, expectedLineNumbers}); + expectedViolations, expectedLineNumbers}); } } } @@ -125,7 +123,7 @@ static Collection data() { * @return String that represents Apex code */ private static String generateClass(boolean outerSharing, Operation outerOperation, boolean innerSharing, - Operation innerOperation) { + Operation innerOperation) { StringBuilder sb = new StringBuilder(); sb.append("public "); @@ -134,12 +132,12 @@ private static String generateClass(boolean outerSharing, Operation outerOperati } sb.append("class Outer {\n"); switch (outerOperation) { - case NONE: - // Do nothing - break; - default: - sb.append(String.format("\t\tpublic void outer%s(){ %s }\n", outerOperation.name(), outerOperation.codeSnippet)); - break; + case NONE: + // Do nothing + break; + default: + sb.append(String.format("\t\tpublic void outer%s(){ %s }\n", outerOperation.name(), outerOperation.codeSnippet)); + break; } sb.append("\tpublic "); if (innerSharing) { @@ -147,12 +145,12 @@ private static String generateClass(boolean outerSharing, Operation outerOperati } sb.append("class Inner {\n"); switch (innerOperation) { - case NONE: - // DO Nothing - break; - default: - sb.append(String.format("\t\tpublic void inner%s(){ %s }\n", innerOperation.name(), innerOperation.codeSnippet)); - break; + case NONE: + // DO Nothing + break; + default: + sb.append(String.format("\t\tpublic void inner%s(){ %s }\n", innerOperation.name(), innerOperation.codeSnippet)); + break; } sb.append("\t}\n"); // Closes class Inner sb.append("}\n"); // Closes class Outer diff --git a/pmd-cli/pmd-cli-checkstyle-suppressions.xml b/pmd-cli/pmd-cli-checkstyle-suppressions.xml deleted file mode 100644 index 03b468029b1..00000000000 --- a/pmd-cli/pmd-cli-checkstyle-suppressions.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - diff --git a/pmd-cli/pom.xml b/pmd-cli/pom.xml index 8d3dba71f25..034af03ff6c 100644 --- a/pmd-cli/pom.xml +++ b/pmd-cli/pom.xml @@ -13,14 +13,6 @@ - - org.apache.maven.plugins - maven-checkstyle-plugin - - pmd-cli-checkstyle-suppressions.xml - - - com.github.siom79.japicmp japicmp-maven-plugin diff --git a/pmd-cli/src/main/java/me/tongfei/progressbar/PmdProgressBarFriend.java b/pmd-cli/src/main/java/me/tongfei/progressbar/PmdProgressBarFriend.java index ac670a560e5..82445f870c0 100644 --- a/pmd-cli/src/main/java/me/tongfei/progressbar/PmdProgressBarFriend.java +++ b/pmd-cli/src/main/java/me/tongfei/progressbar/PmdProgressBarFriend.java @@ -12,31 +12,29 @@ * 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); + ? new InteractiveConsoleProgressBarConsumer(ps) + : new PostCarriageReturnConsoleProgressBarConsumer(ps); } - + private static class PostCarriageReturnConsoleProgressBarConsumer extends ConsoleProgressBarConsumer { PostCarriageReturnConsoleProgressBarConsumer(PrintStream out) { super(out); } - @Override - public void accept(String str) { + @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() { + + @Override public void clear() { // do nothing (prints an empty line otherwise) } } diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/PmdCli.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/PmdCli.java index a31326f4fc1..a8b648de6b3 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/PmdCli.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/PmdCli.java @@ -10,7 +10,8 @@ public final class PmdCli { - private PmdCli() { } + private PmdCli() { + } // package private for test only without calling System.exit static int mainWithoutExit(String[] args) { diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/AbstractAnalysisPmdSubcommand.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/AbstractAnalysisPmdSubcommand.java index 801f7e5bc3f..d2fa590d957 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/AbstractAnalysisPmdSubcommand.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/AbstractAnalysisPmdSubcommand.java @@ -28,8 +28,7 @@ public abstract class AbstractAnalysisPmdSubcommand extends AbstractPmdSubcommand { - @CommandLine.Spec - protected CommandSpec spec; // injected by PicoCli, needed for validations + @CommandLine.Spec protected CommandSpec spec; // injected by PicoCli, needed for validations protected static final String FILE_COLLECTION_OPTION_HEADER = "Input files specification"; @@ -37,49 +36,41 @@ public abstract class AbstractAnalysisPmdSubcommand { @Option(names = {"--encoding", "-e"}, description = "Specifies the character set encoding of the source code files", - defaultValue = "UTF-8") - private Charset encoding; + defaultValue = "UTF-8") private Charset encoding; @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.") - private Path fileListPath; + + "One of --dir, --file-list or --uri must be provided.") private Path fileListPath; @Option(names = {"--uri", "-u"}, description = "Database URI for sources. " - + "One of --dir, --file-list or --uri must be provided.") - private URI uri; + + "One of --dir, --file-list or --uri must be provided.") private URI uri; boolean usesDeprecatedIgnoreListOption = false; @Option(names = "--ignore-list", description = "(DEPRECATED: use --exclude-file-list) 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.") - @Deprecated - protected void setExcludeFileList(Path path) { + + "This option can be combined with --dir, --file-list and --uri.") @Deprecated protected void setExcludeFileList(Path path) { this.excludeFileListPath = path; this.usesDeprecatedIgnoreListOption = true; } - @Option(names = "--exclude", arity = "1..*", description = "Files to be excluded from the analysis") - private List excludeFiles = new ArrayList<>(); + @Option(names = "--exclude", arity = "1..*", description = "Files to be excluded from the analysis") private List excludeFiles = new ArrayList<>(); @Option(names = "--exclude-file-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.") - private Path excludeFileListPath; + + "This option can be combined with --dir, --file-list and --uri.") private Path excludeFileListPath; @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 = ",") - private List relativizeRootPaths; + + "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 = ",") private List relativizeRootPaths; // see the setters #setInputPaths and setPositionalInputPaths for @Option and @Parameters annotations // Note: can't use annotations on the fields here, as otherwise the complete list would be replaced @@ -88,12 +79,11 @@ protected void setExcludeFileList(Path path) { @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 void setInputPaths(final List inputPaths) { + + "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 void setInputPaths(final List inputPaths) { if (this.inputPaths == null) { this.inputPaths = new LinkedHashSet<>(); // linked hashSet in order to maintain order } @@ -101,13 +91,11 @@ protected void setInputPaths(final List inputPaths) { this.inputPaths.addAll(inputPaths); } - @Option(names = "--non-recursive", description = "Don't scan subdirectiories when using the --d (-dir) option.") - private boolean nonRecursive; + @Option(names = "--non-recursive", description = "Don't scan subdirectiories when using the --d (-dir) option.") private boolean nonRecursive; @Parameters(arity = "*", description = "Path to a source file, or directory containing source files to analyze. " - + "Equivalent to using --dir.") - protected void setPositionalInputPaths(final List inputPaths) { + + "Equivalent to using --dir.") protected void setPositionalInputPaths(final List inputPaths) { this.setInputPaths(inputPaths); } @@ -138,7 +126,7 @@ protected void validate(CommandSpec spec) throws ParameterException { 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)"); + + "database URI (--uri or -u), or file list path (--file-list)"); } if (relativizeRootPaths != null) { @@ -156,22 +144,18 @@ protected void validate(CommandSpec spec) throws ParameterException { @Option(names = "--no-fail-on-violation", description = "By default PMD exits with status 4 if violations or duplications are found. " + "Disable this option with '--no-fail-on-violation' to exit with 0 instead. In any case a report with the found violations or duplications will be written.", - defaultValue = "true", negatable = true) - private boolean failOnViolation; + defaultValue = "true", negatable = true) private boolean failOnViolation; @Option(names = "--no-fail-on-error", description = "By default PMD exits with status 5 if recoverable errors occurred (whether or not there are violations or duplications). " + "Disable this option with '--no-fail-on-error' to exit with 0 instead. In any case, a report with the found violations or duplications will be written.", - defaultValue = "true", negatable = true) - private boolean failOnError; + defaultValue = "true", negatable = true) private boolean failOnError; - @Option(names = { "--report-file", "-r" }, + @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.") - private Path reportFile; - + + "The file is created if it does not exist. " + + "If this option is not specified, the report is rendered to standard output.") private Path reportFile; protected abstract C toConfiguration(); @@ -179,18 +163,16 @@ protected void validate(CommandSpec spec) throws ParameterException { protected abstract CliExitCode doExecute(C conf); - @Override - protected CliExitCode execute() { + @Override protected CliExitCode execute() { final C configuration = toConfiguration(); return PmdRootLogger.executeInLoggingContext(configuration, - debug, - this::doExecute); + debug, + this::doExecute); } protected abstract FileCollectionOptions getFileCollectionOptions(); - @Override - protected void validate() throws ParameterException { + @Override protected void validate() throws ParameterException { super.validate(); getFileCollectionOptions().validate(spec); } diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/AbstractPmdSubcommand.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/AbstractPmdSubcommand.java index bd55b1cc140..37246b9ea4b 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/AbstractPmdSubcommand.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/AbstractPmdSubcommand.java @@ -15,17 +15,13 @@ public abstract class AbstractPmdSubcommand implements Callable { - @Spec - protected CommandSpec spec; // injected by PicoCli, needed for validations + @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 = {"-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; + @Option(names = {"--debug", "--verbose", "-D", "-v"}, description = "Debug mode.") protected boolean debug; - @Override - public final Integer call() throws Exception { + @Override public final Integer call() throws Exception { validate(); return execute().getExitCode(); } diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java index 7f22bb57174..957ceb484df 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdCommand.java @@ -25,73 +25,55 @@ import picocli.CommandLine.ParameterException; @Command(name = "cpd", showDefaultValues = true, - description = "Copy/Paste Detector - find duplicate code") + description = "Copy/Paste Detector - find duplicate code") public class CpdCommand extends AbstractAnalysisPmdSubcommand { - @CommandLine.ArgGroup(heading = FILE_COLLECTION_OPTION_HEADER, exclusive = false) - FileCollectionOptions files = new FileCollectionOptions<>(); + @CommandLine.ArgGroup(heading = FILE_COLLECTION_OPTION_HEADER, exclusive = false) FileCollectionOptions files = new FileCollectionOptions<>(); - @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 = {"--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; + 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; + description = "Ignore multiple copies of files of the same name and length in comparison.") private boolean skipDuplicates; - - - @Option(names = { "--format", "-f" }, + @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; + + "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; + 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; + 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-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-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-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 = "--ignore-sequences", description = "Ignore sequences of identifiers and literals") private boolean ignoreIdentifierAndLiteralSequences; /** * @deprecated Since 7.3.0. Use --[no-]fail-on-error instead. */ @Option(names = "--skip-lexical-errors", - description = "Skip files which can't be tokenized due to invalid characters, instead of aborting with an error. Deprecated - use --[no-]fail-on-error instead.") - @Deprecated - private boolean skipLexicalErrors; + description = "Skip files which can't be tokenized due to invalid characters, instead of aborting with an error. Deprecated - use --[no-]fail-on-error instead.") @Deprecated 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; + 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 = CpdLanguagePropertiesDefaults.DEFAULT_SKIP_BLOCKS_PATTERN) - private String skipBlocksPattern; + defaultValue = CpdLanguagePropertiesDefaults.DEFAULT_SKIP_BLOCKS_PATTERN) private String skipBlocksPattern; - @Override - protected FileCollectionOptions getFileCollectionOptions() { + @Override protected FileCollectionOptions getFileCollectionOptions() { return files; } @@ -102,8 +84,7 @@ protected FileCollectionOptions getFileCollectionOptions() { * * @throws ParameterException if the parameters are inconsistent or incomplete */ - @Override - protected CPDConfiguration toConfiguration() { + @Override protected CPDConfiguration toConfiguration() { final CPDConfiguration configuration = new CPDConfiguration(); setCommonConfigProperties(configuration); @@ -128,8 +109,7 @@ protected CPDConfiguration toConfiguration() { return configuration; } - @Override - protected @NonNull CliExitCode doExecute(CPDConfiguration configuration) { + @Override protected @NonNull CliExitCode doExecute(CPDConfiguration configuration) { try (CpdAnalysis cpd = CpdAnalysis.create(configuration)) { MutableBoolean hasViolations = new MutableBoolean(); @@ -157,8 +137,7 @@ protected CPDConfiguration toConfiguration() { */ private static final class CpdSupportedReportFormatsCandidates implements Iterable { - @Override - public Iterator iterator() { + @Override public Iterator iterator() { return CPDConfiguration.getRenderers().stream().sorted().iterator(); } } diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdGuiCommand.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdGuiCommand.java index 6310b58e910..966055b9b9c 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdGuiCommand.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/CpdGuiCommand.java @@ -9,11 +9,10 @@ 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") + 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() { + @Override public void run() { new GUI(); // wait for the process to be killed by the GUI diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PMDVersionProvider.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PMDVersionProvider.java index d35e80b4976..52379248d33 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PMDVersionProvider.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PMDVersionProvider.java @@ -13,8 +13,7 @@ import picocli.CommandLine; class PMDVersionProvider implements CommandLine.IVersionProvider { - @Override - public String[] getVersion() throws Exception { + @Override public String[] getVersion() throws Exception { List lines = new ArrayList<>(PmdBanner.loadBanner()); lines.add(PMDVersion.getFullVersionName()); lines.add("Java version: " + System.getProperty("java.version") + ", vendor: " + System.getProperty("java.vendor") + ", runtime: " + System.getProperty("java.home")); diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdCommand.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdCommand.java index 6f55c1fc928..de908c6904b 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdCommand.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/PmdCommand.java @@ -48,7 +48,7 @@ import picocli.CommandLine.ParameterException; @Command(name = "check", showDefaultValues = true, - description = "The PMD standard source code analyzer") + description = "The PMD standard source code analyzer") public class PmdCommand extends AbstractAnalysisPmdSubcommand { private static final Logger LOG = LoggerFactory.getLogger(PmdCommand.class); @@ -56,30 +56,30 @@ public class PmdCommand extends AbstractAnalysisPmdSubcommand 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); + .append(property.description()).append(lineSeparator); final Object deflt = property.defaultValue(); if (deflt != null && !"".equals(deflt)) { reportPropertiesHelp.append(" Default: ").append(deflt) - .append(lineSeparator); + .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 rulesets; - + private String format; @@ -108,42 +108,36 @@ public class PmdCommand extends AbstractAnalysisPmdSubcommand private boolean showProgressBar; - @CommandLine.ArgGroup(heading = FILE_COLLECTION_OPTION_HEADER, exclusive = false) - FileCollectionOptions files = new FileCollectionOptions<>(); + @CommandLine.ArgGroup(heading = FILE_COLLECTION_OPTION_HEADER, exclusive = false) FileCollectionOptions files = new FileCollectionOptions<>(); - @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 rulesets) { + @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 rulesets) { this.rulesets = rulesets; } - @Option(names = { "--format", "-f" }, + @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) { + 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) { + @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 = "--show-suppressed", description = "Report should show suppressed rule violations if supported by the report format.") - public void setShowSuppressed(final boolean showSuppressed) { + @Option(names = "--show-suppressed", description = "Report should show suppressed rule violations if supported by the report format.") 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) { + defaultValue = "NOPMD") public void setSuppressMarker(final String suppressMarker) { this.suppressMarker = suppressMarker; } @@ -151,42 +145,38 @@ public void setSuppressMarker(final String suppressMarker) { 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) { + 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) { + @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 = "--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) { + completionCandidates = PmdLanguageVersionTypeSupport.class, converter = PmdLanguageVersionTypeSupport.class) public void setLanguageVersion(final List 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("', '", "'", "'"))); - } - }); + .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) { + + "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; } @@ -195,8 +185,7 @@ public void setForceLanguage(final Language forceLanguage) { + "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) { + + "can be specified.") public void setAuxClasspath(final String auxClasspath) { this.auxClasspath = auxClasspath; } @@ -204,39 +193,34 @@ public void setAuxClasspath(final String auxClasspath) { 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) { + + "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) { + @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 = - "Set the number of threads used by PMD. This can be an integer, or a float (or int) followed by the letter `C`, eg `0.5C` or `1C`. " - + "In the latter case, the float will be multiplied by the number of cores of the host machine, and rounded down to an integer. " - + "If the specified number of threads is zero, then PMD will use the main thread for everything. If it is `n` > 0, " - + "PMD will spawn `n` separate analysis threads besides the main thread.", - defaultValue = "1C", converter = NumThreadsConverter.class) - public void setThreads(final int threads) { + "Set the number of threads used by PMD. This can be an integer, or a float (or int) followed by the letter `C`, eg `0.5C` or `1C`. " + + "In the latter case, the float will be multiplied by the number of cores of the host machine, and rounded down to an integer. " + + "If the specified number of threads is zero, then PMD will use the main thread for everything. If it is `n` > 0, " + + "PMD will spawn `n` separate analysis threads besides the main thread.", + defaultValue = "1C", converter = NumThreadsConverter.class) 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) { + description = "Enables / disables progress bar indicator of live analysis progress.") public void setShowProgressBar(final boolean showProgressBar) { this.showProgressBar = showProgressBar; } - @Override - protected FileCollectionOptions getFileCollectionOptions() { + @Override protected FileCollectionOptions getFileCollectionOptions() { return files; } @@ -247,8 +231,7 @@ protected FileCollectionOptions getFileCollectionOptions() { * * @throws ParameterException if the parameters are inconsistent or incomplete */ - @Override - protected PMDConfiguration toConfiguration() { + @Override protected PMDConfiguration toConfiguration() { final PMDConfiguration configuration = new PMDConfiguration(); setCommonConfigProperties(configuration); @@ -265,7 +248,7 @@ protected PMDConfiguration toConfiguration() { 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() @@ -284,9 +267,7 @@ protected PMDConfiguration toConfiguration() { return configuration; } - @Override - @NonNull - protected CliExitCode doExecute(PMDConfiguration configuration) { + @Override @NonNull protected CliExitCode doExecute(PMDConfiguration configuration) { if (benchmark) { TimeTracker.startGlobalTracking(); } @@ -357,8 +338,7 @@ private void finishBenchmarker(final PmdReporter pmdReporter) { try { // No try-with-resources, do not want to close STDERR - @SuppressWarnings("PMD.CloseResource") - final Writer writer = new OutputStreamWriter(System.err); + @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); @@ -371,8 +351,7 @@ private void finishBenchmarker(final PmdReporter pmdReporter) { */ private static final class PmdSupportedReportFormatsCandidates implements Iterable { - @Override - public Iterator iterator() { + @Override public Iterator iterator() { return RendererFactory.supportedRenderers().iterator(); } } @@ -384,13 +363,12 @@ public Iterator iterator() { */ private static final class PmdReportPropertiesCandidates implements Iterable { - @Override - public Iterator iterator() { + @Override public Iterator iterator() { final List 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()); } diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/TreeExportCommand.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/TreeExportCommand.java index 0655739e5d5..b0b8764c3d2 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/TreeExportCommand.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/internal/TreeExportCommand.java @@ -38,50 +38,44 @@ 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); + .append(property.description()).append(lineSeparator); final Object deflt = property.defaultValue(); if (deflt != null && !"".equals(deflt)) { reportPropertiesHelp.append(" Default: ").append(StringUtil.escapeWhitespace(deflt)) - .append(lineSeparator); + .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", + + @Mixin private EncodingMixin encoding; + + @Option(names = {"--format", "-f"}, defaultValue = "xml", description = "The output format.%nValid values: ${COMPLETION-CANDIDATES}", - completionCandidates = TreeRenderersCandidates.class) - private String format; + completionCandidates = TreeRenderersCandidates.class) private String format; - @Option(names = { "--language", "-l" }, defaultValue = "java", + @Option(names = {"--language", "-l"}, defaultValue = "java", description = "The source code language.%nValid values: ${COMPLETION-CANDIDATES}", - completionCandidates = PmdLanguageTypeSupport.class, converter = PmdLanguageTypeSupport.class) - private Language language; + 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(); + completionCandidates = TreeExportReportPropertiesCandidates.class) private Properties properties = new Properties(); - @Option(names = "--file", description = "The file to parse and dump.") - private Path file; + @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; + @Option(names = {"--read-stdin", "-i"}, description = "Read source from standard input.") private boolean readStdin; public TreeExportConfiguration toConfiguration() { final TreeExportConfiguration configuration = new TreeExportConfiguration(); @@ -91,21 +85,19 @@ public TreeExportConfiguration toConfiguration() { configuration.setProperties(properties); configuration.setReadStdin(readStdin); configuration.setSourceEncoding(encoding.getEncoding()); - + return configuration; } - - @Override - protected void validate() throws ParameterException { + + @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() { + + @Override protected CliExitCode execute() { final TreeExporter exporter = new TreeExporter(toConfiguration()); try { exporter.export(); @@ -113,7 +105,7 @@ protected CliExitCode execute() { } catch (final IOException e) { final SimpleMessageReporter reporter = new SimpleMessageReporter(LoggerFactory.getLogger(TreeExportCommand.class)); reporter.error(e, LogMessages.errorDetectedMessage(1, "ast-dump")); - + return CliExitCode.ERROR; } } @@ -123,12 +115,11 @@ protected CliExitCode execute() { */ private static final class TreeRenderersCandidates implements Iterable { - @Override - public Iterator iterator() { + @Override public Iterator iterator() { return TreeRenderers.registeredRenderers().stream().map(TreeRendererDescriptor::id).iterator(); } } - + /** * Provider of candidates for valid report properties. * @@ -136,12 +127,11 @@ public Iterator iterator() { */ private static final class TreeExportReportPropertiesCandidates implements Iterable { - @Override - public Iterator iterator() { + @Override public Iterator iterator() { final List propertyNames = new ArrayList<>(); for (final TreeRendererDescriptor renderer : TreeRenderers.registeredRenderers()) { final PropertySource propertyBundle = renderer.newPropertyBundle(); - + for (final PropertyDescriptor property : propertyBundle.getPropertyDescriptors()) { propertyNames.add(property.name()); } diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/mixins/internal/EncodingMixin.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/mixins/internal/EncodingMixin.java index e6086bb46f7..424d0013d02 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/mixins/internal/EncodingMixin.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/mixins/internal/EncodingMixin.java @@ -13,9 +13,8 @@ */ public class EncodingMixin { - @Option(names = { "--encoding", "-e" }, description = "Specifies the character set encoding of the source code files", - defaultValue = "UTF-8") - private Charset encoding; + @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; diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/LanguageTypeSupport.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/LanguageTypeSupport.java index 0630b125f64..b9100354bc4 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/LanguageTypeSupport.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/LanguageTypeSupport.java @@ -23,8 +23,7 @@ public LanguageTypeSupport(LanguageRegistry languageRegistry) { this.languageRegistry = languageRegistry; } - @Override - public Language convert(final String value) { + @Override public Language convert(final String value) { Language lang = languageRegistry.getLanguageById(value); if (lang == null) { throw new TypeConversionException("Unknown language: " + value); @@ -32,8 +31,7 @@ public Language convert(final String value) { return lang; } - @Override - public Iterator iterator() { + @Override public Iterator iterator() { return languageRegistry.getLanguages().stream().map(Language::getId).iterator(); } } diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/NumThreadsConverter.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/NumThreadsConverter.java index e0f4e90a46d..6e63a069049 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/NumThreadsConverter.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/NumThreadsConverter.java @@ -11,8 +11,7 @@ * Parses a number of threads, either an integer or a float followed by the letter C. */ public class NumThreadsConverter implements ITypeConverter { - @Override - public Integer convert(String s) { + @Override public Integer convert(String s) { boolean isCoreMultiplied = s.endsWith("C"); if (isCoreMultiplied) { s = s.substring(0, s.length() - 1); // remove the C diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/PmdLanguageVersionTypeSupport.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/PmdLanguageVersionTypeSupport.java index fdc5f51efac..42ebd3b970b 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/PmdLanguageVersionTypeSupport.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/PmdLanguageVersionTypeSupport.java @@ -20,8 +20,7 @@ */ public class PmdLanguageVersionTypeSupport implements ITypeConverter, Iterable { - @Override - public Iterator iterator() { + @Override public Iterator 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() @@ -29,13 +28,12 @@ public Iterator iterator() { .collect(Collectors.toCollection(TreeSet::new)).iterator(); } - @Override - public LanguageVersion convert(final String value) throws Exception { + @Override public LanguageVersion convert(final String value) throws Exception { return LanguageRegistry.PMD.getLanguages().stream() - .filter(l -> value.startsWith(l.getId() + "-")) - .map(l -> l.getVersion(value.substring(l.getId().length() + 1))) - .filter(Objects::nonNull) - .findFirst() - .orElseThrow(() -> new TypeConversionException("Unknown language version: " + value)); + .filter(l -> value.startsWith(l.getId() + "-")) + .map(l -> l.getVersion(value.substring(l.getId().length() + 1))) + .filter(Objects::nonNull) + .findFirst() + .orElseThrow(() -> new TypeConversionException("Unknown language version: " + value)); } } diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java index 67c3e413377..82cd26b1b6d 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/commands/typesupport/internal/RulePriorityTypeSupport.java @@ -14,8 +14,7 @@ import picocli.CommandLine.TypeConversionException; public class RulePriorityTypeSupport implements ITypeConverter, Iterable { - @Override - public RulePriority convert(String value) { + @Override public RulePriority convert(String value) { for (RulePriority rulePriority : RulePriority.values()) { String descriptiveName = rulePriority.getName(); String name = rulePriority.name(); @@ -27,8 +26,7 @@ public RulePriority convert(String value) { throw new TypeConversionException("Invalid priority: " + value); } - @Override - public Iterator iterator() { + @Override public Iterator iterator() { List completionValues = new ArrayList<>(); for (RulePriority rulePriority : RulePriority.values()) { completionValues.add(rulePriority.name()); diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/CliExitCode.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/CliExitCode.java index 909f942c6c3..69e8835cad8 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/CliExitCode.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/CliExitCode.java @@ -50,13 +50,13 @@ public int getExitCode() { 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; - case 5: return RECOVERED_ERRORS_OR_VIOLATIONS; - default: - throw new IllegalArgumentException("Not a known exit code: " + i); + case 0: return OK; + case 1: return ERROR; + case 2: return USAGE_ERROR; + case 4: return VIOLATIONS_FOUND; + case 5: return RECOVERED_ERRORS_OR_VIOLATIONS; + default: + throw new IllegalArgumentException("Not a known exit code: " + i); } } } diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/PmdBanner.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/PmdBanner.java index 9807d274d2a..cdc8050caf6 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/PmdBanner.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/PmdBanner.java @@ -19,7 +19,8 @@ public final class PmdBanner { private static final String BANNER_RESOURCE = "/net/sourceforge/pmd/cli/internal/banner.txt"; - private PmdBanner() {} + private PmdBanner() { + } public static List loadBanner() { List lines = new ArrayList<>(); diff --git a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/ProgressBarListener.java b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/ProgressBarListener.java index 39debca2d5b..be4c3627c22 100644 --- a/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/ProgressBarListener.java +++ b/pmd-cli/src/main/java/net/sourceforge/pmd/cli/internal/ProgressBarListener.java @@ -27,11 +27,9 @@ public final class ProgressBarListener implements GlobalAnalysisListener { private final AtomicInteger numErrors = new AtomicInteger(0); private final AtomicInteger numViolations = new AtomicInteger(0); - @Override - public ListenerInitializer initializer() { + @Override public ListenerInitializer initializer() { return new ListenerInitializer() { - @Override - public void setNumberOfFilesToAnalyze(int totalFiles) { + @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") @@ -59,26 +57,21 @@ private String extraMessage() { return String.format("Violations:%d, Errors:%d", numViolations.get(), numErrors.get()); } - @Override - public FileAnalysisListener startFileAnalysis(TextFile file) { + @Override public FileAnalysisListener startFileAnalysis(TextFile file) { return new FileAnalysisListener() { - @Override - public void onRuleViolation(RuleViolation violation) { + @Override public void onRuleViolation(RuleViolation violation) { ProgressBarListener.this.numViolations.addAndGet(1); } - @Override - public void onSuppressedRuleViolation(Report.SuppressedViolation violation) { + @Override public void onSuppressedRuleViolation(Report.SuppressedViolation violation) { /*Not handled*/ } - @Override - public void onError(Report.ProcessingError error) { + @Override public void onError(Report.ProcessingError error) { ProgressBarListener.this.numErrors.addAndGet(1); } - @Override - public void close() { + @Override public void close() { // Refresh progress bar on file analysis end (or file was in cache) progressBar.step(); refreshProgressBar(); @@ -86,8 +79,7 @@ public void close() { }; } - @Override - public void close() throws Exception { + @Override public void close() throws Exception { progressBar.close(); } } diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/BaseCliTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/BaseCliTest.java index c8deed0a7a3..035182c36f0 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/BaseCliTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/BaseCliTest.java @@ -31,13 +31,11 @@ abstract class BaseCliTest { - @BeforeAll - static void disablePicocliAnsi() { + @BeforeAll static void disablePicocliAnsi() { System.setProperty("picocli.ansi", "false"); } - @AfterAll - static void resetPicocliAnsi() { + @AfterAll static void resetPicocliAnsi() { System.clearProperty("picocli.ansi"); } @@ -63,10 +61,10 @@ protected CliExecutionResult runCli(CliExitCode expectedExitCode, String... args System.setErr(new PrintStream(err)); // restoring system properties: --debug might change logging properties SystemLambda.restoreSystemProperties( - () -> { - int actualExitCode = PmdCli.mainWithoutExit(argList.toArray(new String[0])); - exitCode.set(CliExitCode.fromInt(actualExitCode)); - } + () -> { + int actualExitCode = PmdCli.mainWithoutExit(argList.toArray(new String[0])); + exitCode.set(CliExitCode.fromInt(actualExitCode)); + } ); } finally { System.setOut(formerOut); @@ -74,7 +72,7 @@ protected CliExecutionResult runCli(CliExitCode expectedExitCode, String... args } return new CliExecutionResult( - out, err, exitCode.get() + out, err, exitCode.get() ).verify(e -> assertEquals(expectedExitCode, e.exitCode)); } @@ -85,13 +83,11 @@ public static Matcher containsPattern(final String regex) { return new BaseMatcher() { final Pattern pattern = Pattern.compile(regex); - @Override - public void describeTo(Description description) { + @Override public void describeTo(Description description) { description.appendText("a string containing the pattern '" + this.pattern + "'"); } - @Override - public boolean matches(Object o) { + @Override public boolean matches(Object o) { return o instanceof String && pattern.matcher((String) o).find(); } }; @@ -100,15 +96,13 @@ public boolean matches(Object o) { public static Matcher containsStringNTimes(final int times, final String substring) { return new BaseMatcher() { - @Override - public void describeTo(Description description) { + @Override public void describeTo(Description description) { description.appendText("a string containing " + times + " times the substring '" + substring + "'"); } - @Override - public boolean matches(Object o) { + @Override public boolean matches(Object o) { return o instanceof String - && StringUtils.countMatches((String) o, substring) == times; + && StringUtils.countMatches((String) o, substring) == times; } }; } @@ -121,8 +115,8 @@ static class CliExecutionResult { private final CliExitCode exitCode; CliExecutionResult(ByteArrayOutputStream out, - ByteArrayOutputStream err, - CliExitCode exitCode) { + ByteArrayOutputStream err, + CliExitCode exitCode) { this.out = out; this.err = err; this.exitCode = exitCode; diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/CpdCliTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/CpdCliTest.java index d9b0975fab9..8f7c5d754df 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/CpdCliTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/CpdCliTest.java @@ -59,23 +59,19 @@ class CpdCliTest extends BaseCliTest { NUMBER_OF_TOKENS = Collections.unmodifiableMap(map); } - @TempDir - private Path tempDir; + @TempDir private Path tempDir; - @Override - protected List cliStandardArgs() { + @Override protected List cliStandardArgs() { return listOf("cpd"); } - @AfterAll - static void resetLogging() { + @AfterAll static void resetLogging() { // reset logging in case "--debug" changed the logging properties // See also Slf4jSimpleConfigurationForAnt Slf4jSimpleConfiguration.reconfigureDefaultLogLevel(null); } - @Test - void testEmptyResultRendering() throws Exception { + @Test void testEmptyResultRendering() throws Exception { final String expectedFilesXml = getExpectedFileEntriesXml(NUMBER_OF_TOKENS.keySet()); runCliSuccessfully("--minimum-tokens", "340", "--language", "java", "--dir", SRC_DIR, "--format", "xml") .verify(result -> result.checkStdOut(containsPattern(CPD_REPORT_HEADER_PATTERN @@ -101,106 +97,93 @@ private String getExpectedFileEntriesXml(final Collection filenames) { return expectedFilesXmlBuilder.toString(); } - @Test - void debugLogging() throws Exception { + @Test void debugLogging() throws Exception { CliExecutionResult result = runCliSuccessfully("--debug", "--minimum-tokens", "340", "--dir", SRC_DIR); result.checkStdErr(containsString("[DEBUG] Log level is at TRACE")); } - @Test - void debugLoggingShouldMentionLanguage() throws Exception { + @Test void debugLoggingShouldMentionLanguage() throws Exception { final CliExecutionResult result = runCli(VIOLATIONS_FOUND, "--minimum-tokens", "34", "--dir", SRC_DIR, "--debug"); result.checkStdErr(containsString("Created new FileCollector with LanguageVersionDiscoverer(LanguageRegistry(java))")); } - @Test - void defaultLogging() throws Exception { + @Test void defaultLogging() throws Exception { CliExecutionResult result = runCliSuccessfully("--minimum-tokens", "340", "--dir", SRC_DIR); result.checkStdErr(not(containsString("[DEBUG] Log level is at TRACE"))); } - @Test - void testMissingMinimumTokens() throws Exception { + @Test void testMissingMinimumTokens() throws Exception { final CliExecutionResult result = runCli(CliExitCode.USAGE_ERROR); result.checkStdErr(containsString("Missing required option: '--minimum-tokens='")); } - @Test - void testMissingSource() throws Exception { + @Test void testMissingSource() throws Exception { final CliExecutionResult result = runCli(CliExitCode.USAGE_ERROR, "--minimum-tokens", "340"); result.checkStdErr(containsString("Please provide a parameter for source root directory")); } - @Test - void testWrongCliOptionsDoPrintUsage() throws Exception { + @Test void testWrongCliOptionsDoPrintUsage() throws Exception { final CliExecutionResult result = runCli(CliExitCode.USAGE_ERROR, "--invalid", "--minimum-tokens", "340", "-d", SRC_DIR); result.checkStdErr(containsString("Unknown option: '--invalid'")); result.checkStdErr(containsString("Usage: pmd cpd")); } - @Test - void testWrongCliOptionResultsInErrorLoggingAfterDir() throws Exception { + @Test void testWrongCliOptionResultsInErrorLoggingAfterDir() throws Exception { // --ignore-identifiers doesn't take an argument anymore - it is interpreted as a file for inputPaths final CliExecutionResult result = runCli(RECOVERED_ERRORS_OR_VIOLATIONS, "--minimum-tokens", "34", "--dir", SRC_DIR, "--ignore-identifiers", "false"); result.checkStdErr(containsString("No such file false")); } - @Test - void testWrongCliOptionResultsInErrorLoggingBeforeDir() throws Exception { + @Test void testWrongCliOptionResultsInErrorLoggingBeforeDir() throws Exception { // --ignore-identifiers doesn't take an argument anymore - it is interpreted as a file for inputPaths final CliExecutionResult result = runCli(RECOVERED_ERRORS_OR_VIOLATIONS, "--minimum-tokens", "34", "--ignore-identifiers", "false", "--dir", SRC_DIR); result.checkStdErr(containsString("No such file false")); } - @Test - void testFindJavaDuplication() throws Exception { + @Test void testFindJavaDuplication() throws Exception { runCli(VIOLATIONS_FOUND, "--minimum-tokens", "7", "--dir", SRC_DIR) - .verify(result -> result.checkStdOut(containsString( - "Found a 14 line (86 tokens) duplication in the following files:" - ))); + .verify(result -> result.checkStdOut(containsString( + "Found a 14 line (86 tokens) duplication in the following files:" + ))); } /** * Test ignore identifiers argument. */ - @Test - void testIgnoreIdentifiers() throws Exception { + @Test void testIgnoreIdentifiers() throws Exception { runCli(VIOLATIONS_FOUND, "--minimum-tokens", "34", "--dir", SRC_DIR, "--ignore-identifiers", "--debug") - .verify(result -> result.checkStdOut(containsString( - "Found a 14 line (89 tokens) duplication" - ))); + .verify(result -> result.checkStdOut(containsString( + "Found a 14 line (89 tokens) duplication" + ))); } - @Test - void testNoFailOnViolation() throws Exception { + @Test void testNoFailOnViolation() throws Exception { runCli(CliExitCode.OK, "--minimum-tokens", "7", "--dir", SRC_DIR, "--no-fail-on-violation") - .verify(result -> result.checkStdOut(containsString( - "Found a 14 line (86 tokens) duplication in the following files:" - ))); + .verify(result -> result.checkStdOut(containsString( + "Found a 14 line (86 tokens) duplication in the following files:" + ))); } - @Test - void testExcludeFiles() throws Exception { + @Test void testExcludeFiles() throws Exception { runCliSuccessfully("--minimum-tokens", "7", "--dir", SRC_DIR, - "--exclude", SRC_DIR + "/dup2.java", - SRC_DIR + "/dup1.java") - .verify(result -> result.checkStdOut(emptyString())); + "--exclude", SRC_DIR + "/dup2.java", + SRC_DIR + "/dup1.java") + .verify(result -> result.checkStdOut(emptyString())); } - @Test - void testNoDuplicatesResultRendering() throws Exception { + @Test void testNoDuplicatesResultRendering() throws Exception { String expectedReportPattern = CPD_REPORT_HEADER_PATTERN - + "\\Q" // quote start - + " \n" - + " \n" - + " \n" - + " \n" - + "\n" - + "\\E"; // quote end + + "\\Q" // quote start + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + "\\E"; // quote end runCliSuccessfully("--minimum-tokens", "340", "--language", "java", "--dir", SRC_DIR, "--format", "xml") .verify(result -> result.checkStdOut(containsPattern(expectedReportPattern))); @@ -209,28 +192,26 @@ void testNoDuplicatesResultRendering() throws Exception { /** * #1144 CPD encoding argument has no effect */ - @Test - void testEncodingOption() throws Exception { + @Test void testEncodingOption() throws Exception { SystemLambda.restoreSystemProperties(() -> { // set the default encoding under Windows System.setProperty("file.encoding", "Cp1252"); runCli(VIOLATIONS_FOUND, "--minimum-tokens", "34", - "-d", BASE_RES_PATH + "encodingTest/", - "--ignore-identifiers", "--format", "xml", - // request UTF-8 for CPD - "--encoding", "UTF-8", - "--debug") - .verify(r -> { - r.checkStdOut(startsWith("")); - r.checkStdOut(containsPattern("System\\.out\\.println\\([ij] \\+ \"ä\"\\);")); - }); + "-d", BASE_RES_PATH + "encodingTest/", + "--ignore-identifiers", "--format", "xml", + // request UTF-8 for CPD + "--encoding", "UTF-8", + "--debug") + .verify(r -> { + r.checkStdOut(startsWith("")); + r.checkStdOut(containsPattern("System\\.out\\.println\\([ij] \\+ \"ä\"\\);")); + }); }); } - @Test - void testFileList() throws Exception { + @Test void testFileList() throws Exception { runCli(VIOLATIONS_FOUND, "--minimum-tokens", "10", "--file-list", BASE_RES_PATH + "fileList.txt", @@ -241,8 +222,7 @@ void testFileList() throws Exception { }); } - @Test - void testExcludeFileList() throws Exception { + @Test void testExcludeFileList() throws Exception { runCli(OK, "--minimum-tokens", "10", "--file-list", BASE_RES_PATH + "fileList.txt", @@ -258,8 +238,7 @@ void testExcludeFileList() throws Exception { }); } - @Test - void testExcludeFile() throws Exception { + @Test void testExcludeFile() throws Exception { runCli(OK, "--minimum-tokens", "10", "--file-list", BASE_RES_PATH + "fileList.txt", @@ -276,8 +255,7 @@ void testExcludeFile() throws Exception { }); } - @Test - void testExcludeFileListDeprecated() throws Exception { + @Test void testExcludeFileListDeprecated() throws Exception { runCli(OK, "--minimum-tokens", "10", "--file-list", BASE_RES_PATH + "fileList.txt", @@ -295,8 +273,7 @@ void testExcludeFileListDeprecated() throws Exception { } - @Test - void testReportFile(@TempDir Path tmp) throws Exception { + @Test void testReportFile(@TempDir Path tmp) throws Exception { Path reportFile = tmp.resolve("report.txt"); runCli(VIOLATIONS_FOUND, "--minimum-tokens", "10", @@ -317,26 +294,24 @@ void testReportFile(@TempDir Path tmp) throws Exception { /** * See: https://sourceforge.net/p/pmd/bugs/1178/ */ - @Test - void testSkipLexicalErrors() throws Exception { + @Test void testSkipLexicalErrors() throws Exception { runCli(VIOLATIONS_FOUND, - "--minimum-tokens", "10", - "-d", BASE_RES_PATH + "badandgood/", - "--format", "text", - "--skip-lexical-errors") - .verify(r -> { - r.checkStdErr(containsPattern("Skipping file: Lexical error in file .*?BadFile\\.java")); - r.checkStdErr(containsString("--skip-lexical-errors is deprecated. Use --no-fail-on-error instead.")); - r.checkStdOut(containsString("Found a 5 line (13 tokens) duplication")); - }); + "--minimum-tokens", "10", + "-d", BASE_RES_PATH + "badandgood/", + "--format", "text", + "--skip-lexical-errors") + .verify(r -> { + r.checkStdErr(containsPattern("Skipping file: Lexical error in file .*?BadFile\\.java")); + r.checkStdErr(containsString("--skip-lexical-errors is deprecated. Use --no-fail-on-error instead.")); + r.checkStdOut(containsString("Found a 5 line (13 tokens) duplication")); + }); } /** * @see [core] PMD CPD v7.3.0 gives deprecation warning for skipLexicalErrors even when not used #5091 * @throws Exception */ - @Test - void noWarningsWithoutSkipLexicalErrors() throws Exception { + @Test void noWarningsWithoutSkipLexicalErrors() throws Exception { runCliSuccessfully("--minimum-tokens", "340", "--language", "java", "--dir", SRC_DIR, "--format", "text") .verify(r -> { r.checkNoErrorOutput(); @@ -344,8 +319,7 @@ void noWarningsWithoutSkipLexicalErrors() throws Exception { }); } - @Test - void testExitCodeWithLexicalErrors() throws Exception { + @Test void testExitCodeWithLexicalErrors() throws Exception { runCli(RECOVERED_ERRORS_OR_VIOLATIONS, "--minimum-tokens", "10", "-d", Paths.get(BASE_RES_PATH, "badandgood", "BadFile.java").toString(), @@ -356,8 +330,7 @@ void testExitCodeWithLexicalErrors() throws Exception { }); } - @Test - void testExitCodeWithLexicalErrorsNoFail() throws Exception { + @Test void testExitCodeWithLexicalErrorsNoFail() throws Exception { runCli(OK, "--minimum-tokens", "10", "-d", Paths.get(BASE_RES_PATH, "badandgood", "BadFile.java").toString(), @@ -369,8 +342,7 @@ void testExitCodeWithLexicalErrorsNoFail() throws Exception { }); } - @Test - void testExitCodeWithLexicalErrorsAndSkipLexical() throws Exception { + @Test void testExitCodeWithLexicalErrorsAndSkipLexical() throws Exception { runCli(OK, "--minimum-tokens", "10", "-d", Paths.get(BASE_RES_PATH, "badandgood", "BadFile.java").toString(), @@ -382,38 +354,34 @@ void testExitCodeWithLexicalErrorsAndSkipLexical() throws Exception { }); } - @Test - void jsShouldFindDuplicatesWithDifferentFileExtensions() throws Exception { + @Test void jsShouldFindDuplicatesWithDifferentFileExtensions() throws Exception { runCli(VIOLATIONS_FOUND, "--minimum-tokens", "5", "--language", "typescript", - "-d", BASE_RES_PATH + "tsFiles/File1.ts", BASE_RES_PATH + "tsFiles/File2.ts") - .checkStdOut(containsString("Found a 9 line (32 tokens) duplication in the following files")); + "-d", BASE_RES_PATH + "tsFiles/File1.ts", BASE_RES_PATH + "tsFiles/File2.ts") + .checkStdOut(containsString("Found a 9 line (32 tokens) duplication in the following files")); } - @Test - void jsShouldFindNoDuplicatesWithDifferentFileExtensions() throws Exception { + @Test void jsShouldFindNoDuplicatesWithDifferentFileExtensions() throws Exception { runCli(OK, "--minimum-tokens", "5", "--language", "ecmascript", - "-d", BASE_RES_PATH + "tsFiles/") - .checkStdOut(emptyString()); + "-d", BASE_RES_PATH + "tsFiles/") + .checkStdOut(emptyString()); } - @Test - void renderEmptyReportXml() throws Exception { + @Test void renderEmptyReportXml() throws Exception { runCli(OK, "--minimum-tokens", "5", "--language", "ecmascript", - "-f", "xml", - "-d", BASE_RES_PATH + "tsFiles/") - .checkStdOut(containsPattern(CPD_REPORT_HEADER_PATTERN.substring(0, CPD_REPORT_HEADER_PATTERN.length() - 2) + "/>")); + "-f", "xml", + "-d", BASE_RES_PATH + "tsFiles/") + .checkStdOut(containsPattern(CPD_REPORT_HEADER_PATTERN.substring(0, CPD_REPORT_HEADER_PATTERN.length() - 2) + "/>")); } - @Test - void testFileListOnly() throws Exception { + @Test void testFileListOnly() throws Exception { Path fileList = tempDir.resolve("fileList.txt"); StringBuilder fileListContent = new StringBuilder(); fileListContent.append(SRC_PATH.resolve("dup1.java")).append(System.lineSeparator()); fileListContent.append(SRC_PATH.resolve("dup2.java")).append(System.lineSeparator()); Files.write(fileList, fileListContent.toString().getBytes(StandardCharsets.UTF_8)); runCli(VIOLATIONS_FOUND, "--minimum-tokens", "5", "--file-list", fileList.toString()) - .verify(result -> result.checkStdOut(containsString( - "Found a 14 line (86 tokens) duplication in the following files:" - ))); + .verify(result -> result.checkStdOut(containsString( + "Found a 14 line (86 tokens) duplication in the following files:" + ))); } } diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/ForceLanguageCliTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/ForceLanguageCliTest.java index faa57c1f405..a1726048b14 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/ForceLanguageCliTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/ForceLanguageCliTest.java @@ -18,32 +18,28 @@ 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 cliStandardArgs() { + @Override protected List cliStandardArgs() { return listOf( - "check", - "--no-cache", - "-f", "text", - "-R", PmdCliTest.RULESET_WITH_VIOLATION + "check", + "--no-cache", + "-f", "text", + "-R", PmdCliTest.RULESET_WITH_VIOLATION ); } - @Test - void analyzeSingleXmlWithoutForceLanguage() throws Exception { + @Test void analyzeSingleXmlWithoutForceLanguage() throws Exception { runCli(OK, "-d", BASE_DIR + "src/file1.ext") - .verify(r -> r.checkStdOut(containsStringNTimes(0, RULE_MESSAGE))); + .verify(r -> r.checkStdOut(containsStringNTimes(0, RULE_MESSAGE))); } - @Test - void analyzeSingleXmlWithForceLanguage() throws Exception { + @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))); + .verify(r -> r.checkStdOut(containsStringNTimes(1, RULE_MESSAGE))); } - @Test - void analyzeDirectoryWithForceLanguage() throws Exception { + @Test void analyzeDirectoryWithForceLanguage() throws Exception { runCli(VIOLATIONS_FOUND, "-d", BASE_DIR + "src/", "--force-language", "dummy") - .verify(r -> r.checkStdOut(containsStringNTimes(3, RULE_MESSAGE))); + .verify(r -> r.checkStdOut(containsStringNTimes(3, RULE_MESSAGE))); } } diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java index e98aa24ba9a..e432412a1d9 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/PmdCliTest.java @@ -58,27 +58,23 @@ class PmdCliTest extends BaseCliTest { private static final String NOT_A_RULESET = "ThisRuleSetDoesNotExist.xml"; private static final String STRING_TO_REPLACE = "__should_be_replaced__"; - @TempDir - private Path tempDir; + @TempDir private Path tempDir; private Path srcDir; - @AfterEach - void resetLogging() { + @AfterEach void resetLogging() { // reset logging in case "--debug" changed the logging properties // See also Slf4jSimpleConfigurationForAnt Slf4jSimpleConfiguration.reconfigureDefaultLogLevel(null); } - @BeforeEach - void setup() throws IOException { + @BeforeEach void setup() throws IOException { // create a few files srcDir = Files.createDirectories(tempRoot().resolve("src")); writeString(srcDir.resolve("someSource.dummy"), "dummy text"); } - @Test - void testPreExistingReportFile() throws Exception { + @Test void testPreExistingReportFile() throws Exception { Path reportFile = tempRoot().resolve("out/reportFile.txt"); // now we create the file Files.createDirectories(reportFile.getParent()); @@ -91,8 +87,7 @@ void testPreExistingReportFile() throws Exception { assertNotEquals(readString(reportFile), STRING_TO_REPLACE); } - @Test - void testPreExistingReportFileLongOption() throws Exception { + @Test void testPreExistingReportFileLongOption() throws Exception { Path reportFile = tempRoot().resolve("out/reportFile.txt"); // now we create the file Files.createDirectories(reportFile.getParent()); @@ -105,8 +100,7 @@ void testPreExistingReportFileLongOption() throws Exception { assertNotEquals(readString(reportFile), STRING_TO_REPLACE, "Report file should have been overwritten"); } - @Test - void testNonExistentReportFile() throws Exception { + @Test void testNonExistentReportFile() throws Exception { Path reportFile = tempRoot().resolve("out/reportFile.txt"); assertFalse(Files.exists(reportFile), "Report file should not exist"); @@ -119,8 +113,7 @@ void testNonExistentReportFile() throws Exception { } } - @Test - void testNonExistentReportFileLongOption() throws Exception { + @Test void testNonExistentReportFileLongOption() throws Exception { Path reportFile = tempRoot().resolve("out/reportFile.txt"); assertFalse(Files.exists(reportFile), "Report file should not exist"); @@ -130,8 +123,7 @@ void testNonExistentReportFileLongOption() throws Exception { assertTrue(Files.exists(reportFile), "Report file should have been created"); } - @Test - void testFileCollectionWithUnknownFiles() throws Exception { + @Test void testFileCollectionWithUnknownFiles() throws Exception { Path reportFile = tempRoot().resolve("out/reportFile.txt"); Files.createFile(srcDir.resolve("foo.not_analysable")); assertFalse(Files.exists(reportFile), "Report file should not exist"); @@ -146,8 +138,7 @@ void testFileCollectionWithUnknownFiles() throws Exception { assertThat(reportText, not(containsStringIgnoringCase("error"))); } - @Test - void testExcludeFile() throws Exception { + @Test void testExcludeFile() throws Exception { // restoring system properties: --debug might change logging properties SystemLambda.restoreSystemProperties(() -> { @@ -168,8 +159,7 @@ void testExcludeFile() throws Exception { * in the temporary folder, but really in the cwd. The test fails if a file already exists * and makes sure to cleanup the file afterwards. */ - @Test - void testRelativeReportFile() throws Exception { + @Test void testRelativeReportFile() throws Exception { String reportFile = "reportFile.txt"; Path absoluteReportFile = FileSystems.getDefault().getPath(reportFile).toAbsolutePath(); // verify the file doesn't exist yet - we will delete the file at the end! @@ -183,8 +173,7 @@ void testRelativeReportFile() throws Exception { } } - @Test - void testRelativeReportFileLongOption() throws Exception { + @Test void testRelativeReportFileLongOption() throws Exception { String reportFile = "reportFile.txt"; Path absoluteReportFile = FileSystems.getDefault().getPath(reportFile).toAbsolutePath(); // verify the file doesn't exist yet - we will delete the file at the end! @@ -199,38 +188,33 @@ void testRelativeReportFileLongOption() throws Exception { } - @Test - void testRelativeFileInputs() throws Exception { + @Test void testRelativeFileInputs() throws Exception { SystemLambda.restoreSystemProperties(() -> { // change working directory System.setProperty("user.dir", srcDir.toString()); runCli(VIOLATIONS_FOUND, "--dir", ".", "--rulesets", DUMMY_RULESET_WITH_VIOLATIONS) - .verify(res -> res.checkStdOut(containsString( - "./src/test/resources/net/sourceforge/pmd/cli/src/anotherfile.dummy".replace('/', File.separatorChar) - ))); + .verify(res -> res.checkStdOut(containsString( + "./src/test/resources/net/sourceforge/pmd/cli/src/anotherfile.dummy".replace('/', File.separatorChar) + ))); }); } - @Test - void debugLogging() throws Exception { + @Test void debugLogging() throws Exception { CliExecutionResult result = runCliSuccessfully("--debug", "--dir", srcDir.toString(), "--rulesets", RULESET_NO_VIOLATIONS); result.checkStdErr(containsString("[DEBUG] Log level is at TRACE")); } - @Test - void defaultLogging() throws Exception { + @Test void defaultLogging() throws Exception { CliExecutionResult result = runCliSuccessfully("--dir", srcDir.toString(), "--rulesets", RULESET_NO_VIOLATIONS); result.checkStdErr(not(containsString("[DEBUG] Log level is at TRACE"))); } - @Test - void testReportToStdoutNotClosing() throws Exception { + @Test void testReportToStdoutNotClosing() throws Exception { PrintStream originalOut = System.out; PrintStream out = new PrintStream(new FilterOutputStream(originalOut) { - @Override - public void close() { + @Override public void close() { fail("Stream must not be closed"); } }); @@ -242,14 +226,12 @@ public void close() { } } - @Test - void testMissingRuleset() throws Exception { + @Test void testMissingRuleset() throws Exception { CliExecutionResult result = runCli(USAGE_ERROR); result.checkStdErr(containsString("Missing required option: '--rulesets='")); } - - @Test - void testMissingSource() throws Exception { + + @Test void testMissingSource() throws Exception { CliExecutionResult result = runCli(USAGE_ERROR, "--rulesets", RULESET_NO_VIOLATIONS); result.checkStdErr(containsString("Please provide a parameter for source root directory")); } @@ -257,8 +239,7 @@ void testMissingSource() throws Exception { /** * @see [core] Stop printing CLI usage text when exiting due to invalid parameters #3427 */ - @Test - void testWrongCliOptionsDoPrintUsage() throws Exception { + @Test void testWrongCliOptionsDoPrintUsage() throws Exception { runCli(USAGE_ERROR, "--invalid", "--rulesets", RULESET_NO_VIOLATIONS, "-d", srcDir.toString()) .verify(result -> { result.checkStdErr(containsString("Unknown option: '--invalid'")); @@ -270,94 +251,84 @@ void testWrongCliOptionsDoPrintUsage() throws Exception { /** * See https://sourceforge.net/p/pmd/bugs/1231/ */ - @Test - void testWrongRuleset() throws Exception { + @Test void testWrongRuleset() throws Exception { runCli(ERROR, "-d", srcDir.toString(), "-f", "text", "-R", NOT_A_RULESET) - .verify(result -> result.checkStdErr( - containsString("Cannot resolve rule/ruleset reference" - + " '" + NOT_A_RULESET + "'"))); + .verify(result -> result.checkStdErr( + containsString("Cannot resolve rule/ruleset reference" + + " '" + NOT_A_RULESET + "'"))); } /** * See https://sourceforge.net/p/pmd/bugs/1231/ */ - @Test - void testWrongRulesetWithRulename() throws Exception { + @Test void testWrongRulesetWithRulename() throws Exception { runCli(ERROR, "-d", srcDir.toString(), "-f", "text", "-R", NOT_A_RULESET + "/NotARule") - .verify(result -> result.checkStdErr( - containsString("Cannot resolve rule/ruleset reference" - + " '" + NOT_A_RULESET + "/NotARule'"))); + .verify(result -> result.checkStdErr( + containsString("Cannot resolve rule/ruleset reference" + + " '" + NOT_A_RULESET + "/NotARule'"))); } /** * See https://sourceforge.net/p/pmd/bugs/1231/ */ - @Test - void testWrongRulename() throws Exception { + @Test void testWrongRulename() throws Exception { runCli(OK, "-d", srcDir.toString(), "-f", "text", "-R", RULESET_NO_VIOLATIONS + "/ThisRuleDoesNotExist") - .verify(result -> result.checkStdErr( - containsString( - "No rules found. Maybe you misspelled a rule name?" - + " (" + RULESET_NO_VIOLATIONS + "/ThisRuleDoesNotExist)" - ) - )); + .verify(result -> result.checkStdErr( + containsString( + "No rules found. Maybe you misspelled a rule name?" + + " (" + RULESET_NO_VIOLATIONS + "/ThisRuleDoesNotExist)" + ) + )); } - @Test - void changeSourceVersion() throws Exception { + @Test void changeSourceVersion() throws Exception { runCli(OK, "-d", srcDir.toString(), "-f", "text", "-R", RULESET_NO_VIOLATIONS, "--debug", - "--use-version", "dummy-1.2") - .verify(result -> result.checkStdErr( - containsPattern("Adding file .*\\.dummy \\(lang: dummy 1\\.2\\)")) - ); + "--use-version", "dummy-1.2") + .verify(result -> result.checkStdErr( + containsPattern("Adding file .*\\.dummy \\(lang: dummy 1\\.2\\)")) + ); } - @Test - void exitStatusWithViolationsAndWithoutFailOnViolations() throws Exception { + @Test void exitStatusWithViolationsAndWithoutFailOnViolations() throws Exception { runCli(OK, "-d", srcDir.toString(), "-f", "text", "-R", RULESET_WITH_VIOLATION, "--no-fail-on-violation") - .verify(r -> r.checkStdOut( - containsString("Violation from ReportAllRootNodes") - )); + .verify(r -> r.checkStdOut( + containsString("Violation from ReportAllRootNodes") + )); } - @Test - void exitStatusWithNoViolations() throws Exception { + @Test void exitStatusWithNoViolations() throws Exception { runCli(OK, "-d", srcDir.toString(), "-f", "text", "-R", RULESET_NO_VIOLATIONS) - .verify(r -> r.checkStdOut(equalTo(""))); + .verify(r -> r.checkStdOut(equalTo(""))); } - @Test - void exitStatusWithViolations() throws Exception { + @Test void exitStatusWithViolations() throws Exception { runCli(VIOLATIONS_FOUND, "-d", srcDir.toString(), "-f", "text", "-R", RULESET_WITH_VIOLATION) - .verify(r -> r.checkStdOut( - containsString("Violation from ReportAllRootNodes") - )); + .verify(r -> r.checkStdOut( + containsString("Violation from ReportAllRootNodes") + )); } - @Test - void exitStatusWithErrors() throws Exception { + @Test void exitStatusWithErrors() throws Exception { runCli(RECOVERED_ERRORS_OR_VIOLATIONS, "--use-version", "dummy-parserThrows", "-d", srcDir.toString(), "-f", "text", "-R", RULESET_WITH_VIOLATION) - .verify(r -> { - r.checkStdOut(containsString("someSource.dummy\t-\tParseException: Parse exception: ohio")); - r.checkStdErr(containsString("An error occurred while executing PMD.")); - }); + .verify(r -> { + r.checkStdOut(containsString("someSource.dummy\t-\tParseException: Parse exception: ohio")); + r.checkStdErr(containsString("An error occurred while executing PMD.")); + }); } - @Test - void exitStatusWithErrorsNoFail() throws Exception { + @Test void exitStatusWithErrorsNoFail() throws Exception { runCli(OK, "--use-version", "dummy-parserThrows", "-d", srcDir.toString(), "-f", "text", "-R", RULESET_WITH_VIOLATION, "--no-fail-on-error") - .verify(r -> { - r.checkStdOut(containsString("someSource.dummy\t-\tParseException: Parse exception: ohio")); - r.checkStdErr(containsString("An error occurred while executing PMD.")); - }); + .verify(r -> { + r.checkStdOut(containsString("someSource.dummy\t-\tParseException: Parse exception: ohio")); + r.checkStdErr(containsString("An error occurred while executing PMD.")); + }); } - @Test - void testZipFileAsSource() throws Exception { + @Test void testZipFileAsSource() throws Exception { Path zipArchive = createTemporaryZipArchive("sources.zip"); CliExecutionResult result = runCli(VIOLATIONS_FOUND, "--dir", zipArchive.toString(), "--rulesets", "rulesets/dummy/basic.xml"); result.checkStdErr(not(containsStringIgnoringCase("Cannot open zip file"))); @@ -365,8 +336,7 @@ void testZipFileAsSource() throws Exception { result.checkStdOut(containsString(reportPath + ":1:\tSampleXPathRule:\tTest Rule 2")); } - @Test - void testJarFileAsSource() throws Exception { + @Test void testJarFileAsSource() throws Exception { Path jarArchive = createTemporaryZipArchive("sources.jar"); CliExecutionResult result = runCli(VIOLATIONS_FOUND, "--dir", jarArchive.toString(), "--rulesets", "rulesets/dummy/basic.xml"); result.checkStdErr(not(containsStringIgnoringCase("Cannot open zip file"))); @@ -385,8 +355,7 @@ private Path createTemporaryZipArchive(String name) throws Exception { return zipArchive; } - @Test - void testNoRelativizeWithAbsoluteSrcDir() throws Exception { + @Test void testNoRelativizeWithAbsoluteSrcDir() throws Exception { assertTrue(srcDir.isAbsolute(), "srcDir should be absolute"); runCli(VIOLATIONS_FOUND, "--dir", srcDir.toString(), "--rulesets", DUMMY_RULESET_WITH_VIOLATIONS) @@ -394,8 +363,7 @@ void testNoRelativizeWithAbsoluteSrcDir() throws Exception { containsString(srcDir.resolve("someSource.dummy").toString()))); } - @Test - void testNoRelativizeWithRelativeSrcDir() throws Exception { + @Test void testNoRelativizeWithRelativeSrcDir() throws Exception { // Note, that we can't reliably change the current working directory for the current java process // therefore we use the current directory and make sure, we are at the correct place - in pmd-cli Path cwd = Paths.get(".").toRealPath(); @@ -409,8 +377,7 @@ void testNoRelativizeWithRelativeSrcDir() throws Exception { containsString("\n" + IOUtil.normalizePath(relativeSrcDir + "/somefile.dummy")))); } - @Test - void testNoRelativizeWithRelativeSrcDirParent() throws Exception { + @Test void testNoRelativizeWithRelativeSrcDirParent() throws Exception { // Note, that we can't reliably change the current working directory for the current java process // therefore we use the current directory and make sure, we are at the correct place - in pmd-cli Path cwd = Paths.get(".").toRealPath(); @@ -423,12 +390,11 @@ void testNoRelativizeWithRelativeSrcDirParent() throws Exception { String expectedFile = "\n" + relativeSrcDirWithParent.resolve("src/somefile.dummy"); runCli(VIOLATIONS_FOUND, "--dir", relativeSrcDirWithParent.toString(), "--rulesets", - DUMMY_RULESET_WITH_VIOLATIONS) + DUMMY_RULESET_WITH_VIOLATIONS) .verify(result -> result.checkStdOut(containsString(expectedFile))); } - @Test - void testRelativizeWithRootRelativeSrcDir() throws Exception { + @Test void testRelativizeWithRootRelativeSrcDir() throws Exception { // Note, that we can't reliably change the current working directory for the current java process // therefore we use the current directory and make sure, we are at the correct place - in pmd-cli Path cwd = Paths.get(".").toRealPath(); @@ -442,12 +408,11 @@ void testRelativizeWithRootRelativeSrcDir() throws Exception { runCli(VIOLATIONS_FOUND, "--dir", relativeSrcDir, "--rulesets", DUMMY_RULESET_WITH_VIOLATIONS, "--relativize-paths-with", root) .verify(result -> result.checkStdOut( - containsString("\n" + absoluteSrcPath)) - ); + containsString("\n" + absoluteSrcPath)) + ); } - @Test - void testRelativizeWith() throws Exception { + @Test void testRelativizeWith() throws Exception { runCli(VIOLATIONS_FOUND, "--dir", srcDir.toString(), "--rulesets", DUMMY_RULESET_WITH_VIOLATIONS, "-z", srcDir.getParent().toString()) .verify(result -> { @@ -456,8 +421,7 @@ void testRelativizeWith() throws Exception { }); } - @Test - void testRelativizeWithSymLink() throws Exception { + @Test void testRelativizeWithSymLink() throws Exception { // srcDir = /tmp/junit123/src // symlinkedSrcDir = /tmp/junit123/sources -> /tmp/junit123/src Path symlinkedSrcDir = Files.createSymbolicLink(tempRoot().resolve("sources"), srcDir); @@ -470,8 +434,7 @@ void testRelativizeWithSymLink() throws Exception { }); } - @Test - void testRelativizeWithSymLinkParent() throws Exception { + @Test void testRelativizeWithSymLinkParent() throws Exception { // srcDir = /tmp/junit123/src // symlinkedSrcDir = /tmp/junit-relativize-with-123 -> /tmp/junit123/src Path tempPath = Files.createTempDirectory("junit-relativize-with-"); @@ -489,8 +452,7 @@ void testRelativizeWithSymLinkParent() throws Exception { }); } - @Test - void testRelativizeWithMultiple() throws Exception { + @Test void testRelativizeWithMultiple() throws Exception { runCli(VIOLATIONS_FOUND, "--dir", srcDir.toString(), "--rulesets", DUMMY_RULESET_WITH_VIOLATIONS, "-z", srcDir.getParent().toString() + "," + srcDir.toString()) .verify(result -> { @@ -499,8 +461,7 @@ void testRelativizeWithMultiple() throws Exception { }); } - @Test - void testRelativizeWithFileIsError() throws Exception { + @Test void testRelativizeWithFileIsError() throws Exception { runCli(USAGE_ERROR, "--dir", srcDir.toString(), "--rulesets", DUMMY_RULESET_WITH_VIOLATIONS, "-z", srcDir.resolve("someSource.dummy").toString()) .verify(result -> result.checkStdErr( @@ -510,8 +471,7 @@ void testRelativizeWithFileIsError() throws Exception { )); } - @Test - void testFileListOnly() throws Exception { + @Test void testFileListOnly() throws Exception { Path filelist = tempDir.resolve("filelist.txt"); writeString(filelist, srcDir.resolve("someSource.dummy") + System.lineSeparator()); runCli(VIOLATIONS_FOUND, "--file-list", filelist.toString(), "-f", "text", "-R", RULESET_WITH_VIOLATION) @@ -520,8 +480,7 @@ void testFileListOnly() throws Exception { )); } - @Test - void minimumPriorityOption() throws Exception { + @Test void minimumPriorityOption() throws Exception { runCli(VIOLATIONS_FOUND, "-d", srcDir.toString(), "-f", "text", "-R", RULESET_WITH_VIOLATION, "--minimum-priority", "Medium") .verify(r -> r.checkStdOut( containsString("Violation from ReportAllRootNodes") @@ -531,8 +490,7 @@ void minimumPriorityOption() throws Exception { runCliSuccessfully("-d", srcDir.toString(), "-f", "text", "-R", RULESET_WITH_VIOLATION, "--minimum-priority", "Medium_High"); } - @Test - void minimumPriorityOptionNumeric() throws Exception { + @Test void minimumPriorityOptionNumeric() throws Exception { runCli(VIOLATIONS_FOUND, "-d", srcDir.toString(), "-f", "text", "-R", RULESET_WITH_VIOLATION, "--minimum-priority", "3") .verify(r -> r.checkStdOut( containsString("Violation from ReportAllRootNodes") @@ -541,20 +499,17 @@ void minimumPriorityOptionNumeric() throws Exception { runCliSuccessfully("-d", srcDir.toString(), "-f", "text", "-R", RULESET_WITH_VIOLATION, "--minimum-priority", "2"); } - @Test - void defaultThreadCount() throws Exception { + @Test void defaultThreadCount() throws Exception { CliExecutionResult result = runCliSuccessfully("--debug", "--dir", srcDir.toString(), "--rulesets", RULESET_NO_VIOLATIONS); result.checkStdErr(containsString("[DEBUG] Using " + Runtime.getRuntime().availableProcessors() + " threads for analysis")); } - @Test - void monoThreadCount() throws Exception { + @Test void monoThreadCount() throws Exception { CliExecutionResult result = runCliSuccessfully("--debug", "--threads", "0", "--dir", srcDir.toString(), "--rulesets", RULESET_NO_VIOLATIONS); result.checkStdErr(containsString("[DEBUG] Using main thread for analysis")); } - @Test - void oneThreadCount() throws Exception { + @Test void oneThreadCount() throws Exception { CliExecutionResult result = runCliSuccessfully("--debug", "--threads", "1", "--dir", srcDir.toString(), "--rulesets", RULESET_NO_VIOLATIONS); result.checkStdErr(containsString("[DEBUG] Using 1 thread for analysis")); } @@ -579,17 +534,15 @@ private static String readString(Path path) throws IOException { ByteBuffer buf = ByteBuffer.wrap(bytes); return StandardCharsets.UTF_8.decode(buf).toString(); } - - @Override - protected List cliStandardArgs() { + + @Override protected List cliStandardArgs() { return listOf( - "check", "--no-cache", "--no-progress" + "check", "--no-cache", "--no-progress" ); } public static class FooRule extends MockRule { - @Override - public void apply(Node node, RuleContext ctx) { + @Override public void apply(Node node, RuleContext ctx) { ctx.addViolation(node); } } diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/TreeExportCliTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/TreeExportCliTest.java index 6e7ba26db44..35045ca29d7 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/TreeExportCliTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/TreeExportCliTest.java @@ -22,33 +22,30 @@ class TreeExportCliTest extends BaseCliTest { - @TempDir - private Path tmp; + @TempDir private Path tmp; - @Test - void testReadStandardInput() throws Exception { + @Test void testReadStandardInput() throws Exception { SystemLambda.withTextFromSystemIn("(a(b))").execute(() -> { final CliExecutionResult output = runCliSuccessfully("-i", "-f", "xml", "-PlineSeparator=LF"); output.checkStdOut(equalTo("\n" - + "\n" - + " \n" - + " \n" - + " \n" - + "\n")); + + "\n" + + " \n" + + " \n" + + " \n" + + "\n")); }); } - @Test - void testReadFile() throws Exception { + @Test void testReadFile() throws Exception { File file = newFileWithContents("(a(b))"); final CliExecutionResult result = runCliSuccessfully("--file", file.getAbsolutePath(), "-f", "xml", "-PlineSeparator=LF"); result.checkStdOut(equalTo("\n" - + "\n" - + " \n" - + " \n" - + " \n" - + "\n")); + + "\n" + + " \n" + + " \n" + + " \n" + + "\n")); } private File newFileWithContents(String data) throws IOException { @@ -59,15 +56,14 @@ private File newFileWithContents(String data) throws IOException { return file; } - @Override - protected List cliStandardArgs() { + @Override protected List cliStandardArgs() { final List argList = new ArrayList<>(); - + // Set program name and set dummy language argList.add("ast-dump"); argList.add("-l"); argList.add("dummy"); - + return argList; } } diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/BaseCommandTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/BaseCommandTest.java index 6057a549b99..dd221d36539 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/BaseCommandTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/BaseCommandTest.java @@ -18,9 +18,9 @@ abstract class BaseCommandTest { protected abstract T createCommand(); - + protected abstract void addStandardParams(List argList); - + protected void assertError(final String... params) { final T cmd = createCommand(); final ParseResult parseResult = parseCommand(cmd, params); @@ -35,7 +35,7 @@ protected T setupAndParse(final String... params) { return cmd; } - + private ParseResult parseCommand(final Object cmd, final String... params) { final List argList = new ArrayList<>(); argList.addAll(Arrays.asList(params)); @@ -43,11 +43,11 @@ private ParseResult parseCommand(final Object cmd, final String... params) { addStandardParams(argList); final CommandLine commandLine = new CommandLine(cmd) - .setCaseInsensitiveEnumValuesAllowed(true); - + .setCaseInsensitiveEnumValuesAllowed(true); + // Collect errors instead of simply throwing during parsing commandLine.getCommandSpec().parser().collectErrors(true); - + return commandLine.parseArgs(argList.toArray(new String[0])); } diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/CpdCommandTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/CpdCommandTest.java index e089203283a..1d1c48bc240 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/CpdCommandTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/CpdCommandTest.java @@ -17,40 +17,35 @@ class CpdCommandTest extends BaseCommandTest { - @Test - void testMultipleDirs() { + @Test void testMultipleDirs() { final CpdCommand cmd = setupAndParse( - "-d", "a", "b" + "-d", "a", "b" ); assertMultipleDirs(cmd); } - @Test - void testMultipleDirsWithCommas() { + @Test void testMultipleDirsWithCommas() { final CpdCommand cmd = setupAndParse( - "-d", "a,b" + "-d", "a,b" ); assertMultipleDirs(cmd); } - @Test - void testMultipleDirsWithRepeatedOption() { + @Test void testMultipleDirsWithRepeatedOption() { final CpdCommand cmd = setupAndParse( - "-d", "a", "-d", "b" + "-d", "a", "-d", "b" ); assertMultipleDirs(cmd); } - @Test - void testNoPositionalParametersAllowed() { + @Test void testNoPositionalParametersAllowed() { final CpdCommand cmd = setupAndParse( - "-d", "a", "--", "b" + "-d", "a", "--", "b" ); assertMultipleDirs(cmd); } - @Test - void testEmptyDirOption() { + @Test void testEmptyDirOption() { assertError("-d", "-f", "text"); } @@ -59,13 +54,11 @@ private void assertMultipleDirs(final CpdCommand result) { assertEquals(listOf("a", "b"), CollectionUtil.map(config.getInputPathList(), Path::toString)); } - @Override - protected CpdCommand createCommand() { + @Override protected CpdCommand createCommand() { return new CpdCommand(); } - @Override - protected void addStandardParams(final List argList) { + @Override protected void addStandardParams(final List argList) { // If no minimum tokens provided, set default value if (!argList.contains("--minimum-tokens")) { argList.add(0, "--minimum-tokens"); diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/PmdCommandTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/PmdCommandTest.java index 9e2fca1d504..1366a05006e 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/PmdCommandTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/internal/PmdCommandTest.java @@ -19,54 +19,47 @@ class PmdCommandTest extends BaseCommandTest { - @Test - void testVersionGiven() throws Exception { + @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() { + @Test void testMultipleDirsAndRuleSets() { final PmdCommand cmd = setupAndParse( - "-d", "a", "b", "-R", "x.xml", "y.xml" + "-d", "a", "b", "-R", "x.xml", "y.xml" ); assertMultipleDirsAndRulesets(cmd); } - @Test - void testMultipleDirsAndRuleSetsWithCommas() { + @Test void testMultipleDirsAndRuleSetsWithCommas() { final PmdCommand cmd = setupAndParse( - "-d", "a,b", "-R", "x.xml,y.xml" + "-d", "a,b", "-R", "x.xml,y.xml" ); assertMultipleDirsAndRulesets(cmd); } - @Test - void testMultipleDirsAndRuleSetsWithRepeatedOption() { + @Test void testMultipleDirsAndRuleSetsWithRepeatedOption() { final PmdCommand cmd = setupAndParse( - "-d", "a", "-d", "b", "-R", "x.xml", "-R", "y.xml" + "-d", "a", "-d", "b", "-R", "x.xml", "-R", "y.xml" ); assertMultipleDirsAndRulesets(cmd); } - @Test - void testNoPositionalParametersAllowed() { + @Test void testNoPositionalParametersAllowed() { final PmdCommand cmd = setupAndParse( - "-R", "x.xml", "-R", "y.xml", "-d", "a", "--", "b" + "-R", "x.xml", "-R", "y.xml", "-d", "a", "--", "b" ); assertMultipleDirsAndRulesets(cmd); } - @Test - void testEmptyDirOption() { + @Test void testEmptyDirOption() { assertError("-d", "-R", "y.xml"); } - @Test - void testEmptyRulesetOption() { + @Test void testEmptyRulesetOption() { assertError("-R", "-d", "something"); } @@ -76,13 +69,11 @@ private void assertMultipleDirsAndRulesets(final PmdCommand result) { assertEquals(listOf("x.xml", "y.xml"), config.getRuleSetPaths()); } - @Override - protected PmdCommand createCommand() { + @Override protected PmdCommand createCommand() { return new PmdCommand(); } - @Override - protected void addStandardParams(final List argList) { + @Override protected void addStandardParams(final List argList) { // If no language provided, set dummy latest if (!argList.contains("--use-version")) { argList.add(0, "--use-version"); diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/typesupport/internal/NumThreadsConverterTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/typesupport/internal/NumThreadsConverterTest.java index e187d19cfa0..c4d4eba7de0 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/typesupport/internal/NumThreadsConverterTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/commands/typesupport/internal/NumThreadsConverterTest.java @@ -15,9 +15,7 @@ import org.junit.jupiter.params.provider.MethodSource; class NumThreadsConverterTest { - @ParameterizedTest - @MethodSource - void convertToThreadCount(String parameter, int expectedThreadCount) { + @ParameterizedTest @MethodSource void convertToThreadCount(String parameter, int expectedThreadCount) { NumThreadsConverter converter = new NumThreadsConverter(); int actualThreadCount = converter.convert(parameter); assertEquals(expectedThreadCount, actualThreadCount); @@ -31,6 +29,6 @@ private static Collection convertToThreadCount() { of("1C", Runtime.getRuntime().availableProcessors()), of("2C", 2 * Runtime.getRuntime().availableProcessors()), of("0.5C", (int) (0.5 * Runtime.getRuntime().availableProcessors())) - ); + ); } } diff --git a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/CocoLanguageModule.java b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/CocoLanguageModule.java index 711a4a730b1..d968a6e9eab 100644 --- a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/CocoLanguageModule.java +++ b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/CocoLanguageModule.java @@ -24,8 +24,7 @@ public static CocoLanguageModule getInstance() { return (CocoLanguageModule) LanguageRegistry.CPD.getLanguageById(ID); } - @Override - public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { + @Override public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { return new CocoCpdLexer(); } } diff --git a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoBaseListener.java b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoBaseListener.java index f2792e56902..a08c7f3601e 100644 --- a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoBaseListener.java +++ b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoBaseListener.java @@ -20,1350 +20,1796 @@ @SuppressWarnings("PMD.UncommentedEmptyMethodBody") @Deprecated @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public class CocoBaseListener implements CocoListener { - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterModule(CocoParser.ModuleContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitModule(CocoParser.ModuleContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterDeclaration(CocoParser.DeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitDeclaration(CocoParser.DeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAttribute(CocoParser.AttributeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAttribute(CocoParser.AttributeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAttributeDeclaration(CocoParser.AttributeDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAttributeDeclaration(CocoParser.AttributeDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterImportDeclaration(CocoParser.ImportDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitImportDeclaration(CocoParser.ImportDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterVariableDeclaration(CocoParser.VariableDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitVariableDeclaration(CocoParser.VariableDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEnumDeclaration(CocoParser.EnumDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEnumDeclaration(CocoParser.EnumDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStructDeclaration(CocoParser.StructDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStructDeclaration(CocoParser.StructDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterTypeAliasDeclaration(CocoParser.TypeAliasDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitTypeAliasDeclaration(CocoParser.TypeAliasDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFunctionDeclaration(CocoParser.FunctionDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFunctionDeclaration(CocoParser.FunctionDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterInstanceDeclaration(CocoParser.InstanceDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitInstanceDeclaration(CocoParser.InstanceDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterPortDeclaration(CocoParser.PortDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitPortDeclaration(CocoParser.PortDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterComponentDeclaration(CocoParser.ComponentDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitComponentDeclaration(CocoParser.ComponentDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterExternalConstantDeclaration(CocoParser.ExternalConstantDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitExternalConstantDeclaration(CocoParser.ExternalConstantDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterExternalTypeDeclaration(CocoParser.ExternalTypeDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitExternalTypeDeclaration(CocoParser.ExternalTypeDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterExternalTypeElement(CocoParser.ExternalTypeElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitExternalTypeElement(CocoParser.ExternalTypeElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterExternalFunctionDeclaration(CocoParser.ExternalFunctionDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitExternalFunctionDeclaration(CocoParser.ExternalFunctionDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterGenericTypeDeclaration(CocoParser.GenericTypeDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitGenericTypeDeclaration(CocoParser.GenericTypeDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterGenericTypes(CocoParser.GenericTypesContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitGenericTypes(CocoParser.GenericTypesContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterGenericType(CocoParser.GenericTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitGenericType(CocoParser.GenericTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEnumElement(CocoParser.EnumElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEnumElement(CocoParser.EnumElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEnumCase(CocoParser.EnumCaseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEnumCase(CocoParser.EnumCaseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterCaseParameters(CocoParser.CaseParametersContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitCaseParameters(CocoParser.CaseParametersContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterCaseParameter(CocoParser.CaseParameterContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitCaseParameter(CocoParser.CaseParameterContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStructElement(CocoParser.StructElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStructElement(CocoParser.StructElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFieldDeclaration(CocoParser.FieldDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFieldDeclaration(CocoParser.FieldDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterComponentElement(CocoParser.ComponentElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitComponentElement(CocoParser.ComponentElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStaticMemberDeclaration(CocoParser.StaticMemberDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStaticMemberDeclaration(CocoParser.StaticMemberDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterConstructorDeclaration(CocoParser.ConstructorDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitConstructorDeclaration(CocoParser.ConstructorDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIfExpression(CocoParser.IfExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIfExpression(CocoParser.IfExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterTryOperatorExpression(CocoParser.TryOperatorExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitTryOperatorExpression(CocoParser.TryOperatorExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterUnaryOperatorExpression(CocoParser.UnaryOperatorExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitUnaryOperatorExpression(CocoParser.UnaryOperatorExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterOptionalExpression(CocoParser.OptionalExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitOptionalExpression(CocoParser.OptionalExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterArithmicOrLogicalExpression(CocoParser.ArithmicOrLogicalExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitArithmicOrLogicalExpression(CocoParser.ArithmicOrLogicalExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLiteralExpression(CocoParser.LiteralExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLiteralExpression(CocoParser.LiteralExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterArrayLiteralExpression(CocoParser.ArrayLiteralExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitArrayLiteralExpression(CocoParser.ArrayLiteralExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNondetExpression(CocoParser.NondetExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNondetExpression(CocoParser.NondetExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterGroupedExpression(CocoParser.GroupedExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitGroupedExpression(CocoParser.GroupedExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterBlockExpression(CocoParser.BlockExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitBlockExpression(CocoParser.BlockExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterMatchExpression(CocoParser.MatchExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitMatchExpression(CocoParser.MatchExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStructLiteralExpression(CocoParser.StructLiteralExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStructLiteralExpression(CocoParser.StructLiteralExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterMemberReferenceExpression(CocoParser.MemberReferenceExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitMemberReferenceExpression(CocoParser.MemberReferenceExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterAssignmentExpression(CocoParser.AssignmentExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitAssignmentExpression(CocoParser.AssignmentExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterVariableReferenceExpression(CocoParser.VariableReferenceExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitVariableReferenceExpression(CocoParser.VariableReferenceExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterImplicitMemberExpression(CocoParser.ImplicitMemberExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitImplicitMemberExpression(CocoParser.ImplicitMemberExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterExternalFunction(CocoParser.ExternalFunctionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitExternalFunction(CocoParser.ExternalFunctionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterCastExpression(CocoParser.CastExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitCastExpression(CocoParser.CastExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStateInvariantExpression(CocoParser.StateInvariantExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStateInvariantExpression(CocoParser.StateInvariantExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterCallExpression(CocoParser.CallExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitCallExpression(CocoParser.CallExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterExternalLiteral(CocoParser.ExternalLiteralContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitExternalLiteral(CocoParser.ExternalLiteralContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterArraySubscriptExpression(CocoParser.ArraySubscriptExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitArraySubscriptExpression(CocoParser.ArraySubscriptExpressionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterBlockExpression_(CocoParser.BlockExpression_Context ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitBlockExpression_(CocoParser.BlockExpression_Context ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIfExpression_(CocoParser.IfExpression_Context ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIfExpression_(CocoParser.IfExpression_Context ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterMatchExpression_(CocoParser.MatchExpression_Context ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitMatchExpression_(CocoParser.MatchExpression_Context ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNondetExpression_(CocoParser.NondetExpression_Context ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNondetExpression_(CocoParser.NondetExpression_Context ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFieldAssignments(CocoParser.FieldAssignmentsContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFieldAssignments(CocoParser.FieldAssignmentsContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFieldAssignment(CocoParser.FieldAssignmentContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFieldAssignment(CocoParser.FieldAssignmentContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNondetClauses(CocoParser.NondetClausesContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNondetClauses(CocoParser.NondetClausesContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterNondetClause(CocoParser.NondetClauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitNondetClause(CocoParser.NondetClauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterMatchClauses(CocoParser.MatchClausesContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitMatchClauses(CocoParser.MatchClausesContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterMatchClause(CocoParser.MatchClauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitMatchClause(CocoParser.MatchClauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterPattern(CocoParser.PatternContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitPattern(CocoParser.PatternContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEnumCasePattern(CocoParser.EnumCasePatternContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEnumCasePattern(CocoParser.EnumCasePatternContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIdParameterPatterns(CocoParser.IdParameterPatternsContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIdParameterPatterns(CocoParser.IdParameterPatternsContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterIdParameterPattern(CocoParser.IdParameterPatternContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitIdParameterPattern(CocoParser.IdParameterPatternContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterVariableDeclarationPattern(CocoParser.VariableDeclarationPatternContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitVariableDeclarationPattern(CocoParser.VariableDeclarationPatternContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterParameterPatterns(CocoParser.ParameterPatternsContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitParameterPatterns(CocoParser.ParameterPatternsContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterParameterPattern(CocoParser.ParameterPatternContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitParameterPattern(CocoParser.ParameterPatternContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterExpressions(CocoParser.ExpressionsContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitExpressions(CocoParser.ExpressionsContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStatement(CocoParser.StatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStatement(CocoParser.StatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterDeclarationStatement(CocoParser.DeclarationStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitDeclarationStatement(CocoParser.DeclarationStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterReturnStatement(CocoParser.ReturnStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitReturnStatement(CocoParser.ReturnStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterBecomeStatement(CocoParser.BecomeStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitBecomeStatement(CocoParser.BecomeStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterWhileStatement(CocoParser.WhileStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitWhileStatement(CocoParser.WhileStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterForStatement(CocoParser.ForStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitForStatement(CocoParser.ForStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterBreakStatement(CocoParser.BreakStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitBreakStatement(CocoParser.BreakStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterContinueStatement(CocoParser.ContinueStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitContinueStatement(CocoParser.ContinueStatementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterPortElement(CocoParser.PortElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitPortElement(CocoParser.PortElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFunctionInterfaceDeclaration(CocoParser.FunctionInterfaceDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFunctionInterfaceDeclaration(CocoParser.FunctionInterfaceDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterSignalDeclaration(CocoParser.SignalDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSignalDeclaration(CocoParser.SignalDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStateMachineDeclaration(CocoParser.StateMachineDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStateMachineDeclaration(CocoParser.StateMachineDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStateMachineElement(CocoParser.StateMachineElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStateMachineElement(CocoParser.StateMachineElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStateDeclaration(CocoParser.StateDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStateDeclaration(CocoParser.StateDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEventStateDeclaration(CocoParser.EventStateDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEventStateDeclaration(CocoParser.EventStateDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterExecutionStateDeclaration(CocoParser.ExecutionStateDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitExecutionStateDeclaration(CocoParser.ExecutionStateDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEventStateElement(CocoParser.EventStateElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEventStateElement(CocoParser.EventStateElementContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEntryFunctionDeclaration(CocoParser.EntryFunctionDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEntryFunctionDeclaration(CocoParser.EntryFunctionDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterExitFunctionDeclaration(CocoParser.ExitFunctionDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitExitFunctionDeclaration(CocoParser.ExitFunctionDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterStateInvariant(CocoParser.StateInvariantContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitStateInvariant(CocoParser.StateInvariantContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterTransitionDeclaration(CocoParser.TransitionDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitTransitionDeclaration(CocoParser.TransitionDeclarationContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEventTransition(CocoParser.EventTransitionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEventTransition(CocoParser.EventTransitionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEventSource(CocoParser.EventSourceContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEventSource(CocoParser.EventSourceContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterSpontaneousTransition(CocoParser.SpontaneousTransitionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitSpontaneousTransition(CocoParser.SpontaneousTransitionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterTimerTransition(CocoParser.TimerTransitionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitTimerTransition(CocoParser.TimerTransitionContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEventHandler(CocoParser.EventHandlerContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEventHandler(CocoParser.EventHandlerContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterOffer(CocoParser.OfferContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitOffer(CocoParser.OfferContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterOfferClauses(CocoParser.OfferClausesContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitOfferClauses(CocoParser.OfferClausesContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterOfferClause(CocoParser.OfferClauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitOfferClause(CocoParser.OfferClauseContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterParameters(CocoParser.ParametersContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitParameters(CocoParser.ParametersContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterParameter(CocoParser.ParameterContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitParameter(CocoParser.ParameterContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLiteralExpression_(CocoParser.LiteralExpression_Context ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLiteralExpression_(CocoParser.LiteralExpression_Context ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterBinaryType(CocoParser.BinaryTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitBinaryType(CocoParser.BinaryTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterGroupType(CocoParser.GroupTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitGroupType(CocoParser.GroupTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterFunctionType(CocoParser.FunctionTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitFunctionType(CocoParser.FunctionTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterUnaryType(CocoParser.UnaryTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitUnaryType(CocoParser.UnaryTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterLiteralType(CocoParser.LiteralTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitLiteralType(CocoParser.LiteralTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterTypeReference(CocoParser.TypeReferenceContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitTypeReference(CocoParser.TypeReferenceContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterReferenceType(CocoParser.ReferenceTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitReferenceType(CocoParser.ReferenceTypeContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterTypes(CocoParser.TypesContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitTypes(CocoParser.TypesContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterDotIdentifierList(CocoParser.DotIdentifierListContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitDotIdentifierList(CocoParser.DotIdentifierListContext ctx) { } - - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void enterEveryRule(ParserRuleContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void exitEveryRule(ParserRuleContext ctx) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void visitTerminal(TerminalNode node) { } - /** - * {@inheritDoc} - * - *

The default implementation does nothing.

- */ - @Override public void visitErrorNode(ErrorNode node) { } +public class CocoBaseListener implements CocoListener { + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterModule(CocoParser.ModuleContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitModule(CocoParser.ModuleContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDeclaration(CocoParser.DeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDeclaration(CocoParser.DeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAttribute(CocoParser.AttributeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAttribute(CocoParser.AttributeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAttributeDeclaration(CocoParser.AttributeDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAttributeDeclaration(CocoParser.AttributeDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterImportDeclaration(CocoParser.ImportDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitImportDeclaration(CocoParser.ImportDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterVariableDeclaration(CocoParser.VariableDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitVariableDeclaration(CocoParser.VariableDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEnumDeclaration(CocoParser.EnumDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEnumDeclaration(CocoParser.EnumDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStructDeclaration(CocoParser.StructDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStructDeclaration(CocoParser.StructDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterTypeAliasDeclaration(CocoParser.TypeAliasDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitTypeAliasDeclaration(CocoParser.TypeAliasDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFunctionDeclaration(CocoParser.FunctionDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFunctionDeclaration(CocoParser.FunctionDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterInstanceDeclaration(CocoParser.InstanceDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitInstanceDeclaration(CocoParser.InstanceDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPortDeclaration(CocoParser.PortDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPortDeclaration(CocoParser.PortDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterComponentDeclaration(CocoParser.ComponentDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitComponentDeclaration(CocoParser.ComponentDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExternalConstantDeclaration(CocoParser.ExternalConstantDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExternalConstantDeclaration(CocoParser.ExternalConstantDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExternalTypeDeclaration(CocoParser.ExternalTypeDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExternalTypeDeclaration(CocoParser.ExternalTypeDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExternalTypeElement(CocoParser.ExternalTypeElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExternalTypeElement(CocoParser.ExternalTypeElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExternalFunctionDeclaration(CocoParser.ExternalFunctionDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExternalFunctionDeclaration(CocoParser.ExternalFunctionDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterGenericTypeDeclaration(CocoParser.GenericTypeDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitGenericTypeDeclaration(CocoParser.GenericTypeDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterGenericTypes(CocoParser.GenericTypesContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitGenericTypes(CocoParser.GenericTypesContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterGenericType(CocoParser.GenericTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitGenericType(CocoParser.GenericTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEnumElement(CocoParser.EnumElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEnumElement(CocoParser.EnumElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEnumCase(CocoParser.EnumCaseContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEnumCase(CocoParser.EnumCaseContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCaseParameters(CocoParser.CaseParametersContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCaseParameters(CocoParser.CaseParametersContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCaseParameter(CocoParser.CaseParameterContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCaseParameter(CocoParser.CaseParameterContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStructElement(CocoParser.StructElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStructElement(CocoParser.StructElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFieldDeclaration(CocoParser.FieldDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFieldDeclaration(CocoParser.FieldDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterComponentElement(CocoParser.ComponentElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitComponentElement(CocoParser.ComponentElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStaticMemberDeclaration(CocoParser.StaticMemberDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStaticMemberDeclaration(CocoParser.StaticMemberDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterConstructorDeclaration(CocoParser.ConstructorDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitConstructorDeclaration(CocoParser.ConstructorDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIfExpression(CocoParser.IfExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIfExpression(CocoParser.IfExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterTryOperatorExpression(CocoParser.TryOperatorExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitTryOperatorExpression(CocoParser.TryOperatorExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterUnaryOperatorExpression(CocoParser.UnaryOperatorExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitUnaryOperatorExpression(CocoParser.UnaryOperatorExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterOptionalExpression(CocoParser.OptionalExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitOptionalExpression(CocoParser.OptionalExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterArithmicOrLogicalExpression(CocoParser.ArithmicOrLogicalExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitArithmicOrLogicalExpression(CocoParser.ArithmicOrLogicalExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLiteralExpression(CocoParser.LiteralExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLiteralExpression(CocoParser.LiteralExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterArrayLiteralExpression(CocoParser.ArrayLiteralExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitArrayLiteralExpression(CocoParser.ArrayLiteralExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNondetExpression(CocoParser.NondetExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNondetExpression(CocoParser.NondetExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterGroupedExpression(CocoParser.GroupedExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitGroupedExpression(CocoParser.GroupedExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBlockExpression(CocoParser.BlockExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBlockExpression(CocoParser.BlockExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMatchExpression(CocoParser.MatchExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMatchExpression(CocoParser.MatchExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStructLiteralExpression(CocoParser.StructLiteralExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStructLiteralExpression(CocoParser.StructLiteralExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMemberReferenceExpression(CocoParser.MemberReferenceExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMemberReferenceExpression(CocoParser.MemberReferenceExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAssignmentExpression(CocoParser.AssignmentExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAssignmentExpression(CocoParser.AssignmentExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterVariableReferenceExpression(CocoParser.VariableReferenceExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitVariableReferenceExpression(CocoParser.VariableReferenceExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterImplicitMemberExpression(CocoParser.ImplicitMemberExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitImplicitMemberExpression(CocoParser.ImplicitMemberExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExternalFunction(CocoParser.ExternalFunctionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExternalFunction(CocoParser.ExternalFunctionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCastExpression(CocoParser.CastExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCastExpression(CocoParser.CastExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStateInvariantExpression(CocoParser.StateInvariantExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStateInvariantExpression(CocoParser.StateInvariantExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCallExpression(CocoParser.CallExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCallExpression(CocoParser.CallExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExternalLiteral(CocoParser.ExternalLiteralContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExternalLiteral(CocoParser.ExternalLiteralContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterArraySubscriptExpression(CocoParser.ArraySubscriptExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitArraySubscriptExpression(CocoParser.ArraySubscriptExpressionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBlockExpression_(CocoParser.BlockExpression_Context ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBlockExpression_(CocoParser.BlockExpression_Context ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIfExpression_(CocoParser.IfExpression_Context ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIfExpression_(CocoParser.IfExpression_Context ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMatchExpression_(CocoParser.MatchExpression_Context ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMatchExpression_(CocoParser.MatchExpression_Context ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNondetExpression_(CocoParser.NondetExpression_Context ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNondetExpression_(CocoParser.NondetExpression_Context ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFieldAssignments(CocoParser.FieldAssignmentsContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFieldAssignments(CocoParser.FieldAssignmentsContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFieldAssignment(CocoParser.FieldAssignmentContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFieldAssignment(CocoParser.FieldAssignmentContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNondetClauses(CocoParser.NondetClausesContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNondetClauses(CocoParser.NondetClausesContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNondetClause(CocoParser.NondetClauseContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNondetClause(CocoParser.NondetClauseContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMatchClauses(CocoParser.MatchClausesContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMatchClauses(CocoParser.MatchClausesContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMatchClause(CocoParser.MatchClauseContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMatchClause(CocoParser.MatchClauseContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPattern(CocoParser.PatternContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPattern(CocoParser.PatternContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEnumCasePattern(CocoParser.EnumCasePatternContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEnumCasePattern(CocoParser.EnumCasePatternContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIdParameterPatterns(CocoParser.IdParameterPatternsContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIdParameterPatterns(CocoParser.IdParameterPatternsContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIdParameterPattern(CocoParser.IdParameterPatternContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIdParameterPattern(CocoParser.IdParameterPatternContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterVariableDeclarationPattern(CocoParser.VariableDeclarationPatternContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitVariableDeclarationPattern(CocoParser.VariableDeclarationPatternContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterParameterPatterns(CocoParser.ParameterPatternsContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitParameterPatterns(CocoParser.ParameterPatternsContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterParameterPattern(CocoParser.ParameterPatternContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitParameterPattern(CocoParser.ParameterPatternContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExpressions(CocoParser.ExpressionsContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExpressions(CocoParser.ExpressionsContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStatement(CocoParser.StatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStatement(CocoParser.StatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDeclarationStatement(CocoParser.DeclarationStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDeclarationStatement(CocoParser.DeclarationStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterReturnStatement(CocoParser.ReturnStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitReturnStatement(CocoParser.ReturnStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBecomeStatement(CocoParser.BecomeStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBecomeStatement(CocoParser.BecomeStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterWhileStatement(CocoParser.WhileStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitWhileStatement(CocoParser.WhileStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterForStatement(CocoParser.ForStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitForStatement(CocoParser.ForStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBreakStatement(CocoParser.BreakStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBreakStatement(CocoParser.BreakStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterContinueStatement(CocoParser.ContinueStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitContinueStatement(CocoParser.ContinueStatementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPortElement(CocoParser.PortElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPortElement(CocoParser.PortElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFunctionInterfaceDeclaration(CocoParser.FunctionInterfaceDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFunctionInterfaceDeclaration(CocoParser.FunctionInterfaceDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSignalDeclaration(CocoParser.SignalDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSignalDeclaration(CocoParser.SignalDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStateMachineDeclaration(CocoParser.StateMachineDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStateMachineDeclaration(CocoParser.StateMachineDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStateMachineElement(CocoParser.StateMachineElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStateMachineElement(CocoParser.StateMachineElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStateDeclaration(CocoParser.StateDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStateDeclaration(CocoParser.StateDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEventStateDeclaration(CocoParser.EventStateDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEventStateDeclaration(CocoParser.EventStateDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExecutionStateDeclaration(CocoParser.ExecutionStateDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExecutionStateDeclaration(CocoParser.ExecutionStateDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEventStateElement(CocoParser.EventStateElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEventStateElement(CocoParser.EventStateElementContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEntryFunctionDeclaration(CocoParser.EntryFunctionDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEntryFunctionDeclaration(CocoParser.EntryFunctionDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExitFunctionDeclaration(CocoParser.ExitFunctionDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExitFunctionDeclaration(CocoParser.ExitFunctionDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStateInvariant(CocoParser.StateInvariantContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStateInvariant(CocoParser.StateInvariantContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterTransitionDeclaration(CocoParser.TransitionDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitTransitionDeclaration(CocoParser.TransitionDeclarationContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEventTransition(CocoParser.EventTransitionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEventTransition(CocoParser.EventTransitionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEventSource(CocoParser.EventSourceContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEventSource(CocoParser.EventSourceContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSpontaneousTransition(CocoParser.SpontaneousTransitionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSpontaneousTransition(CocoParser.SpontaneousTransitionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterTimerTransition(CocoParser.TimerTransitionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitTimerTransition(CocoParser.TimerTransitionContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEventHandler(CocoParser.EventHandlerContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEventHandler(CocoParser.EventHandlerContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterOffer(CocoParser.OfferContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitOffer(CocoParser.OfferContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterOfferClauses(CocoParser.OfferClausesContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitOfferClauses(CocoParser.OfferClausesContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterOfferClause(CocoParser.OfferClauseContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitOfferClause(CocoParser.OfferClauseContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterParameters(CocoParser.ParametersContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitParameters(CocoParser.ParametersContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterParameter(CocoParser.ParameterContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitParameter(CocoParser.ParameterContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLiteralExpression_(CocoParser.LiteralExpression_Context ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLiteralExpression_(CocoParser.LiteralExpression_Context ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBinaryType(CocoParser.BinaryTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBinaryType(CocoParser.BinaryTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterGroupType(CocoParser.GroupTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitGroupType(CocoParser.GroupTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFunctionType(CocoParser.FunctionTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFunctionType(CocoParser.FunctionTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterUnaryType(CocoParser.UnaryTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitUnaryType(CocoParser.UnaryTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLiteralType(CocoParser.LiteralTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLiteralType(CocoParser.LiteralTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterTypeReference(CocoParser.TypeReferenceContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitTypeReference(CocoParser.TypeReferenceContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterReferenceType(CocoParser.ReferenceTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitReferenceType(CocoParser.ReferenceTypeContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterTypes(CocoParser.TypesContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitTypes(CocoParser.TypesContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDotIdentifierList(CocoParser.DotIdentifierListContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDotIdentifierList(CocoParser.DotIdentifierListContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEveryRule(ParserRuleContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEveryRule(ParserRuleContext ctx) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitTerminal(TerminalNode node) { + } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitErrorNode(ErrorNode node) { + } } diff --git a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoBaseVisitor.java b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoBaseVisitor.java index ec60e5c0488..823ad559680 100644 --- a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoBaseVisitor.java +++ b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoBaseVisitor.java @@ -5,6 +5,7 @@ // CHECKSTYLE:OFF // Generated from net/sourceforge/pmd/lang/coco/ast/Coco.g4 by ANTLR 4.9.3 package net.sourceforge.pmd.lang.coco.ast; + import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; /** @@ -19,775 +20,1104 @@ */ @Deprecated @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public class CocoBaseVisitor extends AbstractParseTreeVisitor implements CocoVisitor { - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitModule(CocoParser.ModuleContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitDeclaration(CocoParser.DeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitAttribute(CocoParser.AttributeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitAttributeDeclaration(CocoParser.AttributeDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitImportDeclaration(CocoParser.ImportDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitVariableDeclaration(CocoParser.VariableDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitEnumDeclaration(CocoParser.EnumDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStructDeclaration(CocoParser.StructDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitTypeAliasDeclaration(CocoParser.TypeAliasDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitFunctionDeclaration(CocoParser.FunctionDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitInstanceDeclaration(CocoParser.InstanceDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitPortDeclaration(CocoParser.PortDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitComponentDeclaration(CocoParser.ComponentDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitExternalConstantDeclaration(CocoParser.ExternalConstantDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitExternalTypeDeclaration(CocoParser.ExternalTypeDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitExternalTypeElement(CocoParser.ExternalTypeElementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitExternalFunctionDeclaration(CocoParser.ExternalFunctionDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitGenericTypeDeclaration(CocoParser.GenericTypeDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitGenericTypes(CocoParser.GenericTypesContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitGenericType(CocoParser.GenericTypeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitEnumElement(CocoParser.EnumElementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitEnumCase(CocoParser.EnumCaseContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitCaseParameters(CocoParser.CaseParametersContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitCaseParameter(CocoParser.CaseParameterContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStructElement(CocoParser.StructElementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitFieldDeclaration(CocoParser.FieldDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitComponentElement(CocoParser.ComponentElementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStaticMemberDeclaration(CocoParser.StaticMemberDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitConstructorDeclaration(CocoParser.ConstructorDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitIfExpression(CocoParser.IfExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitTryOperatorExpression(CocoParser.TryOperatorExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitUnaryOperatorExpression(CocoParser.UnaryOperatorExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitOptionalExpression(CocoParser.OptionalExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitArithmicOrLogicalExpression(CocoParser.ArithmicOrLogicalExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitLiteralExpression(CocoParser.LiteralExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitArrayLiteralExpression(CocoParser.ArrayLiteralExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitNondetExpression(CocoParser.NondetExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitGroupedExpression(CocoParser.GroupedExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitBlockExpression(CocoParser.BlockExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitMatchExpression(CocoParser.MatchExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStructLiteralExpression(CocoParser.StructLiteralExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitMemberReferenceExpression(CocoParser.MemberReferenceExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitAssignmentExpression(CocoParser.AssignmentExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitVariableReferenceExpression(CocoParser.VariableReferenceExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitImplicitMemberExpression(CocoParser.ImplicitMemberExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitExternalFunction(CocoParser.ExternalFunctionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitCastExpression(CocoParser.CastExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStateInvariantExpression(CocoParser.StateInvariantExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitCallExpression(CocoParser.CallExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitExternalLiteral(CocoParser.ExternalLiteralContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitArraySubscriptExpression(CocoParser.ArraySubscriptExpressionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitBlockExpression_(CocoParser.BlockExpression_Context ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitIfExpression_(CocoParser.IfExpression_Context ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitMatchExpression_(CocoParser.MatchExpression_Context ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitNondetExpression_(CocoParser.NondetExpression_Context ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitFieldAssignments(CocoParser.FieldAssignmentsContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitFieldAssignment(CocoParser.FieldAssignmentContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitNondetClauses(CocoParser.NondetClausesContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitNondetClause(CocoParser.NondetClauseContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitMatchClauses(CocoParser.MatchClausesContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitMatchClause(CocoParser.MatchClauseContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitPattern(CocoParser.PatternContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitEnumCasePattern(CocoParser.EnumCasePatternContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitIdParameterPatterns(CocoParser.IdParameterPatternsContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitIdParameterPattern(CocoParser.IdParameterPatternContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitVariableDeclarationPattern(CocoParser.VariableDeclarationPatternContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitParameterPatterns(CocoParser.ParameterPatternsContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitParameterPattern(CocoParser.ParameterPatternContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitExpressions(CocoParser.ExpressionsContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStatement(CocoParser.StatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitDeclarationStatement(CocoParser.DeclarationStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitReturnStatement(CocoParser.ReturnStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitBecomeStatement(CocoParser.BecomeStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitWhileStatement(CocoParser.WhileStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitForStatement(CocoParser.ForStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitBreakStatement(CocoParser.BreakStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitContinueStatement(CocoParser.ContinueStatementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitPortElement(CocoParser.PortElementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitFunctionInterfaceDeclaration(CocoParser.FunctionInterfaceDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitSignalDeclaration(CocoParser.SignalDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStateMachineDeclaration(CocoParser.StateMachineDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStateMachineElement(CocoParser.StateMachineElementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStateDeclaration(CocoParser.StateDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitEventStateDeclaration(CocoParser.EventStateDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitExecutionStateDeclaration(CocoParser.ExecutionStateDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitEventStateElement(CocoParser.EventStateElementContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitEntryFunctionDeclaration(CocoParser.EntryFunctionDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitExitFunctionDeclaration(CocoParser.ExitFunctionDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitStateInvariant(CocoParser.StateInvariantContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitTransitionDeclaration(CocoParser.TransitionDeclarationContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitEventTransition(CocoParser.EventTransitionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitEventSource(CocoParser.EventSourceContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitSpontaneousTransition(CocoParser.SpontaneousTransitionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitTimerTransition(CocoParser.TimerTransitionContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitEventHandler(CocoParser.EventHandlerContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitOffer(CocoParser.OfferContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitOfferClauses(CocoParser.OfferClausesContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitOfferClause(CocoParser.OfferClauseContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitParameters(CocoParser.ParametersContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitParameter(CocoParser.ParameterContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitLiteralExpression_(CocoParser.LiteralExpression_Context ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitBinaryType(CocoParser.BinaryTypeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitGroupType(CocoParser.GroupTypeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitFunctionType(CocoParser.FunctionTypeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitUnaryType(CocoParser.UnaryTypeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitLiteralType(CocoParser.LiteralTypeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitTypeReference(CocoParser.TypeReferenceContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitReferenceType(CocoParser.ReferenceTypeContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitTypes(CocoParser.TypesContext ctx) { return visitChildren(ctx); } - /** - * {@inheritDoc} - * - *

The default implementation returns the result of calling - * {@link #visitChildren} on {@code ctx}.

- */ - @Override public T visitDotIdentifierList(CocoParser.DotIdentifierListContext ctx) { return visitChildren(ctx); } +public class CocoBaseVisitor extends AbstractParseTreeVisitor implements CocoVisitor { + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitModule(CocoParser.ModuleContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDeclaration(CocoParser.DeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAttribute(CocoParser.AttributeContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAttributeDeclaration(CocoParser.AttributeDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitImportDeclaration(CocoParser.ImportDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitVariableDeclaration(CocoParser.VariableDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitEnumDeclaration(CocoParser.EnumDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStructDeclaration(CocoParser.StructDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTypeAliasDeclaration(CocoParser.TypeAliasDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFunctionDeclaration(CocoParser.FunctionDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitInstanceDeclaration(CocoParser.InstanceDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitPortDeclaration(CocoParser.PortDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitComponentDeclaration(CocoParser.ComponentDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExternalConstantDeclaration(CocoParser.ExternalConstantDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExternalTypeDeclaration(CocoParser.ExternalTypeDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExternalTypeElement(CocoParser.ExternalTypeElementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExternalFunctionDeclaration(CocoParser.ExternalFunctionDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitGenericTypeDeclaration(CocoParser.GenericTypeDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitGenericTypes(CocoParser.GenericTypesContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitGenericType(CocoParser.GenericTypeContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitEnumElement(CocoParser.EnumElementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitEnumCase(CocoParser.EnumCaseContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitCaseParameters(CocoParser.CaseParametersContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitCaseParameter(CocoParser.CaseParameterContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStructElement(CocoParser.StructElementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFieldDeclaration(CocoParser.FieldDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitComponentElement(CocoParser.ComponentElementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStaticMemberDeclaration(CocoParser.StaticMemberDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitConstructorDeclaration(CocoParser.ConstructorDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIfExpression(CocoParser.IfExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTryOperatorExpression(CocoParser.TryOperatorExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitUnaryOperatorExpression(CocoParser.UnaryOperatorExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitOptionalExpression(CocoParser.OptionalExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitArithmicOrLogicalExpression(CocoParser.ArithmicOrLogicalExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLiteralExpression(CocoParser.LiteralExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitArrayLiteralExpression(CocoParser.ArrayLiteralExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNondetExpression(CocoParser.NondetExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitGroupedExpression(CocoParser.GroupedExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBlockExpression(CocoParser.BlockExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMatchExpression(CocoParser.MatchExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStructLiteralExpression(CocoParser.StructLiteralExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMemberReferenceExpression(CocoParser.MemberReferenceExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAssignmentExpression(CocoParser.AssignmentExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitVariableReferenceExpression(CocoParser.VariableReferenceExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitImplicitMemberExpression(CocoParser.ImplicitMemberExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExternalFunction(CocoParser.ExternalFunctionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitCastExpression(CocoParser.CastExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStateInvariantExpression(CocoParser.StateInvariantExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitCallExpression(CocoParser.CallExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExternalLiteral(CocoParser.ExternalLiteralContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitArraySubscriptExpression(CocoParser.ArraySubscriptExpressionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBlockExpression_(CocoParser.BlockExpression_Context ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIfExpression_(CocoParser.IfExpression_Context ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMatchExpression_(CocoParser.MatchExpression_Context ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNondetExpression_(CocoParser.NondetExpression_Context ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFieldAssignments(CocoParser.FieldAssignmentsContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFieldAssignment(CocoParser.FieldAssignmentContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNondetClauses(CocoParser.NondetClausesContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNondetClause(CocoParser.NondetClauseContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMatchClauses(CocoParser.MatchClausesContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitMatchClause(CocoParser.MatchClauseContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitPattern(CocoParser.PatternContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitEnumCasePattern(CocoParser.EnumCasePatternContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIdParameterPatterns(CocoParser.IdParameterPatternsContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIdParameterPattern(CocoParser.IdParameterPatternContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitVariableDeclarationPattern(CocoParser.VariableDeclarationPatternContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitParameterPatterns(CocoParser.ParameterPatternsContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitParameterPattern(CocoParser.ParameterPatternContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExpressions(CocoParser.ExpressionsContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStatement(CocoParser.StatementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDeclarationStatement(CocoParser.DeclarationStatementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitReturnStatement(CocoParser.ReturnStatementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBecomeStatement(CocoParser.BecomeStatementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitWhileStatement(CocoParser.WhileStatementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitForStatement(CocoParser.ForStatementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBreakStatement(CocoParser.BreakStatementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitContinueStatement(CocoParser.ContinueStatementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitPortElement(CocoParser.PortElementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFunctionInterfaceDeclaration(CocoParser.FunctionInterfaceDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSignalDeclaration(CocoParser.SignalDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStateMachineDeclaration(CocoParser.StateMachineDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStateMachineElement(CocoParser.StateMachineElementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStateDeclaration(CocoParser.StateDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitEventStateDeclaration(CocoParser.EventStateDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExecutionStateDeclaration(CocoParser.ExecutionStateDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitEventStateElement(CocoParser.EventStateElementContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitEntryFunctionDeclaration(CocoParser.EntryFunctionDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExitFunctionDeclaration(CocoParser.ExitFunctionDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitStateInvariant(CocoParser.StateInvariantContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTransitionDeclaration(CocoParser.TransitionDeclarationContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitEventTransition(CocoParser.EventTransitionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitEventSource(CocoParser.EventSourceContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitSpontaneousTransition(CocoParser.SpontaneousTransitionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTimerTransition(CocoParser.TimerTransitionContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitEventHandler(CocoParser.EventHandlerContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitOffer(CocoParser.OfferContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitOfferClauses(CocoParser.OfferClausesContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitOfferClause(CocoParser.OfferClauseContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitParameters(CocoParser.ParametersContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitParameter(CocoParser.ParameterContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLiteralExpression_(CocoParser.LiteralExpression_Context ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBinaryType(CocoParser.BinaryTypeContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitGroupType(CocoParser.GroupTypeContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFunctionType(CocoParser.FunctionTypeContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitUnaryType(CocoParser.UnaryTypeContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLiteralType(CocoParser.LiteralTypeContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTypeReference(CocoParser.TypeReferenceContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitReferenceType(CocoParser.ReferenceTypeContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTypes(CocoParser.TypesContext ctx) { + return visitChildren(ctx); + } + + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitDotIdentifierList(CocoParser.DotIdentifierListContext ctx) { + return visitChildren(ctx); + } } diff --git a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoListener.java b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoListener.java index bef3fbacbd1..0e339d69dbe 100644 --- a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoListener.java +++ b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoListener.java @@ -5,6 +5,7 @@ // CHECKSTYLE:OFF // Generated from net/sourceforge/pmd/lang/coco/ast/Coco.g4 by ANTLR 4.9.3 package net.sourceforge.pmd.lang.coco.ast; + import org.antlr.v4.runtime.tree.ParseTreeListener; /** @@ -15,1163 +16,1382 @@ */ @Deprecated @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public interface CocoListener extends ParseTreeListener { - /** - * Enter a parse tree produced by {@link CocoParser#module}. - * @param ctx the parse tree - */ - void enterModule(CocoParser.ModuleContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#module}. - * @param ctx the parse tree - */ - void exitModule(CocoParser.ModuleContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#declaration}. - * @param ctx the parse tree - */ - void enterDeclaration(CocoParser.DeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#declaration}. - * @param ctx the parse tree - */ - void exitDeclaration(CocoParser.DeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#attribute}. - * @param ctx the parse tree - */ - void enterAttribute(CocoParser.AttributeContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#attribute}. - * @param ctx the parse tree - */ - void exitAttribute(CocoParser.AttributeContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#attributeDeclaration}. - * @param ctx the parse tree - */ - void enterAttributeDeclaration(CocoParser.AttributeDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#attributeDeclaration}. - * @param ctx the parse tree - */ - void exitAttributeDeclaration(CocoParser.AttributeDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#importDeclaration}. - * @param ctx the parse tree - */ - void enterImportDeclaration(CocoParser.ImportDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#importDeclaration}. - * @param ctx the parse tree - */ - void exitImportDeclaration(CocoParser.ImportDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#variableDeclaration}. - * @param ctx the parse tree - */ - void enterVariableDeclaration(CocoParser.VariableDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#variableDeclaration}. - * @param ctx the parse tree - */ - void exitVariableDeclaration(CocoParser.VariableDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#enumDeclaration}. - * @param ctx the parse tree - */ - void enterEnumDeclaration(CocoParser.EnumDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#enumDeclaration}. - * @param ctx the parse tree - */ - void exitEnumDeclaration(CocoParser.EnumDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#structDeclaration}. - * @param ctx the parse tree - */ - void enterStructDeclaration(CocoParser.StructDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#structDeclaration}. - * @param ctx the parse tree - */ - void exitStructDeclaration(CocoParser.StructDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#typeAliasDeclaration}. - * @param ctx the parse tree - */ - void enterTypeAliasDeclaration(CocoParser.TypeAliasDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#typeAliasDeclaration}. - * @param ctx the parse tree - */ - void exitTypeAliasDeclaration(CocoParser.TypeAliasDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#functionDeclaration}. - * @param ctx the parse tree - */ - void enterFunctionDeclaration(CocoParser.FunctionDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#functionDeclaration}. - * @param ctx the parse tree - */ - void exitFunctionDeclaration(CocoParser.FunctionDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#instanceDeclaration}. - * @param ctx the parse tree - */ - void enterInstanceDeclaration(CocoParser.InstanceDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#instanceDeclaration}. - * @param ctx the parse tree - */ - void exitInstanceDeclaration(CocoParser.InstanceDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#portDeclaration}. - * @param ctx the parse tree - */ - void enterPortDeclaration(CocoParser.PortDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#portDeclaration}. - * @param ctx the parse tree - */ - void exitPortDeclaration(CocoParser.PortDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#componentDeclaration}. - * @param ctx the parse tree - */ - void enterComponentDeclaration(CocoParser.ComponentDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#componentDeclaration}. - * @param ctx the parse tree - */ - void exitComponentDeclaration(CocoParser.ComponentDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#externalConstantDeclaration}. - * @param ctx the parse tree - */ - void enterExternalConstantDeclaration(CocoParser.ExternalConstantDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#externalConstantDeclaration}. - * @param ctx the parse tree - */ - void exitExternalConstantDeclaration(CocoParser.ExternalConstantDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#externalTypeDeclaration}. - * @param ctx the parse tree - */ - void enterExternalTypeDeclaration(CocoParser.ExternalTypeDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#externalTypeDeclaration}. - * @param ctx the parse tree - */ - void exitExternalTypeDeclaration(CocoParser.ExternalTypeDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#externalTypeElement}. - * @param ctx the parse tree - */ - void enterExternalTypeElement(CocoParser.ExternalTypeElementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#externalTypeElement}. - * @param ctx the parse tree - */ - void exitExternalTypeElement(CocoParser.ExternalTypeElementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#externalFunctionDeclaration}. - * @param ctx the parse tree - */ - void enterExternalFunctionDeclaration(CocoParser.ExternalFunctionDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#externalFunctionDeclaration}. - * @param ctx the parse tree - */ - void exitExternalFunctionDeclaration(CocoParser.ExternalFunctionDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#genericTypeDeclaration}. - * @param ctx the parse tree - */ - void enterGenericTypeDeclaration(CocoParser.GenericTypeDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#genericTypeDeclaration}. - * @param ctx the parse tree - */ - void exitGenericTypeDeclaration(CocoParser.GenericTypeDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#genericTypes}. - * @param ctx the parse tree - */ - void enterGenericTypes(CocoParser.GenericTypesContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#genericTypes}. - * @param ctx the parse tree - */ - void exitGenericTypes(CocoParser.GenericTypesContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#genericType}. - * @param ctx the parse tree - */ - void enterGenericType(CocoParser.GenericTypeContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#genericType}. - * @param ctx the parse tree - */ - void exitGenericType(CocoParser.GenericTypeContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#enumElement}. - * @param ctx the parse tree - */ - void enterEnumElement(CocoParser.EnumElementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#enumElement}. - * @param ctx the parse tree - */ - void exitEnumElement(CocoParser.EnumElementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#enumCase}. - * @param ctx the parse tree - */ - void enterEnumCase(CocoParser.EnumCaseContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#enumCase}. - * @param ctx the parse tree - */ - void exitEnumCase(CocoParser.EnumCaseContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#caseParameters}. - * @param ctx the parse tree - */ - void enterCaseParameters(CocoParser.CaseParametersContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#caseParameters}. - * @param ctx the parse tree - */ - void exitCaseParameters(CocoParser.CaseParametersContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#caseParameter}. - * @param ctx the parse tree - */ - void enterCaseParameter(CocoParser.CaseParameterContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#caseParameter}. - * @param ctx the parse tree - */ - void exitCaseParameter(CocoParser.CaseParameterContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#structElement}. - * @param ctx the parse tree - */ - void enterStructElement(CocoParser.StructElementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#structElement}. - * @param ctx the parse tree - */ - void exitStructElement(CocoParser.StructElementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#fieldDeclaration}. - * @param ctx the parse tree - */ - void enterFieldDeclaration(CocoParser.FieldDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#fieldDeclaration}. - * @param ctx the parse tree - */ - void exitFieldDeclaration(CocoParser.FieldDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#componentElement}. - * @param ctx the parse tree - */ - void enterComponentElement(CocoParser.ComponentElementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#componentElement}. - * @param ctx the parse tree - */ - void exitComponentElement(CocoParser.ComponentElementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#staticMemberDeclaration}. - * @param ctx the parse tree - */ - void enterStaticMemberDeclaration(CocoParser.StaticMemberDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#staticMemberDeclaration}. - * @param ctx the parse tree - */ - void exitStaticMemberDeclaration(CocoParser.StaticMemberDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#constructorDeclaration}. - * @param ctx the parse tree - */ - void enterConstructorDeclaration(CocoParser.ConstructorDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#constructorDeclaration}. - * @param ctx the parse tree - */ - void exitConstructorDeclaration(CocoParser.ConstructorDeclarationContext ctx); - /** - * Enter a parse tree produced by the {@code IfExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterIfExpression(CocoParser.IfExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code IfExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitIfExpression(CocoParser.IfExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code TryOperatorExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterTryOperatorExpression(CocoParser.TryOperatorExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code TryOperatorExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitTryOperatorExpression(CocoParser.TryOperatorExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code UnaryOperatorExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterUnaryOperatorExpression(CocoParser.UnaryOperatorExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code UnaryOperatorExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitUnaryOperatorExpression(CocoParser.UnaryOperatorExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code OptionalExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterOptionalExpression(CocoParser.OptionalExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code OptionalExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitOptionalExpression(CocoParser.OptionalExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code ArithmicOrLogicalExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterArithmicOrLogicalExpression(CocoParser.ArithmicOrLogicalExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code ArithmicOrLogicalExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitArithmicOrLogicalExpression(CocoParser.ArithmicOrLogicalExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code LiteralExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterLiteralExpression(CocoParser.LiteralExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code LiteralExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitLiteralExpression(CocoParser.LiteralExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code ArrayLiteralExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterArrayLiteralExpression(CocoParser.ArrayLiteralExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code ArrayLiteralExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitArrayLiteralExpression(CocoParser.ArrayLiteralExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code NondetExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterNondetExpression(CocoParser.NondetExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code NondetExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitNondetExpression(CocoParser.NondetExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code GroupedExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterGroupedExpression(CocoParser.GroupedExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code GroupedExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitGroupedExpression(CocoParser.GroupedExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code BlockExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterBlockExpression(CocoParser.BlockExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code BlockExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitBlockExpression(CocoParser.BlockExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code MatchExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterMatchExpression(CocoParser.MatchExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code MatchExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitMatchExpression(CocoParser.MatchExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code StructLiteralExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterStructLiteralExpression(CocoParser.StructLiteralExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code StructLiteralExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitStructLiteralExpression(CocoParser.StructLiteralExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code MemberReferenceExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterMemberReferenceExpression(CocoParser.MemberReferenceExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code MemberReferenceExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitMemberReferenceExpression(CocoParser.MemberReferenceExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code AssignmentExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterAssignmentExpression(CocoParser.AssignmentExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code AssignmentExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitAssignmentExpression(CocoParser.AssignmentExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code VariableReferenceExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterVariableReferenceExpression(CocoParser.VariableReferenceExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code VariableReferenceExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitVariableReferenceExpression(CocoParser.VariableReferenceExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code ImplicitMemberExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterImplicitMemberExpression(CocoParser.ImplicitMemberExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code ImplicitMemberExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitImplicitMemberExpression(CocoParser.ImplicitMemberExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code ExternalFunction} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterExternalFunction(CocoParser.ExternalFunctionContext ctx); - /** - * Exit a parse tree produced by the {@code ExternalFunction} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitExternalFunction(CocoParser.ExternalFunctionContext ctx); - /** - * Enter a parse tree produced by the {@code CastExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterCastExpression(CocoParser.CastExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code CastExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitCastExpression(CocoParser.CastExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code StateInvariantExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterStateInvariantExpression(CocoParser.StateInvariantExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code StateInvariantExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitStateInvariantExpression(CocoParser.StateInvariantExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code CallExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterCallExpression(CocoParser.CallExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code CallExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitCallExpression(CocoParser.CallExpressionContext ctx); - /** - * Enter a parse tree produced by the {@code ExternalLiteral} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterExternalLiteral(CocoParser.ExternalLiteralContext ctx); - /** - * Exit a parse tree produced by the {@code ExternalLiteral} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitExternalLiteral(CocoParser.ExternalLiteralContext ctx); - /** - * Enter a parse tree produced by the {@code ArraySubscriptExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void enterArraySubscriptExpression(CocoParser.ArraySubscriptExpressionContext ctx); - /** - * Exit a parse tree produced by the {@code ArraySubscriptExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - */ - void exitArraySubscriptExpression(CocoParser.ArraySubscriptExpressionContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#blockExpression_}. - * @param ctx the parse tree - */ - void enterBlockExpression_(CocoParser.BlockExpression_Context ctx); - /** - * Exit a parse tree produced by {@link CocoParser#blockExpression_}. - * @param ctx the parse tree - */ - void exitBlockExpression_(CocoParser.BlockExpression_Context ctx); - /** - * Enter a parse tree produced by {@link CocoParser#ifExpression_}. - * @param ctx the parse tree - */ - void enterIfExpression_(CocoParser.IfExpression_Context ctx); - /** - * Exit a parse tree produced by {@link CocoParser#ifExpression_}. - * @param ctx the parse tree - */ - void exitIfExpression_(CocoParser.IfExpression_Context ctx); - /** - * Enter a parse tree produced by {@link CocoParser#matchExpression_}. - * @param ctx the parse tree - */ - void enterMatchExpression_(CocoParser.MatchExpression_Context ctx); - /** - * Exit a parse tree produced by {@link CocoParser#matchExpression_}. - * @param ctx the parse tree - */ - void exitMatchExpression_(CocoParser.MatchExpression_Context ctx); - /** - * Enter a parse tree produced by {@link CocoParser#nondetExpression_}. - * @param ctx the parse tree - */ - void enterNondetExpression_(CocoParser.NondetExpression_Context ctx); - /** - * Exit a parse tree produced by {@link CocoParser#nondetExpression_}. - * @param ctx the parse tree - */ - void exitNondetExpression_(CocoParser.NondetExpression_Context ctx); - /** - * Enter a parse tree produced by {@link CocoParser#fieldAssignments}. - * @param ctx the parse tree - */ - void enterFieldAssignments(CocoParser.FieldAssignmentsContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#fieldAssignments}. - * @param ctx the parse tree - */ - void exitFieldAssignments(CocoParser.FieldAssignmentsContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#fieldAssignment}. - * @param ctx the parse tree - */ - void enterFieldAssignment(CocoParser.FieldAssignmentContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#fieldAssignment}. - * @param ctx the parse tree - */ - void exitFieldAssignment(CocoParser.FieldAssignmentContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#nondetClauses}. - * @param ctx the parse tree - */ - void enterNondetClauses(CocoParser.NondetClausesContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#nondetClauses}. - * @param ctx the parse tree - */ - void exitNondetClauses(CocoParser.NondetClausesContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#nondetClause}. - * @param ctx the parse tree - */ - void enterNondetClause(CocoParser.NondetClauseContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#nondetClause}. - * @param ctx the parse tree - */ - void exitNondetClause(CocoParser.NondetClauseContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#matchClauses}. - * @param ctx the parse tree - */ - void enterMatchClauses(CocoParser.MatchClausesContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#matchClauses}. - * @param ctx the parse tree - */ - void exitMatchClauses(CocoParser.MatchClausesContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#matchClause}. - * @param ctx the parse tree - */ - void enterMatchClause(CocoParser.MatchClauseContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#matchClause}. - * @param ctx the parse tree - */ - void exitMatchClause(CocoParser.MatchClauseContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#pattern}. - * @param ctx the parse tree - */ - void enterPattern(CocoParser.PatternContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#pattern}. - * @param ctx the parse tree - */ - void exitPattern(CocoParser.PatternContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#enumCasePattern}. - * @param ctx the parse tree - */ - void enterEnumCasePattern(CocoParser.EnumCasePatternContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#enumCasePattern}. - * @param ctx the parse tree - */ - void exitEnumCasePattern(CocoParser.EnumCasePatternContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#idParameterPatterns}. - * @param ctx the parse tree - */ - void enterIdParameterPatterns(CocoParser.IdParameterPatternsContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#idParameterPatterns}. - * @param ctx the parse tree - */ - void exitIdParameterPatterns(CocoParser.IdParameterPatternsContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#idParameterPattern}. - * @param ctx the parse tree - */ - void enterIdParameterPattern(CocoParser.IdParameterPatternContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#idParameterPattern}. - * @param ctx the parse tree - */ - void exitIdParameterPattern(CocoParser.IdParameterPatternContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#variableDeclarationPattern}. - * @param ctx the parse tree - */ - void enterVariableDeclarationPattern(CocoParser.VariableDeclarationPatternContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#variableDeclarationPattern}. - * @param ctx the parse tree - */ - void exitVariableDeclarationPattern(CocoParser.VariableDeclarationPatternContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#parameterPatterns}. - * @param ctx the parse tree - */ - void enterParameterPatterns(CocoParser.ParameterPatternsContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#parameterPatterns}. - * @param ctx the parse tree - */ - void exitParameterPatterns(CocoParser.ParameterPatternsContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#parameterPattern}. - * @param ctx the parse tree - */ - void enterParameterPattern(CocoParser.ParameterPatternContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#parameterPattern}. - * @param ctx the parse tree - */ - void exitParameterPattern(CocoParser.ParameterPatternContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#expressions}. - * @param ctx the parse tree - */ - void enterExpressions(CocoParser.ExpressionsContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#expressions}. - * @param ctx the parse tree - */ - void exitExpressions(CocoParser.ExpressionsContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#statement}. - * @param ctx the parse tree - */ - void enterStatement(CocoParser.StatementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#statement}. - * @param ctx the parse tree - */ - void exitStatement(CocoParser.StatementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#declarationStatement}. - * @param ctx the parse tree - */ - void enterDeclarationStatement(CocoParser.DeclarationStatementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#declarationStatement}. - * @param ctx the parse tree - */ - void exitDeclarationStatement(CocoParser.DeclarationStatementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#returnStatement}. - * @param ctx the parse tree - */ - void enterReturnStatement(CocoParser.ReturnStatementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#returnStatement}. - * @param ctx the parse tree - */ - void exitReturnStatement(CocoParser.ReturnStatementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#becomeStatement}. - * @param ctx the parse tree - */ - void enterBecomeStatement(CocoParser.BecomeStatementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#becomeStatement}. - * @param ctx the parse tree - */ - void exitBecomeStatement(CocoParser.BecomeStatementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#whileStatement}. - * @param ctx the parse tree - */ - void enterWhileStatement(CocoParser.WhileStatementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#whileStatement}. - * @param ctx the parse tree - */ - void exitWhileStatement(CocoParser.WhileStatementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#forStatement}. - * @param ctx the parse tree - */ - void enterForStatement(CocoParser.ForStatementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#forStatement}. - * @param ctx the parse tree - */ - void exitForStatement(CocoParser.ForStatementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#breakStatement}. - * @param ctx the parse tree - */ - void enterBreakStatement(CocoParser.BreakStatementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#breakStatement}. - * @param ctx the parse tree - */ - void exitBreakStatement(CocoParser.BreakStatementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#continueStatement}. - * @param ctx the parse tree - */ - void enterContinueStatement(CocoParser.ContinueStatementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#continueStatement}. - * @param ctx the parse tree - */ - void exitContinueStatement(CocoParser.ContinueStatementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#portElement}. - * @param ctx the parse tree - */ - void enterPortElement(CocoParser.PortElementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#portElement}. - * @param ctx the parse tree - */ - void exitPortElement(CocoParser.PortElementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#functionInterfaceDeclaration}. - * @param ctx the parse tree - */ - void enterFunctionInterfaceDeclaration(CocoParser.FunctionInterfaceDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#functionInterfaceDeclaration}. - * @param ctx the parse tree - */ - void exitFunctionInterfaceDeclaration(CocoParser.FunctionInterfaceDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#signalDeclaration}. - * @param ctx the parse tree - */ - void enterSignalDeclaration(CocoParser.SignalDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#signalDeclaration}. - * @param ctx the parse tree - */ - void exitSignalDeclaration(CocoParser.SignalDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#stateMachineDeclaration}. - * @param ctx the parse tree - */ - void enterStateMachineDeclaration(CocoParser.StateMachineDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#stateMachineDeclaration}. - * @param ctx the parse tree - */ - void exitStateMachineDeclaration(CocoParser.StateMachineDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#stateMachineElement}. - * @param ctx the parse tree - */ - void enterStateMachineElement(CocoParser.StateMachineElementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#stateMachineElement}. - * @param ctx the parse tree - */ - void exitStateMachineElement(CocoParser.StateMachineElementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#stateDeclaration}. - * @param ctx the parse tree - */ - void enterStateDeclaration(CocoParser.StateDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#stateDeclaration}. - * @param ctx the parse tree - */ - void exitStateDeclaration(CocoParser.StateDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#eventStateDeclaration}. - * @param ctx the parse tree - */ - void enterEventStateDeclaration(CocoParser.EventStateDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#eventStateDeclaration}. - * @param ctx the parse tree - */ - void exitEventStateDeclaration(CocoParser.EventStateDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#executionStateDeclaration}. - * @param ctx the parse tree - */ - void enterExecutionStateDeclaration(CocoParser.ExecutionStateDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#executionStateDeclaration}. - * @param ctx the parse tree - */ - void exitExecutionStateDeclaration(CocoParser.ExecutionStateDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#eventStateElement}. - * @param ctx the parse tree - */ - void enterEventStateElement(CocoParser.EventStateElementContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#eventStateElement}. - * @param ctx the parse tree - */ - void exitEventStateElement(CocoParser.EventStateElementContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#entryFunctionDeclaration}. - * @param ctx the parse tree - */ - void enterEntryFunctionDeclaration(CocoParser.EntryFunctionDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#entryFunctionDeclaration}. - * @param ctx the parse tree - */ - void exitEntryFunctionDeclaration(CocoParser.EntryFunctionDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#exitFunctionDeclaration}. - * @param ctx the parse tree - */ - void enterExitFunctionDeclaration(CocoParser.ExitFunctionDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#exitFunctionDeclaration}. - * @param ctx the parse tree - */ - void exitExitFunctionDeclaration(CocoParser.ExitFunctionDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#stateInvariant}. - * @param ctx the parse tree - */ - void enterStateInvariant(CocoParser.StateInvariantContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#stateInvariant}. - * @param ctx the parse tree - */ - void exitStateInvariant(CocoParser.StateInvariantContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#transitionDeclaration}. - * @param ctx the parse tree - */ - void enterTransitionDeclaration(CocoParser.TransitionDeclarationContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#transitionDeclaration}. - * @param ctx the parse tree - */ - void exitTransitionDeclaration(CocoParser.TransitionDeclarationContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#eventTransition}. - * @param ctx the parse tree - */ - void enterEventTransition(CocoParser.EventTransitionContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#eventTransition}. - * @param ctx the parse tree - */ - void exitEventTransition(CocoParser.EventTransitionContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#eventSource}. - * @param ctx the parse tree - */ - void enterEventSource(CocoParser.EventSourceContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#eventSource}. - * @param ctx the parse tree - */ - void exitEventSource(CocoParser.EventSourceContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#spontaneousTransition}. - * @param ctx the parse tree - */ - void enterSpontaneousTransition(CocoParser.SpontaneousTransitionContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#spontaneousTransition}. - * @param ctx the parse tree - */ - void exitSpontaneousTransition(CocoParser.SpontaneousTransitionContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#timerTransition}. - * @param ctx the parse tree - */ - void enterTimerTransition(CocoParser.TimerTransitionContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#timerTransition}. - * @param ctx the parse tree - */ - void exitTimerTransition(CocoParser.TimerTransitionContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#eventHandler}. - * @param ctx the parse tree - */ - void enterEventHandler(CocoParser.EventHandlerContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#eventHandler}. - * @param ctx the parse tree - */ - void exitEventHandler(CocoParser.EventHandlerContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#offer}. - * @param ctx the parse tree - */ - void enterOffer(CocoParser.OfferContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#offer}. - * @param ctx the parse tree - */ - void exitOffer(CocoParser.OfferContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#offerClauses}. - * @param ctx the parse tree - */ - void enterOfferClauses(CocoParser.OfferClausesContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#offerClauses}. - * @param ctx the parse tree - */ - void exitOfferClauses(CocoParser.OfferClausesContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#offerClause}. - * @param ctx the parse tree - */ - void enterOfferClause(CocoParser.OfferClauseContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#offerClause}. - * @param ctx the parse tree - */ - void exitOfferClause(CocoParser.OfferClauseContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#parameters}. - * @param ctx the parse tree - */ - void enterParameters(CocoParser.ParametersContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#parameters}. - * @param ctx the parse tree - */ - void exitParameters(CocoParser.ParametersContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#parameter}. - * @param ctx the parse tree - */ - void enterParameter(CocoParser.ParameterContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#parameter}. - * @param ctx the parse tree - */ - void exitParameter(CocoParser.ParameterContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#literalExpression_}. - * @param ctx the parse tree - */ - void enterLiteralExpression_(CocoParser.LiteralExpression_Context ctx); - /** - * Exit a parse tree produced by {@link CocoParser#literalExpression_}. - * @param ctx the parse tree - */ - void exitLiteralExpression_(CocoParser.LiteralExpression_Context ctx); - /** - * Enter a parse tree produced by the {@code BinaryType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void enterBinaryType(CocoParser.BinaryTypeContext ctx); - /** - * Exit a parse tree produced by the {@code BinaryType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void exitBinaryType(CocoParser.BinaryTypeContext ctx); - /** - * Enter a parse tree produced by the {@code GroupType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void enterGroupType(CocoParser.GroupTypeContext ctx); - /** - * Exit a parse tree produced by the {@code GroupType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void exitGroupType(CocoParser.GroupTypeContext ctx); - /** - * Enter a parse tree produced by the {@code FunctionType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void enterFunctionType(CocoParser.FunctionTypeContext ctx); - /** - * Exit a parse tree produced by the {@code FunctionType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void exitFunctionType(CocoParser.FunctionTypeContext ctx); - /** - * Enter a parse tree produced by the {@code UnaryType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void enterUnaryType(CocoParser.UnaryTypeContext ctx); - /** - * Exit a parse tree produced by the {@code UnaryType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void exitUnaryType(CocoParser.UnaryTypeContext ctx); - /** - * Enter a parse tree produced by the {@code LiteralType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void enterLiteralType(CocoParser.LiteralTypeContext ctx); - /** - * Exit a parse tree produced by the {@code LiteralType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void exitLiteralType(CocoParser.LiteralTypeContext ctx); - /** - * Enter a parse tree produced by the {@code TypeReference} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void enterTypeReference(CocoParser.TypeReferenceContext ctx); - /** - * Exit a parse tree produced by the {@code TypeReference} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void exitTypeReference(CocoParser.TypeReferenceContext ctx); - /** - * Enter a parse tree produced by the {@code ReferenceType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void enterReferenceType(CocoParser.ReferenceTypeContext ctx); - /** - * Exit a parse tree produced by the {@code ReferenceType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - */ - void exitReferenceType(CocoParser.ReferenceTypeContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#types}. - * @param ctx the parse tree - */ - void enterTypes(CocoParser.TypesContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#types}. - * @param ctx the parse tree - */ - void exitTypes(CocoParser.TypesContext ctx); - /** - * Enter a parse tree produced by {@link CocoParser#dotIdentifierList}. - * @param ctx the parse tree - */ - void enterDotIdentifierList(CocoParser.DotIdentifierListContext ctx); - /** - * Exit a parse tree produced by {@link CocoParser#dotIdentifierList}. - * @param ctx the parse tree - */ - void exitDotIdentifierList(CocoParser.DotIdentifierListContext ctx); +public interface CocoListener extends ParseTreeListener { + /** + * Enter a parse tree produced by {@link CocoParser#module}. + * @param ctx the parse tree + */ + void enterModule(CocoParser.ModuleContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#module}. + * @param ctx the parse tree + */ + void exitModule(CocoParser.ModuleContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#declaration}. + * @param ctx the parse tree + */ + void enterDeclaration(CocoParser.DeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#declaration}. + * @param ctx the parse tree + */ + void exitDeclaration(CocoParser.DeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#attribute}. + * @param ctx the parse tree + */ + void enterAttribute(CocoParser.AttributeContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#attribute}. + * @param ctx the parse tree + */ + void exitAttribute(CocoParser.AttributeContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#attributeDeclaration}. + * @param ctx the parse tree + */ + void enterAttributeDeclaration(CocoParser.AttributeDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#attributeDeclaration}. + * @param ctx the parse tree + */ + void exitAttributeDeclaration(CocoParser.AttributeDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#importDeclaration}. + * @param ctx the parse tree + */ + void enterImportDeclaration(CocoParser.ImportDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#importDeclaration}. + * @param ctx the parse tree + */ + void exitImportDeclaration(CocoParser.ImportDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#variableDeclaration}. + * @param ctx the parse tree + */ + void enterVariableDeclaration(CocoParser.VariableDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#variableDeclaration}. + * @param ctx the parse tree + */ + void exitVariableDeclaration(CocoParser.VariableDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#enumDeclaration}. + * @param ctx the parse tree + */ + void enterEnumDeclaration(CocoParser.EnumDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#enumDeclaration}. + * @param ctx the parse tree + */ + void exitEnumDeclaration(CocoParser.EnumDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#structDeclaration}. + * @param ctx the parse tree + */ + void enterStructDeclaration(CocoParser.StructDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#structDeclaration}. + * @param ctx the parse tree + */ + void exitStructDeclaration(CocoParser.StructDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#typeAliasDeclaration}. + * @param ctx the parse tree + */ + void enterTypeAliasDeclaration(CocoParser.TypeAliasDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#typeAliasDeclaration}. + * @param ctx the parse tree + */ + void exitTypeAliasDeclaration(CocoParser.TypeAliasDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#functionDeclaration}. + * @param ctx the parse tree + */ + void enterFunctionDeclaration(CocoParser.FunctionDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#functionDeclaration}. + * @param ctx the parse tree + */ + void exitFunctionDeclaration(CocoParser.FunctionDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#instanceDeclaration}. + * @param ctx the parse tree + */ + void enterInstanceDeclaration(CocoParser.InstanceDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#instanceDeclaration}. + * @param ctx the parse tree + */ + void exitInstanceDeclaration(CocoParser.InstanceDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#portDeclaration}. + * @param ctx the parse tree + */ + void enterPortDeclaration(CocoParser.PortDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#portDeclaration}. + * @param ctx the parse tree + */ + void exitPortDeclaration(CocoParser.PortDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#componentDeclaration}. + * @param ctx the parse tree + */ + void enterComponentDeclaration(CocoParser.ComponentDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#componentDeclaration}. + * @param ctx the parse tree + */ + void exitComponentDeclaration(CocoParser.ComponentDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#externalConstantDeclaration}. + * @param ctx the parse tree + */ + void enterExternalConstantDeclaration(CocoParser.ExternalConstantDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#externalConstantDeclaration}. + * @param ctx the parse tree + */ + void exitExternalConstantDeclaration(CocoParser.ExternalConstantDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#externalTypeDeclaration}. + * @param ctx the parse tree + */ + void enterExternalTypeDeclaration(CocoParser.ExternalTypeDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#externalTypeDeclaration}. + * @param ctx the parse tree + */ + void exitExternalTypeDeclaration(CocoParser.ExternalTypeDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#externalTypeElement}. + * @param ctx the parse tree + */ + void enterExternalTypeElement(CocoParser.ExternalTypeElementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#externalTypeElement}. + * @param ctx the parse tree + */ + void exitExternalTypeElement(CocoParser.ExternalTypeElementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#externalFunctionDeclaration}. + * @param ctx the parse tree + */ + void enterExternalFunctionDeclaration(CocoParser.ExternalFunctionDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#externalFunctionDeclaration}. + * @param ctx the parse tree + */ + void exitExternalFunctionDeclaration(CocoParser.ExternalFunctionDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#genericTypeDeclaration}. + * @param ctx the parse tree + */ + void enterGenericTypeDeclaration(CocoParser.GenericTypeDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#genericTypeDeclaration}. + * @param ctx the parse tree + */ + void exitGenericTypeDeclaration(CocoParser.GenericTypeDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#genericTypes}. + * @param ctx the parse tree + */ + void enterGenericTypes(CocoParser.GenericTypesContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#genericTypes}. + * @param ctx the parse tree + */ + void exitGenericTypes(CocoParser.GenericTypesContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#genericType}. + * @param ctx the parse tree + */ + void enterGenericType(CocoParser.GenericTypeContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#genericType}. + * @param ctx the parse tree + */ + void exitGenericType(CocoParser.GenericTypeContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#enumElement}. + * @param ctx the parse tree + */ + void enterEnumElement(CocoParser.EnumElementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#enumElement}. + * @param ctx the parse tree + */ + void exitEnumElement(CocoParser.EnumElementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#enumCase}. + * @param ctx the parse tree + */ + void enterEnumCase(CocoParser.EnumCaseContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#enumCase}. + * @param ctx the parse tree + */ + void exitEnumCase(CocoParser.EnumCaseContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#caseParameters}. + * @param ctx the parse tree + */ + void enterCaseParameters(CocoParser.CaseParametersContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#caseParameters}. + * @param ctx the parse tree + */ + void exitCaseParameters(CocoParser.CaseParametersContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#caseParameter}. + * @param ctx the parse tree + */ + void enterCaseParameter(CocoParser.CaseParameterContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#caseParameter}. + * @param ctx the parse tree + */ + void exitCaseParameter(CocoParser.CaseParameterContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#structElement}. + * @param ctx the parse tree + */ + void enterStructElement(CocoParser.StructElementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#structElement}. + * @param ctx the parse tree + */ + void exitStructElement(CocoParser.StructElementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#fieldDeclaration}. + * @param ctx the parse tree + */ + void enterFieldDeclaration(CocoParser.FieldDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#fieldDeclaration}. + * @param ctx the parse tree + */ + void exitFieldDeclaration(CocoParser.FieldDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#componentElement}. + * @param ctx the parse tree + */ + void enterComponentElement(CocoParser.ComponentElementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#componentElement}. + * @param ctx the parse tree + */ + void exitComponentElement(CocoParser.ComponentElementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#staticMemberDeclaration}. + * @param ctx the parse tree + */ + void enterStaticMemberDeclaration(CocoParser.StaticMemberDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#staticMemberDeclaration}. + * @param ctx the parse tree + */ + void exitStaticMemberDeclaration(CocoParser.StaticMemberDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#constructorDeclaration}. + * @param ctx the parse tree + */ + void enterConstructorDeclaration(CocoParser.ConstructorDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#constructorDeclaration}. + * @param ctx the parse tree + */ + void exitConstructorDeclaration(CocoParser.ConstructorDeclarationContext ctx); + + /** + * Enter a parse tree produced by the {@code IfExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterIfExpression(CocoParser.IfExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code IfExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitIfExpression(CocoParser.IfExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code TryOperatorExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterTryOperatorExpression(CocoParser.TryOperatorExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code TryOperatorExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitTryOperatorExpression(CocoParser.TryOperatorExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code UnaryOperatorExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterUnaryOperatorExpression(CocoParser.UnaryOperatorExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code UnaryOperatorExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitUnaryOperatorExpression(CocoParser.UnaryOperatorExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code OptionalExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterOptionalExpression(CocoParser.OptionalExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code OptionalExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitOptionalExpression(CocoParser.OptionalExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code ArithmicOrLogicalExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterArithmicOrLogicalExpression(CocoParser.ArithmicOrLogicalExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code ArithmicOrLogicalExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitArithmicOrLogicalExpression(CocoParser.ArithmicOrLogicalExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code LiteralExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterLiteralExpression(CocoParser.LiteralExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code LiteralExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitLiteralExpression(CocoParser.LiteralExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code ArrayLiteralExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterArrayLiteralExpression(CocoParser.ArrayLiteralExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code ArrayLiteralExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitArrayLiteralExpression(CocoParser.ArrayLiteralExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code NondetExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterNondetExpression(CocoParser.NondetExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code NondetExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitNondetExpression(CocoParser.NondetExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code GroupedExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterGroupedExpression(CocoParser.GroupedExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code GroupedExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitGroupedExpression(CocoParser.GroupedExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code BlockExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterBlockExpression(CocoParser.BlockExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code BlockExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitBlockExpression(CocoParser.BlockExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code MatchExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterMatchExpression(CocoParser.MatchExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code MatchExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitMatchExpression(CocoParser.MatchExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code StructLiteralExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterStructLiteralExpression(CocoParser.StructLiteralExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code StructLiteralExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitStructLiteralExpression(CocoParser.StructLiteralExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code MemberReferenceExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterMemberReferenceExpression(CocoParser.MemberReferenceExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code MemberReferenceExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitMemberReferenceExpression(CocoParser.MemberReferenceExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code AssignmentExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterAssignmentExpression(CocoParser.AssignmentExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code AssignmentExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitAssignmentExpression(CocoParser.AssignmentExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code VariableReferenceExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterVariableReferenceExpression(CocoParser.VariableReferenceExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code VariableReferenceExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitVariableReferenceExpression(CocoParser.VariableReferenceExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code ImplicitMemberExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterImplicitMemberExpression(CocoParser.ImplicitMemberExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code ImplicitMemberExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitImplicitMemberExpression(CocoParser.ImplicitMemberExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code ExternalFunction} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterExternalFunction(CocoParser.ExternalFunctionContext ctx); + + /** + * Exit a parse tree produced by the {@code ExternalFunction} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitExternalFunction(CocoParser.ExternalFunctionContext ctx); + + /** + * Enter a parse tree produced by the {@code CastExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterCastExpression(CocoParser.CastExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code CastExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitCastExpression(CocoParser.CastExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code StateInvariantExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterStateInvariantExpression(CocoParser.StateInvariantExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code StateInvariantExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitStateInvariantExpression(CocoParser.StateInvariantExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code CallExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterCallExpression(CocoParser.CallExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code CallExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitCallExpression(CocoParser.CallExpressionContext ctx); + + /** + * Enter a parse tree produced by the {@code ExternalLiteral} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterExternalLiteral(CocoParser.ExternalLiteralContext ctx); + + /** + * Exit a parse tree produced by the {@code ExternalLiteral} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitExternalLiteral(CocoParser.ExternalLiteralContext ctx); + + /** + * Enter a parse tree produced by the {@code ArraySubscriptExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void enterArraySubscriptExpression(CocoParser.ArraySubscriptExpressionContext ctx); + + /** + * Exit a parse tree produced by the {@code ArraySubscriptExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + */ + void exitArraySubscriptExpression(CocoParser.ArraySubscriptExpressionContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#blockExpression_}. + * @param ctx the parse tree + */ + void enterBlockExpression_(CocoParser.BlockExpression_Context ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#blockExpression_}. + * @param ctx the parse tree + */ + void exitBlockExpression_(CocoParser.BlockExpression_Context ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#ifExpression_}. + * @param ctx the parse tree + */ + void enterIfExpression_(CocoParser.IfExpression_Context ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#ifExpression_}. + * @param ctx the parse tree + */ + void exitIfExpression_(CocoParser.IfExpression_Context ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#matchExpression_}. + * @param ctx the parse tree + */ + void enterMatchExpression_(CocoParser.MatchExpression_Context ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#matchExpression_}. + * @param ctx the parse tree + */ + void exitMatchExpression_(CocoParser.MatchExpression_Context ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#nondetExpression_}. + * @param ctx the parse tree + */ + void enterNondetExpression_(CocoParser.NondetExpression_Context ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#nondetExpression_}. + * @param ctx the parse tree + */ + void exitNondetExpression_(CocoParser.NondetExpression_Context ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#fieldAssignments}. + * @param ctx the parse tree + */ + void enterFieldAssignments(CocoParser.FieldAssignmentsContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#fieldAssignments}. + * @param ctx the parse tree + */ + void exitFieldAssignments(CocoParser.FieldAssignmentsContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#fieldAssignment}. + * @param ctx the parse tree + */ + void enterFieldAssignment(CocoParser.FieldAssignmentContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#fieldAssignment}. + * @param ctx the parse tree + */ + void exitFieldAssignment(CocoParser.FieldAssignmentContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#nondetClauses}. + * @param ctx the parse tree + */ + void enterNondetClauses(CocoParser.NondetClausesContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#nondetClauses}. + * @param ctx the parse tree + */ + void exitNondetClauses(CocoParser.NondetClausesContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#nondetClause}. + * @param ctx the parse tree + */ + void enterNondetClause(CocoParser.NondetClauseContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#nondetClause}. + * @param ctx the parse tree + */ + void exitNondetClause(CocoParser.NondetClauseContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#matchClauses}. + * @param ctx the parse tree + */ + void enterMatchClauses(CocoParser.MatchClausesContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#matchClauses}. + * @param ctx the parse tree + */ + void exitMatchClauses(CocoParser.MatchClausesContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#matchClause}. + * @param ctx the parse tree + */ + void enterMatchClause(CocoParser.MatchClauseContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#matchClause}. + * @param ctx the parse tree + */ + void exitMatchClause(CocoParser.MatchClauseContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#pattern}. + * @param ctx the parse tree + */ + void enterPattern(CocoParser.PatternContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#pattern}. + * @param ctx the parse tree + */ + void exitPattern(CocoParser.PatternContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#enumCasePattern}. + * @param ctx the parse tree + */ + void enterEnumCasePattern(CocoParser.EnumCasePatternContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#enumCasePattern}. + * @param ctx the parse tree + */ + void exitEnumCasePattern(CocoParser.EnumCasePatternContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#idParameterPatterns}. + * @param ctx the parse tree + */ + void enterIdParameterPatterns(CocoParser.IdParameterPatternsContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#idParameterPatterns}. + * @param ctx the parse tree + */ + void exitIdParameterPatterns(CocoParser.IdParameterPatternsContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#idParameterPattern}. + * @param ctx the parse tree + */ + void enterIdParameterPattern(CocoParser.IdParameterPatternContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#idParameterPattern}. + * @param ctx the parse tree + */ + void exitIdParameterPattern(CocoParser.IdParameterPatternContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#variableDeclarationPattern}. + * @param ctx the parse tree + */ + void enterVariableDeclarationPattern(CocoParser.VariableDeclarationPatternContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#variableDeclarationPattern}. + * @param ctx the parse tree + */ + void exitVariableDeclarationPattern(CocoParser.VariableDeclarationPatternContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#parameterPatterns}. + * @param ctx the parse tree + */ + void enterParameterPatterns(CocoParser.ParameterPatternsContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#parameterPatterns}. + * @param ctx the parse tree + */ + void exitParameterPatterns(CocoParser.ParameterPatternsContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#parameterPattern}. + * @param ctx the parse tree + */ + void enterParameterPattern(CocoParser.ParameterPatternContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#parameterPattern}. + * @param ctx the parse tree + */ + void exitParameterPattern(CocoParser.ParameterPatternContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#expressions}. + * @param ctx the parse tree + */ + void enterExpressions(CocoParser.ExpressionsContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#expressions}. + * @param ctx the parse tree + */ + void exitExpressions(CocoParser.ExpressionsContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#statement}. + * @param ctx the parse tree + */ + void enterStatement(CocoParser.StatementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#statement}. + * @param ctx the parse tree + */ + void exitStatement(CocoParser.StatementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#declarationStatement}. + * @param ctx the parse tree + */ + void enterDeclarationStatement(CocoParser.DeclarationStatementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#declarationStatement}. + * @param ctx the parse tree + */ + void exitDeclarationStatement(CocoParser.DeclarationStatementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#returnStatement}. + * @param ctx the parse tree + */ + void enterReturnStatement(CocoParser.ReturnStatementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#returnStatement}. + * @param ctx the parse tree + */ + void exitReturnStatement(CocoParser.ReturnStatementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#becomeStatement}. + * @param ctx the parse tree + */ + void enterBecomeStatement(CocoParser.BecomeStatementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#becomeStatement}. + * @param ctx the parse tree + */ + void exitBecomeStatement(CocoParser.BecomeStatementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#whileStatement}. + * @param ctx the parse tree + */ + void enterWhileStatement(CocoParser.WhileStatementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#whileStatement}. + * @param ctx the parse tree + */ + void exitWhileStatement(CocoParser.WhileStatementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#forStatement}. + * @param ctx the parse tree + */ + void enterForStatement(CocoParser.ForStatementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#forStatement}. + * @param ctx the parse tree + */ + void exitForStatement(CocoParser.ForStatementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#breakStatement}. + * @param ctx the parse tree + */ + void enterBreakStatement(CocoParser.BreakStatementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#breakStatement}. + * @param ctx the parse tree + */ + void exitBreakStatement(CocoParser.BreakStatementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#continueStatement}. + * @param ctx the parse tree + */ + void enterContinueStatement(CocoParser.ContinueStatementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#continueStatement}. + * @param ctx the parse tree + */ + void exitContinueStatement(CocoParser.ContinueStatementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#portElement}. + * @param ctx the parse tree + */ + void enterPortElement(CocoParser.PortElementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#portElement}. + * @param ctx the parse tree + */ + void exitPortElement(CocoParser.PortElementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#functionInterfaceDeclaration}. + * @param ctx the parse tree + */ + void enterFunctionInterfaceDeclaration(CocoParser.FunctionInterfaceDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#functionInterfaceDeclaration}. + * @param ctx the parse tree + */ + void exitFunctionInterfaceDeclaration(CocoParser.FunctionInterfaceDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#signalDeclaration}. + * @param ctx the parse tree + */ + void enterSignalDeclaration(CocoParser.SignalDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#signalDeclaration}. + * @param ctx the parse tree + */ + void exitSignalDeclaration(CocoParser.SignalDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#stateMachineDeclaration}. + * @param ctx the parse tree + */ + void enterStateMachineDeclaration(CocoParser.StateMachineDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#stateMachineDeclaration}. + * @param ctx the parse tree + */ + void exitStateMachineDeclaration(CocoParser.StateMachineDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#stateMachineElement}. + * @param ctx the parse tree + */ + void enterStateMachineElement(CocoParser.StateMachineElementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#stateMachineElement}. + * @param ctx the parse tree + */ + void exitStateMachineElement(CocoParser.StateMachineElementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#stateDeclaration}. + * @param ctx the parse tree + */ + void enterStateDeclaration(CocoParser.StateDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#stateDeclaration}. + * @param ctx the parse tree + */ + void exitStateDeclaration(CocoParser.StateDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#eventStateDeclaration}. + * @param ctx the parse tree + */ + void enterEventStateDeclaration(CocoParser.EventStateDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#eventStateDeclaration}. + * @param ctx the parse tree + */ + void exitEventStateDeclaration(CocoParser.EventStateDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#executionStateDeclaration}. + * @param ctx the parse tree + */ + void enterExecutionStateDeclaration(CocoParser.ExecutionStateDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#executionStateDeclaration}. + * @param ctx the parse tree + */ + void exitExecutionStateDeclaration(CocoParser.ExecutionStateDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#eventStateElement}. + * @param ctx the parse tree + */ + void enterEventStateElement(CocoParser.EventStateElementContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#eventStateElement}. + * @param ctx the parse tree + */ + void exitEventStateElement(CocoParser.EventStateElementContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#entryFunctionDeclaration}. + * @param ctx the parse tree + */ + void enterEntryFunctionDeclaration(CocoParser.EntryFunctionDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#entryFunctionDeclaration}. + * @param ctx the parse tree + */ + void exitEntryFunctionDeclaration(CocoParser.EntryFunctionDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#exitFunctionDeclaration}. + * @param ctx the parse tree + */ + void enterExitFunctionDeclaration(CocoParser.ExitFunctionDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#exitFunctionDeclaration}. + * @param ctx the parse tree + */ + void exitExitFunctionDeclaration(CocoParser.ExitFunctionDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#stateInvariant}. + * @param ctx the parse tree + */ + void enterStateInvariant(CocoParser.StateInvariantContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#stateInvariant}. + * @param ctx the parse tree + */ + void exitStateInvariant(CocoParser.StateInvariantContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#transitionDeclaration}. + * @param ctx the parse tree + */ + void enterTransitionDeclaration(CocoParser.TransitionDeclarationContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#transitionDeclaration}. + * @param ctx the parse tree + */ + void exitTransitionDeclaration(CocoParser.TransitionDeclarationContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#eventTransition}. + * @param ctx the parse tree + */ + void enterEventTransition(CocoParser.EventTransitionContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#eventTransition}. + * @param ctx the parse tree + */ + void exitEventTransition(CocoParser.EventTransitionContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#eventSource}. + * @param ctx the parse tree + */ + void enterEventSource(CocoParser.EventSourceContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#eventSource}. + * @param ctx the parse tree + */ + void exitEventSource(CocoParser.EventSourceContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#spontaneousTransition}. + * @param ctx the parse tree + */ + void enterSpontaneousTransition(CocoParser.SpontaneousTransitionContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#spontaneousTransition}. + * @param ctx the parse tree + */ + void exitSpontaneousTransition(CocoParser.SpontaneousTransitionContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#timerTransition}. + * @param ctx the parse tree + */ + void enterTimerTransition(CocoParser.TimerTransitionContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#timerTransition}. + * @param ctx the parse tree + */ + void exitTimerTransition(CocoParser.TimerTransitionContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#eventHandler}. + * @param ctx the parse tree + */ + void enterEventHandler(CocoParser.EventHandlerContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#eventHandler}. + * @param ctx the parse tree + */ + void exitEventHandler(CocoParser.EventHandlerContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#offer}. + * @param ctx the parse tree + */ + void enterOffer(CocoParser.OfferContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#offer}. + * @param ctx the parse tree + */ + void exitOffer(CocoParser.OfferContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#offerClauses}. + * @param ctx the parse tree + */ + void enterOfferClauses(CocoParser.OfferClausesContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#offerClauses}. + * @param ctx the parse tree + */ + void exitOfferClauses(CocoParser.OfferClausesContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#offerClause}. + * @param ctx the parse tree + */ + void enterOfferClause(CocoParser.OfferClauseContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#offerClause}. + * @param ctx the parse tree + */ + void exitOfferClause(CocoParser.OfferClauseContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#parameters}. + * @param ctx the parse tree + */ + void enterParameters(CocoParser.ParametersContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#parameters}. + * @param ctx the parse tree + */ + void exitParameters(CocoParser.ParametersContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#parameter}. + * @param ctx the parse tree + */ + void enterParameter(CocoParser.ParameterContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#parameter}. + * @param ctx the parse tree + */ + void exitParameter(CocoParser.ParameterContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#literalExpression_}. + * @param ctx the parse tree + */ + void enterLiteralExpression_(CocoParser.LiteralExpression_Context ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#literalExpression_}. + * @param ctx the parse tree + */ + void exitLiteralExpression_(CocoParser.LiteralExpression_Context ctx); + + /** + * Enter a parse tree produced by the {@code BinaryType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void enterBinaryType(CocoParser.BinaryTypeContext ctx); + + /** + * Exit a parse tree produced by the {@code BinaryType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void exitBinaryType(CocoParser.BinaryTypeContext ctx); + + /** + * Enter a parse tree produced by the {@code GroupType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void enterGroupType(CocoParser.GroupTypeContext ctx); + + /** + * Exit a parse tree produced by the {@code GroupType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void exitGroupType(CocoParser.GroupTypeContext ctx); + + /** + * Enter a parse tree produced by the {@code FunctionType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void enterFunctionType(CocoParser.FunctionTypeContext ctx); + + /** + * Exit a parse tree produced by the {@code FunctionType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void exitFunctionType(CocoParser.FunctionTypeContext ctx); + + /** + * Enter a parse tree produced by the {@code UnaryType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void enterUnaryType(CocoParser.UnaryTypeContext ctx); + + /** + * Exit a parse tree produced by the {@code UnaryType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void exitUnaryType(CocoParser.UnaryTypeContext ctx); + + /** + * Enter a parse tree produced by the {@code LiteralType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void enterLiteralType(CocoParser.LiteralTypeContext ctx); + + /** + * Exit a parse tree produced by the {@code LiteralType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void exitLiteralType(CocoParser.LiteralTypeContext ctx); + + /** + * Enter a parse tree produced by the {@code TypeReference} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void enterTypeReference(CocoParser.TypeReferenceContext ctx); + + /** + * Exit a parse tree produced by the {@code TypeReference} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void exitTypeReference(CocoParser.TypeReferenceContext ctx); + + /** + * Enter a parse tree produced by the {@code ReferenceType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void enterReferenceType(CocoParser.ReferenceTypeContext ctx); + + /** + * Exit a parse tree produced by the {@code ReferenceType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + */ + void exitReferenceType(CocoParser.ReferenceTypeContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#types}. + * @param ctx the parse tree + */ + void enterTypes(CocoParser.TypesContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#types}. + * @param ctx the parse tree + */ + void exitTypes(CocoParser.TypesContext ctx); + + /** + * Enter a parse tree produced by {@link CocoParser#dotIdentifierList}. + * @param ctx the parse tree + */ + void enterDotIdentifierList(CocoParser.DotIdentifierListContext ctx); + + /** + * Exit a parse tree produced by {@link CocoParser#dotIdentifierList}. + * @param ctx the parse tree + */ + void exitDotIdentifierList(CocoParser.DotIdentifierListContext ctx); } diff --git a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoParser.java b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoParser.java index aac2c30df20..51fe0dcdd17 100644 --- a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoParser.java +++ b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoParser.java @@ -35,8645 +35,10162 @@ @Deprecated @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public class CocoParser extends Parser { - static { RuntimeMetaData.checkVersion("4.9.3", RuntimeMetaData.VERSION); } - - protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = - new PredictionContextCache(); - public static final int - AFTER=1, AS=2, ASSERT=3, ATTRIBUTE=4, BECOME=5, BREAK=6, CASE=7, COMPONENT=8, - CONTINUE=9, ELSE=10, ENUM=11, ENTRY=12, EXECUTION=13, EXIT=14, EXTERNAL=15, - FINAL=16, FOR=17, FUNCTION=18, IF=19, ILLEGAL=20, IMPORT=21, IN=22, INIT=23, - INSTANCE=24, MACHINE=25, MATCH=26, MUT=27, MUTATING=28, NONDET=29, OFFER=30, - OPTIONAL=31, OTHERWISE=32, OUT=33, OUTGOING=34, PERIODIC=35, PORT=36, - PRIVATE=37, RETURN=38, SIGNAL=39, SPONTANEOUS=40, STATE=41, STATIC=42, - STRUCT=43, TYPE=44, UNQUALIFIED=45, VAL=46, VAR=47, WHERE=48, WHILE=49, - IDENTIFIER=50, AT=51, ASSIGN=52, COLON=53, LP=54, RP=55, LC=56, RC=57, - LB=58, RB=59, COMMA=60, SEMI=61, DOT=62, LT=63, GT=64, MUL=65, DIV=66, - MINUS=67, MOD=68, PLUS=69, IMPL=70, ARROW=71, AMP=72, QM=73, PIPE=74, - EXCL=75, ELLIP=76, EQ=77, NE=78, OR=79, AND=80, LE=81, GE=82, WHITESPACE=83, - NEWLINE=84, LINE_COMMENT=85, BLOCK_COMMENT=86, INTEGER=87, BACKTICK_LITERAL=88, - CHAR_LITERAL=89, STRING_LITERAL=90; - public static final int - RULE_module = 0, RULE_declaration = 1, RULE_attribute = 2, RULE_attributeDeclaration = 3, - RULE_importDeclaration = 4, RULE_variableDeclaration = 5, RULE_enumDeclaration = 6, - RULE_structDeclaration = 7, RULE_typeAliasDeclaration = 8, RULE_functionDeclaration = 9, - RULE_instanceDeclaration = 10, RULE_portDeclaration = 11, RULE_componentDeclaration = 12, - RULE_externalConstantDeclaration = 13, RULE_externalTypeDeclaration = 14, - RULE_externalTypeElement = 15, RULE_externalFunctionDeclaration = 16, - RULE_genericTypeDeclaration = 17, RULE_genericTypes = 18, RULE_genericType = 19, - RULE_enumElement = 20, RULE_enumCase = 21, RULE_caseParameters = 22, RULE_caseParameter = 23, - RULE_structElement = 24, RULE_fieldDeclaration = 25, RULE_componentElement = 26, - RULE_staticMemberDeclaration = 27, RULE_constructorDeclaration = 28, RULE_expression = 29, - RULE_blockExpression_ = 30, RULE_ifExpression_ = 31, RULE_matchExpression_ = 32, - RULE_nondetExpression_ = 33, RULE_fieldAssignments = 34, RULE_fieldAssignment = 35, - RULE_nondetClauses = 36, RULE_nondetClause = 37, RULE_matchClauses = 38, - RULE_matchClause = 39, RULE_pattern = 40, RULE_enumCasePattern = 41, RULE_idParameterPatterns = 42, - RULE_idParameterPattern = 43, RULE_variableDeclarationPattern = 44, RULE_parameterPatterns = 45, - RULE_parameterPattern = 46, RULE_expressions = 47, RULE_statement = 48, - RULE_declarationStatement = 49, RULE_returnStatement = 50, RULE_becomeStatement = 51, - RULE_whileStatement = 52, RULE_forStatement = 53, RULE_breakStatement = 54, - RULE_continueStatement = 55, RULE_portElement = 56, RULE_functionInterfaceDeclaration = 57, - RULE_signalDeclaration = 58, RULE_stateMachineDeclaration = 59, RULE_stateMachineElement = 60, - RULE_stateDeclaration = 61, RULE_eventStateDeclaration = 62, RULE_executionStateDeclaration = 63, - RULE_eventStateElement = 64, RULE_entryFunctionDeclaration = 65, RULE_exitFunctionDeclaration = 66, - RULE_stateInvariant = 67, RULE_transitionDeclaration = 68, RULE_eventTransition = 69, - RULE_eventSource = 70, RULE_spontaneousTransition = 71, RULE_timerTransition = 72, - RULE_eventHandler = 73, RULE_offer = 74, RULE_offerClauses = 75, RULE_offerClause = 76, - RULE_parameters = 77, RULE_parameter = 78, RULE_literalExpression_ = 79, - RULE_type = 80, RULE_types = 81, RULE_dotIdentifierList = 82; - private static String[] makeRuleNames() { - return new String[] { - "module", "declaration", "attribute", "attributeDeclaration", "importDeclaration", - "variableDeclaration", "enumDeclaration", "structDeclaration", "typeAliasDeclaration", - "functionDeclaration", "instanceDeclaration", "portDeclaration", "componentDeclaration", - "externalConstantDeclaration", "externalTypeDeclaration", "externalTypeElement", - "externalFunctionDeclaration", "genericTypeDeclaration", "genericTypes", - "genericType", "enumElement", "enumCase", "caseParameters", "caseParameter", - "structElement", "fieldDeclaration", "componentElement", "staticMemberDeclaration", - "constructorDeclaration", "expression", "blockExpression_", "ifExpression_", - "matchExpression_", "nondetExpression_", "fieldAssignments", "fieldAssignment", - "nondetClauses", "nondetClause", "matchClauses", "matchClause", "pattern", - "enumCasePattern", "idParameterPatterns", "idParameterPattern", "variableDeclarationPattern", - "parameterPatterns", "parameterPattern", "expressions", "statement", - "declarationStatement", "returnStatement", "becomeStatement", "whileStatement", - "forStatement", "breakStatement", "continueStatement", "portElement", - "functionInterfaceDeclaration", "signalDeclaration", "stateMachineDeclaration", - "stateMachineElement", "stateDeclaration", "eventStateDeclaration", "executionStateDeclaration", - "eventStateElement", "entryFunctionDeclaration", "exitFunctionDeclaration", - "stateInvariant", "transitionDeclaration", "eventTransition", "eventSource", - "spontaneousTransition", "timerTransition", "eventHandler", "offer", - "offerClauses", "offerClause", "parameters", "parameter", "literalExpression_", - "type", "types", "dotIdentifierList" - }; - } - public static final String[] ruleNames = makeRuleNames(); - - private static String[] makeLiteralNames() { - return new String[] { - null, "'after'", "'as'", "'assert'", "'attribute'", "'become'", "'break'", - "'case'", "'component'", "'continue'", "'else'", "'enum'", "'entry'", - "'execution'", "'exit'", "'external'", "'final'", "'for'", "'function'", - "'if'", "'illegal'", "'import'", "'in'", "'init'", "'instance'", "'machine'", - "'match'", "'mut'", "'mutating'", "'nondet'", "'offer'", "'optional'", - "'otherwise'", "'out'", "'outgoing'", "'periodic'", "'port'", "'private'", - "'return'", "'signal'", "'spontaneous'", "'state'", "'static'", "'struct'", - "'type'", "'unqualified'", "'val'", "'var'", "'where'", "'while'", null, - "'@'", "'='", "':'", "'('", "')'", "'{'", "'}'", "'['", "']'", "','", - "';'", "'.'", "'<'", "'>'", "'*'", "'/'", "'-'", "'%'", "'+'", "'=>'", - "'->'", "'&'", "'?'", "'|'", "'!'", "'...'", "'=='", "'!='", "'||'", - "'&&'", "'<='", "'>='" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, "AFTER", "AS", "ASSERT", "ATTRIBUTE", "BECOME", "BREAK", "CASE", - "COMPONENT", "CONTINUE", "ELSE", "ENUM", "ENTRY", "EXECUTION", "EXIT", - "EXTERNAL", "FINAL", "FOR", "FUNCTION", "IF", "ILLEGAL", "IMPORT", "IN", - "INIT", "INSTANCE", "MACHINE", "MATCH", "MUT", "MUTATING", "NONDET", - "OFFER", "OPTIONAL", "OTHERWISE", "OUT", "OUTGOING", "PERIODIC", "PORT", - "PRIVATE", "RETURN", "SIGNAL", "SPONTANEOUS", "STATE", "STATIC", "STRUCT", - "TYPE", "UNQUALIFIED", "VAL", "VAR", "WHERE", "WHILE", "IDENTIFIER", - "AT", "ASSIGN", "COLON", "LP", "RP", "LC", "RC", "LB", "RB", "COMMA", - "SEMI", "DOT", "LT", "GT", "MUL", "DIV", "MINUS", "MOD", "PLUS", "IMPL", - "ARROW", "AMP", "QM", "PIPE", "EXCL", "ELLIP", "EQ", "NE", "OR", "AND", - "LE", "GE", "WHITESPACE", "NEWLINE", "LINE_COMMENT", "BLOCK_COMMENT", - "INTEGER", "BACKTICK_LITERAL", "CHAR_LITERAL", "STRING_LITERAL" - }; - } - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); - public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); - - /** - * @deprecated Use {@link #VOCABULARY} instead. - */ - @Deprecated - public static final String[] tokenNames; - static { - tokenNames = new String[_SYMBOLIC_NAMES.length]; - for (int i = 0; i < tokenNames.length; i++) { - tokenNames[i] = VOCABULARY.getLiteralName(i); - if (tokenNames[i] == null) { - tokenNames[i] = VOCABULARY.getSymbolicName(i); - } - - if (tokenNames[i] == null) { - tokenNames[i] = ""; - } - } - } - - @Override - @Deprecated - public String[] getTokenNames() { - return tokenNames; - } - - @Override - - public Vocabulary getVocabulary() { - return VOCABULARY; - } - - @Override - public String getGrammarFileName() { return "Coco.g4"; } - - @Override - public String[] getRuleNames() { return ruleNames; } - - @Override - public String getSerializedATN() { return _serializedATN; } - - @Override - public ATN getATN() { return _ATN; } - - public CocoParser(TokenStream input) { - super(input); - _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ModuleContext extends ParserRuleContext { - public TerminalNode EOF() { return getToken(CocoParser.EOF, 0); } - public List declaration() { - return getRuleContexts(DeclarationContext.class); - } - public DeclarationContext declaration(int i) { - return getRuleContext(DeclarationContext.class,i); - } - public ModuleContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_module; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterModule(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitModule(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitModule(this); - else return visitor.visitChildren(this); - } - } - - public final ModuleContext module() throws RecognitionException { - ModuleContext _localctx = new ModuleContext(_ctx, getState()); - enterRule(_localctx, 0, RULE_module); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(169); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ATTRIBUTE) | (1L << COMPONENT) | (1L << ENUM) | (1L << EXTERNAL) | (1L << FUNCTION) | (1L << IMPORT) | (1L << INSTANCE) | (1L << PORT) | (1L << PRIVATE) | (1L << STRUCT) | (1L << TYPE) | (1L << VAL) | (1L << VAR) | (1L << AT))) != 0)) { - { - { - setState(166); - declaration(); - } - } - setState(171); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(172); - match(EOF); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class DeclarationContext extends ParserRuleContext { - public ImportDeclarationContext importDeclaration() { - return getRuleContext(ImportDeclarationContext.class,0); - } - public VariableDeclarationContext variableDeclaration() { - return getRuleContext(VariableDeclarationContext.class,0); - } - public EnumDeclarationContext enumDeclaration() { - return getRuleContext(EnumDeclarationContext.class,0); - } - public StructDeclarationContext structDeclaration() { - return getRuleContext(StructDeclarationContext.class,0); - } - public TypeAliasDeclarationContext typeAliasDeclaration() { - return getRuleContext(TypeAliasDeclarationContext.class,0); - } - public FunctionDeclarationContext functionDeclaration() { - return getRuleContext(FunctionDeclarationContext.class,0); - } - public InstanceDeclarationContext instanceDeclaration() { - return getRuleContext(InstanceDeclarationContext.class,0); - } - public PortDeclarationContext portDeclaration() { - return getRuleContext(PortDeclarationContext.class,0); - } - public ComponentDeclarationContext componentDeclaration() { - return getRuleContext(ComponentDeclarationContext.class,0); - } - public ExternalConstantDeclarationContext externalConstantDeclaration() { - return getRuleContext(ExternalConstantDeclarationContext.class,0); - } - public ExternalFunctionDeclarationContext externalFunctionDeclaration() { - return getRuleContext(ExternalFunctionDeclarationContext.class,0); - } - public ExternalTypeDeclarationContext externalTypeDeclaration() { - return getRuleContext(ExternalTypeDeclarationContext.class,0); - } - public AttributeDeclarationContext attributeDeclaration() { - return getRuleContext(AttributeDeclarationContext.class,0); - } - public List attribute() { - return getRuleContexts(AttributeContext.class); - } - public AttributeContext attribute(int i) { - return getRuleContext(AttributeContext.class,i); - } - public DeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_declaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final DeclarationContext declaration() throws RecognitionException { - DeclarationContext _localctx = new DeclarationContext(_ctx, getState()); - enterRule(_localctx, 2, RULE_declaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(177); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==AT) { - { - { - setState(174); - attribute(); - } - } - setState(179); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(193); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) { - case 1: - { - setState(180); - importDeclaration(); - } - break; - case 2: - { - setState(181); - variableDeclaration(); - } - break; - case 3: - { - setState(182); - enumDeclaration(); - } - break; - case 4: - { - setState(183); - structDeclaration(); - } - break; - case 5: - { - setState(184); - typeAliasDeclaration(); - } - break; - case 6: - { - setState(185); - functionDeclaration(); - } - break; - case 7: - { - setState(186); - instanceDeclaration(); - } - break; - case 8: - { - setState(187); - portDeclaration(); - } - break; - case 9: - { - setState(188); - componentDeclaration(); - } - break; - case 10: - { - setState(189); - externalConstantDeclaration(); - } - break; - case 11: - { - setState(190); - externalFunctionDeclaration(); - } - break; - case 12: - { - setState(191); - externalTypeDeclaration(); - } - break; - case 13: - { - setState(192); - attributeDeclaration(); - } - break; - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class AttributeContext extends ParserRuleContext { - public TerminalNode AT() { return getToken(CocoParser.AT, 0); } - public DotIdentifierListContext dotIdentifierList() { - return getRuleContext(DotIdentifierListContext.class,0); - } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public ExpressionsContext expressions() { - return getRuleContext(ExpressionsContext.class,0); - } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public AttributeContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_attribute; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterAttribute(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitAttribute(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitAttribute(this); - else return visitor.visitChildren(this); - } - } - - public final AttributeContext attribute() throws RecognitionException { - AttributeContext _localctx = new AttributeContext(_ctx, getState()); - enterRule(_localctx, 4, RULE_attribute); - try { - enterOuterAlt(_localctx, 1); - { - setState(195); - match(AT); - setState(196); - dotIdentifierList(); - setState(201); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { - case 1: - { - setState(197); - match(LP); - setState(198); - expressions(); - setState(199); - match(RP); - } - break; - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class AttributeDeclarationContext extends ParserRuleContext { - public TerminalNode ATTRIBUTE() { return getToken(CocoParser.ATTRIBUTE, 0); } - public TerminalNode AT() { return getToken(CocoParser.AT, 0); } - public DotIdentifierListContext dotIdentifierList() { - return getRuleContext(DotIdentifierListContext.class,0); - } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public ParametersContext parameters() { - return getRuleContext(ParametersContext.class,0); - } - public AttributeDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_attributeDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterAttributeDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitAttributeDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitAttributeDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final AttributeDeclarationContext attributeDeclaration() throws RecognitionException { - AttributeDeclarationContext _localctx = new AttributeDeclarationContext(_ctx, getState()); - enterRule(_localctx, 6, RULE_attributeDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(203); - match(ATTRIBUTE); - setState(204); - match(AT); - setState(205); - dotIdentifierList(); - setState(211); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LP) { - { - setState(206); - match(LP); - setState(208); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAR || _la==IDENTIFIER) { - { - setState(207); - parameters(); - } - } - - setState(210); - match(RP); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ImportDeclarationContext extends ParserRuleContext { - public TerminalNode IMPORT() { return getToken(CocoParser.IMPORT, 0); } - public DotIdentifierListContext dotIdentifierList() { - return getRuleContext(DotIdentifierListContext.class,0); - } - public TerminalNode UNQUALIFIED() { return getToken(CocoParser.UNQUALIFIED, 0); } - public TerminalNode AS() { return getToken(CocoParser.AS, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public ImportDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_importDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterImportDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitImportDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitImportDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final ImportDeclarationContext importDeclaration() throws RecognitionException { - ImportDeclarationContext _localctx = new ImportDeclarationContext(_ctx, getState()); - enterRule(_localctx, 8, RULE_importDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(213); - match(IMPORT); - setState(215); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==UNQUALIFIED) { - { - setState(214); - match(UNQUALIFIED); - } - } - - setState(217); - dotIdentifierList(); - setState(220); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==AS) { - { - setState(218); - match(AS); - setState(219); - match(IDENTIFIER); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class VariableDeclarationContext extends ParserRuleContext { - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode VAR() { return getToken(CocoParser.VAR, 0); } - public TerminalNode VAL() { return getToken(CocoParser.VAL, 0); } - public TerminalNode PRIVATE() { return getToken(CocoParser.PRIVATE, 0); } - public GenericTypeDeclarationContext genericTypeDeclaration() { - return getRuleContext(GenericTypeDeclarationContext.class,0); - } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public VariableDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_variableDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterVariableDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitVariableDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitVariableDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final VariableDeclarationContext variableDeclaration() throws RecognitionException { - VariableDeclarationContext _localctx = new VariableDeclarationContext(_ctx, getState()); - enterRule(_localctx, 10, RULE_variableDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(223); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==PRIVATE) { - { - setState(222); - match(PRIVATE); - } - } - - setState(225); - _la = _input.LA(1); - if ( !(_la==VAL || _la==VAR) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(226); - match(IDENTIFIER); - setState(228); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LT) { - { - setState(227); - genericTypeDeclaration(); - } - } - - setState(232); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COLON) { - { - setState(230); - match(COLON); - setState(231); - type(0); - } - } - - setState(236); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==ASSIGN) { - { - setState(234); - match(ASSIGN); - setState(235); - expression(0); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class EnumDeclarationContext extends ParserRuleContext { - public TerminalNode ENUM() { return getToken(CocoParser.ENUM, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LC() { return getToken(CocoParser.LC, 0); } - public TerminalNode RC() { return getToken(CocoParser.RC, 0); } - public GenericTypeDeclarationContext genericTypeDeclaration() { - return getRuleContext(GenericTypeDeclarationContext.class,0); - } - public List enumElement() { - return getRuleContexts(EnumElementContext.class); - } - public EnumElementContext enumElement(int i) { - return getRuleContext(EnumElementContext.class,i); - } - public EnumDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_enumDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterEnumDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitEnumDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitEnumDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final EnumDeclarationContext enumDeclaration() throws RecognitionException { - EnumDeclarationContext _localctx = new EnumDeclarationContext(_ctx, getState()); - enterRule(_localctx, 12, RULE_enumDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(238); - match(ENUM); - setState(239); - match(IDENTIFIER); - setState(241); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LT) { - { - setState(240); - genericTypeDeclaration(); - } - } - - setState(243); - match(LC); - setState(247); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << CASE) | (1L << FUNCTION) | (1L << MUT) | (1L << MUTATING) | (1L << STATIC))) != 0)) { - { - { - setState(244); - enumElement(); - } - } - setState(249); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(250); - match(RC); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class StructDeclarationContext extends ParserRuleContext { - public TerminalNode STRUCT() { return getToken(CocoParser.STRUCT, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LC() { return getToken(CocoParser.LC, 0); } - public TerminalNode RC() { return getToken(CocoParser.RC, 0); } - public GenericTypeDeclarationContext genericTypeDeclaration() { - return getRuleContext(GenericTypeDeclarationContext.class,0); - } - public List structElement() { - return getRuleContexts(StructElementContext.class); - } - public StructElementContext structElement(int i) { - return getRuleContext(StructElementContext.class,i); - } - public StructDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_structDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterStructDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitStructDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitStructDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final StructDeclarationContext structDeclaration() throws RecognitionException { - StructDeclarationContext _localctx = new StructDeclarationContext(_ctx, getState()); - enterRule(_localctx, 14, RULE_structDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(252); - match(STRUCT); - setState(253); - match(IDENTIFIER); - setState(255); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LT) { - { - setState(254); - genericTypeDeclaration(); - } - } - - setState(257); - match(LC); - setState(261); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << FUNCTION) | (1L << MUT) | (1L << MUTATING) | (1L << STATIC) | (1L << VAL) | (1L << VAR) | (1L << IDENTIFIER))) != 0)) { - { - { - setState(258); - structElement(); - } - } - setState(263); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(264); - match(RC); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class TypeAliasDeclarationContext extends ParserRuleContext { - public TerminalNode TYPE() { return getToken(CocoParser.TYPE, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public GenericTypeDeclarationContext genericTypeDeclaration() { - return getRuleContext(GenericTypeDeclarationContext.class,0); - } - public TypeAliasDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_typeAliasDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterTypeAliasDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitTypeAliasDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitTypeAliasDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final TypeAliasDeclarationContext typeAliasDeclaration() throws RecognitionException { - TypeAliasDeclarationContext _localctx = new TypeAliasDeclarationContext(_ctx, getState()); - enterRule(_localctx, 16, RULE_typeAliasDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(266); - match(TYPE); - setState(267); - match(IDENTIFIER); - setState(269); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LT) { - { - setState(268); - genericTypeDeclaration(); - } - } - - setState(271); - match(ASSIGN); - setState(272); - type(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class FunctionDeclarationContext extends ParserRuleContext { - public TerminalNode FUNCTION() { return getToken(CocoParser.FUNCTION, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public GenericTypeDeclarationContext genericTypeDeclaration() { - return getRuleContext(GenericTypeDeclarationContext.class,0); - } - public ParametersContext parameters() { - return getRuleContext(ParametersContext.class,0); - } - public FunctionDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_functionDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterFunctionDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitFunctionDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitFunctionDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final FunctionDeclarationContext functionDeclaration() throws RecognitionException { - FunctionDeclarationContext _localctx = new FunctionDeclarationContext(_ctx, getState()); - enterRule(_localctx, 18, RULE_functionDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(274); - match(FUNCTION); - setState(275); - match(IDENTIFIER); - setState(277); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LT) { - { - setState(276); - genericTypeDeclaration(); - } - } - - setState(279); - match(LP); - setState(281); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAR || _la==IDENTIFIER) { - { - setState(280); - parameters(); - } - } - - setState(283); - match(RP); - setState(284); - match(COLON); - setState(285); - type(0); - setState(286); - match(ASSIGN); - setState(287); - expression(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class InstanceDeclarationContext extends ParserRuleContext { - public TerminalNode INSTANCE() { return getToken(CocoParser.INSTANCE, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public ParametersContext parameters() { - return getRuleContext(ParametersContext.class,0); - } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public BlockExpression_Context blockExpression_() { - return getRuleContext(BlockExpression_Context.class,0); - } - public GenericTypeDeclarationContext genericTypeDeclaration() { - return getRuleContext(GenericTypeDeclarationContext.class,0); - } - public InstanceDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_instanceDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterInstanceDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitInstanceDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitInstanceDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final InstanceDeclarationContext instanceDeclaration() throws RecognitionException { - InstanceDeclarationContext _localctx = new InstanceDeclarationContext(_ctx, getState()); - enterRule(_localctx, 20, RULE_instanceDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(289); - match(INSTANCE); - setState(290); - match(IDENTIFIER); - setState(292); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LT) { - { - setState(291); - genericTypeDeclaration(); - } - } - - setState(294); - match(LP); - setState(295); - parameters(); - setState(296); - match(RP); - setState(297); - blockExpression_(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class PortDeclarationContext extends ParserRuleContext { - public TerminalNode PORT() { return getToken(CocoParser.PORT, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LC() { return getToken(CocoParser.LC, 0); } - public TerminalNode RC() { return getToken(CocoParser.RC, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypesContext types() { - return getRuleContext(TypesContext.class,0); - } - public TerminalNode FINAL() { return getToken(CocoParser.FINAL, 0); } - public List portElement() { - return getRuleContexts(PortElementContext.class); - } - public PortElementContext portElement(int i) { - return getRuleContext(PortElementContext.class,i); - } - public PortDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_portDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterPortDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitPortDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitPortDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final PortDeclarationContext portDeclaration() throws RecognitionException { - PortDeclarationContext _localctx = new PortDeclarationContext(_ctx, getState()); - enterRule(_localctx, 22, RULE_portDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(299); - match(PORT); - setState(300); - match(IDENTIFIER); - setState(303); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COLON) { - { - setState(301); - match(COLON); - setState(302); - types(); - } - } - - setState(306); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==FINAL) { - { - setState(305); - match(FINAL); - } - } - - setState(308); - match(LC); - setState(312); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ENUM) | (1L << EXTERNAL) | (1L << FUNCTION) | (1L << MACHINE) | (1L << OUTGOING) | (1L << PORT) | (1L << STATIC) | (1L << STRUCT) | (1L << TYPE) | (1L << VAL) | (1L << VAR) | (1L << IDENTIFIER) | (1L << AT))) != 0)) { - { - { - setState(309); - portElement(); - } - } - setState(314); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(315); - match(RC); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ComponentDeclarationContext extends ParserRuleContext { - public TerminalNode COMPONENT() { return getToken(CocoParser.COMPONENT, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LC() { return getToken(CocoParser.LC, 0); } - public TerminalNode RC() { return getToken(CocoParser.RC, 0); } - public TerminalNode EXTERNAL() { return getToken(CocoParser.EXTERNAL, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public List componentElement() { - return getRuleContexts(ComponentElementContext.class); - } - public ComponentElementContext componentElement(int i) { - return getRuleContext(ComponentElementContext.class,i); - } - public ComponentDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_componentDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterComponentDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitComponentDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitComponentDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final ComponentDeclarationContext componentDeclaration() throws RecognitionException { - ComponentDeclarationContext _localctx = new ComponentDeclarationContext(_ctx, getState()); - enterRule(_localctx, 24, RULE_componentDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(318); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==EXTERNAL) { - { - setState(317); - match(EXTERNAL); - } - } - - setState(320); - match(COMPONENT); - setState(321); - match(IDENTIFIER); - setState(324); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COLON) { - { - setState(322); - match(COLON); - setState(323); - type(0); - } - } - - setState(326); - match(LC); - setState(330); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << INIT) | (1L << MACHINE) | (1L << PRIVATE) | (1L << STATIC) | (1L << VAL) | (1L << VAR) | (1L << IDENTIFIER) | (1L << AT))) != 0)) { - { - { - setState(327); - componentElement(); - } - } - setState(332); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(333); - match(RC); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ExternalConstantDeclarationContext extends ParserRuleContext { - public TerminalNode EXTERNAL() { return getToken(CocoParser.EXTERNAL, 0); } - public TerminalNode VAL() { return getToken(CocoParser.VAL, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public ExternalConstantDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_externalConstantDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterExternalConstantDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitExternalConstantDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitExternalConstantDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final ExternalConstantDeclarationContext externalConstantDeclaration() throws RecognitionException { - ExternalConstantDeclarationContext _localctx = new ExternalConstantDeclarationContext(_ctx, getState()); - enterRule(_localctx, 26, RULE_externalConstantDeclaration); - try { - enterOuterAlt(_localctx, 1); - { - setState(335); - match(EXTERNAL); - setState(336); - match(VAL); - setState(337); - match(IDENTIFIER); - setState(338); - match(COLON); - setState(339); - type(0); - setState(340); - match(ASSIGN); - setState(341); - expression(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ExternalTypeDeclarationContext extends ParserRuleContext { - public TerminalNode EXTERNAL() { return getToken(CocoParser.EXTERNAL, 0); } - public TerminalNode TYPE() { return getToken(CocoParser.TYPE, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LC() { return getToken(CocoParser.LC, 0); } - public TerminalNode RC() { return getToken(CocoParser.RC, 0); } - public List externalTypeElement() { - return getRuleContexts(ExternalTypeElementContext.class); - } - public ExternalTypeElementContext externalTypeElement(int i) { - return getRuleContext(ExternalTypeElementContext.class,i); - } - public ExternalTypeDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_externalTypeDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterExternalTypeDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitExternalTypeDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitExternalTypeDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final ExternalTypeDeclarationContext externalTypeDeclaration() throws RecognitionException { - ExternalTypeDeclarationContext _localctx = new ExternalTypeDeclarationContext(_ctx, getState()); - enterRule(_localctx, 28, RULE_externalTypeDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(343); - match(EXTERNAL); - setState(344); - match(TYPE); - setState(345); - match(IDENTIFIER); - setState(354); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LC) { - { - setState(346); - match(LC); - setState(350); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << EXTERNAL) | (1L << MUT) | (1L << MUTATING) | (1L << PRIVATE) | (1L << STATIC) | (1L << VAL) | (1L << VAR))) != 0)) { - { - { - setState(347); - externalTypeElement(); - } - } - setState(352); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(353); - match(RC); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ExternalTypeElementContext extends ParserRuleContext { - public StaticMemberDeclarationContext staticMemberDeclaration() { - return getRuleContext(StaticMemberDeclarationContext.class,0); - } - public VariableDeclarationContext variableDeclaration() { - return getRuleContext(VariableDeclarationContext.class,0); - } - public ExternalFunctionDeclarationContext externalFunctionDeclaration() { - return getRuleContext(ExternalFunctionDeclarationContext.class,0); - } - public TerminalNode MUT() { return getToken(CocoParser.MUT, 0); } - public TerminalNode MUTATING() { return getToken(CocoParser.MUTATING, 0); } - public ExternalTypeElementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_externalTypeElement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterExternalTypeElement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitExternalTypeElement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitExternalTypeElement(this); - else return visitor.visitChildren(this); - } - } - - public final ExternalTypeElementContext externalTypeElement() throws RecognitionException { - ExternalTypeElementContext _localctx = new ExternalTypeElementContext(_ctx, getState()); - enterRule(_localctx, 30, RULE_externalTypeElement); - int _la; - try { - setState(362); - _errHandler.sync(this); - switch (_input.LA(1)) { - case STATIC: - enterOuterAlt(_localctx, 1); - { - setState(356); - staticMemberDeclaration(); - } - break; - case PRIVATE: - case VAL: - case VAR: - enterOuterAlt(_localctx, 2); - { - setState(357); - variableDeclaration(); - } - break; - case EXTERNAL: - case MUT: - case MUTATING: - enterOuterAlt(_localctx, 3); - { - setState(359); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==MUT || _la==MUTATING) { - { - setState(358); - _la = _input.LA(1); - if ( !(_la==MUT || _la==MUTATING) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - - setState(361); - externalFunctionDeclaration(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ExternalFunctionDeclarationContext extends ParserRuleContext { - public TerminalNode EXTERNAL() { return getToken(CocoParser.EXTERNAL, 0); } - public TerminalNode FUNCTION() { return getToken(CocoParser.FUNCTION, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public ParametersContext parameters() { - return getRuleContext(ParametersContext.class,0); - } - public ExternalFunctionDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_externalFunctionDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterExternalFunctionDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitExternalFunctionDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitExternalFunctionDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final ExternalFunctionDeclarationContext externalFunctionDeclaration() throws RecognitionException { - ExternalFunctionDeclarationContext _localctx = new ExternalFunctionDeclarationContext(_ctx, getState()); - enterRule(_localctx, 32, RULE_externalFunctionDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(364); - match(EXTERNAL); - setState(365); - match(FUNCTION); - setState(366); - match(IDENTIFIER); - setState(367); - match(LP); - setState(369); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAR || _la==IDENTIFIER) { - { - setState(368); - parameters(); - } - } - - setState(371); - match(RP); - setState(372); - match(COLON); - setState(373); - type(0); - setState(374); - match(ASSIGN); - setState(375); - expression(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class GenericTypeDeclarationContext extends ParserRuleContext { - public TerminalNode LT() { return getToken(CocoParser.LT, 0); } - public GenericTypesContext genericTypes() { - return getRuleContext(GenericTypesContext.class,0); - } - public TerminalNode GT() { return getToken(CocoParser.GT, 0); } - public TerminalNode WHERE() { return getToken(CocoParser.WHERE, 0); } - public ExpressionsContext expressions() { - return getRuleContext(ExpressionsContext.class,0); - } - public GenericTypeDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_genericTypeDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterGenericTypeDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitGenericTypeDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitGenericTypeDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final GenericTypeDeclarationContext genericTypeDeclaration() throws RecognitionException { - GenericTypeDeclarationContext _localctx = new GenericTypeDeclarationContext(_ctx, getState()); - enterRule(_localctx, 34, RULE_genericTypeDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(377); - match(LT); - setState(378); - genericTypes(); - setState(381); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==WHERE) { - { - setState(379); - match(WHERE); - setState(380); - expressions(); - } - } - - setState(383); - match(GT); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class GenericTypesContext extends ParserRuleContext { - public List genericType() { - return getRuleContexts(GenericTypeContext.class); - } - public GenericTypeContext genericType(int i) { - return getRuleContext(GenericTypeContext.class,i); - } - public List COMMA() { return getTokens(CocoParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(CocoParser.COMMA, i); - } - public GenericTypesContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_genericTypes; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterGenericTypes(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitGenericTypes(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitGenericTypes(this); - else return visitor.visitChildren(this); - } - } - - public final GenericTypesContext genericTypes() throws RecognitionException { - GenericTypesContext _localctx = new GenericTypesContext(_ctx, getState()); - enterRule(_localctx, 36, RULE_genericTypes); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(385); - genericType(); - setState(390); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==COMMA) { - { - { - setState(386); - match(COMMA); - setState(387); - genericType(); - } - } - setState(392); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class GenericTypeContext extends ParserRuleContext { - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode VAL() { return getToken(CocoParser.VAL, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public GenericTypeContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_genericType; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterGenericType(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitGenericType(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitGenericType(this); - else return visitor.visitChildren(this); - } - } - - public final GenericTypeContext genericType() throws RecognitionException { - GenericTypeContext _localctx = new GenericTypeContext(_ctx, getState()); - enterRule(_localctx, 38, RULE_genericType); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(394); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAL) { - { - setState(393); - match(VAL); - } - } - - setState(396); - match(IDENTIFIER); - setState(399); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COLON) { - { - setState(397); - match(COLON); - setState(398); - type(0); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class EnumElementContext extends ParserRuleContext { - public EnumCaseContext enumCase() { - return getRuleContext(EnumCaseContext.class,0); - } - public FunctionDeclarationContext functionDeclaration() { - return getRuleContext(FunctionDeclarationContext.class,0); - } - public TerminalNode MUT() { return getToken(CocoParser.MUT, 0); } - public TerminalNode MUTATING() { return getToken(CocoParser.MUTATING, 0); } - public StaticMemberDeclarationContext staticMemberDeclaration() { - return getRuleContext(StaticMemberDeclarationContext.class,0); - } - public EnumElementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_enumElement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterEnumElement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitEnumElement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitEnumElement(this); - else return visitor.visitChildren(this); - } - } - - public final EnumElementContext enumElement() throws RecognitionException { - EnumElementContext _localctx = new EnumElementContext(_ctx, getState()); - enterRule(_localctx, 40, RULE_enumElement); - int _la; - try { - setState(407); - _errHandler.sync(this); - switch (_input.LA(1)) { - case CASE: - enterOuterAlt(_localctx, 1); - { - setState(401); - enumCase(); - } - break; - case FUNCTION: - case MUT: - case MUTATING: - enterOuterAlt(_localctx, 2); - { - setState(403); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==MUT || _la==MUTATING) { - { - setState(402); - _la = _input.LA(1); - if ( !(_la==MUT || _la==MUTATING) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - - setState(405); - functionDeclaration(); - } - break; - case STATIC: - enterOuterAlt(_localctx, 3); - { - setState(406); - staticMemberDeclaration(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class EnumCaseContext extends ParserRuleContext { - public TerminalNode CASE() { return getToken(CocoParser.CASE, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public CaseParametersContext caseParameters() { - return getRuleContext(CaseParametersContext.class,0); - } - public EnumCaseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_enumCase; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterEnumCase(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitEnumCase(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitEnumCase(this); - else return visitor.visitChildren(this); - } - } - - public final EnumCaseContext enumCase() throws RecognitionException { - EnumCaseContext _localctx = new EnumCaseContext(_ctx, getState()); - enterRule(_localctx, 42, RULE_enumCase); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(409); - match(CASE); - setState(410); - match(IDENTIFIER); - setState(416); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LP) { - { - setState(411); - match(LP); - setState(413); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==IDENTIFIER) { - { - setState(412); - caseParameters(); - } - } - - setState(415); - match(RP); - } - } - - setState(420); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==ASSIGN) { - { - setState(418); - match(ASSIGN); - setState(419); - expression(0); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class CaseParametersContext extends ParserRuleContext { - public List caseParameter() { - return getRuleContexts(CaseParameterContext.class); - } - public CaseParameterContext caseParameter(int i) { - return getRuleContext(CaseParameterContext.class,i); - } - public List COMMA() { return getTokens(CocoParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(CocoParser.COMMA, i); - } - public CaseParametersContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_caseParameters; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterCaseParameters(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitCaseParameters(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitCaseParameters(this); - else return visitor.visitChildren(this); - } - } - - public final CaseParametersContext caseParameters() throws RecognitionException { - CaseParametersContext _localctx = new CaseParametersContext(_ctx, getState()); - enterRule(_localctx, 44, RULE_caseParameters); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(422); - caseParameter(); - setState(427); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==COMMA) { - { - { - setState(423); - match(COMMA); - setState(424); - caseParameter(); - } - } - setState(429); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class CaseParameterContext extends ParserRuleContext { - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public CaseParameterContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_caseParameter; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterCaseParameter(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitCaseParameter(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitCaseParameter(this); - else return visitor.visitChildren(this); - } - } - - public final CaseParameterContext caseParameter() throws RecognitionException { - CaseParameterContext _localctx = new CaseParameterContext(_ctx, getState()); - enterRule(_localctx, 46, RULE_caseParameter); - try { - enterOuterAlt(_localctx, 1); - { - setState(430); - match(IDENTIFIER); - setState(431); - match(COLON); - setState(432); - type(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class StructElementContext extends ParserRuleContext { - public FieldDeclarationContext fieldDeclaration() { - return getRuleContext(FieldDeclarationContext.class,0); - } - public FunctionDeclarationContext functionDeclaration() { - return getRuleContext(FunctionDeclarationContext.class,0); - } - public StaticMemberDeclarationContext staticMemberDeclaration() { - return getRuleContext(StaticMemberDeclarationContext.class,0); - } - public TerminalNode SEMI() { return getToken(CocoParser.SEMI, 0); } - public TerminalNode MUT() { return getToken(CocoParser.MUT, 0); } - public TerminalNode MUTATING() { return getToken(CocoParser.MUTATING, 0); } - public StructElementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_structElement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterStructElement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitStructElement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitStructElement(this); - else return visitor.visitChildren(this); - } - } - - public final StructElementContext structElement() throws RecognitionException { - StructElementContext _localctx = new StructElementContext(_ctx, getState()); - enterRule(_localctx, 48, RULE_structElement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(440); - _errHandler.sync(this); - switch (_input.LA(1)) { - case VAL: - case VAR: - case IDENTIFIER: - { - setState(434); - fieldDeclaration(); - } - break; - case FUNCTION: - case MUT: - case MUTATING: - { - setState(436); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==MUT || _la==MUTATING) { - { - setState(435); - _la = _input.LA(1); - if ( !(_la==MUT || _la==MUTATING) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - - setState(438); - functionDeclaration(); - } - break; - case STATIC: - { - setState(439); - staticMemberDeclaration(); - } - break; - default: - throw new NoViableAltException(this); - } - setState(443); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==SEMI) { - { - setState(442); - match(SEMI); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class FieldDeclarationContext extends ParserRuleContext { - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode VAL() { return getToken(CocoParser.VAL, 0); } - public TerminalNode VAR() { return getToken(CocoParser.VAR, 0); } - public FieldDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fieldDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterFieldDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitFieldDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitFieldDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final FieldDeclarationContext fieldDeclaration() throws RecognitionException { - FieldDeclarationContext _localctx = new FieldDeclarationContext(_ctx, getState()); - enterRule(_localctx, 50, RULE_fieldDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(446); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAL || _la==VAR) { - { - setState(445); - _la = _input.LA(1); - if ( !(_la==VAL || _la==VAR) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - - setState(448); - match(IDENTIFIER); - setState(449); - match(COLON); - setState(450); - type(0); - setState(453); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==ASSIGN) { - { - setState(451); - match(ASSIGN); - setState(452); - expression(0); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ComponentElementContext extends ParserRuleContext { - public FieldDeclarationContext fieldDeclaration() { - return getRuleContext(FieldDeclarationContext.class,0); - } - public VariableDeclarationContext variableDeclaration() { - return getRuleContext(VariableDeclarationContext.class,0); - } - public ConstructorDeclarationContext constructorDeclaration() { - return getRuleContext(ConstructorDeclarationContext.class,0); - } - public StateMachineDeclarationContext stateMachineDeclaration() { - return getRuleContext(StateMachineDeclarationContext.class,0); - } - public StaticMemberDeclarationContext staticMemberDeclaration() { - return getRuleContext(StaticMemberDeclarationContext.class,0); - } - public List attribute() { - return getRuleContexts(AttributeContext.class); - } - public AttributeContext attribute(int i) { - return getRuleContext(AttributeContext.class,i); - } - public TerminalNode SEMI() { return getToken(CocoParser.SEMI, 0); } - public ComponentElementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_componentElement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterComponentElement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitComponentElement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitComponentElement(this); - else return visitor.visitChildren(this); - } - } - - public final ComponentElementContext componentElement() throws RecognitionException { - ComponentElementContext _localctx = new ComponentElementContext(_ctx, getState()); - enterRule(_localctx, 52, RULE_componentElement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(458); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==AT) { - { - { - setState(455); - attribute(); - } - } - setState(460); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(466); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,47,_ctx) ) { - case 1: - { - setState(461); - fieldDeclaration(); - } - break; - case 2: - { - setState(462); - variableDeclaration(); - } - break; - case 3: - { - setState(463); - constructorDeclaration(); - } - break; - case 4: - { - setState(464); - stateMachineDeclaration(); - } - break; - case 5: - { - setState(465); - staticMemberDeclaration(); - } - break; - } - setState(469); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==SEMI) { - { - setState(468); - match(SEMI); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class StaticMemberDeclarationContext extends ParserRuleContext { - public TerminalNode STATIC() { return getToken(CocoParser.STATIC, 0); } - public TerminalNode VAL() { return getToken(CocoParser.VAL, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public StaticMemberDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_staticMemberDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterStaticMemberDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitStaticMemberDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitStaticMemberDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final StaticMemberDeclarationContext staticMemberDeclaration() throws RecognitionException { - StaticMemberDeclarationContext _localctx = new StaticMemberDeclarationContext(_ctx, getState()); - enterRule(_localctx, 54, RULE_staticMemberDeclaration); - try { - enterOuterAlt(_localctx, 1); - { - setState(471); - match(STATIC); - setState(472); - match(VAL); - setState(473); - match(IDENTIFIER); - setState(474); - match(COLON); - setState(475); - type(0); - setState(476); - match(ASSIGN); - setState(477); - expression(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ConstructorDeclarationContext extends ParserRuleContext { - public TerminalNode INIT() { return getToken(CocoParser.INIT, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public BlockExpression_Context blockExpression_() { - return getRuleContext(BlockExpression_Context.class,0); - } - public ParametersContext parameters() { - return getRuleContext(ParametersContext.class,0); - } - public ConstructorDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_constructorDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterConstructorDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitConstructorDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitConstructorDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final ConstructorDeclarationContext constructorDeclaration() throws RecognitionException { - ConstructorDeclarationContext _localctx = new ConstructorDeclarationContext(_ctx, getState()); - enterRule(_localctx, 56, RULE_constructorDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(479); - match(INIT); - setState(480); - match(LP); - setState(482); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAR || _la==IDENTIFIER) { - { - setState(481); - parameters(); - } - } - - setState(484); - match(RP); - setState(485); - match(ASSIGN); - setState(486); - blockExpression_(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ExpressionContext extends ParserRuleContext { - public ExpressionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_expression; } - - public ExpressionContext() { } - public void copyFrom(ExpressionContext ctx) { - super.copyFrom(ctx); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class IfExpressionContext extends ExpressionContext { - public IfExpression_Context ifExpression_() { - return getRuleContext(IfExpression_Context.class,0); - } - public IfExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterIfExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitIfExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitIfExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class TryOperatorExpressionContext extends ExpressionContext { - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode QM() { return getToken(CocoParser.QM, 0); } - public TryOperatorExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterTryOperatorExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitTryOperatorExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitTryOperatorExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class UnaryOperatorExpressionContext extends ExpressionContext { - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode MINUS() { return getToken(CocoParser.MINUS, 0); } - public TerminalNode EXCL() { return getToken(CocoParser.EXCL, 0); } - public TerminalNode AMP() { return getToken(CocoParser.AMP, 0); } - public UnaryOperatorExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterUnaryOperatorExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitUnaryOperatorExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitUnaryOperatorExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class OptionalExpressionContext extends ExpressionContext { - public TerminalNode OPTIONAL() { return getToken(CocoParser.OPTIONAL, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public OptionalExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterOptionalExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitOptionalExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitOptionalExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ArithmicOrLogicalExpressionContext extends ExpressionContext { - public List expression() { - return getRuleContexts(ExpressionContext.class); - } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class,i); - } - public TerminalNode MUL() { return getToken(CocoParser.MUL, 0); } - public TerminalNode DIV() { return getToken(CocoParser.DIV, 0); } - public TerminalNode MOD() { return getToken(CocoParser.MOD, 0); } - public TerminalNode PLUS() { return getToken(CocoParser.PLUS, 0); } - public TerminalNode MINUS() { return getToken(CocoParser.MINUS, 0); } - public TerminalNode EQ() { return getToken(CocoParser.EQ, 0); } - public TerminalNode NE() { return getToken(CocoParser.NE, 0); } - public TerminalNode OR() { return getToken(CocoParser.OR, 0); } - public TerminalNode AND() { return getToken(CocoParser.AND, 0); } - public TerminalNode LT() { return getToken(CocoParser.LT, 0); } - public TerminalNode LE() { return getToken(CocoParser.LE, 0); } - public TerminalNode GT() { return getToken(CocoParser.GT, 0); } - public TerminalNode GE() { return getToken(CocoParser.GE, 0); } - public ArithmicOrLogicalExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterArithmicOrLogicalExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitArithmicOrLogicalExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitArithmicOrLogicalExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class LiteralExpressionContext extends ExpressionContext { - public LiteralExpression_Context literalExpression_() { - return getRuleContext(LiteralExpression_Context.class,0); - } - public LiteralExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterLiteralExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitLiteralExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitLiteralExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ArrayLiteralExpressionContext extends ExpressionContext { - public TerminalNode LB() { return getToken(CocoParser.LB, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode RB() { return getToken(CocoParser.RB, 0); } - public ArrayLiteralExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterArrayLiteralExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitArrayLiteralExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitArrayLiteralExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class NondetExpressionContext extends ExpressionContext { - public NondetExpression_Context nondetExpression_() { - return getRuleContext(NondetExpression_Context.class,0); - } - public NondetExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterNondetExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitNondetExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitNondetExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class GroupedExpressionContext extends ExpressionContext { - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public ExpressionsContext expressions() { - return getRuleContext(ExpressionsContext.class,0); - } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public GroupedExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterGroupedExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitGroupedExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitGroupedExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class BlockExpressionContext extends ExpressionContext { - public BlockExpression_Context blockExpression_() { - return getRuleContext(BlockExpression_Context.class,0); - } - public BlockExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterBlockExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitBlockExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitBlockExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class MatchExpressionContext extends ExpressionContext { - public MatchExpression_Context matchExpression_() { - return getRuleContext(MatchExpression_Context.class,0); - } - public MatchExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterMatchExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitMatchExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitMatchExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class StructLiteralExpressionContext extends ExpressionContext { - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode LC() { return getToken(CocoParser.LC, 0); } - public FieldAssignmentsContext fieldAssignments() { - return getRuleContext(FieldAssignmentsContext.class,0); - } - public TerminalNode RC() { return getToken(CocoParser.RC, 0); } - public StructLiteralExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterStructLiteralExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitStructLiteralExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitStructLiteralExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class MemberReferenceExpressionContext extends ExpressionContext { - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode DOT() { return getToken(CocoParser.DOT, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public MemberReferenceExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterMemberReferenceExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitMemberReferenceExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitMemberReferenceExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class AssignmentExpressionContext extends ExpressionContext { - public List expression() { - return getRuleContexts(ExpressionContext.class); - } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class,i); - } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public AssignmentExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterAssignmentExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitAssignmentExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitAssignmentExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class VariableReferenceExpressionContext extends ExpressionContext { - public DotIdentifierListContext dotIdentifierList() { - return getRuleContext(DotIdentifierListContext.class,0); - } - public TerminalNode LT() { return getToken(CocoParser.LT, 0); } - public GenericTypesContext genericTypes() { - return getRuleContext(GenericTypesContext.class,0); - } - public TerminalNode GT() { return getToken(CocoParser.GT, 0); } - public VariableReferenceExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterVariableReferenceExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitVariableReferenceExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitVariableReferenceExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ImplicitMemberExpressionContext extends ExpressionContext { - public TerminalNode DOT() { return getToken(CocoParser.DOT, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public ImplicitMemberExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterImplicitMemberExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitImplicitMemberExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitImplicitMemberExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ExternalFunctionContext extends ExpressionContext { - public ExternalFunctionDeclarationContext externalFunctionDeclaration() { - return getRuleContext(ExternalFunctionDeclarationContext.class,0); - } - public ExternalFunctionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterExternalFunction(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitExternalFunction(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitExternalFunction(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class CastExpressionContext extends ExpressionContext { - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode AS() { return getToken(CocoParser.AS, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public CastExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterCastExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitCastExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitCastExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class StateInvariantExpressionContext extends ExpressionContext { - public StateInvariantContext stateInvariant() { - return getRuleContext(StateInvariantContext.class,0); - } - public StateInvariantExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterStateInvariantExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitStateInvariantExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitStateInvariantExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class CallExpressionContext extends ExpressionContext { - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public ExpressionsContext expressions() { - return getRuleContext(ExpressionsContext.class,0); - } - public CallExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterCallExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitCallExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitCallExpression(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ExternalLiteralContext extends ExpressionContext { - public TerminalNode EXTERNAL() { return getToken(CocoParser.EXTERNAL, 0); } - public TerminalNode BACKTICK_LITERAL() { return getToken(CocoParser.BACKTICK_LITERAL, 0); } - public ExternalLiteralContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterExternalLiteral(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitExternalLiteral(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitExternalLiteral(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ArraySubscriptExpressionContext extends ExpressionContext { - public List expression() { - return getRuleContexts(ExpressionContext.class); - } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class,i); - } - public TerminalNode LB() { return getToken(CocoParser.LB, 0); } - public TerminalNode RB() { return getToken(CocoParser.RB, 0); } - public ArraySubscriptExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterArraySubscriptExpression(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitArraySubscriptExpression(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitArraySubscriptExpression(this); - else return visitor.visitChildren(this); - } - } - - public final ExpressionContext expression() throws RecognitionException { - return expression(0); - } - - private ExpressionContext expression(int _p) throws RecognitionException { - ParserRuleContext _parentctx = _ctx; - int _parentState = getState(); - ExpressionContext _localctx = new ExpressionContext(_ctx, _parentState); - ExpressionContext _prevctx = _localctx; - int _startState = 58; - enterRecursionRule(_localctx, 58, RULE_expression, _p); - int _la; - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(519); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,51,_ctx) ) { - case 1: - { - _localctx = new LiteralExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - - setState(489); - literalExpression_(); - } - break; - case 2: - { - _localctx = new ExternalLiteralContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(490); - match(EXTERNAL); - setState(491); - match(BACKTICK_LITERAL); - } - break; - case 3: - { - _localctx = new ExternalFunctionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(492); - externalFunctionDeclaration(); - } - break; - case 4: - { - _localctx = new VariableReferenceExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(493); - dotIdentifierList(); - setState(498); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,50,_ctx) ) { - case 1: - { - setState(494); - match(LT); - setState(495); - genericTypes(); - setState(496); - match(GT); - } - break; - } - } - break; - case 5: - { - _localctx = new StateInvariantExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(500); - stateInvariant(); - } - break; - case 6: - { - _localctx = new UnaryOperatorExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(501); - _la = _input.LA(1); - if ( !(((((_la - 67)) & ~0x3f) == 0 && ((1L << (_la - 67)) & ((1L << (MINUS - 67)) | (1L << (AMP - 67)) | (1L << (EXCL - 67)))) != 0)) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(502); - expression(14); - } - break; - case 7: - { - _localctx = new IfExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(503); - ifExpression_(); - } - break; - case 8: - { - _localctx = new MatchExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(504); - matchExpression_(); - } - break; - case 9: - { - _localctx = new ImplicitMemberExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(505); - match(DOT); - setState(506); - match(IDENTIFIER); - } - break; - case 10: - { - _localctx = new GroupedExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(507); - match(LP); - setState(508); - expressions(); - setState(509); - match(RP); - } - break; - case 11: - { - _localctx = new ArrayLiteralExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(511); - match(LB); - setState(512); - expression(0); - setState(513); - match(RB); - } - break; - case 12: - { - _localctx = new NondetExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(515); - nondetExpression_(); - } - break; - case 13: - { - _localctx = new OptionalExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(516); - match(OPTIONAL); - setState(517); - expression(2); - } - break; - case 14: - { - _localctx = new BlockExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(518); - blockExpression_(); - } - break; - } - _ctx.stop = _input.LT(-1); - setState(559); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,54,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - if ( _parseListeners!=null ) triggerExitRuleEvent(); - _prevctx = _localctx; - { - setState(557); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,53,_ctx) ) { - case 1: - { - _localctx = new ArithmicOrLogicalExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(521); - if (!(precpred(_ctx, 12))) throw new FailedPredicateException(this, "precpred(_ctx, 12)"); - setState(522); - _la = _input.LA(1); - if ( !(((((_la - 65)) & ~0x3f) == 0 && ((1L << (_la - 65)) & ((1L << (MUL - 65)) | (1L << (DIV - 65)) | (1L << (MOD - 65)))) != 0)) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(523); - expression(13); - } - break; - case 2: - { - _localctx = new ArithmicOrLogicalExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(524); - if (!(precpred(_ctx, 11))) throw new FailedPredicateException(this, "precpred(_ctx, 11)"); - setState(525); - _la = _input.LA(1); - if ( !(_la==MINUS || _la==PLUS) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(526); - expression(12); - } - break; - case 3: - { - _localctx = new ArithmicOrLogicalExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(527); - if (!(precpred(_ctx, 10))) throw new FailedPredicateException(this, "precpred(_ctx, 10)"); - setState(528); - _la = _input.LA(1); - if ( !(((((_la - 63)) & ~0x3f) == 0 && ((1L << (_la - 63)) & ((1L << (LT - 63)) | (1L << (GT - 63)) | (1L << (EQ - 63)) | (1L << (NE - 63)) | (1L << (OR - 63)) | (1L << (AND - 63)) | (1L << (LE - 63)) | (1L << (GE - 63)))) != 0)) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(529); - expression(11); - } - break; - case 4: - { - _localctx = new AssignmentExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(530); - if (!(precpred(_ctx, 9))) throw new FailedPredicateException(this, "precpred(_ctx, 9)"); - setState(531); - match(ASSIGN); - setState(532); - expression(10); - } - break; - case 5: - { - _localctx = new MemberReferenceExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(533); - if (!(precpred(_ctx, 20))) throw new FailedPredicateException(this, "precpred(_ctx, 20)"); - setState(534); - match(DOT); - setState(535); - match(IDENTIFIER); - } - break; - case 6: - { - _localctx = new CallExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(536); - if (!(precpred(_ctx, 18))) throw new FailedPredicateException(this, "precpred(_ctx, 18)"); - setState(537); - match(LP); - setState(539); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ASSERT) | (1L << EXTERNAL) | (1L << IF) | (1L << MATCH) | (1L << NONDET) | (1L << OPTIONAL) | (1L << IDENTIFIER) | (1L << LP) | (1L << LC) | (1L << LB) | (1L << DOT))) != 0) || ((((_la - 67)) & ~0x3f) == 0 && ((1L << (_la - 67)) & ((1L << (MINUS - 67)) | (1L << (AMP - 67)) | (1L << (EXCL - 67)) | (1L << (INTEGER - 67)) | (1L << (CHAR_LITERAL - 67)) | (1L << (STRING_LITERAL - 67)))) != 0)) { - { - setState(538); - expressions(); - } - } - - setState(541); - match(RP); - } - break; - case 7: - { - _localctx = new ArraySubscriptExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(542); - if (!(precpred(_ctx, 17))) throw new FailedPredicateException(this, "precpred(_ctx, 17)"); - setState(543); - match(LB); - setState(544); - expression(0); - setState(545); - match(RB); - } - break; - case 8: - { - _localctx = new StructLiteralExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(547); - if (!(precpred(_ctx, 16))) throw new FailedPredicateException(this, "precpred(_ctx, 16)"); - setState(548); - match(LC); - setState(549); - fieldAssignments(); - setState(550); - match(RC); - } - break; - case 9: - { - _localctx = new TryOperatorExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(552); - if (!(precpred(_ctx, 15))) throw new FailedPredicateException(this, "precpred(_ctx, 15)"); - setState(553); - match(QM); - } - break; - case 10: - { - _localctx = new CastExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(554); - if (!(precpred(_ctx, 13))) throw new FailedPredicateException(this, "precpred(_ctx, 13)"); - setState(555); - match(AS); - setState(556); - type(0); - } - break; - } - } - } - setState(561); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,54,_ctx); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - unrollRecursionContexts(_parentctx); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class BlockExpression_Context extends ParserRuleContext { - public TerminalNode LC() { return getToken(CocoParser.LC, 0); } - public TerminalNode RC() { return getToken(CocoParser.RC, 0); } - public List statement() { - return getRuleContexts(StatementContext.class); - } - public StatementContext statement(int i) { - return getRuleContext(StatementContext.class,i); - } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public BlockExpression_Context(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_blockExpression_; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterBlockExpression_(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitBlockExpression_(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitBlockExpression_(this); - else return visitor.visitChildren(this); - } - } - - public final BlockExpression_Context blockExpression_() throws RecognitionException { - BlockExpression_Context _localctx = new BlockExpression_Context(_ctx, getState()); - enterRule(_localctx, 60, RULE_blockExpression_); - int _la; - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(562); - match(LC); - setState(566); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,55,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(563); - statement(); - } - } - } - setState(568); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,55,_ctx); - } - setState(570); - _errHandler.sync(this); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ASSERT) | (1L << EXTERNAL) | (1L << IF) | (1L << MATCH) | (1L << NONDET) | (1L << OPTIONAL) | (1L << IDENTIFIER) | (1L << LP) | (1L << LC) | (1L << LB) | (1L << DOT))) != 0) || ((((_la - 67)) & ~0x3f) == 0 && ((1L << (_la - 67)) & ((1L << (MINUS - 67)) | (1L << (AMP - 67)) | (1L << (EXCL - 67)) | (1L << (INTEGER - 67)) | (1L << (CHAR_LITERAL - 67)) | (1L << (STRING_LITERAL - 67)))) != 0)) { - { - setState(569); - expression(0); - } - } - - setState(572); - match(RC); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class IfExpression_Context extends ParserRuleContext { - public TerminalNode IF() { return getToken(CocoParser.IF, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public List expression() { - return getRuleContexts(ExpressionContext.class); - } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class,i); - } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public TerminalNode ELSE() { return getToken(CocoParser.ELSE, 0); } - public IfExpression_Context(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_ifExpression_; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterIfExpression_(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitIfExpression_(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitIfExpression_(this); - else return visitor.visitChildren(this); - } - } - - public final IfExpression_Context ifExpression_() throws RecognitionException { - IfExpression_Context _localctx = new IfExpression_Context(_ctx, getState()); - enterRule(_localctx, 62, RULE_ifExpression_); - try { - enterOuterAlt(_localctx, 1); - { - setState(574); - match(IF); - setState(575); - match(LP); - setState(576); - expression(0); - setState(577); - match(RP); - setState(578); - expression(0); - setState(581); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,57,_ctx) ) { - case 1: - { - setState(579); - match(ELSE); - setState(580); - expression(0); - } - break; - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class MatchExpression_Context extends ParserRuleContext { - public TerminalNode MATCH() { return getToken(CocoParser.MATCH, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public TerminalNode LC() { return getToken(CocoParser.LC, 0); } - public MatchClausesContext matchClauses() { - return getRuleContext(MatchClausesContext.class,0); - } - public TerminalNode RC() { return getToken(CocoParser.RC, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public MatchExpression_Context(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_matchExpression_; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterMatchExpression_(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitMatchExpression_(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitMatchExpression_(this); - else return visitor.visitChildren(this); - } - } - - public final MatchExpression_Context matchExpression_() throws RecognitionException { - MatchExpression_Context _localctx = new MatchExpression_Context(_ctx, getState()); - enterRule(_localctx, 64, RULE_matchExpression_); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(585); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==IDENTIFIER) { - { - setState(583); - match(IDENTIFIER); - setState(584); - match(COLON); - } - } - - setState(587); - match(MATCH); - setState(588); - match(LP); - setState(589); - expression(0); - setState(590); - match(RP); - setState(591); - match(LC); - setState(592); - matchClauses(); - setState(593); - match(RC); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class NondetExpression_Context extends ParserRuleContext { - public TerminalNode NONDET() { return getToken(CocoParser.NONDET, 0); } - public TerminalNode LC() { return getToken(CocoParser.LC, 0); } - public NondetClausesContext nondetClauses() { - return getRuleContext(NondetClausesContext.class,0); - } - public TerminalNode RC() { return getToken(CocoParser.RC, 0); } - public TerminalNode OTHERWISE() { return getToken(CocoParser.OTHERWISE, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode COMMA() { return getToken(CocoParser.COMMA, 0); } - public TerminalNode SEMI() { return getToken(CocoParser.SEMI, 0); } - public NondetExpression_Context(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_nondetExpression_; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterNondetExpression_(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitNondetExpression_(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitNondetExpression_(this); - else return visitor.visitChildren(this); - } - } - - public final NondetExpression_Context nondetExpression_() throws RecognitionException { - NondetExpression_Context _localctx = new NondetExpression_Context(_ctx, getState()); - enterRule(_localctx, 66, RULE_nondetExpression_); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(595); - match(NONDET); - setState(596); - match(LC); - setState(597); - nondetClauses(); - setState(600); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==OTHERWISE) { - { - setState(598); - match(OTHERWISE); - setState(599); - expression(0); - } - } - - setState(603); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COMMA || _la==SEMI) { - { - setState(602); - _la = _input.LA(1); - if ( !(_la==COMMA || _la==SEMI) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - - setState(605); - match(RC); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class FieldAssignmentsContext extends ParserRuleContext { - public List fieldAssignment() { - return getRuleContexts(FieldAssignmentContext.class); - } - public FieldAssignmentContext fieldAssignment(int i) { - return getRuleContext(FieldAssignmentContext.class,i); - } - public List COMMA() { return getTokens(CocoParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(CocoParser.COMMA, i); - } - public FieldAssignmentsContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fieldAssignments; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterFieldAssignments(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitFieldAssignments(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitFieldAssignments(this); - else return visitor.visitChildren(this); - } - } - - public final FieldAssignmentsContext fieldAssignments() throws RecognitionException { - FieldAssignmentsContext _localctx = new FieldAssignmentsContext(_ctx, getState()); - enterRule(_localctx, 68, RULE_fieldAssignments); - int _la; - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(607); - fieldAssignment(); - setState(612); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,61,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(608); - match(COMMA); - setState(609); - fieldAssignment(); - } - } - } - setState(614); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,61,_ctx); - } - setState(616); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COMMA) { - { - setState(615); - match(COMMA); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class FieldAssignmentContext extends ParserRuleContext { - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public FieldAssignmentContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_fieldAssignment; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterFieldAssignment(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitFieldAssignment(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitFieldAssignment(this); - else return visitor.visitChildren(this); - } - } - - public final FieldAssignmentContext fieldAssignment() throws RecognitionException { - FieldAssignmentContext _localctx = new FieldAssignmentContext(_ctx, getState()); - enterRule(_localctx, 70, RULE_fieldAssignment); - try { - enterOuterAlt(_localctx, 1); - { - setState(618); - match(IDENTIFIER); - setState(619); - match(ASSIGN); - setState(620); - expression(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class NondetClausesContext extends ParserRuleContext { - public List nondetClause() { - return getRuleContexts(NondetClauseContext.class); - } - public NondetClauseContext nondetClause(int i) { - return getRuleContext(NondetClauseContext.class,i); - } - public List COMMA() { return getTokens(CocoParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(CocoParser.COMMA, i); - } - public List SEMI() { return getTokens(CocoParser.SEMI); } - public TerminalNode SEMI(int i) { - return getToken(CocoParser.SEMI, i); - } - public NondetClausesContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_nondetClauses; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterNondetClauses(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitNondetClauses(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitNondetClauses(this); - else return visitor.visitChildren(this); - } - } - - public final NondetClausesContext nondetClauses() throws RecognitionException { - NondetClausesContext _localctx = new NondetClausesContext(_ctx, getState()); - enterRule(_localctx, 72, RULE_nondetClauses); - int _la; - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(622); - nondetClause(); - setState(627); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,63,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(623); - _la = _input.LA(1); - if ( !(_la==COMMA || _la==SEMI) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(624); - nondetClause(); - } - } - } - setState(629); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,63,_ctx); - } - setState(631); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,64,_ctx) ) { - case 1: - { - setState(630); - _la = _input.LA(1); - if ( !(_la==COMMA || _la==SEMI) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - break; - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class NondetClauseContext extends ParserRuleContext { - public List expression() { - return getRuleContexts(ExpressionContext.class); - } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class,i); - } - public TerminalNode IF() { return getToken(CocoParser.IF, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public NondetClauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_nondetClause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterNondetClause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitNondetClause(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitNondetClause(this); - else return visitor.visitChildren(this); - } - } - - public final NondetClauseContext nondetClause() throws RecognitionException { - NondetClauseContext _localctx = new NondetClauseContext(_ctx, getState()); - enterRule(_localctx, 74, RULE_nondetClause); - try { - enterOuterAlt(_localctx, 1); - { - setState(638); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,65,_ctx) ) { - case 1: - { - setState(633); - match(IF); - setState(634); - match(LP); - setState(635); - expression(0); - setState(636); - match(RP); - } - break; - } - setState(640); - expression(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class MatchClausesContext extends ParserRuleContext { - public List matchClause() { - return getRuleContexts(MatchClauseContext.class); - } - public MatchClauseContext matchClause(int i) { - return getRuleContext(MatchClauseContext.class,i); - } - public List COMMA() { return getTokens(CocoParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(CocoParser.COMMA, i); - } - public List SEMI() { return getTokens(CocoParser.SEMI); } - public TerminalNode SEMI(int i) { - return getToken(CocoParser.SEMI, i); - } - public MatchClausesContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_matchClauses; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterMatchClauses(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitMatchClauses(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitMatchClauses(this); - else return visitor.visitChildren(this); - } - } - - public final MatchClausesContext matchClauses() throws RecognitionException { - MatchClausesContext _localctx = new MatchClausesContext(_ctx, getState()); - enterRule(_localctx, 76, RULE_matchClauses); - int _la; - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(642); - matchClause(); - setState(647); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,66,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(643); - _la = _input.LA(1); - if ( !(_la==COMMA || _la==SEMI) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(644); - matchClause(); - } - } - } - setState(649); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,66,_ctx); - } - setState(651); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COMMA || _la==SEMI) { - { - setState(650); - _la = _input.LA(1); - if ( !(_la==COMMA || _la==SEMI) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class MatchClauseContext extends ParserRuleContext { - public PatternContext pattern() { - return getRuleContext(PatternContext.class,0); - } - public TerminalNode IMPL() { return getToken(CocoParser.IMPL, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public MatchClauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_matchClause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterMatchClause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitMatchClause(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitMatchClause(this); - else return visitor.visitChildren(this); - } - } - - public final MatchClauseContext matchClause() throws RecognitionException { - MatchClauseContext _localctx = new MatchClauseContext(_ctx, getState()); - enterRule(_localctx, 78, RULE_matchClause); - try { - enterOuterAlt(_localctx, 1); - { - setState(653); - pattern(); - setState(654); - match(IMPL); - setState(655); - expression(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class PatternContext extends ParserRuleContext { - public EnumCasePatternContext enumCasePattern() { - return getRuleContext(EnumCasePatternContext.class,0); - } - public LiteralExpression_Context literalExpression_() { - return getRuleContext(LiteralExpression_Context.class,0); - } - public VariableDeclarationPatternContext variableDeclarationPattern() { - return getRuleContext(VariableDeclarationPatternContext.class,0); - } - public PatternContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_pattern; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterPattern(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitPattern(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitPattern(this); - else return visitor.visitChildren(this); - } - } - - public final PatternContext pattern() throws RecognitionException { - PatternContext _localctx = new PatternContext(_ctx, getState()); - enterRule(_localctx, 80, RULE_pattern); - try { - setState(660); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,68,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(657); - enumCasePattern(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(658); - literalExpression_(); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(659); - variableDeclarationPattern(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class EnumCasePatternContext extends ParserRuleContext { - public IdParameterPatternsContext idParameterPatterns() { - return getRuleContext(IdParameterPatternsContext.class,0); - } - public TerminalNode IF() { return getToken(CocoParser.IF, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public EnumCasePatternContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_enumCasePattern; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterEnumCasePattern(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitEnumCasePattern(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitEnumCasePattern(this); - else return visitor.visitChildren(this); - } - } - - public final EnumCasePatternContext enumCasePattern() throws RecognitionException { - EnumCasePatternContext _localctx = new EnumCasePatternContext(_ctx, getState()); - enterRule(_localctx, 82, RULE_enumCasePattern); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(662); - idParameterPatterns(); - setState(668); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==IF) { - { - setState(663); - match(IF); - setState(664); - match(LP); - setState(665); - expression(0); - setState(666); - match(RP); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class IdParameterPatternsContext extends ParserRuleContext { - public List idParameterPattern() { - return getRuleContexts(IdParameterPatternContext.class); - } - public IdParameterPatternContext idParameterPattern(int i) { - return getRuleContext(IdParameterPatternContext.class,i); - } - public List DOT() { return getTokens(CocoParser.DOT); } - public TerminalNode DOT(int i) { - return getToken(CocoParser.DOT, i); - } - public IdParameterPatternsContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_idParameterPatterns; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterIdParameterPatterns(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitIdParameterPatterns(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitIdParameterPatterns(this); - else return visitor.visitChildren(this); - } - } - - public final IdParameterPatternsContext idParameterPatterns() throws RecognitionException { - IdParameterPatternsContext _localctx = new IdParameterPatternsContext(_ctx, getState()); - enterRule(_localctx, 84, RULE_idParameterPatterns); - int _la; - try { - setState(687); - _errHandler.sync(this); - switch (_input.LA(1)) { - case IDENTIFIER: - enterOuterAlt(_localctx, 1); - { - setState(670); - idParameterPattern(); - setState(675); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==DOT) { - { - { - setState(671); - match(DOT); - setState(672); - idParameterPattern(); - } - } - setState(677); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - break; - case DOT: - enterOuterAlt(_localctx, 2); - { - setState(678); - match(DOT); - setState(679); - idParameterPattern(); - setState(684); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==DOT) { - { - { - setState(680); - match(DOT); - setState(681); - idParameterPattern(); - } - } - setState(686); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class IdParameterPatternContext extends ParserRuleContext { - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public ParameterPatternsContext parameterPatterns() { - return getRuleContext(ParameterPatternsContext.class,0); - } - public IdParameterPatternContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_idParameterPattern; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterIdParameterPattern(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitIdParameterPattern(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitIdParameterPattern(this); - else return visitor.visitChildren(this); - } - } - - public final IdParameterPatternContext idParameterPattern() throws RecognitionException { - IdParameterPatternContext _localctx = new IdParameterPatternContext(_ctx, getState()); - enterRule(_localctx, 86, RULE_idParameterPattern); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(689); - match(IDENTIFIER); - setState(695); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LP) { - { - setState(690); - match(LP); - setState(692); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAR || _la==IDENTIFIER) { - { - setState(691); - parameterPatterns(); - } - } - - setState(694); - match(RP); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class VariableDeclarationPatternContext extends ParserRuleContext { - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode VAL() { return getToken(CocoParser.VAL, 0); } - public TerminalNode DOT() { return getToken(CocoParser.DOT, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public VariableDeclarationPatternContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_variableDeclarationPattern; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterVariableDeclarationPattern(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitVariableDeclarationPattern(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitVariableDeclarationPattern(this); - else return visitor.visitChildren(this); - } - } - - public final VariableDeclarationPatternContext variableDeclarationPattern() throws RecognitionException { - VariableDeclarationPatternContext _localctx = new VariableDeclarationPatternContext(_ctx, getState()); - enterRule(_localctx, 88, RULE_variableDeclarationPattern); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(697); - _la = _input.LA(1); - if ( !(_la==VAL || _la==DOT) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(698); - match(IDENTIFIER); - setState(701); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COLON) { - { - setState(699); - match(COLON); - setState(700); - type(0); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ParameterPatternsContext extends ParserRuleContext { - public List parameterPattern() { - return getRuleContexts(ParameterPatternContext.class); - } - public ParameterPatternContext parameterPattern(int i) { - return getRuleContext(ParameterPatternContext.class,i); - } - public List COMMA() { return getTokens(CocoParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(CocoParser.COMMA, i); - } - public ParameterPatternsContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_parameterPatterns; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterParameterPatterns(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitParameterPatterns(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitParameterPatterns(this); - else return visitor.visitChildren(this); - } - } - - public final ParameterPatternsContext parameterPatterns() throws RecognitionException { - ParameterPatternsContext _localctx = new ParameterPatternsContext(_ctx, getState()); - enterRule(_localctx, 90, RULE_parameterPatterns); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(703); - parameterPattern(); - setState(708); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==COMMA) { - { - { - setState(704); - match(COMMA); - setState(705); - parameterPattern(); - } - } - setState(710); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ParameterPatternContext extends ParserRuleContext { - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode VAR() { return getToken(CocoParser.VAR, 0); } - public ParameterPatternContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_parameterPattern; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterParameterPattern(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitParameterPattern(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitParameterPattern(this); - else return visitor.visitChildren(this); - } - } - - public final ParameterPatternContext parameterPattern() throws RecognitionException { - ParameterPatternContext _localctx = new ParameterPatternContext(_ctx, getState()); - enterRule(_localctx, 92, RULE_parameterPattern); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(712); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAR) { - { - setState(711); - match(VAR); - } - } - - setState(714); - match(IDENTIFIER); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ExpressionsContext extends ParserRuleContext { - public List expression() { - return getRuleContexts(ExpressionContext.class); - } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class,i); - } - public List COMMA() { return getTokens(CocoParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(CocoParser.COMMA, i); - } - public ExpressionsContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_expressions; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterExpressions(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitExpressions(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitExpressions(this); - else return visitor.visitChildren(this); - } - } - - public final ExpressionsContext expressions() throws RecognitionException { - ExpressionsContext _localctx = new ExpressionsContext(_ctx, getState()); - enterRule(_localctx, 94, RULE_expressions); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(716); - expression(0); - setState(721); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==COMMA) { - { - { - setState(717); - match(COMMA); - setState(718); - expression(0); - } - } - setState(723); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class StatementContext extends ParserRuleContext { - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public StateInvariantContext stateInvariant() { - return getRuleContext(StateInvariantContext.class,0); - } - public DeclarationStatementContext declarationStatement() { - return getRuleContext(DeclarationStatementContext.class,0); - } - public ReturnStatementContext returnStatement() { - return getRuleContext(ReturnStatementContext.class,0); - } - public BecomeStatementContext becomeStatement() { - return getRuleContext(BecomeStatementContext.class,0); - } - public WhileStatementContext whileStatement() { - return getRuleContext(WhileStatementContext.class,0); - } - public ForStatementContext forStatement() { - return getRuleContext(ForStatementContext.class,0); - } - public BreakStatementContext breakStatement() { - return getRuleContext(BreakStatementContext.class,0); - } - public ContinueStatementContext continueStatement() { - return getRuleContext(ContinueStatementContext.class,0); - } - public List attribute() { - return getRuleContexts(AttributeContext.class); - } - public AttributeContext attribute(int i) { - return getRuleContext(AttributeContext.class,i); - } - public TerminalNode SEMI() { return getToken(CocoParser.SEMI, 0); } - public StatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_statement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitStatement(this); - else return visitor.visitChildren(this); - } - } - - public final StatementContext statement() throws RecognitionException { - StatementContext _localctx = new StatementContext(_ctx, getState()); - enterRule(_localctx, 96, RULE_statement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(727); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==AT) { - { - { - setState(724); - attribute(); - } - } - setState(729); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(745); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,82,_ctx) ) { - case 1: - { - setState(730); - expression(0); - setState(732); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==SEMI) { - { - setState(731); - match(SEMI); - } - } - - } - break; - case 2: - { - setState(734); - stateInvariant(); - setState(736); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==SEMI) { - { - setState(735); - match(SEMI); - } - } - - } - break; - case 3: - { - setState(738); - declarationStatement(); - } - break; - case 4: - { - setState(739); - returnStatement(); - } - break; - case 5: - { - setState(740); - becomeStatement(); - } - break; - case 6: - { - setState(741); - whileStatement(); - } - break; - case 7: - { - setState(742); - forStatement(); - } - break; - case 8: - { - setState(743); - breakStatement(); - } - break; - case 9: - { - setState(744); - continueStatement(); - } - break; - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class DeclarationStatementContext extends ParserRuleContext { - public VariableDeclarationContext variableDeclaration() { - return getRuleContext(VariableDeclarationContext.class,0); - } - public TerminalNode SEMI() { return getToken(CocoParser.SEMI, 0); } - public DeclarationStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_declarationStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterDeclarationStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitDeclarationStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitDeclarationStatement(this); - else return visitor.visitChildren(this); - } - } - - public final DeclarationStatementContext declarationStatement() throws RecognitionException { - DeclarationStatementContext _localctx = new DeclarationStatementContext(_ctx, getState()); - enterRule(_localctx, 98, RULE_declarationStatement); - try { - enterOuterAlt(_localctx, 1); - { - setState(747); - variableDeclaration(); - setState(748); - match(SEMI); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ReturnStatementContext extends ParserRuleContext { - public TerminalNode RETURN() { return getToken(CocoParser.RETURN, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode SEMI() { return getToken(CocoParser.SEMI, 0); } - public ReturnStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_returnStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterReturnStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitReturnStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitReturnStatement(this); - else return visitor.visitChildren(this); - } - } - - public final ReturnStatementContext returnStatement() throws RecognitionException { - ReturnStatementContext _localctx = new ReturnStatementContext(_ctx, getState()); - enterRule(_localctx, 100, RULE_returnStatement); - try { - enterOuterAlt(_localctx, 1); - { - setState(750); - match(RETURN); - setState(751); - expression(0); - setState(752); - match(SEMI); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class BecomeStatementContext extends ParserRuleContext { - public TerminalNode BECOME() { return getToken(CocoParser.BECOME, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode SEMI() { return getToken(CocoParser.SEMI, 0); } - public BecomeStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_becomeStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterBecomeStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitBecomeStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitBecomeStatement(this); - else return visitor.visitChildren(this); - } - } - - public final BecomeStatementContext becomeStatement() throws RecognitionException { - BecomeStatementContext _localctx = new BecomeStatementContext(_ctx, getState()); - enterRule(_localctx, 102, RULE_becomeStatement); - try { - enterOuterAlt(_localctx, 1); - { - setState(754); - match(BECOME); - setState(755); - expression(0); - setState(756); - match(SEMI); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class WhileStatementContext extends ParserRuleContext { - public TerminalNode WHILE() { return getToken(CocoParser.WHILE, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public BlockExpression_Context blockExpression_() { - return getRuleContext(BlockExpression_Context.class,0); - } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public WhileStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_whileStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterWhileStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitWhileStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitWhileStatement(this); - else return visitor.visitChildren(this); - } - } - - public final WhileStatementContext whileStatement() throws RecognitionException { - WhileStatementContext _localctx = new WhileStatementContext(_ctx, getState()); - enterRule(_localctx, 104, RULE_whileStatement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(760); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==IDENTIFIER) { - { - setState(758); - match(IDENTIFIER); - setState(759); - match(COLON); - } - } - - setState(762); - match(WHILE); - setState(763); - match(LP); - setState(764); - expression(0); - setState(765); - match(RP); - setState(766); - blockExpression_(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ForStatementContext extends ParserRuleContext { - public TerminalNode FOR() { return getToken(CocoParser.FOR, 0); } - public List IDENTIFIER() { return getTokens(CocoParser.IDENTIFIER); } - public TerminalNode IDENTIFIER(int i) { - return getToken(CocoParser.IDENTIFIER, i); - } - public TerminalNode IN() { return getToken(CocoParser.IN, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public BlockExpression_Context blockExpression_() { - return getRuleContext(BlockExpression_Context.class,0); - } - public List COLON() { return getTokens(CocoParser.COLON); } - public TerminalNode COLON(int i) { - return getToken(CocoParser.COLON, i); - } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public ForStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_forStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterForStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitForStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitForStatement(this); - else return visitor.visitChildren(this); - } - } - - public final ForStatementContext forStatement() throws RecognitionException { - ForStatementContext _localctx = new ForStatementContext(_ctx, getState()); - enterRule(_localctx, 106, RULE_forStatement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(770); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==IDENTIFIER) { - { - setState(768); - match(IDENTIFIER); - setState(769); - match(COLON); - } - } - - setState(772); - match(FOR); - setState(773); - match(IDENTIFIER); - setState(776); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COLON) { - { - setState(774); - match(COLON); - setState(775); - type(0); - } - } - - setState(778); - match(IN); - setState(779); - expression(0); - setState(780); - blockExpression_(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class BreakStatementContext extends ParserRuleContext { - public TerminalNode BREAK() { return getToken(CocoParser.BREAK, 0); } - public TerminalNode SEMI() { return getToken(CocoParser.SEMI, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public BreakStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_breakStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterBreakStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitBreakStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitBreakStatement(this); - else return visitor.visitChildren(this); - } - } - - public final BreakStatementContext breakStatement() throws RecognitionException { - BreakStatementContext _localctx = new BreakStatementContext(_ctx, getState()); - enterRule(_localctx, 108, RULE_breakStatement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(782); - match(BREAK); - setState(784); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==IDENTIFIER) { - { - setState(783); - match(IDENTIFIER); - } - } - - setState(786); - match(SEMI); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ContinueStatementContext extends ParserRuleContext { - public TerminalNode CONTINUE() { return getToken(CocoParser.CONTINUE, 0); } - public TerminalNode SEMI() { return getToken(CocoParser.SEMI, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public ContinueStatementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_continueStatement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterContinueStatement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitContinueStatement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitContinueStatement(this); - else return visitor.visitChildren(this); - } - } - - public final ContinueStatementContext continueStatement() throws RecognitionException { - ContinueStatementContext _localctx = new ContinueStatementContext(_ctx, getState()); - enterRule(_localctx, 110, RULE_continueStatement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(788); - match(CONTINUE); - setState(790); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==IDENTIFIER) { - { - setState(789); - match(IDENTIFIER); - } - } - - setState(792); - match(SEMI); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class PortElementContext extends ParserRuleContext { - public EnumDeclarationContext enumDeclaration() { - return getRuleContext(EnumDeclarationContext.class,0); - } - public FunctionInterfaceDeclarationContext functionInterfaceDeclaration() { - return getRuleContext(FunctionInterfaceDeclarationContext.class,0); - } - public SignalDeclarationContext signalDeclaration() { - return getRuleContext(SignalDeclarationContext.class,0); - } - public FieldDeclarationContext fieldDeclaration() { - return getRuleContext(FieldDeclarationContext.class,0); - } - public StateMachineDeclarationContext stateMachineDeclaration() { - return getRuleContext(StateMachineDeclarationContext.class,0); - } - public PortDeclarationContext portDeclaration() { - return getRuleContext(PortDeclarationContext.class,0); - } - public StaticMemberDeclarationContext staticMemberDeclaration() { - return getRuleContext(StaticMemberDeclarationContext.class,0); - } - public StructDeclarationContext structDeclaration() { - return getRuleContext(StructDeclarationContext.class,0); - } - public TypeAliasDeclarationContext typeAliasDeclaration() { - return getRuleContext(TypeAliasDeclarationContext.class,0); - } - public ExternalTypeDeclarationContext externalTypeDeclaration() { - return getRuleContext(ExternalTypeDeclarationContext.class,0); - } - public List attribute() { - return getRuleContexts(AttributeContext.class); - } - public AttributeContext attribute(int i) { - return getRuleContext(AttributeContext.class,i); - } - public PortElementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_portElement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterPortElement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitPortElement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitPortElement(this); - else return visitor.visitChildren(this); - } - } - - public final PortElementContext portElement() throws RecognitionException { - PortElementContext _localctx = new PortElementContext(_ctx, getState()); - enterRule(_localctx, 112, RULE_portElement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(797); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==AT) { - { - { - setState(794); - attribute(); - } - } - setState(799); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(810); - _errHandler.sync(this); - switch (_input.LA(1)) { - case ENUM: - { - setState(800); - enumDeclaration(); - } - break; - case FUNCTION: - { - setState(801); - functionInterfaceDeclaration(); - } - break; - case OUTGOING: - { - setState(802); - signalDeclaration(); - } - break; - case VAL: - case VAR: - case IDENTIFIER: - { - setState(803); - fieldDeclaration(); - } - break; - case MACHINE: - { - setState(804); - stateMachineDeclaration(); - } - break; - case PORT: - { - setState(805); - portDeclaration(); - } - break; - case STATIC: - { - setState(806); - staticMemberDeclaration(); - } - break; - case STRUCT: - { - setState(807); - structDeclaration(); - } - break; - case TYPE: - { - setState(808); - typeAliasDeclaration(); - } - break; - case EXTERNAL: - { - setState(809); - externalTypeDeclaration(); - } - break; - default: - throw new NoViableAltException(this); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class FunctionInterfaceDeclarationContext extends ParserRuleContext { - public TerminalNode FUNCTION() { return getToken(CocoParser.FUNCTION, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public ParametersContext parameters() { - return getRuleContext(ParametersContext.class,0); - } - public FunctionInterfaceDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_functionInterfaceDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterFunctionInterfaceDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitFunctionInterfaceDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitFunctionInterfaceDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final FunctionInterfaceDeclarationContext functionInterfaceDeclaration() throws RecognitionException { - FunctionInterfaceDeclarationContext _localctx = new FunctionInterfaceDeclarationContext(_ctx, getState()); - enterRule(_localctx, 114, RULE_functionInterfaceDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(812); - match(FUNCTION); - setState(813); - match(IDENTIFIER); - setState(814); - match(LP); - setState(816); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAR || _la==IDENTIFIER) { - { - setState(815); - parameters(); - } - } - - setState(818); - match(RP); - setState(819); - match(COLON); - setState(820); - type(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class SignalDeclarationContext extends ParserRuleContext { - public TerminalNode OUTGOING() { return getToken(CocoParser.OUTGOING, 0); } - public TerminalNode SIGNAL() { return getToken(CocoParser.SIGNAL, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public ParametersContext parameters() { - return getRuleContext(ParametersContext.class,0); - } - public SignalDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_signalDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterSignalDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitSignalDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitSignalDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final SignalDeclarationContext signalDeclaration() throws RecognitionException { - SignalDeclarationContext _localctx = new SignalDeclarationContext(_ctx, getState()); - enterRule(_localctx, 116, RULE_signalDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(822); - match(OUTGOING); - setState(823); - match(SIGNAL); - setState(824); - match(IDENTIFIER); - setState(825); - match(LP); - setState(827); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAR || _la==IDENTIFIER) { - { - setState(826); - parameters(); - } - } - - setState(829); - match(RP); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class StateMachineDeclarationContext extends ParserRuleContext { - public TerminalNode MACHINE() { return getToken(CocoParser.MACHINE, 0); } - public TerminalNode LC() { return getToken(CocoParser.LC, 0); } - public TerminalNode RC() { return getToken(CocoParser.RC, 0); } - public List IDENTIFIER() { return getTokens(CocoParser.IDENTIFIER); } - public TerminalNode IDENTIFIER(int i) { - return getToken(CocoParser.IDENTIFIER, i); - } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public List stateMachineElement() { - return getRuleContexts(StateMachineElementContext.class); - } - public StateMachineElementContext stateMachineElement(int i) { - return getRuleContext(StateMachineElementContext.class,i); - } - public StateMachineDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_stateMachineDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterStateMachineDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitStateMachineDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitStateMachineDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final StateMachineDeclarationContext stateMachineDeclaration() throws RecognitionException { - StateMachineDeclarationContext _localctx = new StateMachineDeclarationContext(_ctx, getState()); - enterRule(_localctx, 118, RULE_stateMachineDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(831); - match(MACHINE); - setState(833); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==IDENTIFIER) { - { - setState(832); - match(IDENTIFIER); - } - } - - setState(837); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COLON) { - { - setState(835); - match(COLON); - setState(836); - match(IDENTIFIER); - } - } - - setState(839); - match(LC); - setState(843); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << AFTER) | (1L << ASSERT) | (1L << ENUM) | (1L << ENTRY) | (1L << EXECUTION) | (1L << EXIT) | (1L << FUNCTION) | (1L << IF) | (1L << PERIODIC) | (1L << PRIVATE) | (1L << SPONTANEOUS) | (1L << STATE) | (1L << STATIC) | (1L << TYPE) | (1L << VAL) | (1L << VAR) | (1L << IDENTIFIER) | (1L << AT))) != 0)) { - { - { - setState(840); - stateMachineElement(); - } - } - setState(845); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(846); - match(RC); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class StateMachineElementContext extends ParserRuleContext { - public EnumDeclarationContext enumDeclaration() { - return getRuleContext(EnumDeclarationContext.class,0); - } - public EntryFunctionDeclarationContext entryFunctionDeclaration() { - return getRuleContext(EntryFunctionDeclarationContext.class,0); - } - public ExitFunctionDeclarationContext exitFunctionDeclaration() { - return getRuleContext(ExitFunctionDeclarationContext.class,0); - } - public FunctionDeclarationContext functionDeclaration() { - return getRuleContext(FunctionDeclarationContext.class,0); - } - public StateInvariantContext stateInvariant() { - return getRuleContext(StateInvariantContext.class,0); - } - public StateDeclarationContext stateDeclaration() { - return getRuleContext(StateDeclarationContext.class,0); - } - public StaticMemberDeclarationContext staticMemberDeclaration() { - return getRuleContext(StaticMemberDeclarationContext.class,0); - } - public TypeAliasDeclarationContext typeAliasDeclaration() { - return getRuleContext(TypeAliasDeclarationContext.class,0); - } - public VariableDeclarationContext variableDeclaration() { - return getRuleContext(VariableDeclarationContext.class,0); - } - public TransitionDeclarationContext transitionDeclaration() { - return getRuleContext(TransitionDeclarationContext.class,0); - } - public List attribute() { - return getRuleContexts(AttributeContext.class); - } - public AttributeContext attribute(int i) { - return getRuleContext(AttributeContext.class,i); - } - public StateMachineElementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_stateMachineElement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterStateMachineElement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitStateMachineElement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitStateMachineElement(this); - else return visitor.visitChildren(this); - } - } - - public final StateMachineElementContext stateMachineElement() throws RecognitionException { - StateMachineElementContext _localctx = new StateMachineElementContext(_ctx, getState()); - enterRule(_localctx, 120, RULE_stateMachineElement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(851); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==AT) { - { - { - setState(848); - attribute(); - } - } - setState(853); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(864); - _errHandler.sync(this); - switch (_input.LA(1)) { - case ENUM: - { - setState(854); - enumDeclaration(); - } - break; - case ENTRY: - { - setState(855); - entryFunctionDeclaration(); - } - break; - case EXIT: - { - setState(856); - exitFunctionDeclaration(); - } - break; - case FUNCTION: - { - setState(857); - functionDeclaration(); - } - break; - case ASSERT: - { - setState(858); - stateInvariant(); - } - break; - case EXECUTION: - case STATE: - { - setState(859); - stateDeclaration(); - } - break; - case STATIC: - { - setState(860); - staticMemberDeclaration(); - } - break; - case TYPE: - { - setState(861); - typeAliasDeclaration(); - } - break; - case PRIVATE: - case VAL: - case VAR: - { - setState(862); - variableDeclaration(); - } - break; - case AFTER: - case IF: - case PERIODIC: - case SPONTANEOUS: - case IDENTIFIER: - { - setState(863); - transitionDeclaration(); - } - break; - default: - throw new NoViableAltException(this); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class StateDeclarationContext extends ParserRuleContext { - public EventStateDeclarationContext eventStateDeclaration() { - return getRuleContext(EventStateDeclarationContext.class,0); - } - public ExecutionStateDeclarationContext executionStateDeclaration() { - return getRuleContext(ExecutionStateDeclarationContext.class,0); - } - public StateDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_stateDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterStateDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitStateDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitStateDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final StateDeclarationContext stateDeclaration() throws RecognitionException { - StateDeclarationContext _localctx = new StateDeclarationContext(_ctx, getState()); - enterRule(_localctx, 122, RULE_stateDeclaration); - try { - setState(868); - _errHandler.sync(this); - switch (_input.LA(1)) { - case STATE: - enterOuterAlt(_localctx, 1); - { - setState(866); - eventStateDeclaration(); - } - break; - case EXECUTION: - enterOuterAlt(_localctx, 2); - { - setState(867); - executionStateDeclaration(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class EventStateDeclarationContext extends ParserRuleContext { - public TerminalNode STATE() { return getToken(CocoParser.STATE, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LC() { return getToken(CocoParser.LC, 0); } - public TerminalNode RC() { return getToken(CocoParser.RC, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public List eventStateElement() { - return getRuleContexts(EventStateElementContext.class); - } - public EventStateElementContext eventStateElement(int i) { - return getRuleContext(EventStateElementContext.class,i); - } - public ParametersContext parameters() { - return getRuleContext(ParametersContext.class,0); - } - public EventStateDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_eventStateDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterEventStateDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitEventStateDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitEventStateDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final EventStateDeclarationContext eventStateDeclaration() throws RecognitionException { - EventStateDeclarationContext _localctx = new EventStateDeclarationContext(_ctx, getState()); - enterRule(_localctx, 124, RULE_eventStateDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(870); - match(STATE); - setState(871); - match(IDENTIFIER); - setState(877); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LP) { - { - setState(872); - match(LP); - setState(874); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAR || _la==IDENTIFIER) { - { - setState(873); - parameters(); - } - } - - setState(876); - match(RP); - } - } - - setState(879); - match(LC); - setState(883); - _errHandler.sync(this); - _la = _input.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << AFTER) | (1L << ASSERT) | (1L << ENUM) | (1L << ENTRY) | (1L << EXECUTION) | (1L << EXIT) | (1L << FUNCTION) | (1L << IF) | (1L << PERIODIC) | (1L << PRIVATE) | (1L << SPONTANEOUS) | (1L << STATE) | (1L << STATIC) | (1L << STRUCT) | (1L << TYPE) | (1L << VAL) | (1L << VAR) | (1L << IDENTIFIER) | (1L << AT))) != 0)) { - { - { - setState(880); - eventStateElement(); - } - } - setState(885); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(886); - match(RC); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ExecutionStateDeclarationContext extends ParserRuleContext { - public TerminalNode EXECUTION() { return getToken(CocoParser.EXECUTION, 0); } - public TerminalNode STATE() { return getToken(CocoParser.STATE, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public BlockExpression_Context blockExpression_() { - return getRuleContext(BlockExpression_Context.class,0); - } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public ParametersContext parameters() { - return getRuleContext(ParametersContext.class,0); - } - public ExecutionStateDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_executionStateDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterExecutionStateDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitExecutionStateDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitExecutionStateDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final ExecutionStateDeclarationContext executionStateDeclaration() throws RecognitionException { - ExecutionStateDeclarationContext _localctx = new ExecutionStateDeclarationContext(_ctx, getState()); - enterRule(_localctx, 126, RULE_executionStateDeclaration); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(888); - match(EXECUTION); - setState(889); - match(STATE); - setState(890); - match(IDENTIFIER); - setState(896); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LP) { - { - setState(891); - match(LP); - setState(893); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAR || _la==IDENTIFIER) { - { - setState(892); - parameters(); - } - } - - setState(895); - match(RP); - } - } - - setState(898); - blockExpression_(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class EventStateElementContext extends ParserRuleContext { - public EnumDeclarationContext enumDeclaration() { - return getRuleContext(EnumDeclarationContext.class,0); - } - public EntryFunctionDeclarationContext entryFunctionDeclaration() { - return getRuleContext(EntryFunctionDeclarationContext.class,0); - } - public ExitFunctionDeclarationContext exitFunctionDeclaration() { - return getRuleContext(ExitFunctionDeclarationContext.class,0); - } - public FunctionDeclarationContext functionDeclaration() { - return getRuleContext(FunctionDeclarationContext.class,0); - } - public StateDeclarationContext stateDeclaration() { - return getRuleContext(StateDeclarationContext.class,0); - } - public StateInvariantContext stateInvariant() { - return getRuleContext(StateInvariantContext.class,0); - } - public StaticMemberDeclarationContext staticMemberDeclaration() { - return getRuleContext(StaticMemberDeclarationContext.class,0); - } - public StructDeclarationContext structDeclaration() { - return getRuleContext(StructDeclarationContext.class,0); - } - public TransitionDeclarationContext transitionDeclaration() { - return getRuleContext(TransitionDeclarationContext.class,0); - } - public TypeAliasDeclarationContext typeAliasDeclaration() { - return getRuleContext(TypeAliasDeclarationContext.class,0); - } - public VariableDeclarationContext variableDeclaration() { - return getRuleContext(VariableDeclarationContext.class,0); - } - public List attribute() { - return getRuleContexts(AttributeContext.class); - } - public AttributeContext attribute(int i) { - return getRuleContext(AttributeContext.class,i); - } - public EventStateElementContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_eventStateElement; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterEventStateElement(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitEventStateElement(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitEventStateElement(this); - else return visitor.visitChildren(this); - } - } - - public final EventStateElementContext eventStateElement() throws RecognitionException { - EventStateElementContext _localctx = new EventStateElementContext(_ctx, getState()); - enterRule(_localctx, 128, RULE_eventStateElement); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(903); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==AT) { - { - { - setState(900); - attribute(); - } - } - setState(905); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(917); - _errHandler.sync(this); - switch (_input.LA(1)) { - case ENUM: - { - setState(906); - enumDeclaration(); - } - break; - case ENTRY: - { - setState(907); - entryFunctionDeclaration(); - } - break; - case EXIT: - { - setState(908); - exitFunctionDeclaration(); - } - break; - case FUNCTION: - { - setState(909); - functionDeclaration(); - } - break; - case EXECUTION: - case STATE: - { - setState(910); - stateDeclaration(); - } - break; - case ASSERT: - { - setState(911); - stateInvariant(); - } - break; - case STATIC: - { - setState(912); - staticMemberDeclaration(); - } - break; - case STRUCT: - { - setState(913); - structDeclaration(); - } - break; - case AFTER: - case IF: - case PERIODIC: - case SPONTANEOUS: - case IDENTIFIER: - { - setState(914); - transitionDeclaration(); - } - break; - case TYPE: - { - setState(915); - typeAliasDeclaration(); - } - break; - case PRIVATE: - case VAL: - case VAR: - { - setState(916); - variableDeclaration(); - } - break; - default: - throw new NoViableAltException(this); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class EntryFunctionDeclarationContext extends ParserRuleContext { - public TerminalNode ENTRY() { return getToken(CocoParser.ENTRY, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public EntryFunctionDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_entryFunctionDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterEntryFunctionDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitEntryFunctionDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitEntryFunctionDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final EntryFunctionDeclarationContext entryFunctionDeclaration() throws RecognitionException { - EntryFunctionDeclarationContext _localctx = new EntryFunctionDeclarationContext(_ctx, getState()); - enterRule(_localctx, 130, RULE_entryFunctionDeclaration); - try { - enterOuterAlt(_localctx, 1); - { - setState(919); - match(ENTRY); - setState(920); - match(LP); - setState(921); - match(RP); - setState(922); - match(ASSIGN); - setState(923); - expression(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ExitFunctionDeclarationContext extends ParserRuleContext { - public TerminalNode EXIT() { return getToken(CocoParser.EXIT, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public ExitFunctionDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_exitFunctionDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterExitFunctionDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitExitFunctionDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitExitFunctionDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final ExitFunctionDeclarationContext exitFunctionDeclaration() throws RecognitionException { - ExitFunctionDeclarationContext _localctx = new ExitFunctionDeclarationContext(_ctx, getState()); - enterRule(_localctx, 132, RULE_exitFunctionDeclaration); - try { - enterOuterAlt(_localctx, 1); - { - setState(925); - match(EXIT); - setState(926); - match(LP); - setState(927); - match(RP); - setState(928); - match(ASSIGN); - setState(929); - expression(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class StateInvariantContext extends ParserRuleContext { - public TerminalNode ASSERT() { return getToken(CocoParser.ASSERT, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public StateInvariantContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_stateInvariant; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterStateInvariant(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitStateInvariant(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitStateInvariant(this); - else return visitor.visitChildren(this); - } - } - - public final StateInvariantContext stateInvariant() throws RecognitionException { - StateInvariantContext _localctx = new StateInvariantContext(_ctx, getState()); - enterRule(_localctx, 134, RULE_stateInvariant); - try { - enterOuterAlt(_localctx, 1); - { - setState(931); - match(ASSERT); - setState(932); - match(LP); - setState(933); - expression(0); - setState(934); - match(RP); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class TransitionDeclarationContext extends ParserRuleContext { - public EventTransitionContext eventTransition() { - return getRuleContext(EventTransitionContext.class,0); - } - public SpontaneousTransitionContext spontaneousTransition() { - return getRuleContext(SpontaneousTransitionContext.class,0); - } - public TimerTransitionContext timerTransition() { - return getRuleContext(TimerTransitionContext.class,0); - } - public TransitionDeclarationContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_transitionDeclaration; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterTransitionDeclaration(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitTransitionDeclaration(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitTransitionDeclaration(this); - else return visitor.visitChildren(this); - } - } - - public final TransitionDeclarationContext transitionDeclaration() throws RecognitionException { - TransitionDeclarationContext _localctx = new TransitionDeclarationContext(_ctx, getState()); - enterRule(_localctx, 136, RULE_transitionDeclaration); - try { - setState(939); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,105,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(936); - eventTransition(); - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(937); - spontaneousTransition(); - } - break; - case 3: - enterOuterAlt(_localctx, 3); - { - setState(938); - timerTransition(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class EventTransitionContext extends ParserRuleContext { - public DotIdentifierListContext dotIdentifierList() { - return getRuleContext(DotIdentifierListContext.class,0); - } - public List LP() { return getTokens(CocoParser.LP); } - public TerminalNode LP(int i) { - return getToken(CocoParser.LP, i); - } - public List RP() { return getTokens(CocoParser.RP); } - public TerminalNode RP(int i) { - return getToken(CocoParser.RP, i); - } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public EventHandlerContext eventHandler() { - return getRuleContext(EventHandlerContext.class,0); - } - public TerminalNode IF() { return getToken(CocoParser.IF, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public List eventSource() { - return getRuleContexts(EventSourceContext.class); - } - public EventSourceContext eventSource(int i) { - return getRuleContext(EventSourceContext.class,i); - } - public List DOT() { return getTokens(CocoParser.DOT); } - public TerminalNode DOT(int i) { - return getToken(CocoParser.DOT, i); - } - public ParametersContext parameters() { - return getRuleContext(ParametersContext.class,0); - } - public EventTransitionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_eventTransition; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterEventTransition(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitEventTransition(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitEventTransition(this); - else return visitor.visitChildren(this); - } - } - - public final EventTransitionContext eventTransition() throws RecognitionException { - EventTransitionContext _localctx = new EventTransitionContext(_ctx, getState()); - enterRule(_localctx, 138, RULE_eventTransition); - int _la; - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(946); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==IF) { - { - setState(941); - match(IF); - setState(942); - match(LP); - setState(943); - expression(0); - setState(944); - match(RP); - } - } - - setState(953); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,107,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(948); - eventSource(); - setState(949); - match(DOT); - } - } - } - setState(955); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,107,_ctx); - } - setState(956); - dotIdentifierList(); - setState(957); - match(LP); - setState(959); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAR || _la==IDENTIFIER) { - { - setState(958); - parameters(); - } - } - - setState(961); - match(RP); - setState(962); - match(ASSIGN); - setState(963); - eventHandler(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class EventSourceContext extends ParserRuleContext { - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode LB() { return getToken(CocoParser.LB, 0); } - public PatternContext pattern() { - return getRuleContext(PatternContext.class,0); - } - public TerminalNode RB() { return getToken(CocoParser.RB, 0); } - public TerminalNode PIPE() { return getToken(CocoParser.PIPE, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public EventSourceContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_eventSource; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterEventSource(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitEventSource(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitEventSource(this); - else return visitor.visitChildren(this); - } - } - - public final EventSourceContext eventSource() throws RecognitionException { - EventSourceContext _localctx = new EventSourceContext(_ctx, getState()); - enterRule(_localctx, 140, RULE_eventSource); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(965); - match(IDENTIFIER); - setState(974); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==LB) { - { - setState(966); - match(LB); - setState(967); - pattern(); - setState(970); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==PIPE) { - { - setState(968); - match(PIPE); - setState(969); - expression(0); - } - } - - setState(972); - match(RB); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class SpontaneousTransitionContext extends ParserRuleContext { - public TerminalNode SPONTANEOUS() { return getToken(CocoParser.SPONTANEOUS, 0); } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public List expression() { - return getRuleContexts(ExpressionContext.class); - } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class,i); - } - public TerminalNode IF() { return getToken(CocoParser.IF, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public SpontaneousTransitionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_spontaneousTransition; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterSpontaneousTransition(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitSpontaneousTransition(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitSpontaneousTransition(this); - else return visitor.visitChildren(this); - } - } - - public final SpontaneousTransitionContext spontaneousTransition() throws RecognitionException { - SpontaneousTransitionContext _localctx = new SpontaneousTransitionContext(_ctx, getState()); - enterRule(_localctx, 142, RULE_spontaneousTransition); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(981); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==IF) { - { - setState(976); - match(IF); - setState(977); - match(LP); - setState(978); - expression(0); - setState(979); - match(RP); - } - } - - setState(983); - match(SPONTANEOUS); - setState(984); - match(ASSIGN); - setState(985); - expression(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class TimerTransitionContext extends ParserRuleContext { - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public List expression() { - return getRuleContexts(ExpressionContext.class); - } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class,i); - } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public TerminalNode ASSIGN() { return getToken(CocoParser.ASSIGN, 0); } - public TerminalNode AFTER() { return getToken(CocoParser.AFTER, 0); } - public TerminalNode PERIODIC() { return getToken(CocoParser.PERIODIC, 0); } - public TimerTransitionContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_timerTransition; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterTimerTransition(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitTimerTransition(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitTimerTransition(this); - else return visitor.visitChildren(this); - } - } - - public final TimerTransitionContext timerTransition() throws RecognitionException { - TimerTransitionContext _localctx = new TimerTransitionContext(_ctx, getState()); - enterRule(_localctx, 144, RULE_timerTransition); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(987); - _la = _input.LA(1); - if ( !(_la==AFTER || _la==PERIODIC) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(988); - match(LP); - setState(989); - expression(0); - setState(990); - match(RP); - setState(991); - match(ASSIGN); - setState(992); - expression(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class EventHandlerContext extends ParserRuleContext { - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode ILLEGAL() { return getToken(CocoParser.ILLEGAL, 0); } - public OfferContext offer() { - return getRuleContext(OfferContext.class,0); - } - public EventHandlerContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_eventHandler; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterEventHandler(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitEventHandler(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitEventHandler(this); - else return visitor.visitChildren(this); - } - } - - public final EventHandlerContext eventHandler() throws RecognitionException { - EventHandlerContext _localctx = new EventHandlerContext(_ctx, getState()); - enterRule(_localctx, 146, RULE_eventHandler); - try { - setState(997); - _errHandler.sync(this); - switch (_input.LA(1)) { - case ASSERT: - case EXTERNAL: - case IF: - case MATCH: - case NONDET: - case OPTIONAL: - case IDENTIFIER: - case LP: - case LC: - case LB: - case DOT: - case MINUS: - case AMP: - case EXCL: - case INTEGER: - case CHAR_LITERAL: - case STRING_LITERAL: - enterOuterAlt(_localctx, 1); - { - setState(994); - expression(0); - } - break; - case ILLEGAL: - enterOuterAlt(_localctx, 2); - { - setState(995); - match(ILLEGAL); - } - break; - case OFFER: - enterOuterAlt(_localctx, 3); - { - setState(996); - offer(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class OfferContext extends ParserRuleContext { - public TerminalNode OFFER() { return getToken(CocoParser.OFFER, 0); } - public TerminalNode LC() { return getToken(CocoParser.LC, 0); } - public OfferClausesContext offerClauses() { - return getRuleContext(OfferClausesContext.class,0); - } - public TerminalNode RC() { return getToken(CocoParser.RC, 0); } - public TerminalNode OTHERWISE() { return getToken(CocoParser.OTHERWISE, 0); } - public EventHandlerContext eventHandler() { - return getRuleContext(EventHandlerContext.class,0); - } - public TerminalNode COMMA() { return getToken(CocoParser.COMMA, 0); } - public OfferContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_offer; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterOffer(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitOffer(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitOffer(this); - else return visitor.visitChildren(this); - } - } - - public final OfferContext offer() throws RecognitionException { - OfferContext _localctx = new OfferContext(_ctx, getState()); - enterRule(_localctx, 148, RULE_offer); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(999); - match(OFFER); - setState(1000); - match(LC); - setState(1001); - offerClauses(); - setState(1007); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==OTHERWISE) { - { - setState(1002); - match(OTHERWISE); - setState(1003); - eventHandler(); - setState(1005); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COMMA) { - { - setState(1004); - match(COMMA); - } - } - - } - } - - setState(1009); - match(RC); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class OfferClausesContext extends ParserRuleContext { - public List offerClause() { - return getRuleContexts(OfferClauseContext.class); - } - public OfferClauseContext offerClause(int i) { - return getRuleContext(OfferClauseContext.class,i); - } - public List COMMA() { return getTokens(CocoParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(CocoParser.COMMA, i); - } - public OfferClausesContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_offerClauses; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterOfferClauses(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitOfferClauses(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitOfferClauses(this); - else return visitor.visitChildren(this); - } - } - - public final OfferClausesContext offerClauses() throws RecognitionException { - OfferClausesContext _localctx = new OfferClausesContext(_ctx, getState()); - enterRule(_localctx, 150, RULE_offerClauses); - int _la; - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(1011); - offerClause(); - setState(1016); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,115,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(1012); - match(COMMA); - setState(1013); - offerClause(); - } - } - } - setState(1018); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,115,_ctx); - } - setState(1020); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COMMA) { - { - setState(1019); - match(COMMA); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class OfferClauseContext extends ParserRuleContext { - public EventHandlerContext eventHandler() { - return getRuleContext(EventHandlerContext.class,0); - } - public List attribute() { - return getRuleContexts(AttributeContext.class); - } - public AttributeContext attribute(int i) { - return getRuleContext(AttributeContext.class,i); - } - public TerminalNode IF() { return getToken(CocoParser.IF, 0); } - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class,0); - } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public OfferClauseContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_offerClause; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterOfferClause(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitOfferClause(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitOfferClause(this); - else return visitor.visitChildren(this); - } - } - - public final OfferClauseContext offerClause() throws RecognitionException { - OfferClauseContext _localctx = new OfferClauseContext(_ctx, getState()); - enterRule(_localctx, 152, RULE_offerClause); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(1025); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==AT) { - { - { - setState(1022); - attribute(); - } - } - setState(1027); - _errHandler.sync(this); - _la = _input.LA(1); - } - setState(1033); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,118,_ctx) ) { - case 1: - { - setState(1028); - match(IF); - setState(1029); - match(LP); - setState(1030); - expression(0); - setState(1031); - match(RP); - } - break; - } - setState(1035); - eventHandler(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ParametersContext extends ParserRuleContext { - public List parameter() { - return getRuleContexts(ParameterContext.class); - } - public ParameterContext parameter(int i) { - return getRuleContext(ParameterContext.class,i); - } - public List COMMA() { return getTokens(CocoParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(CocoParser.COMMA, i); - } - public ParametersContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_parameters; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterParameters(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitParameters(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitParameters(this); - else return visitor.visitChildren(this); - } - } - - public final ParametersContext parameters() throws RecognitionException { - ParametersContext _localctx = new ParametersContext(_ctx, getState()); - enterRule(_localctx, 154, RULE_parameters); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(1037); - parameter(); - setState(1042); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==COMMA) { - { - { - setState(1038); - match(COMMA); - setState(1039); - parameter(); - } - } - setState(1044); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ParameterContext extends ParserRuleContext { - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TerminalNode VAR() { return getToken(CocoParser.VAR, 0); } - public TerminalNode ELLIP() { return getToken(CocoParser.ELLIP, 0); } - public TerminalNode COLON() { return getToken(CocoParser.COLON, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public GenericTypeDeclarationContext genericTypeDeclaration() { - return getRuleContext(GenericTypeDeclarationContext.class,0); - } - public ParameterContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_parameter; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterParameter(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitParameter(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitParameter(this); - else return visitor.visitChildren(this); - } - } - - public final ParameterContext parameter() throws RecognitionException { - ParameterContext _localctx = new ParameterContext(_ctx, getState()); - enterRule(_localctx, 156, RULE_parameter); - int _la; - try { - setState(1058); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,123,_ctx) ) { - case 1: - enterOuterAlt(_localctx, 1); - { - setState(1046); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==VAR) { - { - setState(1045); - match(VAR); - } - } - - setState(1048); - match(IDENTIFIER); - setState(1050); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==ELLIP) { - { - setState(1049); - match(ELLIP); - } - } - - setState(1054); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==COLON) { - { - setState(1052); - match(COLON); - setState(1053); - type(0); - } - } - - } - break; - case 2: - enterOuterAlt(_localctx, 2); - { - setState(1056); - match(IDENTIFIER); - setState(1057); - genericTypeDeclaration(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class LiteralExpression_Context extends ParserRuleContext { - public TerminalNode INTEGER() { return getToken(CocoParser.INTEGER, 0); } - public TerminalNode CHAR_LITERAL() { return getToken(CocoParser.CHAR_LITERAL, 0); } - public TerminalNode STRING_LITERAL() { return getToken(CocoParser.STRING_LITERAL, 0); } - public LiteralExpression_Context(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_literalExpression_; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterLiteralExpression_(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitLiteralExpression_(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitLiteralExpression_(this); - else return visitor.visitChildren(this); - } - } - - public final LiteralExpression_Context literalExpression_() throws RecognitionException { - LiteralExpression_Context _localctx = new LiteralExpression_Context(_ctx, getState()); - enterRule(_localctx, 158, RULE_literalExpression_); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(1060); - _la = _input.LA(1); - if ( !(((((_la - 87)) & ~0x3f) == 0 && ((1L << (_la - 87)) & ((1L << (INTEGER - 87)) | (1L << (CHAR_LITERAL - 87)) | (1L << (STRING_LITERAL - 87)))) != 0)) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class TypeContext extends ParserRuleContext { - public TypeContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_type; } - - public TypeContext() { } - public void copyFrom(TypeContext ctx) { - super.copyFrom(ctx); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class BinaryTypeContext extends TypeContext { - public List type() { - return getRuleContexts(TypeContext.class); - } - public TypeContext type(int i) { - return getRuleContext(TypeContext.class,i); - } - public TerminalNode MUL() { return getToken(CocoParser.MUL, 0); } - public TerminalNode DIV() { return getToken(CocoParser.DIV, 0); } - public TerminalNode MOD() { return getToken(CocoParser.MOD, 0); } - public TerminalNode PLUS() { return getToken(CocoParser.PLUS, 0); } - public TerminalNode MINUS() { return getToken(CocoParser.MINUS, 0); } - public BinaryTypeContext(TypeContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterBinaryType(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitBinaryType(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitBinaryType(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class GroupTypeContext extends TypeContext { - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public GroupTypeContext(TypeContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterGroupType(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitGroupType(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitGroupType(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class FunctionTypeContext extends TypeContext { - public TerminalNode LP() { return getToken(CocoParser.LP, 0); } - public TypesContext types() { - return getRuleContext(TypesContext.class,0); - } - public TerminalNode RP() { return getToken(CocoParser.RP, 0); } - public TerminalNode ARROW() { return getToken(CocoParser.ARROW, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public FunctionTypeContext(TypeContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterFunctionType(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitFunctionType(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitFunctionType(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class UnaryTypeContext extends TypeContext { - public TerminalNode MINUS() { return getToken(CocoParser.MINUS, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public UnaryTypeContext(TypeContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterUnaryType(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitUnaryType(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitUnaryType(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class LiteralTypeContext extends TypeContext { - public LiteralExpression_Context literalExpression_() { - return getRuleContext(LiteralExpression_Context.class,0); - } - public LiteralTypeContext(TypeContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterLiteralType(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitLiteralType(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitLiteralType(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class TypeReferenceContext extends TypeContext { - public DotIdentifierListContext dotIdentifierList() { - return getRuleContext(DotIdentifierListContext.class,0); - } - public TerminalNode LT() { return getToken(CocoParser.LT, 0); } - public TypesContext types() { - return getRuleContext(TypesContext.class,0); - } - public TerminalNode GT() { return getToken(CocoParser.GT, 0); } - public TerminalNode DOT() { return getToken(CocoParser.DOT, 0); } - public TerminalNode IDENTIFIER() { return getToken(CocoParser.IDENTIFIER, 0); } - public TypeReferenceContext(TypeContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterTypeReference(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitTypeReference(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitTypeReference(this); - else return visitor.visitChildren(this); - } - } - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class ReferenceTypeContext extends TypeContext { - public TerminalNode AMP() { return getToken(CocoParser.AMP, 0); } - public TypeContext type() { - return getRuleContext(TypeContext.class,0); - } - public TerminalNode MUT() { return getToken(CocoParser.MUT, 0); } - public TerminalNode OUT() { return getToken(CocoParser.OUT, 0); } - public ReferenceTypeContext(TypeContext ctx) { copyFrom(ctx); } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterReferenceType(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitReferenceType(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitReferenceType(this); - else return visitor.visitChildren(this); - } - } - - public final TypeContext type() throws RecognitionException { - return type(0); - } - - private TypeContext type(int _p) throws RecognitionException { - ParserRuleContext _parentctx = _ctx; - int _parentState = getState(); - TypeContext _localctx = new TypeContext(_ctx, _parentState); - TypeContext _prevctx = _localctx; - int _startState = 160; - enterRecursionRule(_localctx, 160, RULE_type, _p); - int _la; - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(1092); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,127,_ctx) ) { - case 1: - { - _localctx = new GroupTypeContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - - setState(1063); - match(LP); - setState(1064); - type(0); - setState(1065); - match(RP); - } - break; - case 2: - { - _localctx = new TypeReferenceContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(1067); - dotIdentifierList(); - setState(1072); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,124,_ctx) ) { - case 1: - { - setState(1068); - match(LT); - setState(1069); - types(); - setState(1070); - match(GT); - } - break; - } - setState(1076); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,125,_ctx) ) { - case 1: - { - setState(1074); - match(DOT); - setState(1075); - match(IDENTIFIER); - } - break; - } - } - break; - case 3: - { - _localctx = new FunctionTypeContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(1078); - match(LP); - setState(1079); - types(); - setState(1080); - match(RP); - setState(1081); - match(ARROW); - setState(1082); - type(4); - } - break; - case 4: - { - _localctx = new LiteralTypeContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(1084); - literalExpression_(); - } - break; - case 5: - { - _localctx = new ReferenceTypeContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(1085); - match(AMP); - setState(1087); - _errHandler.sync(this); - _la = _input.LA(1); - if (_la==MUT || _la==OUT) { - { - setState(1086); - _la = _input.LA(1); - if ( !(_la==MUT || _la==OUT) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - } - } - - setState(1089); - type(2); - } - break; - case 6: - { - _localctx = new UnaryTypeContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(1090); - match(MINUS); - setState(1091); - type(1); - } - break; - } - _ctx.stop = _input.LT(-1); - setState(1102); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,129,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - if ( _parseListeners!=null ) triggerExitRuleEvent(); - _prevctx = _localctx; - { - setState(1100); - _errHandler.sync(this); - switch ( getInterpreter().adaptivePredict(_input,128,_ctx) ) { - case 1: - { - _localctx = new BinaryTypeContext(new TypeContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_type); - setState(1094); - if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); - setState(1095); - _la = _input.LA(1); - if ( !(((((_la - 65)) & ~0x3f) == 0 && ((1L << (_la - 65)) & ((1L << (MUL - 65)) | (1L << (DIV - 65)) | (1L << (MOD - 65)))) != 0)) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(1096); - type(9); - } - break; - case 2: - { - _localctx = new BinaryTypeContext(new TypeContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_type); - setState(1097); - if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); - setState(1098); - _la = _input.LA(1); - if ( !(_la==MINUS || _la==PLUS) ) { - _errHandler.recoverInline(this); - } - else { - if ( _input.LA(1)==Token.EOF ) matchedEOF = true; - _errHandler.reportMatch(this); - consume(); - } - setState(1099); - type(8); - } - break; - } - } - } - setState(1104); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,129,_ctx); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - unrollRecursionContexts(_parentctx); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class TypesContext extends ParserRuleContext { - public List type() { - return getRuleContexts(TypeContext.class); - } - public TypeContext type(int i) { - return getRuleContext(TypeContext.class,i); - } - public List COMMA() { return getTokens(CocoParser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(CocoParser.COMMA, i); - } - public TypesContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_types; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterTypes(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitTypes(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitTypes(this); - else return visitor.visitChildren(this); - } - } - - public final TypesContext types() throws RecognitionException { - TypesContext _localctx = new TypesContext(_ctx, getState()); - enterRule(_localctx, 162, RULE_types); - int _la; - try { - enterOuterAlt(_localctx, 1); - { - setState(1105); - type(0); - setState(1110); - _errHandler.sync(this); - _la = _input.LA(1); - while (_la==COMMA) { - { - { - setState(1106); - match(COMMA); - setState(1107); - type(0); - } - } - setState(1112); - _errHandler.sync(this); - _la = _input.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public static class DotIdentifierListContext extends ParserRuleContext { - public List IDENTIFIER() { return getTokens(CocoParser.IDENTIFIER); } - public TerminalNode IDENTIFIER(int i) { - return getToken(CocoParser.IDENTIFIER, i); - } - public List DOT() { return getTokens(CocoParser.DOT); } - public TerminalNode DOT(int i) { - return getToken(CocoParser.DOT, i); - } - public DotIdentifierListContext(ParserRuleContext parent, int invokingState) { - super(parent, invokingState); - } - @Override public int getRuleIndex() { return RULE_dotIdentifierList; } - @Override - public void enterRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).enterDotIdentifierList(this); - } - @Override - public void exitRule(ParseTreeListener listener) { - if ( listener instanceof CocoListener ) ((CocoListener)listener).exitDotIdentifierList(this); - } - @Override - public T accept(ParseTreeVisitor visitor) { - if ( visitor instanceof CocoVisitor ) return ((CocoVisitor)visitor).visitDotIdentifierList(this); - else return visitor.visitChildren(this); - } - } - - public final DotIdentifierListContext dotIdentifierList() throws RecognitionException { - DotIdentifierListContext _localctx = new DotIdentifierListContext(_ctx, getState()); - enterRule(_localctx, 164, RULE_dotIdentifierList); - try { - int _alt; - enterOuterAlt(_localctx, 1); - { - setState(1113); - match(IDENTIFIER); - setState(1118); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,131,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - setState(1114); - match(DOT); - setState(1115); - match(IDENTIFIER); - } - } - } - setState(1120); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input,131,_ctx); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - _errHandler.reportError(this, re); - _errHandler.recover(this, re); - } - finally { - exitRule(); - } - return _localctx; - } - - public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { - switch (ruleIndex) { - case 29: - return expression_sempred((ExpressionContext)_localctx, predIndex); - case 80: - return type_sempred((TypeContext)_localctx, predIndex); - } - return true; - } - private boolean expression_sempred(ExpressionContext _localctx, int predIndex) { - switch (predIndex) { - case 0: - return precpred(_ctx, 12); - case 1: - return precpred(_ctx, 11); - case 2: - return precpred(_ctx, 10); - case 3: - return precpred(_ctx, 9); - case 4: - return precpred(_ctx, 20); - case 5: - return precpred(_ctx, 18); - case 6: - return precpred(_ctx, 17); - case 7: - return precpred(_ctx, 16); - case 8: - return precpred(_ctx, 15); - case 9: - return precpred(_ctx, 13); - } - return true; - } - private boolean type_sempred(TypeContext _localctx, int predIndex) { - switch (predIndex) { - case 10: - return precpred(_ctx, 8); - case 11: - return precpred(_ctx, 7); - } - return true; - } - - public static final String _serializedATN = - "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\\\u0464\4\2\t\2\4"+ - "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ - "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ - "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ - "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ - "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+ - ",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+ - "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+ - "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I"+ - "\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT"+ - "\3\2\7\2\u00aa\n\2\f\2\16\2\u00ad\13\2\3\2\3\2\3\3\7\3\u00b2\n\3\f\3\16"+ - "\3\u00b5\13\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\5\3"+ - "\u00c4\n\3\3\4\3\4\3\4\3\4\3\4\3\4\5\4\u00cc\n\4\3\5\3\5\3\5\3\5\3\5\5"+ - "\5\u00d3\n\5\3\5\5\5\u00d6\n\5\3\6\3\6\5\6\u00da\n\6\3\6\3\6\3\6\5\6\u00df"+ - "\n\6\3\7\5\7\u00e2\n\7\3\7\3\7\3\7\5\7\u00e7\n\7\3\7\3\7\5\7\u00eb\n\7"+ - "\3\7\3\7\5\7\u00ef\n\7\3\b\3\b\3\b\5\b\u00f4\n\b\3\b\3\b\7\b\u00f8\n\b"+ - "\f\b\16\b\u00fb\13\b\3\b\3\b\3\t\3\t\3\t\5\t\u0102\n\t\3\t\3\t\7\t\u0106"+ - "\n\t\f\t\16\t\u0109\13\t\3\t\3\t\3\n\3\n\3\n\5\n\u0110\n\n\3\n\3\n\3\n"+ - "\3\13\3\13\3\13\5\13\u0118\n\13\3\13\3\13\5\13\u011c\n\13\3\13\3\13\3"+ - "\13\3\13\3\13\3\13\3\f\3\f\3\f\5\f\u0127\n\f\3\f\3\f\3\f\3\f\3\f\3\r\3"+ - "\r\3\r\3\r\5\r\u0132\n\r\3\r\5\r\u0135\n\r\3\r\3\r\7\r\u0139\n\r\f\r\16"+ - "\r\u013c\13\r\3\r\3\r\3\16\5\16\u0141\n\16\3\16\3\16\3\16\3\16\5\16\u0147"+ - "\n\16\3\16\3\16\7\16\u014b\n\16\f\16\16\16\u014e\13\16\3\16\3\16\3\17"+ - "\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20\3\20\7\20\u015f"+ - "\n\20\f\20\16\20\u0162\13\20\3\20\5\20\u0165\n\20\3\21\3\21\3\21\5\21"+ - "\u016a\n\21\3\21\5\21\u016d\n\21\3\22\3\22\3\22\3\22\3\22\5\22\u0174\n"+ - "\22\3\22\3\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\5\23\u0180\n\23"+ - "\3\23\3\23\3\24\3\24\3\24\7\24\u0187\n\24\f\24\16\24\u018a\13\24\3\25"+ - "\5\25\u018d\n\25\3\25\3\25\3\25\5\25\u0192\n\25\3\26\3\26\5\26\u0196\n"+ - "\26\3\26\3\26\5\26\u019a\n\26\3\27\3\27\3\27\3\27\5\27\u01a0\n\27\3\27"+ - "\5\27\u01a3\n\27\3\27\3\27\5\27\u01a7\n\27\3\30\3\30\3\30\7\30\u01ac\n"+ - "\30\f\30\16\30\u01af\13\30\3\31\3\31\3\31\3\31\3\32\3\32\5\32\u01b7\n"+ - "\32\3\32\3\32\5\32\u01bb\n\32\3\32\5\32\u01be\n\32\3\33\5\33\u01c1\n\33"+ - "\3\33\3\33\3\33\3\33\3\33\5\33\u01c8\n\33\3\34\7\34\u01cb\n\34\f\34\16"+ - "\34\u01ce\13\34\3\34\3\34\3\34\3\34\3\34\5\34\u01d5\n\34\3\34\5\34\u01d8"+ - "\n\34\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\36\3\36\3\36\5\36\u01e5"+ - "\n\36\3\36\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37"+ - "\3\37\5\37\u01f5\n\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37"+ - "\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\5\37\u020a\n\37\3\37\3\37"+ - "\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37"+ - "\3\37\3\37\5\37\u021e\n\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37"+ - "\3\37\3\37\3\37\3\37\3\37\3\37\3\37\7\37\u0230\n\37\f\37\16\37\u0233\13"+ - "\37\3 \3 \7 \u0237\n \f \16 \u023a\13 \3 \5 \u023d\n \3 \3 \3!\3!\3!\3"+ - "!\3!\3!\3!\5!\u0248\n!\3\"\3\"\5\"\u024c\n\"\3\"\3\"\3\"\3\"\3\"\3\"\3"+ - "\"\3\"\3#\3#\3#\3#\3#\5#\u025b\n#\3#\5#\u025e\n#\3#\3#\3$\3$\3$\7$\u0265"+ - "\n$\f$\16$\u0268\13$\3$\5$\u026b\n$\3%\3%\3%\3%\3&\3&\3&\7&\u0274\n&\f"+ - "&\16&\u0277\13&\3&\5&\u027a\n&\3\'\3\'\3\'\3\'\3\'\5\'\u0281\n\'\3\'\3"+ - "\'\3(\3(\3(\7(\u0288\n(\f(\16(\u028b\13(\3(\5(\u028e\n(\3)\3)\3)\3)\3"+ - "*\3*\3*\5*\u0297\n*\3+\3+\3+\3+\3+\3+\5+\u029f\n+\3,\3,\3,\7,\u02a4\n"+ - ",\f,\16,\u02a7\13,\3,\3,\3,\3,\7,\u02ad\n,\f,\16,\u02b0\13,\5,\u02b2\n"+ - ",\3-\3-\3-\5-\u02b7\n-\3-\5-\u02ba\n-\3.\3.\3.\3.\5.\u02c0\n.\3/\3/\3"+ - "/\7/\u02c5\n/\f/\16/\u02c8\13/\3\60\5\60\u02cb\n\60\3\60\3\60\3\61\3\61"+ - "\3\61\7\61\u02d2\n\61\f\61\16\61\u02d5\13\61\3\62\7\62\u02d8\n\62\f\62"+ - "\16\62\u02db\13\62\3\62\3\62\5\62\u02df\n\62\3\62\3\62\5\62\u02e3\n\62"+ - "\3\62\3\62\3\62\3\62\3\62\3\62\3\62\5\62\u02ec\n\62\3\63\3\63\3\63\3\64"+ - "\3\64\3\64\3\64\3\65\3\65\3\65\3\65\3\66\3\66\5\66\u02fb\n\66\3\66\3\66"+ - "\3\66\3\66\3\66\3\66\3\67\3\67\5\67\u0305\n\67\3\67\3\67\3\67\3\67\5\67"+ - "\u030b\n\67\3\67\3\67\3\67\3\67\38\38\58\u0313\n8\38\38\39\39\59\u0319"+ - "\n9\39\39\3:\7:\u031e\n:\f:\16:\u0321\13:\3:\3:\3:\3:\3:\3:\3:\3:\3:\3"+ - ":\5:\u032d\n:\3;\3;\3;\3;\5;\u0333\n;\3;\3;\3;\3;\3<\3<\3<\3<\3<\5<\u033e"+ - "\n<\3<\3<\3=\3=\5=\u0344\n=\3=\3=\5=\u0348\n=\3=\3=\7=\u034c\n=\f=\16"+ - "=\u034f\13=\3=\3=\3>\7>\u0354\n>\f>\16>\u0357\13>\3>\3>\3>\3>\3>\3>\3"+ - ">\3>\3>\3>\5>\u0363\n>\3?\3?\5?\u0367\n?\3@\3@\3@\3@\5@\u036d\n@\3@\5"+ - "@\u0370\n@\3@\3@\7@\u0374\n@\f@\16@\u0377\13@\3@\3@\3A\3A\3A\3A\3A\5A"+ - "\u0380\nA\3A\5A\u0383\nA\3A\3A\3B\7B\u0388\nB\fB\16B\u038b\13B\3B\3B\3"+ - "B\3B\3B\3B\3B\3B\3B\3B\3B\5B\u0398\nB\3C\3C\3C\3C\3C\3C\3D\3D\3D\3D\3"+ - "D\3D\3E\3E\3E\3E\3E\3F\3F\3F\5F\u03ae\nF\3G\3G\3G\3G\3G\5G\u03b5\nG\3"+ - "G\3G\3G\7G\u03ba\nG\fG\16G\u03bd\13G\3G\3G\3G\5G\u03c2\nG\3G\3G\3G\3G"+ - "\3H\3H\3H\3H\3H\5H\u03cd\nH\3H\3H\5H\u03d1\nH\3I\3I\3I\3I\3I\5I\u03d8"+ - "\nI\3I\3I\3I\3I\3J\3J\3J\3J\3J\3J\3J\3K\3K\3K\5K\u03e8\nK\3L\3L\3L\3L"+ - "\3L\3L\5L\u03f0\nL\5L\u03f2\nL\3L\3L\3M\3M\3M\7M\u03f9\nM\fM\16M\u03fc"+ - "\13M\3M\5M\u03ff\nM\3N\7N\u0402\nN\fN\16N\u0405\13N\3N\3N\3N\3N\3N\5N"+ - "\u040c\nN\3N\3N\3O\3O\3O\7O\u0413\nO\fO\16O\u0416\13O\3P\5P\u0419\nP\3"+ - "P\3P\5P\u041d\nP\3P\3P\5P\u0421\nP\3P\3P\5P\u0425\nP\3Q\3Q\3R\3R\3R\3"+ - "R\3R\3R\3R\3R\3R\3R\5R\u0433\nR\3R\3R\5R\u0437\nR\3R\3R\3R\3R\3R\3R\3"+ - "R\3R\3R\5R\u0442\nR\3R\3R\3R\5R\u0447\nR\3R\3R\3R\3R\3R\3R\7R\u044f\n"+ - "R\fR\16R\u0452\13R\3S\3S\3S\7S\u0457\nS\fS\16S\u045a\13S\3T\3T\3T\7T\u045f"+ - "\nT\fT\16T\u0462\13T\3T\2\4<\u00a2U\2\4\6\b\n\f\16\20\22\24\26\30\32\34"+ - "\36 \"$&(*,.\60\62\64\668:<>@BDFHJLNPRTVXZ\\^`bdfhjlnprtvxz|~\u0080\u0082"+ - "\u0084\u0086\u0088\u008a\u008c\u008e\u0090\u0092\u0094\u0096\u0098\u009a"+ - "\u009c\u009e\u00a0\u00a2\u00a4\u00a6\2\r\3\2\60\61\3\2\35\36\5\2EEJJM"+ - "M\4\2CDFF\4\2EEGG\4\2ABOT\3\2>?\4\2\60\60@@\4\2\3\3%%\4\2YY[\\\4\2\35"+ - "\35##\2\u04e0\2\u00ab\3\2\2\2\4\u00b3\3\2\2\2\6\u00c5\3\2\2\2\b\u00cd"+ - "\3\2\2\2\n\u00d7\3\2\2\2\f\u00e1\3\2\2\2\16\u00f0\3\2\2\2\20\u00fe\3\2"+ - "\2\2\22\u010c\3\2\2\2\24\u0114\3\2\2\2\26\u0123\3\2\2\2\30\u012d\3\2\2"+ - "\2\32\u0140\3\2\2\2\34\u0151\3\2\2\2\36\u0159\3\2\2\2 \u016c\3\2\2\2\""+ - "\u016e\3\2\2\2$\u017b\3\2\2\2&\u0183\3\2\2\2(\u018c\3\2\2\2*\u0199\3\2"+ - "\2\2,\u019b\3\2\2\2.\u01a8\3\2\2\2\60\u01b0\3\2\2\2\62\u01ba\3\2\2\2\64"+ - "\u01c0\3\2\2\2\66\u01cc\3\2\2\28\u01d9\3\2\2\2:\u01e1\3\2\2\2<\u0209\3"+ - "\2\2\2>\u0234\3\2\2\2@\u0240\3\2\2\2B\u024b\3\2\2\2D\u0255\3\2\2\2F\u0261"+ - "\3\2\2\2H\u026c\3\2\2\2J\u0270\3\2\2\2L\u0280\3\2\2\2N\u0284\3\2\2\2P"+ - "\u028f\3\2\2\2R\u0296\3\2\2\2T\u0298\3\2\2\2V\u02b1\3\2\2\2X\u02b3\3\2"+ - "\2\2Z\u02bb\3\2\2\2\\\u02c1\3\2\2\2^\u02ca\3\2\2\2`\u02ce\3\2\2\2b\u02d9"+ - "\3\2\2\2d\u02ed\3\2\2\2f\u02f0\3\2\2\2h\u02f4\3\2\2\2j\u02fa\3\2\2\2l"+ - "\u0304\3\2\2\2n\u0310\3\2\2\2p\u0316\3\2\2\2r\u031f\3\2\2\2t\u032e\3\2"+ - "\2\2v\u0338\3\2\2\2x\u0341\3\2\2\2z\u0355\3\2\2\2|\u0366\3\2\2\2~\u0368"+ - "\3\2\2\2\u0080\u037a\3\2\2\2\u0082\u0389\3\2\2\2\u0084\u0399\3\2\2\2\u0086"+ - "\u039f\3\2\2\2\u0088\u03a5\3\2\2\2\u008a\u03ad\3\2\2\2\u008c\u03b4\3\2"+ - "\2\2\u008e\u03c7\3\2\2\2\u0090\u03d7\3\2\2\2\u0092\u03dd\3\2\2\2\u0094"+ - "\u03e7\3\2\2\2\u0096\u03e9\3\2\2\2\u0098\u03f5\3\2\2\2\u009a\u0403\3\2"+ - "\2\2\u009c\u040f\3\2\2\2\u009e\u0424\3\2\2\2\u00a0\u0426\3\2\2\2\u00a2"+ - "\u0446\3\2\2\2\u00a4\u0453\3\2\2\2\u00a6\u045b\3\2\2\2\u00a8\u00aa\5\4"+ - "\3\2\u00a9\u00a8\3\2\2\2\u00aa\u00ad\3\2\2\2\u00ab\u00a9\3\2\2\2\u00ab"+ - "\u00ac\3\2\2\2\u00ac\u00ae\3\2\2\2\u00ad\u00ab\3\2\2\2\u00ae\u00af\7\2"+ - "\2\3\u00af\3\3\2\2\2\u00b0\u00b2\5\6\4\2\u00b1\u00b0\3\2\2\2\u00b2\u00b5"+ - "\3\2\2\2\u00b3\u00b1\3\2\2\2\u00b3\u00b4\3\2\2\2\u00b4\u00c3\3\2\2\2\u00b5"+ - "\u00b3\3\2\2\2\u00b6\u00c4\5\n\6\2\u00b7\u00c4\5\f\7\2\u00b8\u00c4\5\16"+ - "\b\2\u00b9\u00c4\5\20\t\2\u00ba\u00c4\5\22\n\2\u00bb\u00c4\5\24\13\2\u00bc"+ - "\u00c4\5\26\f\2\u00bd\u00c4\5\30\r\2\u00be\u00c4\5\32\16\2\u00bf\u00c4"+ - "\5\34\17\2\u00c0\u00c4\5\"\22\2\u00c1\u00c4\5\36\20\2\u00c2\u00c4\5\b"+ - "\5\2\u00c3\u00b6\3\2\2\2\u00c3\u00b7\3\2\2\2\u00c3\u00b8\3\2\2\2\u00c3"+ - "\u00b9\3\2\2\2\u00c3\u00ba\3\2\2\2\u00c3\u00bb\3\2\2\2\u00c3\u00bc\3\2"+ - "\2\2\u00c3\u00bd\3\2\2\2\u00c3\u00be\3\2\2\2\u00c3\u00bf\3\2\2\2\u00c3"+ - "\u00c0\3\2\2\2\u00c3\u00c1\3\2\2\2\u00c3\u00c2\3\2\2\2\u00c4\5\3\2\2\2"+ - "\u00c5\u00c6\7\65\2\2\u00c6\u00cb\5\u00a6T\2\u00c7\u00c8\78\2\2\u00c8"+ - "\u00c9\5`\61\2\u00c9\u00ca\79\2\2\u00ca\u00cc\3\2\2\2\u00cb\u00c7\3\2"+ - "\2\2\u00cb\u00cc\3\2\2\2\u00cc\7\3\2\2\2\u00cd\u00ce\7\6\2\2\u00ce\u00cf"+ - "\7\65\2\2\u00cf\u00d5\5\u00a6T\2\u00d0\u00d2\78\2\2\u00d1\u00d3\5\u009c"+ - "O\2\u00d2\u00d1\3\2\2\2\u00d2\u00d3\3\2\2\2\u00d3\u00d4\3\2\2\2\u00d4"+ - "\u00d6\79\2\2\u00d5\u00d0\3\2\2\2\u00d5\u00d6\3\2\2\2\u00d6\t\3\2\2\2"+ - "\u00d7\u00d9\7\27\2\2\u00d8\u00da\7/\2\2\u00d9\u00d8\3\2\2\2\u00d9\u00da"+ - "\3\2\2\2\u00da\u00db\3\2\2\2\u00db\u00de\5\u00a6T\2\u00dc\u00dd\7\4\2"+ - "\2\u00dd\u00df\7\64\2\2\u00de\u00dc\3\2\2\2\u00de\u00df\3\2\2\2\u00df"+ - "\13\3\2\2\2\u00e0\u00e2\7\'\2\2\u00e1\u00e0\3\2\2\2\u00e1\u00e2\3\2\2"+ - "\2\u00e2\u00e3\3\2\2\2\u00e3\u00e4\t\2\2\2\u00e4\u00e6\7\64\2\2\u00e5"+ - "\u00e7\5$\23\2\u00e6\u00e5\3\2\2\2\u00e6\u00e7\3\2\2\2\u00e7\u00ea\3\2"+ - "\2\2\u00e8\u00e9\7\67\2\2\u00e9\u00eb\5\u00a2R\2\u00ea\u00e8\3\2\2\2\u00ea"+ - "\u00eb\3\2\2\2\u00eb\u00ee\3\2\2\2\u00ec\u00ed\7\66\2\2\u00ed\u00ef\5"+ - "<\37\2\u00ee\u00ec\3\2\2\2\u00ee\u00ef\3\2\2\2\u00ef\r\3\2\2\2\u00f0\u00f1"+ - "\7\r\2\2\u00f1\u00f3\7\64\2\2\u00f2\u00f4\5$\23\2\u00f3\u00f2\3\2\2\2"+ - "\u00f3\u00f4\3\2\2\2\u00f4\u00f5\3\2\2\2\u00f5\u00f9\7:\2\2\u00f6\u00f8"+ - "\5*\26\2\u00f7\u00f6\3\2\2\2\u00f8\u00fb\3\2\2\2\u00f9\u00f7\3\2\2\2\u00f9"+ - "\u00fa\3\2\2\2\u00fa\u00fc\3\2\2\2\u00fb\u00f9\3\2\2\2\u00fc\u00fd\7;"+ - "\2\2\u00fd\17\3\2\2\2\u00fe\u00ff\7-\2\2\u00ff\u0101\7\64\2\2\u0100\u0102"+ - "\5$\23\2\u0101\u0100\3\2\2\2\u0101\u0102\3\2\2\2\u0102\u0103\3\2\2\2\u0103"+ - "\u0107\7:\2\2\u0104\u0106\5\62\32\2\u0105\u0104\3\2\2\2\u0106\u0109\3"+ - "\2\2\2\u0107\u0105\3\2\2\2\u0107\u0108\3\2\2\2\u0108\u010a\3\2\2\2\u0109"+ - "\u0107\3\2\2\2\u010a\u010b\7;\2\2\u010b\21\3\2\2\2\u010c\u010d\7.\2\2"+ - "\u010d\u010f\7\64\2\2\u010e\u0110\5$\23\2\u010f\u010e\3\2\2\2\u010f\u0110"+ - "\3\2\2\2\u0110\u0111\3\2\2\2\u0111\u0112\7\66\2\2\u0112\u0113\5\u00a2"+ - "R\2\u0113\23\3\2\2\2\u0114\u0115\7\24\2\2\u0115\u0117\7\64\2\2\u0116\u0118"+ - "\5$\23\2\u0117\u0116\3\2\2\2\u0117\u0118\3\2\2\2\u0118\u0119\3\2\2\2\u0119"+ - "\u011b\78\2\2\u011a\u011c\5\u009cO\2\u011b\u011a\3\2\2\2\u011b\u011c\3"+ - "\2\2\2\u011c\u011d\3\2\2\2\u011d\u011e\79\2\2\u011e\u011f\7\67\2\2\u011f"+ - "\u0120\5\u00a2R\2\u0120\u0121\7\66\2\2\u0121\u0122\5<\37\2\u0122\25\3"+ - "\2\2\2\u0123\u0124\7\32\2\2\u0124\u0126\7\64\2\2\u0125\u0127\5$\23\2\u0126"+ - "\u0125\3\2\2\2\u0126\u0127\3\2\2\2\u0127\u0128\3\2\2\2\u0128\u0129\78"+ - "\2\2\u0129\u012a\5\u009cO\2\u012a\u012b\79\2\2\u012b\u012c\5> \2\u012c"+ - "\27\3\2\2\2\u012d\u012e\7&\2\2\u012e\u0131\7\64\2\2\u012f\u0130\7\67\2"+ - "\2\u0130\u0132\5\u00a4S\2\u0131\u012f\3\2\2\2\u0131\u0132\3\2\2\2\u0132"+ - "\u0134\3\2\2\2\u0133\u0135\7\22\2\2\u0134\u0133\3\2\2\2\u0134\u0135\3"+ - "\2\2\2\u0135\u0136\3\2\2\2\u0136\u013a\7:\2\2\u0137\u0139\5r:\2\u0138"+ - "\u0137\3\2\2\2\u0139\u013c\3\2\2\2\u013a\u0138\3\2\2\2\u013a\u013b\3\2"+ - "\2\2\u013b\u013d\3\2\2\2\u013c\u013a\3\2\2\2\u013d\u013e\7;\2\2\u013e"+ - "\31\3\2\2\2\u013f\u0141\7\21\2\2\u0140\u013f\3\2\2\2\u0140\u0141\3\2\2"+ - "\2\u0141\u0142\3\2\2\2\u0142\u0143\7\n\2\2\u0143\u0146\7\64\2\2\u0144"+ - "\u0145\7\67\2\2\u0145\u0147\5\u00a2R\2\u0146\u0144\3\2\2\2\u0146\u0147"+ - "\3\2\2\2\u0147\u0148\3\2\2\2\u0148\u014c\7:\2\2\u0149\u014b\5\66\34\2"+ - "\u014a\u0149\3\2\2\2\u014b\u014e\3\2\2\2\u014c\u014a\3\2\2\2\u014c\u014d"+ - "\3\2\2\2\u014d\u014f\3\2\2\2\u014e\u014c\3\2\2\2\u014f\u0150\7;\2\2\u0150"+ - "\33\3\2\2\2\u0151\u0152\7\21\2\2\u0152\u0153\7\60\2\2\u0153\u0154\7\64"+ - "\2\2\u0154\u0155\7\67\2\2\u0155\u0156\5\u00a2R\2\u0156\u0157\7\66\2\2"+ - "\u0157\u0158\5<\37\2\u0158\35\3\2\2\2\u0159\u015a\7\21\2\2\u015a\u015b"+ - "\7.\2\2\u015b\u0164\7\64\2\2\u015c\u0160\7:\2\2\u015d\u015f\5 \21\2\u015e"+ - "\u015d\3\2\2\2\u015f\u0162\3\2\2\2\u0160\u015e\3\2\2\2\u0160\u0161\3\2"+ - "\2\2\u0161\u0163\3\2\2\2\u0162\u0160\3\2\2\2\u0163\u0165\7;\2\2\u0164"+ - "\u015c\3\2\2\2\u0164\u0165\3\2\2\2\u0165\37\3\2\2\2\u0166\u016d\58\35"+ - "\2\u0167\u016d\5\f\7\2\u0168\u016a\t\3\2\2\u0169\u0168\3\2\2\2\u0169\u016a"+ - "\3\2\2\2\u016a\u016b\3\2\2\2\u016b\u016d\5\"\22\2\u016c\u0166\3\2\2\2"+ - "\u016c\u0167\3\2\2\2\u016c\u0169\3\2\2\2\u016d!\3\2\2\2\u016e\u016f\7"+ - "\21\2\2\u016f\u0170\7\24\2\2\u0170\u0171\7\64\2\2\u0171\u0173\78\2\2\u0172"+ - "\u0174\5\u009cO\2\u0173\u0172\3\2\2\2\u0173\u0174\3\2\2\2\u0174\u0175"+ - "\3\2\2\2\u0175\u0176\79\2\2\u0176\u0177\7\67\2\2\u0177\u0178\5\u00a2R"+ - "\2\u0178\u0179\7\66\2\2\u0179\u017a\5<\37\2\u017a#\3\2\2\2\u017b\u017c"+ - "\7A\2\2\u017c\u017f\5&\24\2\u017d\u017e\7\62\2\2\u017e\u0180\5`\61\2\u017f"+ - "\u017d\3\2\2\2\u017f\u0180\3\2\2\2\u0180\u0181\3\2\2\2\u0181\u0182\7B"+ - "\2\2\u0182%\3\2\2\2\u0183\u0188\5(\25\2\u0184\u0185\7>\2\2\u0185\u0187"+ - "\5(\25\2\u0186\u0184\3\2\2\2\u0187\u018a\3\2\2\2\u0188\u0186\3\2\2\2\u0188"+ - "\u0189\3\2\2\2\u0189\'\3\2\2\2\u018a\u0188\3\2\2\2\u018b\u018d\7\60\2"+ - "\2\u018c\u018b\3\2\2\2\u018c\u018d\3\2\2\2\u018d\u018e\3\2\2\2\u018e\u0191"+ - "\7\64\2\2\u018f\u0190\7\67\2\2\u0190\u0192\5\u00a2R\2\u0191\u018f\3\2"+ - "\2\2\u0191\u0192\3\2\2\2\u0192)\3\2\2\2\u0193\u019a\5,\27\2\u0194\u0196"+ - "\t\3\2\2\u0195\u0194\3\2\2\2\u0195\u0196\3\2\2\2\u0196\u0197\3\2\2\2\u0197"+ - "\u019a\5\24\13\2\u0198\u019a\58\35\2\u0199\u0193\3\2\2\2\u0199\u0195\3"+ - "\2\2\2\u0199\u0198\3\2\2\2\u019a+\3\2\2\2\u019b\u019c\7\t\2\2\u019c\u01a2"+ - "\7\64\2\2\u019d\u019f\78\2\2\u019e\u01a0\5.\30\2\u019f\u019e\3\2\2\2\u019f"+ - "\u01a0\3\2\2\2\u01a0\u01a1\3\2\2\2\u01a1\u01a3\79\2\2\u01a2\u019d\3\2"+ - "\2\2\u01a2\u01a3\3\2\2\2\u01a3\u01a6\3\2\2\2\u01a4\u01a5\7\66\2\2\u01a5"+ - "\u01a7\5<\37\2\u01a6\u01a4\3\2\2\2\u01a6\u01a7\3\2\2\2\u01a7-\3\2\2\2"+ - "\u01a8\u01ad\5\60\31\2\u01a9\u01aa\7>\2\2\u01aa\u01ac\5\60\31\2\u01ab"+ - "\u01a9\3\2\2\2\u01ac\u01af\3\2\2\2\u01ad\u01ab\3\2\2\2\u01ad\u01ae\3\2"+ - "\2\2\u01ae/\3\2\2\2\u01af\u01ad\3\2\2\2\u01b0\u01b1\7\64\2\2\u01b1\u01b2"+ - "\7\67\2\2\u01b2\u01b3\5\u00a2R\2\u01b3\61\3\2\2\2\u01b4\u01bb\5\64\33"+ - "\2\u01b5\u01b7\t\3\2\2\u01b6\u01b5\3\2\2\2\u01b6\u01b7\3\2\2\2\u01b7\u01b8"+ - "\3\2\2\2\u01b8\u01bb\5\24\13\2\u01b9\u01bb\58\35\2\u01ba\u01b4\3\2\2\2"+ - "\u01ba\u01b6\3\2\2\2\u01ba\u01b9\3\2\2\2\u01bb\u01bd\3\2\2\2\u01bc\u01be"+ - "\7?\2\2\u01bd\u01bc\3\2\2\2\u01bd\u01be\3\2\2\2\u01be\63\3\2\2\2\u01bf"+ - "\u01c1\t\2\2\2\u01c0\u01bf\3\2\2\2\u01c0\u01c1\3\2\2\2\u01c1\u01c2\3\2"+ - "\2\2\u01c2\u01c3\7\64\2\2\u01c3\u01c4\7\67\2\2\u01c4\u01c7\5\u00a2R\2"+ - "\u01c5\u01c6\7\66\2\2\u01c6\u01c8\5<\37\2\u01c7\u01c5\3\2\2\2\u01c7\u01c8"+ - "\3\2\2\2\u01c8\65\3\2\2\2\u01c9\u01cb\5\6\4\2\u01ca\u01c9\3\2\2\2\u01cb"+ - "\u01ce\3\2\2\2\u01cc\u01ca\3\2\2\2\u01cc\u01cd\3\2\2\2\u01cd\u01d4\3\2"+ - "\2\2\u01ce\u01cc\3\2\2\2\u01cf\u01d5\5\64\33\2\u01d0\u01d5\5\f\7\2\u01d1"+ - "\u01d5\5:\36\2\u01d2\u01d5\5x=\2\u01d3\u01d5\58\35\2\u01d4\u01cf\3\2\2"+ - "\2\u01d4\u01d0\3\2\2\2\u01d4\u01d1\3\2\2\2\u01d4\u01d2\3\2\2\2\u01d4\u01d3"+ - "\3\2\2\2\u01d5\u01d7\3\2\2\2\u01d6\u01d8\7?\2\2\u01d7\u01d6\3\2\2\2\u01d7"+ - "\u01d8\3\2\2\2\u01d8\67\3\2\2\2\u01d9\u01da\7,\2\2\u01da\u01db\7\60\2"+ - "\2\u01db\u01dc\7\64\2\2\u01dc\u01dd\7\67\2\2\u01dd\u01de\5\u00a2R\2\u01de"+ - "\u01df\7\66\2\2\u01df\u01e0\5<\37\2\u01e09\3\2\2\2\u01e1\u01e2\7\31\2"+ - "\2\u01e2\u01e4\78\2\2\u01e3\u01e5\5\u009cO\2\u01e4\u01e3\3\2\2\2\u01e4"+ - "\u01e5\3\2\2\2\u01e5\u01e6\3\2\2\2\u01e6\u01e7\79\2\2\u01e7\u01e8\7\66"+ - "\2\2\u01e8\u01e9\5> \2\u01e9;\3\2\2\2\u01ea\u01eb\b\37\1\2\u01eb\u020a"+ - "\5\u00a0Q\2\u01ec\u01ed\7\21\2\2\u01ed\u020a\7Z\2\2\u01ee\u020a\5\"\22"+ - "\2\u01ef\u01f4\5\u00a6T\2\u01f0\u01f1\7A\2\2\u01f1\u01f2\5&\24\2\u01f2"+ - "\u01f3\7B\2\2\u01f3\u01f5\3\2\2\2\u01f4\u01f0\3\2\2\2\u01f4\u01f5\3\2"+ - "\2\2\u01f5\u020a\3\2\2\2\u01f6\u020a\5\u0088E\2\u01f7\u01f8\t\4\2\2\u01f8"+ - "\u020a\5<\37\20\u01f9\u020a\5@!\2\u01fa\u020a\5B\"\2\u01fb\u01fc\7@\2"+ - "\2\u01fc\u020a\7\64\2\2\u01fd\u01fe\78\2\2\u01fe\u01ff\5`\61\2\u01ff\u0200"+ - "\79\2\2\u0200\u020a\3\2\2\2\u0201\u0202\7<\2\2\u0202\u0203\5<\37\2\u0203"+ - "\u0204\7=\2\2\u0204\u020a\3\2\2\2\u0205\u020a\5D#\2\u0206\u0207\7!\2\2"+ - "\u0207\u020a\5<\37\4\u0208\u020a\5> \2\u0209\u01ea\3\2\2\2\u0209\u01ec"+ - "\3\2\2\2\u0209\u01ee\3\2\2\2\u0209\u01ef\3\2\2\2\u0209\u01f6\3\2\2\2\u0209"+ - "\u01f7\3\2\2\2\u0209\u01f9\3\2\2\2\u0209\u01fa\3\2\2\2\u0209\u01fb\3\2"+ - "\2\2\u0209\u01fd\3\2\2\2\u0209\u0201\3\2\2\2\u0209\u0205\3\2\2\2\u0209"+ - "\u0206\3\2\2\2\u0209\u0208\3\2\2\2\u020a\u0231\3\2\2\2\u020b\u020c\f\16"+ - "\2\2\u020c\u020d\t\5\2\2\u020d\u0230\5<\37\17\u020e\u020f\f\r\2\2\u020f"+ - "\u0210\t\6\2\2\u0210\u0230\5<\37\16\u0211\u0212\f\f\2\2\u0212\u0213\t"+ - "\7\2\2\u0213\u0230\5<\37\r\u0214\u0215\f\13\2\2\u0215\u0216\7\66\2\2\u0216"+ - "\u0230\5<\37\f\u0217\u0218\f\26\2\2\u0218\u0219\7@\2\2\u0219\u0230\7\64"+ - "\2\2\u021a\u021b\f\24\2\2\u021b\u021d\78\2\2\u021c\u021e\5`\61\2\u021d"+ - "\u021c\3\2\2\2\u021d\u021e\3\2\2\2\u021e\u021f\3\2\2\2\u021f\u0230\79"+ - "\2\2\u0220\u0221\f\23\2\2\u0221\u0222\7<\2\2\u0222\u0223\5<\37\2\u0223"+ - "\u0224\7=\2\2\u0224\u0230\3\2\2\2\u0225\u0226\f\22\2\2\u0226\u0227\7:"+ - "\2\2\u0227\u0228\5F$\2\u0228\u0229\7;\2\2\u0229\u0230\3\2\2\2\u022a\u022b"+ - "\f\21\2\2\u022b\u0230\7K\2\2\u022c\u022d\f\17\2\2\u022d\u022e\7\4\2\2"+ - "\u022e\u0230\5\u00a2R\2\u022f\u020b\3\2\2\2\u022f\u020e\3\2\2\2\u022f"+ - "\u0211\3\2\2\2\u022f\u0214\3\2\2\2\u022f\u0217\3\2\2\2\u022f\u021a\3\2"+ - "\2\2\u022f\u0220\3\2\2\2\u022f\u0225\3\2\2\2\u022f\u022a\3\2\2\2\u022f"+ - "\u022c\3\2\2\2\u0230\u0233\3\2\2\2\u0231\u022f\3\2\2\2\u0231\u0232\3\2"+ - "\2\2\u0232=\3\2\2\2\u0233\u0231\3\2\2\2\u0234\u0238\7:\2\2\u0235\u0237"+ - "\5b\62\2\u0236\u0235\3\2\2\2\u0237\u023a\3\2\2\2\u0238\u0236\3\2\2\2\u0238"+ - "\u0239\3\2\2\2\u0239\u023c\3\2\2\2\u023a\u0238\3\2\2\2\u023b\u023d\5<"+ - "\37\2\u023c\u023b\3\2\2\2\u023c\u023d\3\2\2\2\u023d\u023e\3\2\2\2\u023e"+ - "\u023f\7;\2\2\u023f?\3\2\2\2\u0240\u0241\7\25\2\2\u0241\u0242\78\2\2\u0242"+ - "\u0243\5<\37\2\u0243\u0244\79\2\2\u0244\u0247\5<\37\2\u0245\u0246\7\f"+ - "\2\2\u0246\u0248\5<\37\2\u0247\u0245\3\2\2\2\u0247\u0248\3\2\2\2\u0248"+ - "A\3\2\2\2\u0249\u024a\7\64\2\2\u024a\u024c\7\67\2\2\u024b\u0249\3\2\2"+ - "\2\u024b\u024c\3\2\2\2\u024c\u024d\3\2\2\2\u024d\u024e\7\34\2\2\u024e"+ - "\u024f\78\2\2\u024f\u0250\5<\37\2\u0250\u0251\79\2\2\u0251\u0252\7:\2"+ - "\2\u0252\u0253\5N(\2\u0253\u0254\7;\2\2\u0254C\3\2\2\2\u0255\u0256\7\37"+ - "\2\2\u0256\u0257\7:\2\2\u0257\u025a\5J&\2\u0258\u0259\7\"\2\2\u0259\u025b"+ - "\5<\37\2\u025a\u0258\3\2\2\2\u025a\u025b\3\2\2\2\u025b\u025d\3\2\2\2\u025c"+ - "\u025e\t\b\2\2\u025d\u025c\3\2\2\2\u025d\u025e\3\2\2\2\u025e\u025f\3\2"+ - "\2\2\u025f\u0260\7;\2\2\u0260E\3\2\2\2\u0261\u0266\5H%\2\u0262\u0263\7"+ - ">\2\2\u0263\u0265\5H%\2\u0264\u0262\3\2\2\2\u0265\u0268\3\2\2\2\u0266"+ - "\u0264\3\2\2\2\u0266\u0267\3\2\2\2\u0267\u026a\3\2\2\2\u0268\u0266\3\2"+ - "\2\2\u0269\u026b\7>\2\2\u026a\u0269\3\2\2\2\u026a\u026b\3\2\2\2\u026b"+ - "G\3\2\2\2\u026c\u026d\7\64\2\2\u026d\u026e\7\66\2\2\u026e\u026f\5<\37"+ - "\2\u026fI\3\2\2\2\u0270\u0275\5L\'\2\u0271\u0272\t\b\2\2\u0272\u0274\5"+ - "L\'\2\u0273\u0271\3\2\2\2\u0274\u0277\3\2\2\2\u0275\u0273\3\2\2\2\u0275"+ - "\u0276\3\2\2\2\u0276\u0279\3\2\2\2\u0277\u0275\3\2\2\2\u0278\u027a\t\b"+ - "\2\2\u0279\u0278\3\2\2\2\u0279\u027a\3\2\2\2\u027aK\3\2\2\2\u027b\u027c"+ - "\7\25\2\2\u027c\u027d\78\2\2\u027d\u027e\5<\37\2\u027e\u027f\79\2\2\u027f"+ - "\u0281\3\2\2\2\u0280\u027b\3\2\2\2\u0280\u0281\3\2\2\2\u0281\u0282\3\2"+ - "\2\2\u0282\u0283\5<\37\2\u0283M\3\2\2\2\u0284\u0289\5P)\2\u0285\u0286"+ - "\t\b\2\2\u0286\u0288\5P)\2\u0287\u0285\3\2\2\2\u0288\u028b\3\2\2\2\u0289"+ - "\u0287\3\2\2\2\u0289\u028a\3\2\2\2\u028a\u028d\3\2\2\2\u028b\u0289\3\2"+ - "\2\2\u028c\u028e\t\b\2\2\u028d\u028c\3\2\2\2\u028d\u028e\3\2\2\2\u028e"+ - "O\3\2\2\2\u028f\u0290\5R*\2\u0290\u0291\7H\2\2\u0291\u0292\5<\37\2\u0292"+ - "Q\3\2\2\2\u0293\u0297\5T+\2\u0294\u0297\5\u00a0Q\2\u0295\u0297\5Z.\2\u0296"+ - "\u0293\3\2\2\2\u0296\u0294\3\2\2\2\u0296\u0295\3\2\2\2\u0297S\3\2\2\2"+ - "\u0298\u029e\5V,\2\u0299\u029a\7\25\2\2\u029a\u029b\78\2\2\u029b\u029c"+ - "\5<\37\2\u029c\u029d\79\2\2\u029d\u029f\3\2\2\2\u029e\u0299\3\2\2\2\u029e"+ - "\u029f\3\2\2\2\u029fU\3\2\2\2\u02a0\u02a5\5X-\2\u02a1\u02a2\7@\2\2\u02a2"+ - "\u02a4\5X-\2\u02a3\u02a1\3\2\2\2\u02a4\u02a7\3\2\2\2\u02a5\u02a3\3\2\2"+ - "\2\u02a5\u02a6\3\2\2\2\u02a6\u02b2\3\2\2\2\u02a7\u02a5\3\2\2\2\u02a8\u02a9"+ - "\7@\2\2\u02a9\u02ae\5X-\2\u02aa\u02ab\7@\2\2\u02ab\u02ad\5X-\2\u02ac\u02aa"+ - "\3\2\2\2\u02ad\u02b0\3\2\2\2\u02ae\u02ac\3\2\2\2\u02ae\u02af\3\2\2\2\u02af"+ - "\u02b2\3\2\2\2\u02b0\u02ae\3\2\2\2\u02b1\u02a0\3\2\2\2\u02b1\u02a8\3\2"+ - "\2\2\u02b2W\3\2\2\2\u02b3\u02b9\7\64\2\2\u02b4\u02b6\78\2\2\u02b5\u02b7"+ - "\5\\/\2\u02b6\u02b5\3\2\2\2\u02b6\u02b7\3\2\2\2\u02b7\u02b8\3\2\2\2\u02b8"+ - "\u02ba\79\2\2\u02b9\u02b4\3\2\2\2\u02b9\u02ba\3\2\2\2\u02baY\3\2\2\2\u02bb"+ - "\u02bc\t\t\2\2\u02bc\u02bf\7\64\2\2\u02bd\u02be\7\67\2\2\u02be\u02c0\5"+ - "\u00a2R\2\u02bf\u02bd\3\2\2\2\u02bf\u02c0\3\2\2\2\u02c0[\3\2\2\2\u02c1"+ - "\u02c6\5^\60\2\u02c2\u02c3\7>\2\2\u02c3\u02c5\5^\60\2\u02c4\u02c2\3\2"+ - "\2\2\u02c5\u02c8\3\2\2\2\u02c6\u02c4\3\2\2\2\u02c6\u02c7\3\2\2\2\u02c7"+ - "]\3\2\2\2\u02c8\u02c6\3\2\2\2\u02c9\u02cb\7\61\2\2\u02ca\u02c9\3\2\2\2"+ - "\u02ca\u02cb\3\2\2\2\u02cb\u02cc\3\2\2\2\u02cc\u02cd\7\64\2\2\u02cd_\3"+ - "\2\2\2\u02ce\u02d3\5<\37\2\u02cf\u02d0\7>\2\2\u02d0\u02d2\5<\37\2\u02d1"+ - "\u02cf\3\2\2\2\u02d2\u02d5\3\2\2\2\u02d3\u02d1\3\2\2\2\u02d3\u02d4\3\2"+ - "\2\2\u02d4a\3\2\2\2\u02d5\u02d3\3\2\2\2\u02d6\u02d8\5\6\4\2\u02d7\u02d6"+ - "\3\2\2\2\u02d8\u02db\3\2\2\2\u02d9\u02d7\3\2\2\2\u02d9\u02da\3\2\2\2\u02da"+ - "\u02eb\3\2\2\2\u02db\u02d9\3\2\2\2\u02dc\u02de\5<\37\2\u02dd\u02df\7?"+ - "\2\2\u02de\u02dd\3\2\2\2\u02de\u02df\3\2\2\2\u02df\u02ec\3\2\2\2\u02e0"+ - "\u02e2\5\u0088E\2\u02e1\u02e3\7?\2\2\u02e2\u02e1\3\2\2\2\u02e2\u02e3\3"+ - "\2\2\2\u02e3\u02ec\3\2\2\2\u02e4\u02ec\5d\63\2\u02e5\u02ec\5f\64\2\u02e6"+ - "\u02ec\5h\65\2\u02e7\u02ec\5j\66\2\u02e8\u02ec\5l\67\2\u02e9\u02ec\5n"+ - "8\2\u02ea\u02ec\5p9\2\u02eb\u02dc\3\2\2\2\u02eb\u02e0\3\2\2\2\u02eb\u02e4"+ - "\3\2\2\2\u02eb\u02e5\3\2\2\2\u02eb\u02e6\3\2\2\2\u02eb\u02e7\3\2\2\2\u02eb"+ - "\u02e8\3\2\2\2\u02eb\u02e9\3\2\2\2\u02eb\u02ea\3\2\2\2\u02ecc\3\2\2\2"+ - "\u02ed\u02ee\5\f\7\2\u02ee\u02ef\7?\2\2\u02efe\3\2\2\2\u02f0\u02f1\7("+ - "\2\2\u02f1\u02f2\5<\37\2\u02f2\u02f3\7?\2\2\u02f3g\3\2\2\2\u02f4\u02f5"+ - "\7\7\2\2\u02f5\u02f6\5<\37\2\u02f6\u02f7\7?\2\2\u02f7i\3\2\2\2\u02f8\u02f9"+ - "\7\64\2\2\u02f9\u02fb\7\67\2\2\u02fa\u02f8\3\2\2\2\u02fa\u02fb\3\2\2\2"+ - "\u02fb\u02fc\3\2\2\2\u02fc\u02fd\7\63\2\2\u02fd\u02fe\78\2\2\u02fe\u02ff"+ - "\5<\37\2\u02ff\u0300\79\2\2\u0300\u0301\5> \2\u0301k\3\2\2\2\u0302\u0303"+ - "\7\64\2\2\u0303\u0305\7\67\2\2\u0304\u0302\3\2\2\2\u0304\u0305\3\2\2\2"+ - "\u0305\u0306\3\2\2\2\u0306\u0307\7\23\2\2\u0307\u030a\7\64\2\2\u0308\u0309"+ - "\7\67\2\2\u0309\u030b\5\u00a2R\2\u030a\u0308\3\2\2\2\u030a\u030b\3\2\2"+ - "\2\u030b\u030c\3\2\2\2\u030c\u030d\7\30\2\2\u030d\u030e\5<\37\2\u030e"+ - "\u030f\5> \2\u030fm\3\2\2\2\u0310\u0312\7\b\2\2\u0311\u0313\7\64\2\2\u0312"+ - "\u0311\3\2\2\2\u0312\u0313\3\2\2\2\u0313\u0314\3\2\2\2\u0314\u0315\7?"+ - "\2\2\u0315o\3\2\2\2\u0316\u0318\7\13\2\2\u0317\u0319\7\64\2\2\u0318\u0317"+ - "\3\2\2\2\u0318\u0319\3\2\2\2\u0319\u031a\3\2\2\2\u031a\u031b\7?\2\2\u031b"+ - "q\3\2\2\2\u031c\u031e\5\6\4\2\u031d\u031c\3\2\2\2\u031e\u0321\3\2\2\2"+ - "\u031f\u031d\3\2\2\2\u031f\u0320\3\2\2\2\u0320\u032c\3\2\2\2\u0321\u031f"+ - "\3\2\2\2\u0322\u032d\5\16\b\2\u0323\u032d\5t;\2\u0324\u032d\5v<\2\u0325"+ - "\u032d\5\64\33\2\u0326\u032d\5x=\2\u0327\u032d\5\30\r\2\u0328\u032d\5"+ - "8\35\2\u0329\u032d\5\20\t\2\u032a\u032d\5\22\n\2\u032b\u032d\5\36\20\2"+ - "\u032c\u0322\3\2\2\2\u032c\u0323\3\2\2\2\u032c\u0324\3\2\2\2\u032c\u0325"+ - "\3\2\2\2\u032c\u0326\3\2\2\2\u032c\u0327\3\2\2\2\u032c\u0328\3\2\2\2\u032c"+ - "\u0329\3\2\2\2\u032c\u032a\3\2\2\2\u032c\u032b\3\2\2\2\u032ds\3\2\2\2"+ - "\u032e\u032f\7\24\2\2\u032f\u0330\7\64\2\2\u0330\u0332\78\2\2\u0331\u0333"+ - "\5\u009cO\2\u0332\u0331\3\2\2\2\u0332\u0333\3\2\2\2\u0333\u0334\3\2\2"+ - "\2\u0334\u0335\79\2\2\u0335\u0336\7\67\2\2\u0336\u0337\5\u00a2R\2\u0337"+ - "u\3\2\2\2\u0338\u0339\7$\2\2\u0339\u033a\7)\2\2\u033a\u033b\7\64\2\2\u033b"+ - "\u033d\78\2\2\u033c\u033e\5\u009cO\2\u033d\u033c\3\2\2\2\u033d\u033e\3"+ - "\2\2\2\u033e\u033f\3\2\2\2\u033f\u0340\79\2\2\u0340w\3\2\2\2\u0341\u0343"+ - "\7\33\2\2\u0342\u0344\7\64\2\2\u0343\u0342\3\2\2\2\u0343\u0344\3\2\2\2"+ - "\u0344\u0347\3\2\2\2\u0345\u0346\7\67\2\2\u0346\u0348\7\64\2\2\u0347\u0345"+ - "\3\2\2\2\u0347\u0348\3\2\2\2\u0348\u0349\3\2\2\2\u0349\u034d\7:\2\2\u034a"+ - "\u034c\5z>\2\u034b\u034a\3\2\2\2\u034c\u034f\3\2\2\2\u034d\u034b\3\2\2"+ - "\2\u034d\u034e\3\2\2\2\u034e\u0350\3\2\2\2\u034f\u034d\3\2\2\2\u0350\u0351"+ - "\7;\2\2\u0351y\3\2\2\2\u0352\u0354\5\6\4\2\u0353\u0352\3\2\2\2\u0354\u0357"+ - "\3\2\2\2\u0355\u0353\3\2\2\2\u0355\u0356\3\2\2\2\u0356\u0362\3\2\2\2\u0357"+ - "\u0355\3\2\2\2\u0358\u0363\5\16\b\2\u0359\u0363\5\u0084C\2\u035a\u0363"+ - "\5\u0086D\2\u035b\u0363\5\24\13\2\u035c\u0363\5\u0088E\2\u035d\u0363\5"+ - "|?\2\u035e\u0363\58\35\2\u035f\u0363\5\22\n\2\u0360\u0363\5\f\7\2\u0361"+ - "\u0363\5\u008aF\2\u0362\u0358\3\2\2\2\u0362\u0359\3\2\2\2\u0362\u035a"+ - "\3\2\2\2\u0362\u035b\3\2\2\2\u0362\u035c\3\2\2\2\u0362\u035d\3\2\2\2\u0362"+ - "\u035e\3\2\2\2\u0362\u035f\3\2\2\2\u0362\u0360\3\2\2\2\u0362\u0361\3\2"+ - "\2\2\u0363{\3\2\2\2\u0364\u0367\5~@\2\u0365\u0367\5\u0080A\2\u0366\u0364"+ - "\3\2\2\2\u0366\u0365\3\2\2\2\u0367}\3\2\2\2\u0368\u0369\7+\2\2\u0369\u036f"+ - "\7\64\2\2\u036a\u036c\78\2\2\u036b\u036d\5\u009cO\2\u036c\u036b\3\2\2"+ - "\2\u036c\u036d\3\2\2\2\u036d\u036e\3\2\2\2\u036e\u0370\79\2\2\u036f\u036a"+ - "\3\2\2\2\u036f\u0370\3\2\2\2\u0370\u0371\3\2\2\2\u0371\u0375\7:\2\2\u0372"+ - "\u0374\5\u0082B\2\u0373\u0372\3\2\2\2\u0374\u0377\3\2\2\2\u0375\u0373"+ - "\3\2\2\2\u0375\u0376\3\2\2\2\u0376\u0378\3\2\2\2\u0377\u0375\3\2\2\2\u0378"+ - "\u0379\7;\2\2\u0379\177\3\2\2\2\u037a\u037b\7\17\2\2\u037b\u037c\7+\2"+ - "\2\u037c\u0382\7\64\2\2\u037d\u037f\78\2\2\u037e\u0380\5\u009cO\2\u037f"+ - "\u037e\3\2\2\2\u037f\u0380\3\2\2\2\u0380\u0381\3\2\2\2\u0381\u0383\79"+ - "\2\2\u0382\u037d\3\2\2\2\u0382\u0383\3\2\2\2\u0383\u0384\3\2\2\2\u0384"+ - "\u0385\5> \2\u0385\u0081\3\2\2\2\u0386\u0388\5\6\4\2\u0387\u0386\3\2\2"+ - "\2\u0388\u038b\3\2\2\2\u0389\u0387\3\2\2\2\u0389\u038a\3\2\2\2\u038a\u0397"+ - "\3\2\2\2\u038b\u0389\3\2\2\2\u038c\u0398\5\16\b\2\u038d\u0398\5\u0084"+ - "C\2\u038e\u0398\5\u0086D\2\u038f\u0398\5\24\13\2\u0390\u0398\5|?\2\u0391"+ - "\u0398\5\u0088E\2\u0392\u0398\58\35\2\u0393\u0398\5\20\t\2\u0394\u0398"+ - "\5\u008aF\2\u0395\u0398\5\22\n\2\u0396\u0398\5\f\7\2\u0397\u038c\3\2\2"+ - "\2\u0397\u038d\3\2\2\2\u0397\u038e\3\2\2\2\u0397\u038f\3\2\2\2\u0397\u0390"+ - "\3\2\2\2\u0397\u0391\3\2\2\2\u0397\u0392\3\2\2\2\u0397\u0393\3\2\2\2\u0397"+ - "\u0394\3\2\2\2\u0397\u0395\3\2\2\2\u0397\u0396\3\2\2\2\u0398\u0083\3\2"+ - "\2\2\u0399\u039a\7\16\2\2\u039a\u039b\78\2\2\u039b\u039c\79\2\2\u039c"+ - "\u039d\7\66\2\2\u039d\u039e\5<\37\2\u039e\u0085\3\2\2\2\u039f\u03a0\7"+ - "\20\2\2\u03a0\u03a1\78\2\2\u03a1\u03a2\79\2\2\u03a2\u03a3\7\66\2\2\u03a3"+ - "\u03a4\5<\37\2\u03a4\u0087\3\2\2\2\u03a5\u03a6\7\5\2\2\u03a6\u03a7\78"+ - "\2\2\u03a7\u03a8\5<\37\2\u03a8\u03a9\79\2\2\u03a9\u0089\3\2\2\2\u03aa"+ - "\u03ae\5\u008cG\2\u03ab\u03ae\5\u0090I\2\u03ac\u03ae\5\u0092J\2\u03ad"+ - "\u03aa\3\2\2\2\u03ad\u03ab\3\2\2\2\u03ad\u03ac\3\2\2\2\u03ae\u008b\3\2"+ - "\2\2\u03af\u03b0\7\25\2\2\u03b0\u03b1\78\2\2\u03b1\u03b2\5<\37\2\u03b2"+ - "\u03b3\79\2\2\u03b3\u03b5\3\2\2\2\u03b4\u03af\3\2\2\2\u03b4\u03b5\3\2"+ - "\2\2\u03b5\u03bb\3\2\2\2\u03b6\u03b7\5\u008eH\2\u03b7\u03b8\7@\2\2\u03b8"+ - "\u03ba\3\2\2\2\u03b9\u03b6\3\2\2\2\u03ba\u03bd\3\2\2\2\u03bb\u03b9\3\2"+ - "\2\2\u03bb\u03bc\3\2\2\2\u03bc\u03be\3\2\2\2\u03bd\u03bb\3\2\2\2\u03be"+ - "\u03bf\5\u00a6T\2\u03bf\u03c1\78\2\2\u03c0\u03c2\5\u009cO\2\u03c1\u03c0"+ - "\3\2\2\2\u03c1\u03c2\3\2\2\2\u03c2\u03c3\3\2\2\2\u03c3\u03c4\79\2\2\u03c4"+ - "\u03c5\7\66\2\2\u03c5\u03c6\5\u0094K\2\u03c6\u008d\3\2\2\2\u03c7\u03d0"+ - "\7\64\2\2\u03c8\u03c9\7<\2\2\u03c9\u03cc\5R*\2\u03ca\u03cb\7L\2\2\u03cb"+ - "\u03cd\5<\37\2\u03cc\u03ca\3\2\2\2\u03cc\u03cd\3\2\2\2\u03cd\u03ce\3\2"+ - "\2\2\u03ce\u03cf\7=\2\2\u03cf\u03d1\3\2\2\2\u03d0\u03c8\3\2\2\2\u03d0"+ - "\u03d1\3\2\2\2\u03d1\u008f\3\2\2\2\u03d2\u03d3\7\25\2\2\u03d3\u03d4\7"+ - "8\2\2\u03d4\u03d5\5<\37\2\u03d5\u03d6\79\2\2\u03d6\u03d8\3\2\2\2\u03d7"+ - "\u03d2\3\2\2\2\u03d7\u03d8\3\2\2\2\u03d8\u03d9\3\2\2\2\u03d9\u03da\7*"+ - "\2\2\u03da\u03db\7\66\2\2\u03db\u03dc\5<\37\2\u03dc\u0091\3\2\2\2\u03dd"+ - "\u03de\t\n\2\2\u03de\u03df\78\2\2\u03df\u03e0\5<\37\2\u03e0\u03e1\79\2"+ - "\2\u03e1\u03e2\7\66\2\2\u03e2\u03e3\5<\37\2\u03e3\u0093\3\2\2\2\u03e4"+ - "\u03e8\5<\37\2\u03e5\u03e8\7\26\2\2\u03e6\u03e8\5\u0096L\2\u03e7\u03e4"+ - "\3\2\2\2\u03e7\u03e5\3\2\2\2\u03e7\u03e6\3\2\2\2\u03e8\u0095\3\2\2\2\u03e9"+ - "\u03ea\7 \2\2\u03ea\u03eb\7:\2\2\u03eb\u03f1\5\u0098M\2\u03ec\u03ed\7"+ - "\"\2\2\u03ed\u03ef\5\u0094K\2\u03ee\u03f0\7>\2\2\u03ef\u03ee\3\2\2\2\u03ef"+ - "\u03f0\3\2\2\2\u03f0\u03f2\3\2\2\2\u03f1\u03ec\3\2\2\2\u03f1\u03f2\3\2"+ - "\2\2\u03f2\u03f3\3\2\2\2\u03f3\u03f4\7;\2\2\u03f4\u0097\3\2\2\2\u03f5"+ - "\u03fa\5\u009aN\2\u03f6\u03f7\7>\2\2\u03f7\u03f9\5\u009aN\2\u03f8\u03f6"+ - "\3\2\2\2\u03f9\u03fc\3\2\2\2\u03fa\u03f8\3\2\2\2\u03fa\u03fb\3\2\2\2\u03fb"+ - "\u03fe\3\2\2\2\u03fc\u03fa\3\2\2\2\u03fd\u03ff\7>\2\2\u03fe\u03fd\3\2"+ - "\2\2\u03fe\u03ff\3\2\2\2\u03ff\u0099\3\2\2\2\u0400\u0402\5\6\4\2\u0401"+ - "\u0400\3\2\2\2\u0402\u0405\3\2\2\2\u0403\u0401\3\2\2\2\u0403\u0404\3\2"+ - "\2\2\u0404\u040b\3\2\2\2\u0405\u0403\3\2\2\2\u0406\u0407\7\25\2\2\u0407"+ - "\u0408\78\2\2\u0408\u0409\5<\37\2\u0409\u040a\79\2\2\u040a\u040c\3\2\2"+ - "\2\u040b\u0406\3\2\2\2\u040b\u040c\3\2\2\2\u040c\u040d\3\2\2\2\u040d\u040e"+ - "\5\u0094K\2\u040e\u009b\3\2\2\2\u040f\u0414\5\u009eP\2\u0410\u0411\7>"+ - "\2\2\u0411\u0413\5\u009eP\2\u0412\u0410\3\2\2\2\u0413\u0416\3\2\2\2\u0414"+ - "\u0412\3\2\2\2\u0414\u0415\3\2\2\2\u0415\u009d\3\2\2\2\u0416\u0414\3\2"+ - "\2\2\u0417\u0419\7\61\2\2\u0418\u0417\3\2\2\2\u0418\u0419\3\2\2\2\u0419"+ - "\u041a\3\2\2\2\u041a\u041c\7\64\2\2\u041b\u041d\7N\2\2\u041c\u041b\3\2"+ - "\2\2\u041c\u041d\3\2\2\2\u041d\u0420\3\2\2\2\u041e\u041f\7\67\2\2\u041f"+ - "\u0421\5\u00a2R\2\u0420\u041e\3\2\2\2\u0420\u0421\3\2\2\2\u0421\u0425"+ - "\3\2\2\2\u0422\u0423\7\64\2\2\u0423\u0425\5$\23\2\u0424\u0418\3\2\2\2"+ - "\u0424\u0422\3\2\2\2\u0425\u009f\3\2\2\2\u0426\u0427\t\13\2\2\u0427\u00a1"+ - "\3\2\2\2\u0428\u0429\bR\1\2\u0429\u042a\78\2\2\u042a\u042b\5\u00a2R\2"+ - "\u042b\u042c\79\2\2\u042c\u0447\3\2\2\2\u042d\u0432\5\u00a6T\2\u042e\u042f"+ - "\7A\2\2\u042f\u0430\5\u00a4S\2\u0430\u0431\7B\2\2\u0431\u0433\3\2\2\2"+ - "\u0432\u042e\3\2\2\2\u0432\u0433\3\2\2\2\u0433\u0436\3\2\2\2\u0434\u0435"+ - "\7@\2\2\u0435\u0437\7\64\2\2\u0436\u0434\3\2\2\2\u0436\u0437\3\2\2\2\u0437"+ - "\u0447\3\2\2\2\u0438\u0439\78\2\2\u0439\u043a\5\u00a4S\2\u043a\u043b\7"+ - "9\2\2\u043b\u043c\7I\2\2\u043c\u043d\5\u00a2R\6\u043d\u0447\3\2\2\2\u043e"+ - "\u0447\5\u00a0Q\2\u043f\u0441\7J\2\2\u0440\u0442\t\f\2\2\u0441\u0440\3"+ - "\2\2\2\u0441\u0442\3\2\2\2\u0442\u0443\3\2\2\2\u0443\u0447\5\u00a2R\4"+ - "\u0444\u0445\7E\2\2\u0445\u0447\5\u00a2R\3\u0446\u0428\3\2\2\2\u0446\u042d"+ - "\3\2\2\2\u0446\u0438\3\2\2\2\u0446\u043e\3\2\2\2\u0446\u043f\3\2\2\2\u0446"+ - "\u0444\3\2\2\2\u0447\u0450\3\2\2\2\u0448\u0449\f\n\2\2\u0449\u044a\t\5"+ - "\2\2\u044a\u044f\5\u00a2R\13\u044b\u044c\f\t\2\2\u044c\u044d\t\6\2\2\u044d"+ - "\u044f\5\u00a2R\n\u044e\u0448\3\2\2\2\u044e\u044b\3\2\2\2\u044f\u0452"+ - "\3\2\2\2\u0450\u044e\3\2\2\2\u0450\u0451\3\2\2\2\u0451\u00a3\3\2\2\2\u0452"+ - "\u0450\3\2\2\2\u0453\u0458\5\u00a2R\2\u0454\u0455\7>\2\2\u0455\u0457\5"+ - "\u00a2R\2\u0456\u0454\3\2\2\2\u0457\u045a\3\2\2\2\u0458\u0456\3\2\2\2"+ - "\u0458\u0459\3\2\2\2\u0459\u00a5\3\2\2\2\u045a\u0458\3\2\2\2\u045b\u0460"+ - "\7\64\2\2\u045c\u045d\7@\2\2\u045d\u045f\7\64\2\2\u045e\u045c\3\2\2\2"+ - "\u045f\u0462\3\2\2\2\u0460\u045e\3\2\2\2\u0460\u0461\3\2\2\2\u0461\u00a7"+ - "\3\2\2\2\u0462\u0460\3\2\2\2\u0086\u00ab\u00b3\u00c3\u00cb\u00d2\u00d5"+ - "\u00d9\u00de\u00e1\u00e6\u00ea\u00ee\u00f3\u00f9\u0101\u0107\u010f\u0117"+ - "\u011b\u0126\u0131\u0134\u013a\u0140\u0146\u014c\u0160\u0164\u0169\u016c"+ - "\u0173\u017f\u0188\u018c\u0191\u0195\u0199\u019f\u01a2\u01a6\u01ad\u01b6"+ - "\u01ba\u01bd\u01c0\u01c7\u01cc\u01d4\u01d7\u01e4\u01f4\u0209\u021d\u022f"+ - "\u0231\u0238\u023c\u0247\u024b\u025a\u025d\u0266\u026a\u0275\u0279\u0280"+ - "\u0289\u028d\u0296\u029e\u02a5\u02ae\u02b1\u02b6\u02b9\u02bf\u02c6\u02ca"+ - "\u02d3\u02d9\u02de\u02e2\u02eb\u02fa\u0304\u030a\u0312\u0318\u031f\u032c"+ - "\u0332\u033d\u0343\u0347\u034d\u0355\u0362\u0366\u036c\u036f\u0375\u037f"+ - "\u0382\u0389\u0397\u03ad\u03b4\u03bb\u03c1\u03cc\u03d0\u03d7\u03e7\u03ef"+ - "\u03f1\u03fa\u03fe\u0403\u040b\u0414\u0418\u041c\u0420\u0424\u0432\u0436"+ - "\u0441\u0446\u044e\u0450\u0458\u0460"; - public static final ATN _ATN = - new ATNDeserializer().deserialize(_serializedATN.toCharArray()); - static { - _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; - for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { - _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); - } - } +public class CocoParser extends Parser { + static { + RuntimeMetaData.checkVersion("4.9.3", RuntimeMetaData.VERSION); + } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + AFTER = 1, AS = 2, ASSERT = 3, ATTRIBUTE = 4, BECOME = 5, BREAK = 6, CASE = 7, COMPONENT = 8, + CONTINUE = 9, ELSE = 10, ENUM = 11, ENTRY = 12, EXECUTION = 13, EXIT = 14, EXTERNAL = 15, + FINAL = 16, FOR = 17, FUNCTION = 18, IF = 19, ILLEGAL = 20, IMPORT = 21, IN = 22, INIT = 23, + INSTANCE = 24, MACHINE = 25, MATCH = 26, MUT = 27, MUTATING = 28, NONDET = 29, OFFER = 30, + OPTIONAL = 31, OTHERWISE = 32, OUT = 33, OUTGOING = 34, PERIODIC = 35, PORT = 36, + PRIVATE = 37, RETURN = 38, SIGNAL = 39, SPONTANEOUS = 40, STATE = 41, STATIC = 42, + STRUCT = 43, TYPE = 44, UNQUALIFIED = 45, VAL = 46, VAR = 47, WHERE = 48, WHILE = 49, + IDENTIFIER = 50, AT = 51, ASSIGN = 52, COLON = 53, LP = 54, RP = 55, LC = 56, RC = 57, + LB = 58, RB = 59, COMMA = 60, SEMI = 61, DOT = 62, LT = 63, GT = 64, MUL = 65, DIV = 66, + MINUS = 67, MOD = 68, PLUS = 69, IMPL = 70, ARROW = 71, AMP = 72, QM = 73, PIPE = 74, + EXCL = 75, ELLIP = 76, EQ = 77, NE = 78, OR = 79, AND = 80, LE = 81, GE = 82, WHITESPACE = 83, + NEWLINE = 84, LINE_COMMENT = 85, BLOCK_COMMENT = 86, INTEGER = 87, BACKTICK_LITERAL = 88, + CHAR_LITERAL = 89, STRING_LITERAL = 90; + public static final int + RULE_module = 0, RULE_declaration = 1, RULE_attribute = 2, RULE_attributeDeclaration = 3, + RULE_importDeclaration = 4, RULE_variableDeclaration = 5, RULE_enumDeclaration = 6, + RULE_structDeclaration = 7, RULE_typeAliasDeclaration = 8, RULE_functionDeclaration = 9, + RULE_instanceDeclaration = 10, RULE_portDeclaration = 11, RULE_componentDeclaration = 12, + RULE_externalConstantDeclaration = 13, RULE_externalTypeDeclaration = 14, + RULE_externalTypeElement = 15, RULE_externalFunctionDeclaration = 16, + RULE_genericTypeDeclaration = 17, RULE_genericTypes = 18, RULE_genericType = 19, + RULE_enumElement = 20, RULE_enumCase = 21, RULE_caseParameters = 22, RULE_caseParameter = 23, + RULE_structElement = 24, RULE_fieldDeclaration = 25, RULE_componentElement = 26, + RULE_staticMemberDeclaration = 27, RULE_constructorDeclaration = 28, RULE_expression = 29, + RULE_blockExpression_ = 30, RULE_ifExpression_ = 31, RULE_matchExpression_ = 32, + RULE_nondetExpression_ = 33, RULE_fieldAssignments = 34, RULE_fieldAssignment = 35, + RULE_nondetClauses = 36, RULE_nondetClause = 37, RULE_matchClauses = 38, + RULE_matchClause = 39, RULE_pattern = 40, RULE_enumCasePattern = 41, RULE_idParameterPatterns = 42, + RULE_idParameterPattern = 43, RULE_variableDeclarationPattern = 44, RULE_parameterPatterns = 45, + RULE_parameterPattern = 46, RULE_expressions = 47, RULE_statement = 48, + RULE_declarationStatement = 49, RULE_returnStatement = 50, RULE_becomeStatement = 51, + RULE_whileStatement = 52, RULE_forStatement = 53, RULE_breakStatement = 54, + RULE_continueStatement = 55, RULE_portElement = 56, RULE_functionInterfaceDeclaration = 57, + RULE_signalDeclaration = 58, RULE_stateMachineDeclaration = 59, RULE_stateMachineElement = 60, + RULE_stateDeclaration = 61, RULE_eventStateDeclaration = 62, RULE_executionStateDeclaration = 63, + RULE_eventStateElement = 64, RULE_entryFunctionDeclaration = 65, RULE_exitFunctionDeclaration = 66, + RULE_stateInvariant = 67, RULE_transitionDeclaration = 68, RULE_eventTransition = 69, + RULE_eventSource = 70, RULE_spontaneousTransition = 71, RULE_timerTransition = 72, + RULE_eventHandler = 73, RULE_offer = 74, RULE_offerClauses = 75, RULE_offerClause = 76, + RULE_parameters = 77, RULE_parameter = 78, RULE_literalExpression_ = 79, + RULE_type = 80, RULE_types = 81, RULE_dotIdentifierList = 82; + + private static String[] makeRuleNames() { + return new String[]{ + "module", "declaration", "attribute", "attributeDeclaration", "importDeclaration", + "variableDeclaration", "enumDeclaration", "structDeclaration", "typeAliasDeclaration", + "functionDeclaration", "instanceDeclaration", "portDeclaration", "componentDeclaration", + "externalConstantDeclaration", "externalTypeDeclaration", "externalTypeElement", + "externalFunctionDeclaration", "genericTypeDeclaration", "genericTypes", + "genericType", "enumElement", "enumCase", "caseParameters", "caseParameter", + "structElement", "fieldDeclaration", "componentElement", "staticMemberDeclaration", + "constructorDeclaration", "expression", "blockExpression_", "ifExpression_", + "matchExpression_", "nondetExpression_", "fieldAssignments", "fieldAssignment", + "nondetClauses", "nondetClause", "matchClauses", "matchClause", "pattern", + "enumCasePattern", "idParameterPatterns", "idParameterPattern", "variableDeclarationPattern", + "parameterPatterns", "parameterPattern", "expressions", "statement", + "declarationStatement", "returnStatement", "becomeStatement", "whileStatement", + "forStatement", "breakStatement", "continueStatement", "portElement", + "functionInterfaceDeclaration", "signalDeclaration", "stateMachineDeclaration", + "stateMachineElement", "stateDeclaration", "eventStateDeclaration", "executionStateDeclaration", + "eventStateElement", "entryFunctionDeclaration", "exitFunctionDeclaration", + "stateInvariant", "transitionDeclaration", "eventTransition", "eventSource", + "spontaneousTransition", "timerTransition", "eventHandler", "offer", + "offerClauses", "offerClause", "parameters", "parameter", "literalExpression_", + "type", "types", "dotIdentifierList" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[]{ + null, "'after'", "'as'", "'assert'", "'attribute'", "'become'", "'break'", + "'case'", "'component'", "'continue'", "'else'", "'enum'", "'entry'", + "'execution'", "'exit'", "'external'", "'final'", "'for'", "'function'", + "'if'", "'illegal'", "'import'", "'in'", "'init'", "'instance'", "'machine'", + "'match'", "'mut'", "'mutating'", "'nondet'", "'offer'", "'optional'", + "'otherwise'", "'out'", "'outgoing'", "'periodic'", "'port'", "'private'", + "'return'", "'signal'", "'spontaneous'", "'state'", "'static'", "'struct'", + "'type'", "'unqualified'", "'val'", "'var'", "'where'", "'while'", null, + "'@'", "'='", "':'", "'('", "')'", "'{'", "'}'", "'['", "']'", "','", + "';'", "'.'", "'<'", "'>'", "'*'", "'/'", "'-'", "'%'", "'+'", "'=>'", + "'->'", "'&'", "'?'", "'|'", "'!'", "'...'", "'=='", "'!='", "'||'", + "'&&'", "'<='", "'>='" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + + private static String[] makeSymbolicNames() { + return new String[]{ + null, "AFTER", "AS", "ASSERT", "ATTRIBUTE", "BECOME", "BREAK", "CASE", + "COMPONENT", "CONTINUE", "ELSE", "ENUM", "ENTRY", "EXECUTION", "EXIT", + "EXTERNAL", "FINAL", "FOR", "FUNCTION", "IF", "ILLEGAL", "IMPORT", "IN", + "INIT", "INSTANCE", "MACHINE", "MATCH", "MUT", "MUTATING", "NONDET", + "OFFER", "OPTIONAL", "OTHERWISE", "OUT", "OUTGOING", "PERIODIC", "PORT", + "PRIVATE", "RETURN", "SIGNAL", "SPONTANEOUS", "STATE", "STATIC", "STRUCT", + "TYPE", "UNQUALIFIED", "VAL", "VAR", "WHERE", "WHILE", "IDENTIFIER", + "AT", "ASSIGN", "COLON", "LP", "RP", "LC", "RC", "LB", "RB", "COMMA", + "SEMI", "DOT", "LT", "GT", "MUL", "DIV", "MINUS", "MOD", "PLUS", "IMPL", + "ARROW", "AMP", "QM", "PIPE", "EXCL", "ELLIP", "EQ", "NE", "OR", "AND", + "LE", "GE", "WHITESPACE", "NEWLINE", "LINE_COMMENT", "BLOCK_COMMENT", + "INTEGER", "BACKTICK_LITERAL", "CHAR_LITERAL", "STRING_LITERAL" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated public static final String[] tokenNames; + + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override @Deprecated public String[] getTokenNames() { + return tokenNames; + } + + @Override public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override public String getGrammarFileName() { + return "Coco.g4"; + } + + @Override public String[] getRuleNames() { + return ruleNames; + } + + @Override public String getSerializedATN() { + return _serializedATN; + } + + @Override public ATN getATN() { + return _ATN; + } + + public CocoParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache); + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ModuleContext extends ParserRuleContext { + public TerminalNode EOF() { + return getToken(CocoParser.EOF, 0); + } + + public List declaration() { + return getRuleContexts(DeclarationContext.class); + } + + public DeclarationContext declaration(int i) { + return getRuleContext(DeclarationContext.class, i); + } + + public ModuleContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_module; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterModule(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitModule(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitModule(this); + else return visitor.visitChildren(this); + } + } + + public final ModuleContext module() throws RecognitionException { + ModuleContext _localctx = new ModuleContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_module); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(169); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ATTRIBUTE) | (1L << COMPONENT) | (1L << ENUM) | (1L << EXTERNAL) | (1L << FUNCTION) | (1L << IMPORT) | (1L << INSTANCE) | (1L << PORT) | (1L << PRIVATE) | (1L << STRUCT) | (1L << TYPE) | (1L << VAL) | (1L << VAR) | (1L << AT))) != 0)) { + { + { + setState(166); + declaration(); + } + } + setState(171); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(172); + match(EOF); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class DeclarationContext extends ParserRuleContext { + public ImportDeclarationContext importDeclaration() { + return getRuleContext(ImportDeclarationContext.class, 0); + } + + public VariableDeclarationContext variableDeclaration() { + return getRuleContext(VariableDeclarationContext.class, 0); + } + + public EnumDeclarationContext enumDeclaration() { + return getRuleContext(EnumDeclarationContext.class, 0); + } + + public StructDeclarationContext structDeclaration() { + return getRuleContext(StructDeclarationContext.class, 0); + } + + public TypeAliasDeclarationContext typeAliasDeclaration() { + return getRuleContext(TypeAliasDeclarationContext.class, 0); + } + + public FunctionDeclarationContext functionDeclaration() { + return getRuleContext(FunctionDeclarationContext.class, 0); + } + + public InstanceDeclarationContext instanceDeclaration() { + return getRuleContext(InstanceDeclarationContext.class, 0); + } + + public PortDeclarationContext portDeclaration() { + return getRuleContext(PortDeclarationContext.class, 0); + } + + public ComponentDeclarationContext componentDeclaration() { + return getRuleContext(ComponentDeclarationContext.class, 0); + } + + public ExternalConstantDeclarationContext externalConstantDeclaration() { + return getRuleContext(ExternalConstantDeclarationContext.class, 0); + } + + public ExternalFunctionDeclarationContext externalFunctionDeclaration() { + return getRuleContext(ExternalFunctionDeclarationContext.class, 0); + } + + public ExternalTypeDeclarationContext externalTypeDeclaration() { + return getRuleContext(ExternalTypeDeclarationContext.class, 0); + } + + public AttributeDeclarationContext attributeDeclaration() { + return getRuleContext(AttributeDeclarationContext.class, 0); + } + + public List attribute() { + return getRuleContexts(AttributeContext.class); + } + + public AttributeContext attribute(int i) { + return getRuleContext(AttributeContext.class, i); + } + + public DeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_declaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final DeclarationContext declaration() throws RecognitionException { + DeclarationContext _localctx = new DeclarationContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_declaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(177); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == AT) { + { + { + setState(174); + attribute(); + } + } + setState(179); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(193); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 2, _ctx)) { + case 1: + { + setState(180); + importDeclaration(); + } + break; + case 2: + { + setState(181); + variableDeclaration(); + } + break; + case 3: + { + setState(182); + enumDeclaration(); + } + break; + case 4: + { + setState(183); + structDeclaration(); + } + break; + case 5: + { + setState(184); + typeAliasDeclaration(); + } + break; + case 6: + { + setState(185); + functionDeclaration(); + } + break; + case 7: + { + setState(186); + instanceDeclaration(); + } + break; + case 8: + { + setState(187); + portDeclaration(); + } + break; + case 9: + { + setState(188); + componentDeclaration(); + } + break; + case 10: + { + setState(189); + externalConstantDeclaration(); + } + break; + case 11: + { + setState(190); + externalFunctionDeclaration(); + } + break; + case 12: + { + setState(191); + externalTypeDeclaration(); + } + break; + case 13: + { + setState(192); + attributeDeclaration(); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class AttributeContext extends ParserRuleContext { + public TerminalNode AT() { + return getToken(CocoParser.AT, 0); + } + + public DotIdentifierListContext dotIdentifierList() { + return getRuleContext(DotIdentifierListContext.class, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public ExpressionsContext expressions() { + return getRuleContext(ExpressionsContext.class, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public AttributeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_attribute; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterAttribute(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitAttribute(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitAttribute(this); + else return visitor.visitChildren(this); + } + } + + public final AttributeContext attribute() throws RecognitionException { + AttributeContext _localctx = new AttributeContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_attribute); + try { + enterOuterAlt(_localctx, 1); + { + setState(195); + match(AT); + setState(196); + dotIdentifierList(); + setState(201); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 3, _ctx)) { + case 1: + { + setState(197); + match(LP); + setState(198); + expressions(); + setState(199); + match(RP); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class AttributeDeclarationContext extends ParserRuleContext { + public TerminalNode ATTRIBUTE() { + return getToken(CocoParser.ATTRIBUTE, 0); + } + + public TerminalNode AT() { + return getToken(CocoParser.AT, 0); + } + + public DotIdentifierListContext dotIdentifierList() { + return getRuleContext(DotIdentifierListContext.class, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public ParametersContext parameters() { + return getRuleContext(ParametersContext.class, 0); + } + + public AttributeDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_attributeDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterAttributeDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitAttributeDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitAttributeDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final AttributeDeclarationContext attributeDeclaration() throws RecognitionException { + AttributeDeclarationContext _localctx = new AttributeDeclarationContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_attributeDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(203); + match(ATTRIBUTE); + setState(204); + match(AT); + setState(205); + dotIdentifierList(); + setState(211); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LP) { + { + setState(206); + match(LP); + setState(208); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAR || _la == IDENTIFIER) { + { + setState(207); + parameters(); + } + } + + setState(210); + match(RP); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ImportDeclarationContext extends ParserRuleContext { + public TerminalNode IMPORT() { + return getToken(CocoParser.IMPORT, 0); + } + + public DotIdentifierListContext dotIdentifierList() { + return getRuleContext(DotIdentifierListContext.class, 0); + } + + public TerminalNode UNQUALIFIED() { + return getToken(CocoParser.UNQUALIFIED, 0); + } + + public TerminalNode AS() { + return getToken(CocoParser.AS, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public ImportDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_importDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterImportDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitImportDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitImportDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final ImportDeclarationContext importDeclaration() throws RecognitionException { + ImportDeclarationContext _localctx = new ImportDeclarationContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_importDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(213); + match(IMPORT); + setState(215); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == UNQUALIFIED) { + { + setState(214); + match(UNQUALIFIED); + } + } + + setState(217); + dotIdentifierList(); + setState(220); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == AS) { + { + setState(218); + match(AS); + setState(219); + match(IDENTIFIER); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class VariableDeclarationContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode VAR() { + return getToken(CocoParser.VAR, 0); + } + + public TerminalNode VAL() { + return getToken(CocoParser.VAL, 0); + } + + public TerminalNode PRIVATE() { + return getToken(CocoParser.PRIVATE, 0); + } + + public GenericTypeDeclarationContext genericTypeDeclaration() { + return getRuleContext(GenericTypeDeclarationContext.class, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public VariableDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_variableDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterVariableDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitVariableDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitVariableDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final VariableDeclarationContext variableDeclaration() throws RecognitionException { + VariableDeclarationContext _localctx = new VariableDeclarationContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_variableDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(223); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == PRIVATE) { + { + setState(222); + match(PRIVATE); + } + } + + setState(225); + _la = _input.LA(1); + if (!(_la == VAL || _la == VAR)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(226); + match(IDENTIFIER); + setState(228); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LT) { + { + setState(227); + genericTypeDeclaration(); + } + } + + setState(232); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COLON) { + { + setState(230); + match(COLON); + setState(231); + type(0); + } + } + + setState(236); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == ASSIGN) { + { + setState(234); + match(ASSIGN); + setState(235); + expression(0); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class EnumDeclarationContext extends ParserRuleContext { + public TerminalNode ENUM() { + return getToken(CocoParser.ENUM, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LC() { + return getToken(CocoParser.LC, 0); + } + + public TerminalNode RC() { + return getToken(CocoParser.RC, 0); + } + + public GenericTypeDeclarationContext genericTypeDeclaration() { + return getRuleContext(GenericTypeDeclarationContext.class, 0); + } + + public List enumElement() { + return getRuleContexts(EnumElementContext.class); + } + + public EnumElementContext enumElement(int i) { + return getRuleContext(EnumElementContext.class, i); + } + + public EnumDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_enumDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterEnumDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitEnumDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitEnumDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final EnumDeclarationContext enumDeclaration() throws RecognitionException { + EnumDeclarationContext _localctx = new EnumDeclarationContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_enumDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(238); + match(ENUM); + setState(239); + match(IDENTIFIER); + setState(241); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LT) { + { + setState(240); + genericTypeDeclaration(); + } + } + + setState(243); + match(LC); + setState(247); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << CASE) | (1L << FUNCTION) | (1L << MUT) | (1L << MUTATING) | (1L << STATIC))) != 0)) { + { + { + setState(244); + enumElement(); + } + } + setState(249); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(250); + match(RC); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class StructDeclarationContext extends ParserRuleContext { + public TerminalNode STRUCT() { + return getToken(CocoParser.STRUCT, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LC() { + return getToken(CocoParser.LC, 0); + } + + public TerminalNode RC() { + return getToken(CocoParser.RC, 0); + } + + public GenericTypeDeclarationContext genericTypeDeclaration() { + return getRuleContext(GenericTypeDeclarationContext.class, 0); + } + + public List structElement() { + return getRuleContexts(StructElementContext.class); + } + + public StructElementContext structElement(int i) { + return getRuleContext(StructElementContext.class, i); + } + + public StructDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_structDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterStructDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitStructDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitStructDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final StructDeclarationContext structDeclaration() throws RecognitionException { + StructDeclarationContext _localctx = new StructDeclarationContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_structDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(252); + match(STRUCT); + setState(253); + match(IDENTIFIER); + setState(255); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LT) { + { + setState(254); + genericTypeDeclaration(); + } + } + + setState(257); + match(LC); + setState(261); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << FUNCTION) | (1L << MUT) | (1L << MUTATING) | (1L << STATIC) | (1L << VAL) | (1L << VAR) | (1L << IDENTIFIER))) != 0)) { + { + { + setState(258); + structElement(); + } + } + setState(263); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(264); + match(RC); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class TypeAliasDeclarationContext extends ParserRuleContext { + public TerminalNode TYPE() { + return getToken(CocoParser.TYPE, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public GenericTypeDeclarationContext genericTypeDeclaration() { + return getRuleContext(GenericTypeDeclarationContext.class, 0); + } + + public TypeAliasDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_typeAliasDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterTypeAliasDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitTypeAliasDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitTypeAliasDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final TypeAliasDeclarationContext typeAliasDeclaration() throws RecognitionException { + TypeAliasDeclarationContext _localctx = new TypeAliasDeclarationContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_typeAliasDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(266); + match(TYPE); + setState(267); + match(IDENTIFIER); + setState(269); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LT) { + { + setState(268); + genericTypeDeclaration(); + } + } + + setState(271); + match(ASSIGN); + setState(272); + type(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class FunctionDeclarationContext extends ParserRuleContext { + public TerminalNode FUNCTION() { + return getToken(CocoParser.FUNCTION, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public GenericTypeDeclarationContext genericTypeDeclaration() { + return getRuleContext(GenericTypeDeclarationContext.class, 0); + } + + public ParametersContext parameters() { + return getRuleContext(ParametersContext.class, 0); + } + + public FunctionDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_functionDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterFunctionDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitFunctionDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitFunctionDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final FunctionDeclarationContext functionDeclaration() throws RecognitionException { + FunctionDeclarationContext _localctx = new FunctionDeclarationContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_functionDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(274); + match(FUNCTION); + setState(275); + match(IDENTIFIER); + setState(277); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LT) { + { + setState(276); + genericTypeDeclaration(); + } + } + + setState(279); + match(LP); + setState(281); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAR || _la == IDENTIFIER) { + { + setState(280); + parameters(); + } + } + + setState(283); + match(RP); + setState(284); + match(COLON); + setState(285); + type(0); + setState(286); + match(ASSIGN); + setState(287); + expression(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class InstanceDeclarationContext extends ParserRuleContext { + public TerminalNode INSTANCE() { + return getToken(CocoParser.INSTANCE, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public ParametersContext parameters() { + return getRuleContext(ParametersContext.class, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public BlockExpression_Context blockExpression_() { + return getRuleContext(BlockExpression_Context.class, 0); + } + + public GenericTypeDeclarationContext genericTypeDeclaration() { + return getRuleContext(GenericTypeDeclarationContext.class, 0); + } + + public InstanceDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_instanceDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterInstanceDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitInstanceDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitInstanceDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final InstanceDeclarationContext instanceDeclaration() throws RecognitionException { + InstanceDeclarationContext _localctx = new InstanceDeclarationContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_instanceDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(289); + match(INSTANCE); + setState(290); + match(IDENTIFIER); + setState(292); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LT) { + { + setState(291); + genericTypeDeclaration(); + } + } + + setState(294); + match(LP); + setState(295); + parameters(); + setState(296); + match(RP); + setState(297); + blockExpression_(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class PortDeclarationContext extends ParserRuleContext { + public TerminalNode PORT() { + return getToken(CocoParser.PORT, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LC() { + return getToken(CocoParser.LC, 0); + } + + public TerminalNode RC() { + return getToken(CocoParser.RC, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypesContext types() { + return getRuleContext(TypesContext.class, 0); + } + + public TerminalNode FINAL() { + return getToken(CocoParser.FINAL, 0); + } + + public List portElement() { + return getRuleContexts(PortElementContext.class); + } + + public PortElementContext portElement(int i) { + return getRuleContext(PortElementContext.class, i); + } + + public PortDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_portDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterPortDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitPortDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitPortDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final PortDeclarationContext portDeclaration() throws RecognitionException { + PortDeclarationContext _localctx = new PortDeclarationContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_portDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(299); + match(PORT); + setState(300); + match(IDENTIFIER); + setState(303); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COLON) { + { + setState(301); + match(COLON); + setState(302); + types(); + } + } + + setState(306); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == FINAL) { + { + setState(305); + match(FINAL); + } + } + + setState(308); + match(LC); + setState(312); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ENUM) | (1L << EXTERNAL) | (1L << FUNCTION) | (1L << MACHINE) | (1L << OUTGOING) | (1L << PORT) | (1L << STATIC) | (1L << STRUCT) | (1L << TYPE) | (1L << VAL) | (1L << VAR) | (1L << IDENTIFIER) | (1L << AT))) != 0)) { + { + { + setState(309); + portElement(); + } + } + setState(314); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(315); + match(RC); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ComponentDeclarationContext extends ParserRuleContext { + public TerminalNode COMPONENT() { + return getToken(CocoParser.COMPONENT, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LC() { + return getToken(CocoParser.LC, 0); + } + + public TerminalNode RC() { + return getToken(CocoParser.RC, 0); + } + + public TerminalNode EXTERNAL() { + return getToken(CocoParser.EXTERNAL, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public List componentElement() { + return getRuleContexts(ComponentElementContext.class); + } + + public ComponentElementContext componentElement(int i) { + return getRuleContext(ComponentElementContext.class, i); + } + + public ComponentDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_componentDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterComponentDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitComponentDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitComponentDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final ComponentDeclarationContext componentDeclaration() throws RecognitionException { + ComponentDeclarationContext _localctx = new ComponentDeclarationContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_componentDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(318); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == EXTERNAL) { + { + setState(317); + match(EXTERNAL); + } + } + + setState(320); + match(COMPONENT); + setState(321); + match(IDENTIFIER); + setState(324); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COLON) { + { + setState(322); + match(COLON); + setState(323); + type(0); + } + } + + setState(326); + match(LC); + setState(330); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << INIT) | (1L << MACHINE) | (1L << PRIVATE) | (1L << STATIC) | (1L << VAL) | (1L << VAR) | (1L << IDENTIFIER) | (1L << AT))) != 0)) { + { + { + setState(327); + componentElement(); + } + } + setState(332); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(333); + match(RC); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ExternalConstantDeclarationContext extends ParserRuleContext { + public TerminalNode EXTERNAL() { + return getToken(CocoParser.EXTERNAL, 0); + } + + public TerminalNode VAL() { + return getToken(CocoParser.VAL, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public ExternalConstantDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_externalConstantDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterExternalConstantDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitExternalConstantDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitExternalConstantDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final ExternalConstantDeclarationContext externalConstantDeclaration() throws RecognitionException { + ExternalConstantDeclarationContext _localctx = new ExternalConstantDeclarationContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_externalConstantDeclaration); + try { + enterOuterAlt(_localctx, 1); + { + setState(335); + match(EXTERNAL); + setState(336); + match(VAL); + setState(337); + match(IDENTIFIER); + setState(338); + match(COLON); + setState(339); + type(0); + setState(340); + match(ASSIGN); + setState(341); + expression(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ExternalTypeDeclarationContext extends ParserRuleContext { + public TerminalNode EXTERNAL() { + return getToken(CocoParser.EXTERNAL, 0); + } + + public TerminalNode TYPE() { + return getToken(CocoParser.TYPE, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LC() { + return getToken(CocoParser.LC, 0); + } + + public TerminalNode RC() { + return getToken(CocoParser.RC, 0); + } + + public List externalTypeElement() { + return getRuleContexts(ExternalTypeElementContext.class); + } + + public ExternalTypeElementContext externalTypeElement(int i) { + return getRuleContext(ExternalTypeElementContext.class, i); + } + + public ExternalTypeDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_externalTypeDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterExternalTypeDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitExternalTypeDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitExternalTypeDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final ExternalTypeDeclarationContext externalTypeDeclaration() throws RecognitionException { + ExternalTypeDeclarationContext _localctx = new ExternalTypeDeclarationContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_externalTypeDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(343); + match(EXTERNAL); + setState(344); + match(TYPE); + setState(345); + match(IDENTIFIER); + setState(354); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LC) { + { + setState(346); + match(LC); + setState(350); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << EXTERNAL) | (1L << MUT) | (1L << MUTATING) | (1L << PRIVATE) | (1L << STATIC) | (1L << VAL) | (1L << VAR))) != 0)) { + { + { + setState(347); + externalTypeElement(); + } + } + setState(352); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(353); + match(RC); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ExternalTypeElementContext extends ParserRuleContext { + public StaticMemberDeclarationContext staticMemberDeclaration() { + return getRuleContext(StaticMemberDeclarationContext.class, 0); + } + + public VariableDeclarationContext variableDeclaration() { + return getRuleContext(VariableDeclarationContext.class, 0); + } + + public ExternalFunctionDeclarationContext externalFunctionDeclaration() { + return getRuleContext(ExternalFunctionDeclarationContext.class, 0); + } + + public TerminalNode MUT() { + return getToken(CocoParser.MUT, 0); + } + + public TerminalNode MUTATING() { + return getToken(CocoParser.MUTATING, 0); + } + + public ExternalTypeElementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_externalTypeElement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterExternalTypeElement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitExternalTypeElement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitExternalTypeElement(this); + else return visitor.visitChildren(this); + } + } + + public final ExternalTypeElementContext externalTypeElement() throws RecognitionException { + ExternalTypeElementContext _localctx = new ExternalTypeElementContext(_ctx, getState()); + enterRule(_localctx, 30, RULE_externalTypeElement); + int _la; + try { + setState(362); + _errHandler.sync(this); + switch (_input.LA(1)) { + case STATIC: + enterOuterAlt(_localctx, 1); + { + setState(356); + staticMemberDeclaration(); + } + break; + case PRIVATE: + case VAL: + case VAR: + enterOuterAlt(_localctx, 2); + { + setState(357); + variableDeclaration(); + } + break; + case EXTERNAL: + case MUT: + case MUTATING: + enterOuterAlt(_localctx, 3); + { + setState(359); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == MUT || _la == MUTATING) { + { + setState(358); + _la = _input.LA(1); + if (!(_la == MUT || _la == MUTATING)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + + setState(361); + externalFunctionDeclaration(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ExternalFunctionDeclarationContext extends ParserRuleContext { + public TerminalNode EXTERNAL() { + return getToken(CocoParser.EXTERNAL, 0); + } + + public TerminalNode FUNCTION() { + return getToken(CocoParser.FUNCTION, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public ParametersContext parameters() { + return getRuleContext(ParametersContext.class, 0); + } + + public ExternalFunctionDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_externalFunctionDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterExternalFunctionDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitExternalFunctionDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitExternalFunctionDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final ExternalFunctionDeclarationContext externalFunctionDeclaration() throws RecognitionException { + ExternalFunctionDeclarationContext _localctx = new ExternalFunctionDeclarationContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_externalFunctionDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(364); + match(EXTERNAL); + setState(365); + match(FUNCTION); + setState(366); + match(IDENTIFIER); + setState(367); + match(LP); + setState(369); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAR || _la == IDENTIFIER) { + { + setState(368); + parameters(); + } + } + + setState(371); + match(RP); + setState(372); + match(COLON); + setState(373); + type(0); + setState(374); + match(ASSIGN); + setState(375); + expression(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class GenericTypeDeclarationContext extends ParserRuleContext { + public TerminalNode LT() { + return getToken(CocoParser.LT, 0); + } + + public GenericTypesContext genericTypes() { + return getRuleContext(GenericTypesContext.class, 0); + } + + public TerminalNode GT() { + return getToken(CocoParser.GT, 0); + } + + public TerminalNode WHERE() { + return getToken(CocoParser.WHERE, 0); + } + + public ExpressionsContext expressions() { + return getRuleContext(ExpressionsContext.class, 0); + } + + public GenericTypeDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_genericTypeDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterGenericTypeDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitGenericTypeDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitGenericTypeDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final GenericTypeDeclarationContext genericTypeDeclaration() throws RecognitionException { + GenericTypeDeclarationContext _localctx = new GenericTypeDeclarationContext(_ctx, getState()); + enterRule(_localctx, 34, RULE_genericTypeDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(377); + match(LT); + setState(378); + genericTypes(); + setState(381); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == WHERE) { + { + setState(379); + match(WHERE); + setState(380); + expressions(); + } + } + + setState(383); + match(GT); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class GenericTypesContext extends ParserRuleContext { + public List genericType() { + return getRuleContexts(GenericTypeContext.class); + } + + public GenericTypeContext genericType(int i) { + return getRuleContext(GenericTypeContext.class, i); + } + + public List COMMA() { + return getTokens(CocoParser.COMMA); + } + + public TerminalNode COMMA(int i) { + return getToken(CocoParser.COMMA, i); + } + + public GenericTypesContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_genericTypes; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterGenericTypes(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitGenericTypes(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitGenericTypes(this); + else return visitor.visitChildren(this); + } + } + + public final GenericTypesContext genericTypes() throws RecognitionException { + GenericTypesContext _localctx = new GenericTypesContext(_ctx, getState()); + enterRule(_localctx, 36, RULE_genericTypes); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(385); + genericType(); + setState(390); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == COMMA) { + { + { + setState(386); + match(COMMA); + setState(387); + genericType(); + } + } + setState(392); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class GenericTypeContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode VAL() { + return getToken(CocoParser.VAL, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public GenericTypeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_genericType; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterGenericType(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitGenericType(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitGenericType(this); + else return visitor.visitChildren(this); + } + } + + public final GenericTypeContext genericType() throws RecognitionException { + GenericTypeContext _localctx = new GenericTypeContext(_ctx, getState()); + enterRule(_localctx, 38, RULE_genericType); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(394); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAL) { + { + setState(393); + match(VAL); + } + } + + setState(396); + match(IDENTIFIER); + setState(399); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COLON) { + { + setState(397); + match(COLON); + setState(398); + type(0); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class EnumElementContext extends ParserRuleContext { + public EnumCaseContext enumCase() { + return getRuleContext(EnumCaseContext.class, 0); + } + + public FunctionDeclarationContext functionDeclaration() { + return getRuleContext(FunctionDeclarationContext.class, 0); + } + + public TerminalNode MUT() { + return getToken(CocoParser.MUT, 0); + } + + public TerminalNode MUTATING() { + return getToken(CocoParser.MUTATING, 0); + } + + public StaticMemberDeclarationContext staticMemberDeclaration() { + return getRuleContext(StaticMemberDeclarationContext.class, 0); + } + + public EnumElementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_enumElement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterEnumElement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitEnumElement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitEnumElement(this); + else return visitor.visitChildren(this); + } + } + + public final EnumElementContext enumElement() throws RecognitionException { + EnumElementContext _localctx = new EnumElementContext(_ctx, getState()); + enterRule(_localctx, 40, RULE_enumElement); + int _la; + try { + setState(407); + _errHandler.sync(this); + switch (_input.LA(1)) { + case CASE: + enterOuterAlt(_localctx, 1); + { + setState(401); + enumCase(); + } + break; + case FUNCTION: + case MUT: + case MUTATING: + enterOuterAlt(_localctx, 2); + { + setState(403); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == MUT || _la == MUTATING) { + { + setState(402); + _la = _input.LA(1); + if (!(_la == MUT || _la == MUTATING)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + + setState(405); + functionDeclaration(); + } + break; + case STATIC: + enterOuterAlt(_localctx, 3); + { + setState(406); + staticMemberDeclaration(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class EnumCaseContext extends ParserRuleContext { + public TerminalNode CASE() { + return getToken(CocoParser.CASE, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public CaseParametersContext caseParameters() { + return getRuleContext(CaseParametersContext.class, 0); + } + + public EnumCaseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_enumCase; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterEnumCase(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitEnumCase(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitEnumCase(this); + else return visitor.visitChildren(this); + } + } + + public final EnumCaseContext enumCase() throws RecognitionException { + EnumCaseContext _localctx = new EnumCaseContext(_ctx, getState()); + enterRule(_localctx, 42, RULE_enumCase); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(409); + match(CASE); + setState(410); + match(IDENTIFIER); + setState(416); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LP) { + { + setState(411); + match(LP); + setState(413); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == IDENTIFIER) { + { + setState(412); + caseParameters(); + } + } + + setState(415); + match(RP); + } + } + + setState(420); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == ASSIGN) { + { + setState(418); + match(ASSIGN); + setState(419); + expression(0); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class CaseParametersContext extends ParserRuleContext { + public List caseParameter() { + return getRuleContexts(CaseParameterContext.class); + } + + public CaseParameterContext caseParameter(int i) { + return getRuleContext(CaseParameterContext.class, i); + } + + public List COMMA() { + return getTokens(CocoParser.COMMA); + } + + public TerminalNode COMMA(int i) { + return getToken(CocoParser.COMMA, i); + } + + public CaseParametersContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_caseParameters; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterCaseParameters(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitCaseParameters(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitCaseParameters(this); + else return visitor.visitChildren(this); + } + } + + public final CaseParametersContext caseParameters() throws RecognitionException { + CaseParametersContext _localctx = new CaseParametersContext(_ctx, getState()); + enterRule(_localctx, 44, RULE_caseParameters); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(422); + caseParameter(); + setState(427); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == COMMA) { + { + { + setState(423); + match(COMMA); + setState(424); + caseParameter(); + } + } + setState(429); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class CaseParameterContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public CaseParameterContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_caseParameter; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterCaseParameter(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitCaseParameter(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitCaseParameter(this); + else return visitor.visitChildren(this); + } + } + + public final CaseParameterContext caseParameter() throws RecognitionException { + CaseParameterContext _localctx = new CaseParameterContext(_ctx, getState()); + enterRule(_localctx, 46, RULE_caseParameter); + try { + enterOuterAlt(_localctx, 1); + { + setState(430); + match(IDENTIFIER); + setState(431); + match(COLON); + setState(432); + type(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class StructElementContext extends ParserRuleContext { + public FieldDeclarationContext fieldDeclaration() { + return getRuleContext(FieldDeclarationContext.class, 0); + } + + public FunctionDeclarationContext functionDeclaration() { + return getRuleContext(FunctionDeclarationContext.class, 0); + } + + public StaticMemberDeclarationContext staticMemberDeclaration() { + return getRuleContext(StaticMemberDeclarationContext.class, 0); + } + + public TerminalNode SEMI() { + return getToken(CocoParser.SEMI, 0); + } + + public TerminalNode MUT() { + return getToken(CocoParser.MUT, 0); + } + + public TerminalNode MUTATING() { + return getToken(CocoParser.MUTATING, 0); + } + + public StructElementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_structElement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterStructElement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitStructElement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitStructElement(this); + else return visitor.visitChildren(this); + } + } + + public final StructElementContext structElement() throws RecognitionException { + StructElementContext _localctx = new StructElementContext(_ctx, getState()); + enterRule(_localctx, 48, RULE_structElement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(440); + _errHandler.sync(this); + switch (_input.LA(1)) { + case VAL: + case VAR: + case IDENTIFIER: + { + setState(434); + fieldDeclaration(); + } + break; + case FUNCTION: + case MUT: + case MUTATING: + { + setState(436); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == MUT || _la == MUTATING) { + { + setState(435); + _la = _input.LA(1); + if (!(_la == MUT || _la == MUTATING)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + + setState(438); + functionDeclaration(); + } + break; + case STATIC: + { + setState(439); + staticMemberDeclaration(); + } + break; + default: + throw new NoViableAltException(this); + } + setState(443); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == SEMI) { + { + setState(442); + match(SEMI); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class FieldDeclarationContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode VAL() { + return getToken(CocoParser.VAL, 0); + } + + public TerminalNode VAR() { + return getToken(CocoParser.VAR, 0); + } + + public FieldDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_fieldDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterFieldDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitFieldDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitFieldDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final FieldDeclarationContext fieldDeclaration() throws RecognitionException { + FieldDeclarationContext _localctx = new FieldDeclarationContext(_ctx, getState()); + enterRule(_localctx, 50, RULE_fieldDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(446); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAL || _la == VAR) { + { + setState(445); + _la = _input.LA(1); + if (!(_la == VAL || _la == VAR)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + + setState(448); + match(IDENTIFIER); + setState(449); + match(COLON); + setState(450); + type(0); + setState(453); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == ASSIGN) { + { + setState(451); + match(ASSIGN); + setState(452); + expression(0); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ComponentElementContext extends ParserRuleContext { + public FieldDeclarationContext fieldDeclaration() { + return getRuleContext(FieldDeclarationContext.class, 0); + } + + public VariableDeclarationContext variableDeclaration() { + return getRuleContext(VariableDeclarationContext.class, 0); + } + + public ConstructorDeclarationContext constructorDeclaration() { + return getRuleContext(ConstructorDeclarationContext.class, 0); + } + + public StateMachineDeclarationContext stateMachineDeclaration() { + return getRuleContext(StateMachineDeclarationContext.class, 0); + } + + public StaticMemberDeclarationContext staticMemberDeclaration() { + return getRuleContext(StaticMemberDeclarationContext.class, 0); + } + + public List attribute() { + return getRuleContexts(AttributeContext.class); + } + + public AttributeContext attribute(int i) { + return getRuleContext(AttributeContext.class, i); + } + + public TerminalNode SEMI() { + return getToken(CocoParser.SEMI, 0); + } + + public ComponentElementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_componentElement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterComponentElement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitComponentElement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitComponentElement(this); + else return visitor.visitChildren(this); + } + } + + public final ComponentElementContext componentElement() throws RecognitionException { + ComponentElementContext _localctx = new ComponentElementContext(_ctx, getState()); + enterRule(_localctx, 52, RULE_componentElement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(458); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == AT) { + { + { + setState(455); + attribute(); + } + } + setState(460); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(466); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 47, _ctx)) { + case 1: + { + setState(461); + fieldDeclaration(); + } + break; + case 2: + { + setState(462); + variableDeclaration(); + } + break; + case 3: + { + setState(463); + constructorDeclaration(); + } + break; + case 4: + { + setState(464); + stateMachineDeclaration(); + } + break; + case 5: + { + setState(465); + staticMemberDeclaration(); + } + break; + } + setState(469); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == SEMI) { + { + setState(468); + match(SEMI); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class StaticMemberDeclarationContext extends ParserRuleContext { + public TerminalNode STATIC() { + return getToken(CocoParser.STATIC, 0); + } + + public TerminalNode VAL() { + return getToken(CocoParser.VAL, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public StaticMemberDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_staticMemberDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterStaticMemberDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitStaticMemberDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitStaticMemberDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final StaticMemberDeclarationContext staticMemberDeclaration() throws RecognitionException { + StaticMemberDeclarationContext _localctx = new StaticMemberDeclarationContext(_ctx, getState()); + enterRule(_localctx, 54, RULE_staticMemberDeclaration); + try { + enterOuterAlt(_localctx, 1); + { + setState(471); + match(STATIC); + setState(472); + match(VAL); + setState(473); + match(IDENTIFIER); + setState(474); + match(COLON); + setState(475); + type(0); + setState(476); + match(ASSIGN); + setState(477); + expression(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ConstructorDeclarationContext extends ParserRuleContext { + public TerminalNode INIT() { + return getToken(CocoParser.INIT, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public BlockExpression_Context blockExpression_() { + return getRuleContext(BlockExpression_Context.class, 0); + } + + public ParametersContext parameters() { + return getRuleContext(ParametersContext.class, 0); + } + + public ConstructorDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_constructorDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterConstructorDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitConstructorDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitConstructorDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final ConstructorDeclarationContext constructorDeclaration() throws RecognitionException { + ConstructorDeclarationContext _localctx = new ConstructorDeclarationContext(_ctx, getState()); + enterRule(_localctx, 56, RULE_constructorDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(479); + match(INIT); + setState(480); + match(LP); + setState(482); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAR || _la == IDENTIFIER) { + { + setState(481); + parameters(); + } + } + + setState(484); + match(RP); + setState(485); + match(ASSIGN); + setState(486); + blockExpression_(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ExpressionContext extends ParserRuleContext { + public ExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_expression; + } + + public ExpressionContext() { + } + + public void copyFrom(ExpressionContext ctx) { + super.copyFrom(ctx); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class IfExpressionContext extends ExpressionContext { + public IfExpression_Context ifExpression_() { + return getRuleContext(IfExpression_Context.class, 0); + } + + public IfExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterIfExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitIfExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitIfExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class TryOperatorExpressionContext extends ExpressionContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode QM() { + return getToken(CocoParser.QM, 0); + } + + public TryOperatorExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterTryOperatorExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitTryOperatorExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitTryOperatorExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class UnaryOperatorExpressionContext extends ExpressionContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode MINUS() { + return getToken(CocoParser.MINUS, 0); + } + + public TerminalNode EXCL() { + return getToken(CocoParser.EXCL, 0); + } + + public TerminalNode AMP() { + return getToken(CocoParser.AMP, 0); + } + + public UnaryOperatorExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterUnaryOperatorExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitUnaryOperatorExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitUnaryOperatorExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class OptionalExpressionContext extends ExpressionContext { + public TerminalNode OPTIONAL() { + return getToken(CocoParser.OPTIONAL, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public OptionalExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterOptionalExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitOptionalExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitOptionalExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ArithmicOrLogicalExpressionContext extends ExpressionContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class, i); + } + + public TerminalNode MUL() { + return getToken(CocoParser.MUL, 0); + } + + public TerminalNode DIV() { + return getToken(CocoParser.DIV, 0); + } + + public TerminalNode MOD() { + return getToken(CocoParser.MOD, 0); + } + + public TerminalNode PLUS() { + return getToken(CocoParser.PLUS, 0); + } + + public TerminalNode MINUS() { + return getToken(CocoParser.MINUS, 0); + } + + public TerminalNode EQ() { + return getToken(CocoParser.EQ, 0); + } + + public TerminalNode NE() { + return getToken(CocoParser.NE, 0); + } + + public TerminalNode OR() { + return getToken(CocoParser.OR, 0); + } + + public TerminalNode AND() { + return getToken(CocoParser.AND, 0); + } + + public TerminalNode LT() { + return getToken(CocoParser.LT, 0); + } + + public TerminalNode LE() { + return getToken(CocoParser.LE, 0); + } + + public TerminalNode GT() { + return getToken(CocoParser.GT, 0); + } + + public TerminalNode GE() { + return getToken(CocoParser.GE, 0); + } + + public ArithmicOrLogicalExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterArithmicOrLogicalExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitArithmicOrLogicalExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitArithmicOrLogicalExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class LiteralExpressionContext extends ExpressionContext { + public LiteralExpression_Context literalExpression_() { + return getRuleContext(LiteralExpression_Context.class, 0); + } + + public LiteralExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterLiteralExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitLiteralExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitLiteralExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ArrayLiteralExpressionContext extends ExpressionContext { + public TerminalNode LB() { + return getToken(CocoParser.LB, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode RB() { + return getToken(CocoParser.RB, 0); + } + + public ArrayLiteralExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterArrayLiteralExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitArrayLiteralExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitArrayLiteralExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class NondetExpressionContext extends ExpressionContext { + public NondetExpression_Context nondetExpression_() { + return getRuleContext(NondetExpression_Context.class, 0); + } + + public NondetExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterNondetExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitNondetExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitNondetExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class GroupedExpressionContext extends ExpressionContext { + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public ExpressionsContext expressions() { + return getRuleContext(ExpressionsContext.class, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public GroupedExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterGroupedExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitGroupedExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitGroupedExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class BlockExpressionContext extends ExpressionContext { + public BlockExpression_Context blockExpression_() { + return getRuleContext(BlockExpression_Context.class, 0); + } + + public BlockExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterBlockExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitBlockExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitBlockExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class MatchExpressionContext extends ExpressionContext { + public MatchExpression_Context matchExpression_() { + return getRuleContext(MatchExpression_Context.class, 0); + } + + public MatchExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterMatchExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitMatchExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitMatchExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class StructLiteralExpressionContext extends ExpressionContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode LC() { + return getToken(CocoParser.LC, 0); + } + + public FieldAssignmentsContext fieldAssignments() { + return getRuleContext(FieldAssignmentsContext.class, 0); + } + + public TerminalNode RC() { + return getToken(CocoParser.RC, 0); + } + + public StructLiteralExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterStructLiteralExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitStructLiteralExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitStructLiteralExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class MemberReferenceExpressionContext extends ExpressionContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode DOT() { + return getToken(CocoParser.DOT, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public MemberReferenceExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterMemberReferenceExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitMemberReferenceExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitMemberReferenceExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class AssignmentExpressionContext extends ExpressionContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class, i); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public AssignmentExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterAssignmentExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitAssignmentExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitAssignmentExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class VariableReferenceExpressionContext extends ExpressionContext { + public DotIdentifierListContext dotIdentifierList() { + return getRuleContext(DotIdentifierListContext.class, 0); + } + + public TerminalNode LT() { + return getToken(CocoParser.LT, 0); + } + + public GenericTypesContext genericTypes() { + return getRuleContext(GenericTypesContext.class, 0); + } + + public TerminalNode GT() { + return getToken(CocoParser.GT, 0); + } + + public VariableReferenceExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterVariableReferenceExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitVariableReferenceExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitVariableReferenceExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ImplicitMemberExpressionContext extends ExpressionContext { + public TerminalNode DOT() { + return getToken(CocoParser.DOT, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public ImplicitMemberExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterImplicitMemberExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitImplicitMemberExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitImplicitMemberExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ExternalFunctionContext extends ExpressionContext { + public ExternalFunctionDeclarationContext externalFunctionDeclaration() { + return getRuleContext(ExternalFunctionDeclarationContext.class, 0); + } + + public ExternalFunctionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterExternalFunction(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitExternalFunction(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitExternalFunction(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class CastExpressionContext extends ExpressionContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode AS() { + return getToken(CocoParser.AS, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public CastExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterCastExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitCastExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitCastExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class StateInvariantExpressionContext extends ExpressionContext { + public StateInvariantContext stateInvariant() { + return getRuleContext(StateInvariantContext.class, 0); + } + + public StateInvariantExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterStateInvariantExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitStateInvariantExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitStateInvariantExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class CallExpressionContext extends ExpressionContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public ExpressionsContext expressions() { + return getRuleContext(ExpressionsContext.class, 0); + } + + public CallExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterCallExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitCallExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitCallExpression(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ExternalLiteralContext extends ExpressionContext { + public TerminalNode EXTERNAL() { + return getToken(CocoParser.EXTERNAL, 0); + } + + public TerminalNode BACKTICK_LITERAL() { + return getToken(CocoParser.BACKTICK_LITERAL, 0); + } + + public ExternalLiteralContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterExternalLiteral(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitExternalLiteral(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitExternalLiteral(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ArraySubscriptExpressionContext extends ExpressionContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class, i); + } + + public TerminalNode LB() { + return getToken(CocoParser.LB, 0); + } + + public TerminalNode RB() { + return getToken(CocoParser.RB, 0); + } + + public ArraySubscriptExpressionContext(ExpressionContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterArraySubscriptExpression(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitArraySubscriptExpression(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitArraySubscriptExpression(this); + else return visitor.visitChildren(this); + } + } + + public final ExpressionContext expression() throws RecognitionException { + return expression(0); + } + + private ExpressionContext expression(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + ExpressionContext _localctx = new ExpressionContext(_ctx, _parentState); + ExpressionContext _prevctx = _localctx; + int _startState = 58; + enterRecursionRule(_localctx, 58, RULE_expression, _p); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(519); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 51, _ctx)) { + case 1: + { + _localctx = new LiteralExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + + setState(489); + literalExpression_(); + } + break; + case 2: + { + _localctx = new ExternalLiteralContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(490); + match(EXTERNAL); + setState(491); + match(BACKTICK_LITERAL); + } + break; + case 3: + { + _localctx = new ExternalFunctionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(492); + externalFunctionDeclaration(); + } + break; + case 4: + { + _localctx = new VariableReferenceExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(493); + dotIdentifierList(); + setState(498); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 50, _ctx)) { + case 1: + { + setState(494); + match(LT); + setState(495); + genericTypes(); + setState(496); + match(GT); + } + break; + } + } + break; + case 5: + { + _localctx = new StateInvariantExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(500); + stateInvariant(); + } + break; + case 6: + { + _localctx = new UnaryOperatorExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(501); + _la = _input.LA(1); + if (!(((((_la - 67)) & ~0x3f) == 0 && ((1L << (_la - 67)) & ((1L << (MINUS - 67)) | (1L << (AMP - 67)) | (1L << (EXCL - 67)))) != 0))) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(502); + expression(14); + } + break; + case 7: + { + _localctx = new IfExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(503); + ifExpression_(); + } + break; + case 8: + { + _localctx = new MatchExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(504); + matchExpression_(); + } + break; + case 9: + { + _localctx = new ImplicitMemberExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(505); + match(DOT); + setState(506); + match(IDENTIFIER); + } + break; + case 10: + { + _localctx = new GroupedExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(507); + match(LP); + setState(508); + expressions(); + setState(509); + match(RP); + } + break; + case 11: + { + _localctx = new ArrayLiteralExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(511); + match(LB); + setState(512); + expression(0); + setState(513); + match(RB); + } + break; + case 12: + { + _localctx = new NondetExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(515); + nondetExpression_(); + } + break; + case 13: + { + _localctx = new OptionalExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(516); + match(OPTIONAL); + setState(517); + expression(2); + } + break; + case 14: + { + _localctx = new BlockExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(518); + blockExpression_(); + } + break; + } + _ctx.stop = _input.LT(-1); + setState(559); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 54, _ctx); + while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) { + if (_alt == 1) { + if (_parseListeners != null) triggerExitRuleEvent(); + _prevctx = _localctx; + { + setState(557); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 53, _ctx)) { + case 1: + { + _localctx = new ArithmicOrLogicalExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(521); + if (!(precpred(_ctx, 12))) throw new FailedPredicateException(this, "precpred(_ctx, 12)"); + setState(522); + _la = _input.LA(1); + if (!(((((_la - 65)) & ~0x3f) == 0 && ((1L << (_la - 65)) & ((1L << (MUL - 65)) | (1L << (DIV - 65)) | (1L << (MOD - 65)))) != 0))) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(523); + expression(13); + } + break; + case 2: + { + _localctx = new ArithmicOrLogicalExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(524); + if (!(precpred(_ctx, 11))) throw new FailedPredicateException(this, "precpred(_ctx, 11)"); + setState(525); + _la = _input.LA(1); + if (!(_la == MINUS || _la == PLUS)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(526); + expression(12); + } + break; + case 3: + { + _localctx = new ArithmicOrLogicalExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(527); + if (!(precpred(_ctx, 10))) throw new FailedPredicateException(this, "precpred(_ctx, 10)"); + setState(528); + _la = _input.LA(1); + if (!(((((_la - 63)) & ~0x3f) == 0 && ((1L << (_la - 63)) & ((1L << (LT - 63)) | (1L << (GT - 63)) | (1L << (EQ - 63)) | (1L << (NE - 63)) | (1L << (OR - 63)) | (1L << (AND - 63)) | (1L << (LE - 63)) | (1L << (GE - 63)))) != 0))) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(529); + expression(11); + } + break; + case 4: + { + _localctx = new AssignmentExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(530); + if (!(precpred(_ctx, 9))) throw new FailedPredicateException(this, "precpred(_ctx, 9)"); + setState(531); + match(ASSIGN); + setState(532); + expression(10); + } + break; + case 5: + { + _localctx = new MemberReferenceExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(533); + if (!(precpred(_ctx, 20))) throw new FailedPredicateException(this, "precpred(_ctx, 20)"); + setState(534); + match(DOT); + setState(535); + match(IDENTIFIER); + } + break; + case 6: + { + _localctx = new CallExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(536); + if (!(precpred(_ctx, 18))) throw new FailedPredicateException(this, "precpred(_ctx, 18)"); + setState(537); + match(LP); + setState(539); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ASSERT) | (1L << EXTERNAL) | (1L << IF) | (1L << MATCH) | (1L << NONDET) | (1L << OPTIONAL) | (1L << IDENTIFIER) | (1L << LP) | (1L << LC) | (1L << LB) | (1L << DOT))) != 0) || ((((_la - 67)) & ~0x3f) == 0 && ((1L << (_la - 67)) & ((1L << (MINUS - 67)) | (1L << (AMP - 67)) | (1L << (EXCL - 67)) | (1L << (INTEGER - 67)) | (1L << (CHAR_LITERAL - 67)) | (1L << (STRING_LITERAL - 67)))) != 0)) { + { + setState(538); + expressions(); + } + } + + setState(541); + match(RP); + } + break; + case 7: + { + _localctx = new ArraySubscriptExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(542); + if (!(precpred(_ctx, 17))) throw new FailedPredicateException(this, "precpred(_ctx, 17)"); + setState(543); + match(LB); + setState(544); + expression(0); + setState(545); + match(RB); + } + break; + case 8: + { + _localctx = new StructLiteralExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(547); + if (!(precpred(_ctx, 16))) throw new FailedPredicateException(this, "precpred(_ctx, 16)"); + setState(548); + match(LC); + setState(549); + fieldAssignments(); + setState(550); + match(RC); + } + break; + case 9: + { + _localctx = new TryOperatorExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(552); + if (!(precpred(_ctx, 15))) throw new FailedPredicateException(this, "precpred(_ctx, 15)"); + setState(553); + match(QM); + } + break; + case 10: + { + _localctx = new CastExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(554); + if (!(precpred(_ctx, 13))) throw new FailedPredicateException(this, "precpred(_ctx, 13)"); + setState(555); + match(AS); + setState(556); + type(0); + } + break; + } + } + } + setState(561); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 54, _ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class BlockExpression_Context extends ParserRuleContext { + public TerminalNode LC() { + return getToken(CocoParser.LC, 0); + } + + public TerminalNode RC() { + return getToken(CocoParser.RC, 0); + } + + public List statement() { + return getRuleContexts(StatementContext.class); + } + + public StatementContext statement(int i) { + return getRuleContext(StatementContext.class, i); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public BlockExpression_Context(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_blockExpression_; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterBlockExpression_(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitBlockExpression_(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitBlockExpression_(this); + else return visitor.visitChildren(this); + } + } + + public final BlockExpression_Context blockExpression_() throws RecognitionException { + BlockExpression_Context _localctx = new BlockExpression_Context(_ctx, getState()); + enterRule(_localctx, 60, RULE_blockExpression_); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(562); + match(LC); + setState(566); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 55, _ctx); + while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) { + if (_alt == 1) { + { + { + setState(563); + statement(); + } + } + } + setState(568); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 55, _ctx); + } + setState(570); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << ASSERT) | (1L << EXTERNAL) | (1L << IF) | (1L << MATCH) | (1L << NONDET) | (1L << OPTIONAL) | (1L << IDENTIFIER) | (1L << LP) | (1L << LC) | (1L << LB) | (1L << DOT))) != 0) || ((((_la - 67)) & ~0x3f) == 0 && ((1L << (_la - 67)) & ((1L << (MINUS - 67)) | (1L << (AMP - 67)) | (1L << (EXCL - 67)) | (1L << (INTEGER - 67)) | (1L << (CHAR_LITERAL - 67)) | (1L << (STRING_LITERAL - 67)))) != 0)) { + { + setState(569); + expression(0); + } + } + + setState(572); + match(RC); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class IfExpression_Context extends ParserRuleContext { + public TerminalNode IF() { + return getToken(CocoParser.IF, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class, i); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public TerminalNode ELSE() { + return getToken(CocoParser.ELSE, 0); + } + + public IfExpression_Context(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_ifExpression_; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterIfExpression_(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitIfExpression_(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitIfExpression_(this); + else return visitor.visitChildren(this); + } + } + + public final IfExpression_Context ifExpression_() throws RecognitionException { + IfExpression_Context _localctx = new IfExpression_Context(_ctx, getState()); + enterRule(_localctx, 62, RULE_ifExpression_); + try { + enterOuterAlt(_localctx, 1); + { + setState(574); + match(IF); + setState(575); + match(LP); + setState(576); + expression(0); + setState(577); + match(RP); + setState(578); + expression(0); + setState(581); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 57, _ctx)) { + case 1: + { + setState(579); + match(ELSE); + setState(580); + expression(0); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class MatchExpression_Context extends ParserRuleContext { + public TerminalNode MATCH() { + return getToken(CocoParser.MATCH, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public TerminalNode LC() { + return getToken(CocoParser.LC, 0); + } + + public MatchClausesContext matchClauses() { + return getRuleContext(MatchClausesContext.class, 0); + } + + public TerminalNode RC() { + return getToken(CocoParser.RC, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public MatchExpression_Context(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_matchExpression_; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterMatchExpression_(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitMatchExpression_(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitMatchExpression_(this); + else return visitor.visitChildren(this); + } + } + + public final MatchExpression_Context matchExpression_() throws RecognitionException { + MatchExpression_Context _localctx = new MatchExpression_Context(_ctx, getState()); + enterRule(_localctx, 64, RULE_matchExpression_); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(585); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == IDENTIFIER) { + { + setState(583); + match(IDENTIFIER); + setState(584); + match(COLON); + } + } + + setState(587); + match(MATCH); + setState(588); + match(LP); + setState(589); + expression(0); + setState(590); + match(RP); + setState(591); + match(LC); + setState(592); + matchClauses(); + setState(593); + match(RC); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class NondetExpression_Context extends ParserRuleContext { + public TerminalNode NONDET() { + return getToken(CocoParser.NONDET, 0); + } + + public TerminalNode LC() { + return getToken(CocoParser.LC, 0); + } + + public NondetClausesContext nondetClauses() { + return getRuleContext(NondetClausesContext.class, 0); + } + + public TerminalNode RC() { + return getToken(CocoParser.RC, 0); + } + + public TerminalNode OTHERWISE() { + return getToken(CocoParser.OTHERWISE, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode COMMA() { + return getToken(CocoParser.COMMA, 0); + } + + public TerminalNode SEMI() { + return getToken(CocoParser.SEMI, 0); + } + + public NondetExpression_Context(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_nondetExpression_; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterNondetExpression_(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitNondetExpression_(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitNondetExpression_(this); + else return visitor.visitChildren(this); + } + } + + public final NondetExpression_Context nondetExpression_() throws RecognitionException { + NondetExpression_Context _localctx = new NondetExpression_Context(_ctx, getState()); + enterRule(_localctx, 66, RULE_nondetExpression_); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(595); + match(NONDET); + setState(596); + match(LC); + setState(597); + nondetClauses(); + setState(600); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == OTHERWISE) { + { + setState(598); + match(OTHERWISE); + setState(599); + expression(0); + } + } + + setState(603); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COMMA || _la == SEMI) { + { + setState(602); + _la = _input.LA(1); + if (!(_la == COMMA || _la == SEMI)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + + setState(605); + match(RC); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class FieldAssignmentsContext extends ParserRuleContext { + public List fieldAssignment() { + return getRuleContexts(FieldAssignmentContext.class); + } + + public FieldAssignmentContext fieldAssignment(int i) { + return getRuleContext(FieldAssignmentContext.class, i); + } + + public List COMMA() { + return getTokens(CocoParser.COMMA); + } + + public TerminalNode COMMA(int i) { + return getToken(CocoParser.COMMA, i); + } + + public FieldAssignmentsContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_fieldAssignments; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterFieldAssignments(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitFieldAssignments(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitFieldAssignments(this); + else return visitor.visitChildren(this); + } + } + + public final FieldAssignmentsContext fieldAssignments() throws RecognitionException { + FieldAssignmentsContext _localctx = new FieldAssignmentsContext(_ctx, getState()); + enterRule(_localctx, 68, RULE_fieldAssignments); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(607); + fieldAssignment(); + setState(612); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 61, _ctx); + while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) { + if (_alt == 1) { + { + { + setState(608); + match(COMMA); + setState(609); + fieldAssignment(); + } + } + } + setState(614); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 61, _ctx); + } + setState(616); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COMMA) { + { + setState(615); + match(COMMA); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class FieldAssignmentContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public FieldAssignmentContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_fieldAssignment; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterFieldAssignment(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitFieldAssignment(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitFieldAssignment(this); + else return visitor.visitChildren(this); + } + } + + public final FieldAssignmentContext fieldAssignment() throws RecognitionException { + FieldAssignmentContext _localctx = new FieldAssignmentContext(_ctx, getState()); + enterRule(_localctx, 70, RULE_fieldAssignment); + try { + enterOuterAlt(_localctx, 1); + { + setState(618); + match(IDENTIFIER); + setState(619); + match(ASSIGN); + setState(620); + expression(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class NondetClausesContext extends ParserRuleContext { + public List nondetClause() { + return getRuleContexts(NondetClauseContext.class); + } + + public NondetClauseContext nondetClause(int i) { + return getRuleContext(NondetClauseContext.class, i); + } + + public List COMMA() { + return getTokens(CocoParser.COMMA); + } + + public TerminalNode COMMA(int i) { + return getToken(CocoParser.COMMA, i); + } + + public List SEMI() { + return getTokens(CocoParser.SEMI); + } + + public TerminalNode SEMI(int i) { + return getToken(CocoParser.SEMI, i); + } + + public NondetClausesContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_nondetClauses; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterNondetClauses(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitNondetClauses(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitNondetClauses(this); + else return visitor.visitChildren(this); + } + } + + public final NondetClausesContext nondetClauses() throws RecognitionException { + NondetClausesContext _localctx = new NondetClausesContext(_ctx, getState()); + enterRule(_localctx, 72, RULE_nondetClauses); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(622); + nondetClause(); + setState(627); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 63, _ctx); + while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) { + if (_alt == 1) { + { + { + setState(623); + _la = _input.LA(1); + if (!(_la == COMMA || _la == SEMI)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(624); + nondetClause(); + } + } + } + setState(629); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 63, _ctx); + } + setState(631); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 64, _ctx)) { + case 1: + { + setState(630); + _la = _input.LA(1); + if (!(_la == COMMA || _la == SEMI)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class NondetClauseContext extends ParserRuleContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class, i); + } + + public TerminalNode IF() { + return getToken(CocoParser.IF, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public NondetClauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_nondetClause; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterNondetClause(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitNondetClause(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitNondetClause(this); + else return visitor.visitChildren(this); + } + } + + public final NondetClauseContext nondetClause() throws RecognitionException { + NondetClauseContext _localctx = new NondetClauseContext(_ctx, getState()); + enterRule(_localctx, 74, RULE_nondetClause); + try { + enterOuterAlt(_localctx, 1); + { + setState(638); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 65, _ctx)) { + case 1: + { + setState(633); + match(IF); + setState(634); + match(LP); + setState(635); + expression(0); + setState(636); + match(RP); + } + break; + } + setState(640); + expression(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class MatchClausesContext extends ParserRuleContext { + public List matchClause() { + return getRuleContexts(MatchClauseContext.class); + } + + public MatchClauseContext matchClause(int i) { + return getRuleContext(MatchClauseContext.class, i); + } + + public List COMMA() { + return getTokens(CocoParser.COMMA); + } + + public TerminalNode COMMA(int i) { + return getToken(CocoParser.COMMA, i); + } + + public List SEMI() { + return getTokens(CocoParser.SEMI); + } + + public TerminalNode SEMI(int i) { + return getToken(CocoParser.SEMI, i); + } + + public MatchClausesContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_matchClauses; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterMatchClauses(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitMatchClauses(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitMatchClauses(this); + else return visitor.visitChildren(this); + } + } + + public final MatchClausesContext matchClauses() throws RecognitionException { + MatchClausesContext _localctx = new MatchClausesContext(_ctx, getState()); + enterRule(_localctx, 76, RULE_matchClauses); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(642); + matchClause(); + setState(647); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 66, _ctx); + while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) { + if (_alt == 1) { + { + { + setState(643); + _la = _input.LA(1); + if (!(_la == COMMA || _la == SEMI)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(644); + matchClause(); + } + } + } + setState(649); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 66, _ctx); + } + setState(651); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COMMA || _la == SEMI) { + { + setState(650); + _la = _input.LA(1); + if (!(_la == COMMA || _la == SEMI)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class MatchClauseContext extends ParserRuleContext { + public PatternContext pattern() { + return getRuleContext(PatternContext.class, 0); + } + + public TerminalNode IMPL() { + return getToken(CocoParser.IMPL, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public MatchClauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_matchClause; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterMatchClause(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitMatchClause(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitMatchClause(this); + else return visitor.visitChildren(this); + } + } + + public final MatchClauseContext matchClause() throws RecognitionException { + MatchClauseContext _localctx = new MatchClauseContext(_ctx, getState()); + enterRule(_localctx, 78, RULE_matchClause); + try { + enterOuterAlt(_localctx, 1); + { + setState(653); + pattern(); + setState(654); + match(IMPL); + setState(655); + expression(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class PatternContext extends ParserRuleContext { + public EnumCasePatternContext enumCasePattern() { + return getRuleContext(EnumCasePatternContext.class, 0); + } + + public LiteralExpression_Context literalExpression_() { + return getRuleContext(LiteralExpression_Context.class, 0); + } + + public VariableDeclarationPatternContext variableDeclarationPattern() { + return getRuleContext(VariableDeclarationPatternContext.class, 0); + } + + public PatternContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_pattern; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterPattern(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitPattern(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitPattern(this); + else return visitor.visitChildren(this); + } + } + + public final PatternContext pattern() throws RecognitionException { + PatternContext _localctx = new PatternContext(_ctx, getState()); + enterRule(_localctx, 80, RULE_pattern); + try { + setState(660); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 68, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(657); + enumCasePattern(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(658); + literalExpression_(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(659); + variableDeclarationPattern(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class EnumCasePatternContext extends ParserRuleContext { + public IdParameterPatternsContext idParameterPatterns() { + return getRuleContext(IdParameterPatternsContext.class, 0); + } + + public TerminalNode IF() { + return getToken(CocoParser.IF, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public EnumCasePatternContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_enumCasePattern; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterEnumCasePattern(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitEnumCasePattern(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitEnumCasePattern(this); + else return visitor.visitChildren(this); + } + } + + public final EnumCasePatternContext enumCasePattern() throws RecognitionException { + EnumCasePatternContext _localctx = new EnumCasePatternContext(_ctx, getState()); + enterRule(_localctx, 82, RULE_enumCasePattern); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(662); + idParameterPatterns(); + setState(668); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == IF) { + { + setState(663); + match(IF); + setState(664); + match(LP); + setState(665); + expression(0); + setState(666); + match(RP); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class IdParameterPatternsContext extends ParserRuleContext { + public List idParameterPattern() { + return getRuleContexts(IdParameterPatternContext.class); + } + + public IdParameterPatternContext idParameterPattern(int i) { + return getRuleContext(IdParameterPatternContext.class, i); + } + + public List DOT() { + return getTokens(CocoParser.DOT); + } + + public TerminalNode DOT(int i) { + return getToken(CocoParser.DOT, i); + } + + public IdParameterPatternsContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_idParameterPatterns; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterIdParameterPatterns(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitIdParameterPatterns(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitIdParameterPatterns(this); + else return visitor.visitChildren(this); + } + } + + public final IdParameterPatternsContext idParameterPatterns() throws RecognitionException { + IdParameterPatternsContext _localctx = new IdParameterPatternsContext(_ctx, getState()); + enterRule(_localctx, 84, RULE_idParameterPatterns); + int _la; + try { + setState(687); + _errHandler.sync(this); + switch (_input.LA(1)) { + case IDENTIFIER: + enterOuterAlt(_localctx, 1); + { + setState(670); + idParameterPattern(); + setState(675); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == DOT) { + { + { + setState(671); + match(DOT); + setState(672); + idParameterPattern(); + } + } + setState(677); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + break; + case DOT: + enterOuterAlt(_localctx, 2); + { + setState(678); + match(DOT); + setState(679); + idParameterPattern(); + setState(684); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == DOT) { + { + { + setState(680); + match(DOT); + setState(681); + idParameterPattern(); + } + } + setState(686); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class IdParameterPatternContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public ParameterPatternsContext parameterPatterns() { + return getRuleContext(ParameterPatternsContext.class, 0); + } + + public IdParameterPatternContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_idParameterPattern; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterIdParameterPattern(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitIdParameterPattern(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitIdParameterPattern(this); + else return visitor.visitChildren(this); + } + } + + public final IdParameterPatternContext idParameterPattern() throws RecognitionException { + IdParameterPatternContext _localctx = new IdParameterPatternContext(_ctx, getState()); + enterRule(_localctx, 86, RULE_idParameterPattern); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(689); + match(IDENTIFIER); + setState(695); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LP) { + { + setState(690); + match(LP); + setState(692); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAR || _la == IDENTIFIER) { + { + setState(691); + parameterPatterns(); + } + } + + setState(694); + match(RP); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class VariableDeclarationPatternContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode VAL() { + return getToken(CocoParser.VAL, 0); + } + + public TerminalNode DOT() { + return getToken(CocoParser.DOT, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public VariableDeclarationPatternContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_variableDeclarationPattern; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterVariableDeclarationPattern(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitVariableDeclarationPattern(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitVariableDeclarationPattern(this); + else return visitor.visitChildren(this); + } + } + + public final VariableDeclarationPatternContext variableDeclarationPattern() throws RecognitionException { + VariableDeclarationPatternContext _localctx = new VariableDeclarationPatternContext(_ctx, getState()); + enterRule(_localctx, 88, RULE_variableDeclarationPattern); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(697); + _la = _input.LA(1); + if (!(_la == VAL || _la == DOT)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(698); + match(IDENTIFIER); + setState(701); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COLON) { + { + setState(699); + match(COLON); + setState(700); + type(0); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ParameterPatternsContext extends ParserRuleContext { + public List parameterPattern() { + return getRuleContexts(ParameterPatternContext.class); + } + + public ParameterPatternContext parameterPattern(int i) { + return getRuleContext(ParameterPatternContext.class, i); + } + + public List COMMA() { + return getTokens(CocoParser.COMMA); + } + + public TerminalNode COMMA(int i) { + return getToken(CocoParser.COMMA, i); + } + + public ParameterPatternsContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_parameterPatterns; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterParameterPatterns(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitParameterPatterns(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitParameterPatterns(this); + else return visitor.visitChildren(this); + } + } + + public final ParameterPatternsContext parameterPatterns() throws RecognitionException { + ParameterPatternsContext _localctx = new ParameterPatternsContext(_ctx, getState()); + enterRule(_localctx, 90, RULE_parameterPatterns); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(703); + parameterPattern(); + setState(708); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == COMMA) { + { + { + setState(704); + match(COMMA); + setState(705); + parameterPattern(); + } + } + setState(710); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ParameterPatternContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode VAR() { + return getToken(CocoParser.VAR, 0); + } + + public ParameterPatternContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_parameterPattern; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterParameterPattern(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitParameterPattern(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitParameterPattern(this); + else return visitor.visitChildren(this); + } + } + + public final ParameterPatternContext parameterPattern() throws RecognitionException { + ParameterPatternContext _localctx = new ParameterPatternContext(_ctx, getState()); + enterRule(_localctx, 92, RULE_parameterPattern); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(712); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAR) { + { + setState(711); + match(VAR); + } + } + + setState(714); + match(IDENTIFIER); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ExpressionsContext extends ParserRuleContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class, i); + } + + public List COMMA() { + return getTokens(CocoParser.COMMA); + } + + public TerminalNode COMMA(int i) { + return getToken(CocoParser.COMMA, i); + } + + public ExpressionsContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_expressions; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterExpressions(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitExpressions(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitExpressions(this); + else return visitor.visitChildren(this); + } + } + + public final ExpressionsContext expressions() throws RecognitionException { + ExpressionsContext _localctx = new ExpressionsContext(_ctx, getState()); + enterRule(_localctx, 94, RULE_expressions); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(716); + expression(0); + setState(721); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == COMMA) { + { + { + setState(717); + match(COMMA); + setState(718); + expression(0); + } + } + setState(723); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class StatementContext extends ParserRuleContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public StateInvariantContext stateInvariant() { + return getRuleContext(StateInvariantContext.class, 0); + } + + public DeclarationStatementContext declarationStatement() { + return getRuleContext(DeclarationStatementContext.class, 0); + } + + public ReturnStatementContext returnStatement() { + return getRuleContext(ReturnStatementContext.class, 0); + } + + public BecomeStatementContext becomeStatement() { + return getRuleContext(BecomeStatementContext.class, 0); + } + + public WhileStatementContext whileStatement() { + return getRuleContext(WhileStatementContext.class, 0); + } + + public ForStatementContext forStatement() { + return getRuleContext(ForStatementContext.class, 0); + } + + public BreakStatementContext breakStatement() { + return getRuleContext(BreakStatementContext.class, 0); + } + + public ContinueStatementContext continueStatement() { + return getRuleContext(ContinueStatementContext.class, 0); + } + + public List attribute() { + return getRuleContexts(AttributeContext.class); + } + + public AttributeContext attribute(int i) { + return getRuleContext(AttributeContext.class, i); + } + + public TerminalNode SEMI() { + return getToken(CocoParser.SEMI, 0); + } + + public StatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_statement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterStatement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitStatement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitStatement(this); + else return visitor.visitChildren(this); + } + } + + public final StatementContext statement() throws RecognitionException { + StatementContext _localctx = new StatementContext(_ctx, getState()); + enterRule(_localctx, 96, RULE_statement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(727); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == AT) { + { + { + setState(724); + attribute(); + } + } + setState(729); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(745); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 82, _ctx)) { + case 1: + { + setState(730); + expression(0); + setState(732); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == SEMI) { + { + setState(731); + match(SEMI); + } + } + + } + break; + case 2: + { + setState(734); + stateInvariant(); + setState(736); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == SEMI) { + { + setState(735); + match(SEMI); + } + } + + } + break; + case 3: + { + setState(738); + declarationStatement(); + } + break; + case 4: + { + setState(739); + returnStatement(); + } + break; + case 5: + { + setState(740); + becomeStatement(); + } + break; + case 6: + { + setState(741); + whileStatement(); + } + break; + case 7: + { + setState(742); + forStatement(); + } + break; + case 8: + { + setState(743); + breakStatement(); + } + break; + case 9: + { + setState(744); + continueStatement(); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class DeclarationStatementContext extends ParserRuleContext { + public VariableDeclarationContext variableDeclaration() { + return getRuleContext(VariableDeclarationContext.class, 0); + } + + public TerminalNode SEMI() { + return getToken(CocoParser.SEMI, 0); + } + + public DeclarationStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_declarationStatement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterDeclarationStatement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitDeclarationStatement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitDeclarationStatement(this); + else return visitor.visitChildren(this); + } + } + + public final DeclarationStatementContext declarationStatement() throws RecognitionException { + DeclarationStatementContext _localctx = new DeclarationStatementContext(_ctx, getState()); + enterRule(_localctx, 98, RULE_declarationStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(747); + variableDeclaration(); + setState(748); + match(SEMI); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ReturnStatementContext extends ParserRuleContext { + public TerminalNode RETURN() { + return getToken(CocoParser.RETURN, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode SEMI() { + return getToken(CocoParser.SEMI, 0); + } + + public ReturnStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_returnStatement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterReturnStatement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitReturnStatement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitReturnStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ReturnStatementContext returnStatement() throws RecognitionException { + ReturnStatementContext _localctx = new ReturnStatementContext(_ctx, getState()); + enterRule(_localctx, 100, RULE_returnStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(750); + match(RETURN); + setState(751); + expression(0); + setState(752); + match(SEMI); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class BecomeStatementContext extends ParserRuleContext { + public TerminalNode BECOME() { + return getToken(CocoParser.BECOME, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode SEMI() { + return getToken(CocoParser.SEMI, 0); + } + + public BecomeStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_becomeStatement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterBecomeStatement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitBecomeStatement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitBecomeStatement(this); + else return visitor.visitChildren(this); + } + } + + public final BecomeStatementContext becomeStatement() throws RecognitionException { + BecomeStatementContext _localctx = new BecomeStatementContext(_ctx, getState()); + enterRule(_localctx, 102, RULE_becomeStatement); + try { + enterOuterAlt(_localctx, 1); + { + setState(754); + match(BECOME); + setState(755); + expression(0); + setState(756); + match(SEMI); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class WhileStatementContext extends ParserRuleContext { + public TerminalNode WHILE() { + return getToken(CocoParser.WHILE, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public BlockExpression_Context blockExpression_() { + return getRuleContext(BlockExpression_Context.class, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public WhileStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_whileStatement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterWhileStatement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitWhileStatement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitWhileStatement(this); + else return visitor.visitChildren(this); + } + } + + public final WhileStatementContext whileStatement() throws RecognitionException { + WhileStatementContext _localctx = new WhileStatementContext(_ctx, getState()); + enterRule(_localctx, 104, RULE_whileStatement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(760); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == IDENTIFIER) { + { + setState(758); + match(IDENTIFIER); + setState(759); + match(COLON); + } + } + + setState(762); + match(WHILE); + setState(763); + match(LP); + setState(764); + expression(0); + setState(765); + match(RP); + setState(766); + blockExpression_(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ForStatementContext extends ParserRuleContext { + public TerminalNode FOR() { + return getToken(CocoParser.FOR, 0); + } + + public List IDENTIFIER() { + return getTokens(CocoParser.IDENTIFIER); + } + + public TerminalNode IDENTIFIER(int i) { + return getToken(CocoParser.IDENTIFIER, i); + } + + public TerminalNode IN() { + return getToken(CocoParser.IN, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public BlockExpression_Context blockExpression_() { + return getRuleContext(BlockExpression_Context.class, 0); + } + + public List COLON() { + return getTokens(CocoParser.COLON); + } + + public TerminalNode COLON(int i) { + return getToken(CocoParser.COLON, i); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public ForStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_forStatement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterForStatement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitForStatement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitForStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ForStatementContext forStatement() throws RecognitionException { + ForStatementContext _localctx = new ForStatementContext(_ctx, getState()); + enterRule(_localctx, 106, RULE_forStatement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(770); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == IDENTIFIER) { + { + setState(768); + match(IDENTIFIER); + setState(769); + match(COLON); + } + } + + setState(772); + match(FOR); + setState(773); + match(IDENTIFIER); + setState(776); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COLON) { + { + setState(774); + match(COLON); + setState(775); + type(0); + } + } + + setState(778); + match(IN); + setState(779); + expression(0); + setState(780); + blockExpression_(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class BreakStatementContext extends ParserRuleContext { + public TerminalNode BREAK() { + return getToken(CocoParser.BREAK, 0); + } + + public TerminalNode SEMI() { + return getToken(CocoParser.SEMI, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public BreakStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_breakStatement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterBreakStatement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitBreakStatement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitBreakStatement(this); + else return visitor.visitChildren(this); + } + } + + public final BreakStatementContext breakStatement() throws RecognitionException { + BreakStatementContext _localctx = new BreakStatementContext(_ctx, getState()); + enterRule(_localctx, 108, RULE_breakStatement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(782); + match(BREAK); + setState(784); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == IDENTIFIER) { + { + setState(783); + match(IDENTIFIER); + } + } + + setState(786); + match(SEMI); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ContinueStatementContext extends ParserRuleContext { + public TerminalNode CONTINUE() { + return getToken(CocoParser.CONTINUE, 0); + } + + public TerminalNode SEMI() { + return getToken(CocoParser.SEMI, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public ContinueStatementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_continueStatement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterContinueStatement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitContinueStatement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitContinueStatement(this); + else return visitor.visitChildren(this); + } + } + + public final ContinueStatementContext continueStatement() throws RecognitionException { + ContinueStatementContext _localctx = new ContinueStatementContext(_ctx, getState()); + enterRule(_localctx, 110, RULE_continueStatement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(788); + match(CONTINUE); + setState(790); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == IDENTIFIER) { + { + setState(789); + match(IDENTIFIER); + } + } + + setState(792); + match(SEMI); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class PortElementContext extends ParserRuleContext { + public EnumDeclarationContext enumDeclaration() { + return getRuleContext(EnumDeclarationContext.class, 0); + } + + public FunctionInterfaceDeclarationContext functionInterfaceDeclaration() { + return getRuleContext(FunctionInterfaceDeclarationContext.class, 0); + } + + public SignalDeclarationContext signalDeclaration() { + return getRuleContext(SignalDeclarationContext.class, 0); + } + + public FieldDeclarationContext fieldDeclaration() { + return getRuleContext(FieldDeclarationContext.class, 0); + } + + public StateMachineDeclarationContext stateMachineDeclaration() { + return getRuleContext(StateMachineDeclarationContext.class, 0); + } + + public PortDeclarationContext portDeclaration() { + return getRuleContext(PortDeclarationContext.class, 0); + } + + public StaticMemberDeclarationContext staticMemberDeclaration() { + return getRuleContext(StaticMemberDeclarationContext.class, 0); + } + + public StructDeclarationContext structDeclaration() { + return getRuleContext(StructDeclarationContext.class, 0); + } + + public TypeAliasDeclarationContext typeAliasDeclaration() { + return getRuleContext(TypeAliasDeclarationContext.class, 0); + } + + public ExternalTypeDeclarationContext externalTypeDeclaration() { + return getRuleContext(ExternalTypeDeclarationContext.class, 0); + } + + public List attribute() { + return getRuleContexts(AttributeContext.class); + } + + public AttributeContext attribute(int i) { + return getRuleContext(AttributeContext.class, i); + } + + public PortElementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_portElement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterPortElement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitPortElement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitPortElement(this); + else return visitor.visitChildren(this); + } + } + + public final PortElementContext portElement() throws RecognitionException { + PortElementContext _localctx = new PortElementContext(_ctx, getState()); + enterRule(_localctx, 112, RULE_portElement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(797); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == AT) { + { + { + setState(794); + attribute(); + } + } + setState(799); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(810); + _errHandler.sync(this); + switch (_input.LA(1)) { + case ENUM: + { + setState(800); + enumDeclaration(); + } + break; + case FUNCTION: + { + setState(801); + functionInterfaceDeclaration(); + } + break; + case OUTGOING: + { + setState(802); + signalDeclaration(); + } + break; + case VAL: + case VAR: + case IDENTIFIER: + { + setState(803); + fieldDeclaration(); + } + break; + case MACHINE: + { + setState(804); + stateMachineDeclaration(); + } + break; + case PORT: + { + setState(805); + portDeclaration(); + } + break; + case STATIC: + { + setState(806); + staticMemberDeclaration(); + } + break; + case STRUCT: + { + setState(807); + structDeclaration(); + } + break; + case TYPE: + { + setState(808); + typeAliasDeclaration(); + } + break; + case EXTERNAL: + { + setState(809); + externalTypeDeclaration(); + } + break; + default: + throw new NoViableAltException(this); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class FunctionInterfaceDeclarationContext extends ParserRuleContext { + public TerminalNode FUNCTION() { + return getToken(CocoParser.FUNCTION, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public ParametersContext parameters() { + return getRuleContext(ParametersContext.class, 0); + } + + public FunctionInterfaceDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_functionInterfaceDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterFunctionInterfaceDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitFunctionInterfaceDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitFunctionInterfaceDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final FunctionInterfaceDeclarationContext functionInterfaceDeclaration() throws RecognitionException { + FunctionInterfaceDeclarationContext _localctx = new FunctionInterfaceDeclarationContext(_ctx, getState()); + enterRule(_localctx, 114, RULE_functionInterfaceDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(812); + match(FUNCTION); + setState(813); + match(IDENTIFIER); + setState(814); + match(LP); + setState(816); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAR || _la == IDENTIFIER) { + { + setState(815); + parameters(); + } + } + + setState(818); + match(RP); + setState(819); + match(COLON); + setState(820); + type(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class SignalDeclarationContext extends ParserRuleContext { + public TerminalNode OUTGOING() { + return getToken(CocoParser.OUTGOING, 0); + } + + public TerminalNode SIGNAL() { + return getToken(CocoParser.SIGNAL, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public ParametersContext parameters() { + return getRuleContext(ParametersContext.class, 0); + } + + public SignalDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_signalDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterSignalDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitSignalDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitSignalDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final SignalDeclarationContext signalDeclaration() throws RecognitionException { + SignalDeclarationContext _localctx = new SignalDeclarationContext(_ctx, getState()); + enterRule(_localctx, 116, RULE_signalDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(822); + match(OUTGOING); + setState(823); + match(SIGNAL); + setState(824); + match(IDENTIFIER); + setState(825); + match(LP); + setState(827); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAR || _la == IDENTIFIER) { + { + setState(826); + parameters(); + } + } + + setState(829); + match(RP); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class StateMachineDeclarationContext extends ParserRuleContext { + public TerminalNode MACHINE() { + return getToken(CocoParser.MACHINE, 0); + } + + public TerminalNode LC() { + return getToken(CocoParser.LC, 0); + } + + public TerminalNode RC() { + return getToken(CocoParser.RC, 0); + } + + public List IDENTIFIER() { + return getTokens(CocoParser.IDENTIFIER); + } + + public TerminalNode IDENTIFIER(int i) { + return getToken(CocoParser.IDENTIFIER, i); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public List stateMachineElement() { + return getRuleContexts(StateMachineElementContext.class); + } + + public StateMachineElementContext stateMachineElement(int i) { + return getRuleContext(StateMachineElementContext.class, i); + } + + public StateMachineDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_stateMachineDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterStateMachineDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitStateMachineDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitStateMachineDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final StateMachineDeclarationContext stateMachineDeclaration() throws RecognitionException { + StateMachineDeclarationContext _localctx = new StateMachineDeclarationContext(_ctx, getState()); + enterRule(_localctx, 118, RULE_stateMachineDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(831); + match(MACHINE); + setState(833); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == IDENTIFIER) { + { + setState(832); + match(IDENTIFIER); + } + } + + setState(837); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COLON) { + { + setState(835); + match(COLON); + setState(836); + match(IDENTIFIER); + } + } + + setState(839); + match(LC); + setState(843); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << AFTER) | (1L << ASSERT) | (1L << ENUM) | (1L << ENTRY) | (1L << EXECUTION) | (1L << EXIT) | (1L << FUNCTION) | (1L << IF) | (1L << PERIODIC) | (1L << PRIVATE) | (1L << SPONTANEOUS) | (1L << STATE) | (1L << STATIC) | (1L << TYPE) | (1L << VAL) | (1L << VAR) | (1L << IDENTIFIER) | (1L << AT))) != 0)) { + { + { + setState(840); + stateMachineElement(); + } + } + setState(845); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(846); + match(RC); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class StateMachineElementContext extends ParserRuleContext { + public EnumDeclarationContext enumDeclaration() { + return getRuleContext(EnumDeclarationContext.class, 0); + } + + public EntryFunctionDeclarationContext entryFunctionDeclaration() { + return getRuleContext(EntryFunctionDeclarationContext.class, 0); + } + + public ExitFunctionDeclarationContext exitFunctionDeclaration() { + return getRuleContext(ExitFunctionDeclarationContext.class, 0); + } + + public FunctionDeclarationContext functionDeclaration() { + return getRuleContext(FunctionDeclarationContext.class, 0); + } + + public StateInvariantContext stateInvariant() { + return getRuleContext(StateInvariantContext.class, 0); + } + + public StateDeclarationContext stateDeclaration() { + return getRuleContext(StateDeclarationContext.class, 0); + } + + public StaticMemberDeclarationContext staticMemberDeclaration() { + return getRuleContext(StaticMemberDeclarationContext.class, 0); + } + + public TypeAliasDeclarationContext typeAliasDeclaration() { + return getRuleContext(TypeAliasDeclarationContext.class, 0); + } + + public VariableDeclarationContext variableDeclaration() { + return getRuleContext(VariableDeclarationContext.class, 0); + } + + public TransitionDeclarationContext transitionDeclaration() { + return getRuleContext(TransitionDeclarationContext.class, 0); + } + + public List attribute() { + return getRuleContexts(AttributeContext.class); + } + + public AttributeContext attribute(int i) { + return getRuleContext(AttributeContext.class, i); + } + + public StateMachineElementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_stateMachineElement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterStateMachineElement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitStateMachineElement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitStateMachineElement(this); + else return visitor.visitChildren(this); + } + } + + public final StateMachineElementContext stateMachineElement() throws RecognitionException { + StateMachineElementContext _localctx = new StateMachineElementContext(_ctx, getState()); + enterRule(_localctx, 120, RULE_stateMachineElement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(851); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == AT) { + { + { + setState(848); + attribute(); + } + } + setState(853); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(864); + _errHandler.sync(this); + switch (_input.LA(1)) { + case ENUM: + { + setState(854); + enumDeclaration(); + } + break; + case ENTRY: + { + setState(855); + entryFunctionDeclaration(); + } + break; + case EXIT: + { + setState(856); + exitFunctionDeclaration(); + } + break; + case FUNCTION: + { + setState(857); + functionDeclaration(); + } + break; + case ASSERT: + { + setState(858); + stateInvariant(); + } + break; + case EXECUTION: + case STATE: + { + setState(859); + stateDeclaration(); + } + break; + case STATIC: + { + setState(860); + staticMemberDeclaration(); + } + break; + case TYPE: + { + setState(861); + typeAliasDeclaration(); + } + break; + case PRIVATE: + case VAL: + case VAR: + { + setState(862); + variableDeclaration(); + } + break; + case AFTER: + case IF: + case PERIODIC: + case SPONTANEOUS: + case IDENTIFIER: + { + setState(863); + transitionDeclaration(); + } + break; + default: + throw new NoViableAltException(this); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class StateDeclarationContext extends ParserRuleContext { + public EventStateDeclarationContext eventStateDeclaration() { + return getRuleContext(EventStateDeclarationContext.class, 0); + } + + public ExecutionStateDeclarationContext executionStateDeclaration() { + return getRuleContext(ExecutionStateDeclarationContext.class, 0); + } + + public StateDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_stateDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterStateDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitStateDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitStateDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final StateDeclarationContext stateDeclaration() throws RecognitionException { + StateDeclarationContext _localctx = new StateDeclarationContext(_ctx, getState()); + enterRule(_localctx, 122, RULE_stateDeclaration); + try { + setState(868); + _errHandler.sync(this); + switch (_input.LA(1)) { + case STATE: + enterOuterAlt(_localctx, 1); + { + setState(866); + eventStateDeclaration(); + } + break; + case EXECUTION: + enterOuterAlt(_localctx, 2); + { + setState(867); + executionStateDeclaration(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class EventStateDeclarationContext extends ParserRuleContext { + public TerminalNode STATE() { + return getToken(CocoParser.STATE, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LC() { + return getToken(CocoParser.LC, 0); + } + + public TerminalNode RC() { + return getToken(CocoParser.RC, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public List eventStateElement() { + return getRuleContexts(EventStateElementContext.class); + } + + public EventStateElementContext eventStateElement(int i) { + return getRuleContext(EventStateElementContext.class, i); + } + + public ParametersContext parameters() { + return getRuleContext(ParametersContext.class, 0); + } + + public EventStateDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_eventStateDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterEventStateDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitEventStateDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitEventStateDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final EventStateDeclarationContext eventStateDeclaration() throws RecognitionException { + EventStateDeclarationContext _localctx = new EventStateDeclarationContext(_ctx, getState()); + enterRule(_localctx, 124, RULE_eventStateDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(870); + match(STATE); + setState(871); + match(IDENTIFIER); + setState(877); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LP) { + { + setState(872); + match(LP); + setState(874); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAR || _la == IDENTIFIER) { + { + setState(873); + parameters(); + } + } + + setState(876); + match(RP); + } + } + + setState(879); + match(LC); + setState(883); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << AFTER) | (1L << ASSERT) | (1L << ENUM) | (1L << ENTRY) | (1L << EXECUTION) | (1L << EXIT) | (1L << FUNCTION) | (1L << IF) | (1L << PERIODIC) | (1L << PRIVATE) | (1L << SPONTANEOUS) | (1L << STATE) | (1L << STATIC) | (1L << STRUCT) | (1L << TYPE) | (1L << VAL) | (1L << VAR) | (1L << IDENTIFIER) | (1L << AT))) != 0)) { + { + { + setState(880); + eventStateElement(); + } + } + setState(885); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(886); + match(RC); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ExecutionStateDeclarationContext extends ParserRuleContext { + public TerminalNode EXECUTION() { + return getToken(CocoParser.EXECUTION, 0); + } + + public TerminalNode STATE() { + return getToken(CocoParser.STATE, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public BlockExpression_Context blockExpression_() { + return getRuleContext(BlockExpression_Context.class, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public ParametersContext parameters() { + return getRuleContext(ParametersContext.class, 0); + } + + public ExecutionStateDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_executionStateDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterExecutionStateDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitExecutionStateDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitExecutionStateDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final ExecutionStateDeclarationContext executionStateDeclaration() throws RecognitionException { + ExecutionStateDeclarationContext _localctx = new ExecutionStateDeclarationContext(_ctx, getState()); + enterRule(_localctx, 126, RULE_executionStateDeclaration); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(888); + match(EXECUTION); + setState(889); + match(STATE); + setState(890); + match(IDENTIFIER); + setState(896); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LP) { + { + setState(891); + match(LP); + setState(893); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAR || _la == IDENTIFIER) { + { + setState(892); + parameters(); + } + } + + setState(895); + match(RP); + } + } + + setState(898); + blockExpression_(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class EventStateElementContext extends ParserRuleContext { + public EnumDeclarationContext enumDeclaration() { + return getRuleContext(EnumDeclarationContext.class, 0); + } + + public EntryFunctionDeclarationContext entryFunctionDeclaration() { + return getRuleContext(EntryFunctionDeclarationContext.class, 0); + } + + public ExitFunctionDeclarationContext exitFunctionDeclaration() { + return getRuleContext(ExitFunctionDeclarationContext.class, 0); + } + + public FunctionDeclarationContext functionDeclaration() { + return getRuleContext(FunctionDeclarationContext.class, 0); + } + + public StateDeclarationContext stateDeclaration() { + return getRuleContext(StateDeclarationContext.class, 0); + } + + public StateInvariantContext stateInvariant() { + return getRuleContext(StateInvariantContext.class, 0); + } + + public StaticMemberDeclarationContext staticMemberDeclaration() { + return getRuleContext(StaticMemberDeclarationContext.class, 0); + } + + public StructDeclarationContext structDeclaration() { + return getRuleContext(StructDeclarationContext.class, 0); + } + + public TransitionDeclarationContext transitionDeclaration() { + return getRuleContext(TransitionDeclarationContext.class, 0); + } + + public TypeAliasDeclarationContext typeAliasDeclaration() { + return getRuleContext(TypeAliasDeclarationContext.class, 0); + } + + public VariableDeclarationContext variableDeclaration() { + return getRuleContext(VariableDeclarationContext.class, 0); + } + + public List attribute() { + return getRuleContexts(AttributeContext.class); + } + + public AttributeContext attribute(int i) { + return getRuleContext(AttributeContext.class, i); + } + + public EventStateElementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_eventStateElement; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterEventStateElement(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitEventStateElement(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitEventStateElement(this); + else return visitor.visitChildren(this); + } + } + + public final EventStateElementContext eventStateElement() throws RecognitionException { + EventStateElementContext _localctx = new EventStateElementContext(_ctx, getState()); + enterRule(_localctx, 128, RULE_eventStateElement); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(903); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == AT) { + { + { + setState(900); + attribute(); + } + } + setState(905); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(917); + _errHandler.sync(this); + switch (_input.LA(1)) { + case ENUM: + { + setState(906); + enumDeclaration(); + } + break; + case ENTRY: + { + setState(907); + entryFunctionDeclaration(); + } + break; + case EXIT: + { + setState(908); + exitFunctionDeclaration(); + } + break; + case FUNCTION: + { + setState(909); + functionDeclaration(); + } + break; + case EXECUTION: + case STATE: + { + setState(910); + stateDeclaration(); + } + break; + case ASSERT: + { + setState(911); + stateInvariant(); + } + break; + case STATIC: + { + setState(912); + staticMemberDeclaration(); + } + break; + case STRUCT: + { + setState(913); + structDeclaration(); + } + break; + case AFTER: + case IF: + case PERIODIC: + case SPONTANEOUS: + case IDENTIFIER: + { + setState(914); + transitionDeclaration(); + } + break; + case TYPE: + { + setState(915); + typeAliasDeclaration(); + } + break; + case PRIVATE: + case VAL: + case VAR: + { + setState(916); + variableDeclaration(); + } + break; + default: + throw new NoViableAltException(this); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class EntryFunctionDeclarationContext extends ParserRuleContext { + public TerminalNode ENTRY() { + return getToken(CocoParser.ENTRY, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public EntryFunctionDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_entryFunctionDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterEntryFunctionDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitEntryFunctionDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitEntryFunctionDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final EntryFunctionDeclarationContext entryFunctionDeclaration() throws RecognitionException { + EntryFunctionDeclarationContext _localctx = new EntryFunctionDeclarationContext(_ctx, getState()); + enterRule(_localctx, 130, RULE_entryFunctionDeclaration); + try { + enterOuterAlt(_localctx, 1); + { + setState(919); + match(ENTRY); + setState(920); + match(LP); + setState(921); + match(RP); + setState(922); + match(ASSIGN); + setState(923); + expression(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ExitFunctionDeclarationContext extends ParserRuleContext { + public TerminalNode EXIT() { + return getToken(CocoParser.EXIT, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public ExitFunctionDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_exitFunctionDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterExitFunctionDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitExitFunctionDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitExitFunctionDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final ExitFunctionDeclarationContext exitFunctionDeclaration() throws RecognitionException { + ExitFunctionDeclarationContext _localctx = new ExitFunctionDeclarationContext(_ctx, getState()); + enterRule(_localctx, 132, RULE_exitFunctionDeclaration); + try { + enterOuterAlt(_localctx, 1); + { + setState(925); + match(EXIT); + setState(926); + match(LP); + setState(927); + match(RP); + setState(928); + match(ASSIGN); + setState(929); + expression(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class StateInvariantContext extends ParserRuleContext { + public TerminalNode ASSERT() { + return getToken(CocoParser.ASSERT, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public StateInvariantContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_stateInvariant; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterStateInvariant(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitStateInvariant(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitStateInvariant(this); + else return visitor.visitChildren(this); + } + } + + public final StateInvariantContext stateInvariant() throws RecognitionException { + StateInvariantContext _localctx = new StateInvariantContext(_ctx, getState()); + enterRule(_localctx, 134, RULE_stateInvariant); + try { + enterOuterAlt(_localctx, 1); + { + setState(931); + match(ASSERT); + setState(932); + match(LP); + setState(933); + expression(0); + setState(934); + match(RP); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class TransitionDeclarationContext extends ParserRuleContext { + public EventTransitionContext eventTransition() { + return getRuleContext(EventTransitionContext.class, 0); + } + + public SpontaneousTransitionContext spontaneousTransition() { + return getRuleContext(SpontaneousTransitionContext.class, 0); + } + + public TimerTransitionContext timerTransition() { + return getRuleContext(TimerTransitionContext.class, 0); + } + + public TransitionDeclarationContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_transitionDeclaration; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterTransitionDeclaration(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitTransitionDeclaration(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitTransitionDeclaration(this); + else return visitor.visitChildren(this); + } + } + + public final TransitionDeclarationContext transitionDeclaration() throws RecognitionException { + TransitionDeclarationContext _localctx = new TransitionDeclarationContext(_ctx, getState()); + enterRule(_localctx, 136, RULE_transitionDeclaration); + try { + setState(939); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 105, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(936); + eventTransition(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(937); + spontaneousTransition(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(938); + timerTransition(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class EventTransitionContext extends ParserRuleContext { + public DotIdentifierListContext dotIdentifierList() { + return getRuleContext(DotIdentifierListContext.class, 0); + } + + public List LP() { + return getTokens(CocoParser.LP); + } + + public TerminalNode LP(int i) { + return getToken(CocoParser.LP, i); + } + + public List RP() { + return getTokens(CocoParser.RP); + } + + public TerminalNode RP(int i) { + return getToken(CocoParser.RP, i); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public EventHandlerContext eventHandler() { + return getRuleContext(EventHandlerContext.class, 0); + } + + public TerminalNode IF() { + return getToken(CocoParser.IF, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public List eventSource() { + return getRuleContexts(EventSourceContext.class); + } + + public EventSourceContext eventSource(int i) { + return getRuleContext(EventSourceContext.class, i); + } + + public List DOT() { + return getTokens(CocoParser.DOT); + } + + public TerminalNode DOT(int i) { + return getToken(CocoParser.DOT, i); + } + + public ParametersContext parameters() { + return getRuleContext(ParametersContext.class, 0); + } + + public EventTransitionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_eventTransition; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterEventTransition(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitEventTransition(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitEventTransition(this); + else return visitor.visitChildren(this); + } + } + + public final EventTransitionContext eventTransition() throws RecognitionException { + EventTransitionContext _localctx = new EventTransitionContext(_ctx, getState()); + enterRule(_localctx, 138, RULE_eventTransition); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(946); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == IF) { + { + setState(941); + match(IF); + setState(942); + match(LP); + setState(943); + expression(0); + setState(944); + match(RP); + } + } + + setState(953); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 107, _ctx); + while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) { + if (_alt == 1) { + { + { + setState(948); + eventSource(); + setState(949); + match(DOT); + } + } + } + setState(955); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 107, _ctx); + } + setState(956); + dotIdentifierList(); + setState(957); + match(LP); + setState(959); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAR || _la == IDENTIFIER) { + { + setState(958); + parameters(); + } + } + + setState(961); + match(RP); + setState(962); + match(ASSIGN); + setState(963); + eventHandler(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class EventSourceContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode LB() { + return getToken(CocoParser.LB, 0); + } + + public PatternContext pattern() { + return getRuleContext(PatternContext.class, 0); + } + + public TerminalNode RB() { + return getToken(CocoParser.RB, 0); + } + + public TerminalNode PIPE() { + return getToken(CocoParser.PIPE, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public EventSourceContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_eventSource; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterEventSource(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitEventSource(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitEventSource(this); + else return visitor.visitChildren(this); + } + } + + public final EventSourceContext eventSource() throws RecognitionException { + EventSourceContext _localctx = new EventSourceContext(_ctx, getState()); + enterRule(_localctx, 140, RULE_eventSource); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(965); + match(IDENTIFIER); + setState(974); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == LB) { + { + setState(966); + match(LB); + setState(967); + pattern(); + setState(970); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == PIPE) { + { + setState(968); + match(PIPE); + setState(969); + expression(0); + } + } + + setState(972); + match(RB); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class SpontaneousTransitionContext extends ParserRuleContext { + public TerminalNode SPONTANEOUS() { + return getToken(CocoParser.SPONTANEOUS, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class, i); + } + + public TerminalNode IF() { + return getToken(CocoParser.IF, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public SpontaneousTransitionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_spontaneousTransition; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterSpontaneousTransition(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitSpontaneousTransition(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitSpontaneousTransition(this); + else return visitor.visitChildren(this); + } + } + + public final SpontaneousTransitionContext spontaneousTransition() throws RecognitionException { + SpontaneousTransitionContext _localctx = new SpontaneousTransitionContext(_ctx, getState()); + enterRule(_localctx, 142, RULE_spontaneousTransition); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(981); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == IF) { + { + setState(976); + match(IF); + setState(977); + match(LP); + setState(978); + expression(0); + setState(979); + match(RP); + } + } + + setState(983); + match(SPONTANEOUS); + setState(984); + match(ASSIGN); + setState(985); + expression(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class TimerTransitionContext extends ParserRuleContext { + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class, i); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public TerminalNode ASSIGN() { + return getToken(CocoParser.ASSIGN, 0); + } + + public TerminalNode AFTER() { + return getToken(CocoParser.AFTER, 0); + } + + public TerminalNode PERIODIC() { + return getToken(CocoParser.PERIODIC, 0); + } + + public TimerTransitionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_timerTransition; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterTimerTransition(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitTimerTransition(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitTimerTransition(this); + else return visitor.visitChildren(this); + } + } + + public final TimerTransitionContext timerTransition() throws RecognitionException { + TimerTransitionContext _localctx = new TimerTransitionContext(_ctx, getState()); + enterRule(_localctx, 144, RULE_timerTransition); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(987); + _la = _input.LA(1); + if (!(_la == AFTER || _la == PERIODIC)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(988); + match(LP); + setState(989); + expression(0); + setState(990); + match(RP); + setState(991); + match(ASSIGN); + setState(992); + expression(0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class EventHandlerContext extends ParserRuleContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode ILLEGAL() { + return getToken(CocoParser.ILLEGAL, 0); + } + + public OfferContext offer() { + return getRuleContext(OfferContext.class, 0); + } + + public EventHandlerContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_eventHandler; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterEventHandler(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitEventHandler(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitEventHandler(this); + else return visitor.visitChildren(this); + } + } + + public final EventHandlerContext eventHandler() throws RecognitionException { + EventHandlerContext _localctx = new EventHandlerContext(_ctx, getState()); + enterRule(_localctx, 146, RULE_eventHandler); + try { + setState(997); + _errHandler.sync(this); + switch (_input.LA(1)) { + case ASSERT: + case EXTERNAL: + case IF: + case MATCH: + case NONDET: + case OPTIONAL: + case IDENTIFIER: + case LP: + case LC: + case LB: + case DOT: + case MINUS: + case AMP: + case EXCL: + case INTEGER: + case CHAR_LITERAL: + case STRING_LITERAL: + enterOuterAlt(_localctx, 1); + { + setState(994); + expression(0); + } + break; + case ILLEGAL: + enterOuterAlt(_localctx, 2); + { + setState(995); + match(ILLEGAL); + } + break; + case OFFER: + enterOuterAlt(_localctx, 3); + { + setState(996); + offer(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class OfferContext extends ParserRuleContext { + public TerminalNode OFFER() { + return getToken(CocoParser.OFFER, 0); + } + + public TerminalNode LC() { + return getToken(CocoParser.LC, 0); + } + + public OfferClausesContext offerClauses() { + return getRuleContext(OfferClausesContext.class, 0); + } + + public TerminalNode RC() { + return getToken(CocoParser.RC, 0); + } + + public TerminalNode OTHERWISE() { + return getToken(CocoParser.OTHERWISE, 0); + } + + public EventHandlerContext eventHandler() { + return getRuleContext(EventHandlerContext.class, 0); + } + + public TerminalNode COMMA() { + return getToken(CocoParser.COMMA, 0); + } + + public OfferContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_offer; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterOffer(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitOffer(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitOffer(this); + else return visitor.visitChildren(this); + } + } + + public final OfferContext offer() throws RecognitionException { + OfferContext _localctx = new OfferContext(_ctx, getState()); + enterRule(_localctx, 148, RULE_offer); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(999); + match(OFFER); + setState(1000); + match(LC); + setState(1001); + offerClauses(); + setState(1007); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == OTHERWISE) { + { + setState(1002); + match(OTHERWISE); + setState(1003); + eventHandler(); + setState(1005); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COMMA) { + { + setState(1004); + match(COMMA); + } + } + + } + } + + setState(1009); + match(RC); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class OfferClausesContext extends ParserRuleContext { + public List offerClause() { + return getRuleContexts(OfferClauseContext.class); + } + + public OfferClauseContext offerClause(int i) { + return getRuleContext(OfferClauseContext.class, i); + } + + public List COMMA() { + return getTokens(CocoParser.COMMA); + } + + public TerminalNode COMMA(int i) { + return getToken(CocoParser.COMMA, i); + } + + public OfferClausesContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_offerClauses; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterOfferClauses(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitOfferClauses(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitOfferClauses(this); + else return visitor.visitChildren(this); + } + } + + public final OfferClausesContext offerClauses() throws RecognitionException { + OfferClausesContext _localctx = new OfferClausesContext(_ctx, getState()); + enterRule(_localctx, 150, RULE_offerClauses); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(1011); + offerClause(); + setState(1016); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 115, _ctx); + while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) { + if (_alt == 1) { + { + { + setState(1012); + match(COMMA); + setState(1013); + offerClause(); + } + } + } + setState(1018); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 115, _ctx); + } + setState(1020); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COMMA) { + { + setState(1019); + match(COMMA); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class OfferClauseContext extends ParserRuleContext { + public EventHandlerContext eventHandler() { + return getRuleContext(EventHandlerContext.class, 0); + } + + public List attribute() { + return getRuleContexts(AttributeContext.class); + } + + public AttributeContext attribute(int i) { + return getRuleContext(AttributeContext.class, i); + } + + public TerminalNode IF() { + return getToken(CocoParser.IF, 0); + } + + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public OfferClauseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_offerClause; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterOfferClause(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitOfferClause(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitOfferClause(this); + else return visitor.visitChildren(this); + } + } + + public final OfferClauseContext offerClause() throws RecognitionException { + OfferClauseContext _localctx = new OfferClauseContext(_ctx, getState()); + enterRule(_localctx, 152, RULE_offerClause); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(1025); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == AT) { + { + { + setState(1022); + attribute(); + } + } + setState(1027); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(1033); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 118, _ctx)) { + case 1: + { + setState(1028); + match(IF); + setState(1029); + match(LP); + setState(1030); + expression(0); + setState(1031); + match(RP); + } + break; + } + setState(1035); + eventHandler(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ParametersContext extends ParserRuleContext { + public List parameter() { + return getRuleContexts(ParameterContext.class); + } + + public ParameterContext parameter(int i) { + return getRuleContext(ParameterContext.class, i); + } + + public List COMMA() { + return getTokens(CocoParser.COMMA); + } + + public TerminalNode COMMA(int i) { + return getToken(CocoParser.COMMA, i); + } + + public ParametersContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_parameters; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterParameters(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitParameters(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitParameters(this); + else return visitor.visitChildren(this); + } + } + + public final ParametersContext parameters() throws RecognitionException { + ParametersContext _localctx = new ParametersContext(_ctx, getState()); + enterRule(_localctx, 154, RULE_parameters); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(1037); + parameter(); + setState(1042); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == COMMA) { + { + { + setState(1038); + match(COMMA); + setState(1039); + parameter(); + } + } + setState(1044); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ParameterContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TerminalNode VAR() { + return getToken(CocoParser.VAR, 0); + } + + public TerminalNode ELLIP() { + return getToken(CocoParser.ELLIP, 0); + } + + public TerminalNode COLON() { + return getToken(CocoParser.COLON, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public GenericTypeDeclarationContext genericTypeDeclaration() { + return getRuleContext(GenericTypeDeclarationContext.class, 0); + } + + public ParameterContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_parameter; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterParameter(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitParameter(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitParameter(this); + else return visitor.visitChildren(this); + } + } + + public final ParameterContext parameter() throws RecognitionException { + ParameterContext _localctx = new ParameterContext(_ctx, getState()); + enterRule(_localctx, 156, RULE_parameter); + int _la; + try { + setState(1058); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 123, _ctx)) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(1046); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == VAR) { + { + setState(1045); + match(VAR); + } + } + + setState(1048); + match(IDENTIFIER); + setState(1050); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == ELLIP) { + { + setState(1049); + match(ELLIP); + } + } + + setState(1054); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == COLON) { + { + setState(1052); + match(COLON); + setState(1053); + type(0); + } + } + + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(1056); + match(IDENTIFIER); + setState(1057); + genericTypeDeclaration(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class LiteralExpression_Context extends ParserRuleContext { + public TerminalNode INTEGER() { + return getToken(CocoParser.INTEGER, 0); + } + + public TerminalNode CHAR_LITERAL() { + return getToken(CocoParser.CHAR_LITERAL, 0); + } + + public TerminalNode STRING_LITERAL() { + return getToken(CocoParser.STRING_LITERAL, 0); + } + + public LiteralExpression_Context(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_literalExpression_; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterLiteralExpression_(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitLiteralExpression_(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitLiteralExpression_(this); + else return visitor.visitChildren(this); + } + } + + public final LiteralExpression_Context literalExpression_() throws RecognitionException { + LiteralExpression_Context _localctx = new LiteralExpression_Context(_ctx, getState()); + enterRule(_localctx, 158, RULE_literalExpression_); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(1060); + _la = _input.LA(1); + if (!(((((_la - 87)) & ~0x3f) == 0 && ((1L << (_la - 87)) & ((1L << (INTEGER - 87)) | (1L << (CHAR_LITERAL - 87)) | (1L << (STRING_LITERAL - 87)))) != 0))) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class TypeContext extends ParserRuleContext { + public TypeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_type; + } + + public TypeContext() { + } + + public void copyFrom(TypeContext ctx) { + super.copyFrom(ctx); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class BinaryTypeContext extends TypeContext { + public List type() { + return getRuleContexts(TypeContext.class); + } + + public TypeContext type(int i) { + return getRuleContext(TypeContext.class, i); + } + + public TerminalNode MUL() { + return getToken(CocoParser.MUL, 0); + } + + public TerminalNode DIV() { + return getToken(CocoParser.DIV, 0); + } + + public TerminalNode MOD() { + return getToken(CocoParser.MOD, 0); + } + + public TerminalNode PLUS() { + return getToken(CocoParser.PLUS, 0); + } + + public TerminalNode MINUS() { + return getToken(CocoParser.MINUS, 0); + } + + public BinaryTypeContext(TypeContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterBinaryType(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitBinaryType(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitBinaryType(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class GroupTypeContext extends TypeContext { + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public GroupTypeContext(TypeContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterGroupType(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitGroupType(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitGroupType(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class FunctionTypeContext extends TypeContext { + public TerminalNode LP() { + return getToken(CocoParser.LP, 0); + } + + public TypesContext types() { + return getRuleContext(TypesContext.class, 0); + } + + public TerminalNode RP() { + return getToken(CocoParser.RP, 0); + } + + public TerminalNode ARROW() { + return getToken(CocoParser.ARROW, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public FunctionTypeContext(TypeContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterFunctionType(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitFunctionType(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitFunctionType(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class UnaryTypeContext extends TypeContext { + public TerminalNode MINUS() { + return getToken(CocoParser.MINUS, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public UnaryTypeContext(TypeContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterUnaryType(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitUnaryType(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitUnaryType(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class LiteralTypeContext extends TypeContext { + public LiteralExpression_Context literalExpression_() { + return getRuleContext(LiteralExpression_Context.class, 0); + } + + public LiteralTypeContext(TypeContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterLiteralType(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitLiteralType(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitLiteralType(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class TypeReferenceContext extends TypeContext { + public DotIdentifierListContext dotIdentifierList() { + return getRuleContext(DotIdentifierListContext.class, 0); + } + + public TerminalNode LT() { + return getToken(CocoParser.LT, 0); + } + + public TypesContext types() { + return getRuleContext(TypesContext.class, 0); + } + + public TerminalNode GT() { + return getToken(CocoParser.GT, 0); + } + + public TerminalNode DOT() { + return getToken(CocoParser.DOT, 0); + } + + public TerminalNode IDENTIFIER() { + return getToken(CocoParser.IDENTIFIER, 0); + } + + public TypeReferenceContext(TypeContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterTypeReference(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitTypeReference(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitTypeReference(this); + else return visitor.visitChildren(this); + } + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class ReferenceTypeContext extends TypeContext { + public TerminalNode AMP() { + return getToken(CocoParser.AMP, 0); + } + + public TypeContext type() { + return getRuleContext(TypeContext.class, 0); + } + + public TerminalNode MUT() { + return getToken(CocoParser.MUT, 0); + } + + public TerminalNode OUT() { + return getToken(CocoParser.OUT, 0); + } + + public ReferenceTypeContext(TypeContext ctx) { + copyFrom(ctx); + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterReferenceType(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitReferenceType(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitReferenceType(this); + else return visitor.visitChildren(this); + } + } + + public final TypeContext type() throws RecognitionException { + return type(0); + } + + private TypeContext type(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + TypeContext _localctx = new TypeContext(_ctx, _parentState); + TypeContext _prevctx = _localctx; + int _startState = 160; + enterRecursionRule(_localctx, 160, RULE_type, _p); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(1092); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 127, _ctx)) { + case 1: + { + _localctx = new GroupTypeContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + + setState(1063); + match(LP); + setState(1064); + type(0); + setState(1065); + match(RP); + } + break; + case 2: + { + _localctx = new TypeReferenceContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(1067); + dotIdentifierList(); + setState(1072); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 124, _ctx)) { + case 1: + { + setState(1068); + match(LT); + setState(1069); + types(); + setState(1070); + match(GT); + } + break; + } + setState(1076); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 125, _ctx)) { + case 1: + { + setState(1074); + match(DOT); + setState(1075); + match(IDENTIFIER); + } + break; + } + } + break; + case 3: + { + _localctx = new FunctionTypeContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(1078); + match(LP); + setState(1079); + types(); + setState(1080); + match(RP); + setState(1081); + match(ARROW); + setState(1082); + type(4); + } + break; + case 4: + { + _localctx = new LiteralTypeContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(1084); + literalExpression_(); + } + break; + case 5: + { + _localctx = new ReferenceTypeContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(1085); + match(AMP); + setState(1087); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la == MUT || _la == OUT) { + { + setState(1086); + _la = _input.LA(1); + if (!(_la == MUT || _la == OUT)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + + setState(1089); + type(2); + } + break; + case 6: + { + _localctx = new UnaryTypeContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(1090); + match(MINUS); + setState(1091); + type(1); + } + break; + } + _ctx.stop = _input.LT(-1); + setState(1102); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 129, _ctx); + while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) { + if (_alt == 1) { + if (_parseListeners != null) triggerExitRuleEvent(); + _prevctx = _localctx; + { + setState(1100); + _errHandler.sync(this); + switch (getInterpreter().adaptivePredict(_input, 128, _ctx)) { + case 1: + { + _localctx = new BinaryTypeContext(new TypeContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_type); + setState(1094); + if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); + setState(1095); + _la = _input.LA(1); + if (!(((((_la - 65)) & ~0x3f) == 0 && ((1L << (_la - 65)) & ((1L << (MUL - 65)) | (1L << (DIV - 65)) | (1L << (MOD - 65)))) != 0))) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(1096); + type(9); + } + break; + case 2: + { + _localctx = new BinaryTypeContext(new TypeContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_type); + setState(1097); + if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); + setState(1098); + _la = _input.LA(1); + if (!(_la == MINUS || _la == PLUS)) { + _errHandler.recoverInline(this); + } else { + if (_input.LA(1) == Token.EOF) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(1099); + type(8); + } + break; + } + } + } + setState(1104); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 129, _ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class TypesContext extends ParserRuleContext { + public List type() { + return getRuleContexts(TypeContext.class); + } + + public TypeContext type(int i) { + return getRuleContext(TypeContext.class, i); + } + + public List COMMA() { + return getTokens(CocoParser.COMMA); + } + + public TerminalNode COMMA(int i) { + return getToken(CocoParser.COMMA, i); + } + + public TypesContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_types; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterTypes(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitTypes(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitTypes(this); + else return visitor.visitChildren(this); + } + } + + public final TypesContext types() throws RecognitionException { + TypesContext _localctx = new TypesContext(_ctx, getState()); + enterRule(_localctx, 162, RULE_types); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(1105); + type(0); + setState(1110); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la == COMMA) { + { + { + setState(1106); + match(COMMA); + setState(1107); + type(0); + } + } + setState(1112); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") + public static class DotIdentifierListContext extends ParserRuleContext { + public List IDENTIFIER() { + return getTokens(CocoParser.IDENTIFIER); + } + + public TerminalNode IDENTIFIER(int i) { + return getToken(CocoParser.IDENTIFIER, i); + } + + public List DOT() { + return getTokens(CocoParser.DOT); + } + + public TerminalNode DOT(int i) { + return getToken(CocoParser.DOT, i); + } + + public DotIdentifierListContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + + @Override public int getRuleIndex() { + return RULE_dotIdentifierList; + } + + @Override public void enterRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).enterDotIdentifierList(this); + } + + @Override public void exitRule(ParseTreeListener listener) { + if (listener instanceof CocoListener) ((CocoListener) listener).exitDotIdentifierList(this); + } + + @Override public T accept(ParseTreeVisitor visitor) { + if (visitor instanceof CocoVisitor) return ((CocoVisitor) visitor).visitDotIdentifierList(this); + else return visitor.visitChildren(this); + } + } + + public final DotIdentifierListContext dotIdentifierList() throws RecognitionException { + DotIdentifierListContext _localctx = new DotIdentifierListContext(_ctx, getState()); + enterRule(_localctx, 164, RULE_dotIdentifierList); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(1113); + match(IDENTIFIER); + setState(1118); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 131, _ctx); + while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) { + if (_alt == 1) { + { + { + setState(1114); + match(DOT); + setState(1115); + match(IDENTIFIER); + } + } + } + setState(1120); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input, 131, _ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { + switch (ruleIndex) { + case 29: + return expression_sempred((ExpressionContext) _localctx, predIndex); + case 80: + return type_sempred((TypeContext) _localctx, predIndex); + } + return true; + } + + private boolean expression_sempred(ExpressionContext _localctx, int predIndex) { + switch (predIndex) { + case 0: + return precpred(_ctx, 12); + case 1: + return precpred(_ctx, 11); + case 2: + return precpred(_ctx, 10); + case 3: + return precpred(_ctx, 9); + case 4: + return precpred(_ctx, 20); + case 5: + return precpred(_ctx, 18); + case 6: + return precpred(_ctx, 17); + case 7: + return precpred(_ctx, 16); + case 8: + return precpred(_ctx, 15); + case 9: + return precpred(_ctx, 13); + } + return true; + } + + private boolean type_sempred(TypeContext _localctx, int predIndex) { + switch (predIndex) { + case 10: + return precpred(_ctx, 8); + case 11: + return precpred(_ctx, 7); + } + return true; + } + + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\\\u0464\4\2\t\2\4" + + "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t" + + "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22" + + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31" + + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!" + + "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4" + + ",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t" + + "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t=" + + "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I" + + "\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT" + + "\3\2\7\2\u00aa\n\2\f\2\16\2\u00ad\13\2\3\2\3\2\3\3\7\3\u00b2\n\3\f\3\16" + + "\3\u00b5\13\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\5\3" + + "\u00c4\n\3\3\4\3\4\3\4\3\4\3\4\3\4\5\4\u00cc\n\4\3\5\3\5\3\5\3\5\3\5\5" + + "\5\u00d3\n\5\3\5\5\5\u00d6\n\5\3\6\3\6\5\6\u00da\n\6\3\6\3\6\3\6\5\6\u00df" + + "\n\6\3\7\5\7\u00e2\n\7\3\7\3\7\3\7\5\7\u00e7\n\7\3\7\3\7\5\7\u00eb\n\7" + + "\3\7\3\7\5\7\u00ef\n\7\3\b\3\b\3\b\5\b\u00f4\n\b\3\b\3\b\7\b\u00f8\n\b" + + "\f\b\16\b\u00fb\13\b\3\b\3\b\3\t\3\t\3\t\5\t\u0102\n\t\3\t\3\t\7\t\u0106" + + "\n\t\f\t\16\t\u0109\13\t\3\t\3\t\3\n\3\n\3\n\5\n\u0110\n\n\3\n\3\n\3\n" + + "\3\13\3\13\3\13\5\13\u0118\n\13\3\13\3\13\5\13\u011c\n\13\3\13\3\13\3" + + "\13\3\13\3\13\3\13\3\f\3\f\3\f\5\f\u0127\n\f\3\f\3\f\3\f\3\f\3\f\3\r\3" + + "\r\3\r\3\r\5\r\u0132\n\r\3\r\5\r\u0135\n\r\3\r\3\r\7\r\u0139\n\r\f\r\16" + + "\r\u013c\13\r\3\r\3\r\3\16\5\16\u0141\n\16\3\16\3\16\3\16\3\16\5\16\u0147" + + "\n\16\3\16\3\16\7\16\u014b\n\16\f\16\16\16\u014e\13\16\3\16\3\16\3\17" + + "\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20\3\20\7\20\u015f" + + "\n\20\f\20\16\20\u0162\13\20\3\20\5\20\u0165\n\20\3\21\3\21\3\21\5\21" + + "\u016a\n\21\3\21\5\21\u016d\n\21\3\22\3\22\3\22\3\22\3\22\5\22\u0174\n" + + "\22\3\22\3\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\5\23\u0180\n\23" + + "\3\23\3\23\3\24\3\24\3\24\7\24\u0187\n\24\f\24\16\24\u018a\13\24\3\25" + + "\5\25\u018d\n\25\3\25\3\25\3\25\5\25\u0192\n\25\3\26\3\26\5\26\u0196\n" + + "\26\3\26\3\26\5\26\u019a\n\26\3\27\3\27\3\27\3\27\5\27\u01a0\n\27\3\27" + + "\5\27\u01a3\n\27\3\27\3\27\5\27\u01a7\n\27\3\30\3\30\3\30\7\30\u01ac\n" + + "\30\f\30\16\30\u01af\13\30\3\31\3\31\3\31\3\31\3\32\3\32\5\32\u01b7\n" + + "\32\3\32\3\32\5\32\u01bb\n\32\3\32\5\32\u01be\n\32\3\33\5\33\u01c1\n\33" + + "\3\33\3\33\3\33\3\33\3\33\5\33\u01c8\n\33\3\34\7\34\u01cb\n\34\f\34\16" + + "\34\u01ce\13\34\3\34\3\34\3\34\3\34\3\34\5\34\u01d5\n\34\3\34\5\34\u01d8" + + "\n\34\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\36\3\36\3\36\5\36\u01e5" + + "\n\36\3\36\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37" + + "\3\37\5\37\u01f5\n\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37" + + "\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\5\37\u020a\n\37\3\37\3\37" + + "\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37" + + "\3\37\3\37\5\37\u021e\n\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37" + + "\3\37\3\37\3\37\3\37\3\37\3\37\3\37\7\37\u0230\n\37\f\37\16\37\u0233\13" + + "\37\3 \3 \7 \u0237\n \f \16 \u023a\13 \3 \5 \u023d\n \3 \3 \3!\3!\3!\3" + + "!\3!\3!\3!\5!\u0248\n!\3\"\3\"\5\"\u024c\n\"\3\"\3\"\3\"\3\"\3\"\3\"\3" + + "\"\3\"\3#\3#\3#\3#\3#\5#\u025b\n#\3#\5#\u025e\n#\3#\3#\3$\3$\3$\7$\u0265" + + "\n$\f$\16$\u0268\13$\3$\5$\u026b\n$\3%\3%\3%\3%\3&\3&\3&\7&\u0274\n&\f" + + "&\16&\u0277\13&\3&\5&\u027a\n&\3\'\3\'\3\'\3\'\3\'\5\'\u0281\n\'\3\'\3" + + "\'\3(\3(\3(\7(\u0288\n(\f(\16(\u028b\13(\3(\5(\u028e\n(\3)\3)\3)\3)\3" + + "*\3*\3*\5*\u0297\n*\3+\3+\3+\3+\3+\3+\5+\u029f\n+\3,\3,\3,\7,\u02a4\n" + + ",\f,\16,\u02a7\13,\3,\3,\3,\3,\7,\u02ad\n,\f,\16,\u02b0\13,\5,\u02b2\n" + + ",\3-\3-\3-\5-\u02b7\n-\3-\5-\u02ba\n-\3.\3.\3.\3.\5.\u02c0\n.\3/\3/\3" + + "/\7/\u02c5\n/\f/\16/\u02c8\13/\3\60\5\60\u02cb\n\60\3\60\3\60\3\61\3\61" + + "\3\61\7\61\u02d2\n\61\f\61\16\61\u02d5\13\61\3\62\7\62\u02d8\n\62\f\62" + + "\16\62\u02db\13\62\3\62\3\62\5\62\u02df\n\62\3\62\3\62\5\62\u02e3\n\62" + + "\3\62\3\62\3\62\3\62\3\62\3\62\3\62\5\62\u02ec\n\62\3\63\3\63\3\63\3\64" + + "\3\64\3\64\3\64\3\65\3\65\3\65\3\65\3\66\3\66\5\66\u02fb\n\66\3\66\3\66" + + "\3\66\3\66\3\66\3\66\3\67\3\67\5\67\u0305\n\67\3\67\3\67\3\67\3\67\5\67" + + "\u030b\n\67\3\67\3\67\3\67\3\67\38\38\58\u0313\n8\38\38\39\39\59\u0319" + + "\n9\39\39\3:\7:\u031e\n:\f:\16:\u0321\13:\3:\3:\3:\3:\3:\3:\3:\3:\3:\3" + + ":\5:\u032d\n:\3;\3;\3;\3;\5;\u0333\n;\3;\3;\3;\3;\3<\3<\3<\3<\3<\5<\u033e" + + "\n<\3<\3<\3=\3=\5=\u0344\n=\3=\3=\5=\u0348\n=\3=\3=\7=\u034c\n=\f=\16" + + "=\u034f\13=\3=\3=\3>\7>\u0354\n>\f>\16>\u0357\13>\3>\3>\3>\3>\3>\3>\3" + + ">\3>\3>\3>\5>\u0363\n>\3?\3?\5?\u0367\n?\3@\3@\3@\3@\5@\u036d\n@\3@\5" + + "@\u0370\n@\3@\3@\7@\u0374\n@\f@\16@\u0377\13@\3@\3@\3A\3A\3A\3A\3A\5A" + + "\u0380\nA\3A\5A\u0383\nA\3A\3A\3B\7B\u0388\nB\fB\16B\u038b\13B\3B\3B\3" + + "B\3B\3B\3B\3B\3B\3B\3B\3B\5B\u0398\nB\3C\3C\3C\3C\3C\3C\3D\3D\3D\3D\3" + + "D\3D\3E\3E\3E\3E\3E\3F\3F\3F\5F\u03ae\nF\3G\3G\3G\3G\3G\5G\u03b5\nG\3" + + "G\3G\3G\7G\u03ba\nG\fG\16G\u03bd\13G\3G\3G\3G\5G\u03c2\nG\3G\3G\3G\3G" + + "\3H\3H\3H\3H\3H\5H\u03cd\nH\3H\3H\5H\u03d1\nH\3I\3I\3I\3I\3I\5I\u03d8" + + "\nI\3I\3I\3I\3I\3J\3J\3J\3J\3J\3J\3J\3K\3K\3K\5K\u03e8\nK\3L\3L\3L\3L" + + "\3L\3L\5L\u03f0\nL\5L\u03f2\nL\3L\3L\3M\3M\3M\7M\u03f9\nM\fM\16M\u03fc" + + "\13M\3M\5M\u03ff\nM\3N\7N\u0402\nN\fN\16N\u0405\13N\3N\3N\3N\3N\3N\5N" + + "\u040c\nN\3N\3N\3O\3O\3O\7O\u0413\nO\fO\16O\u0416\13O\3P\5P\u0419\nP\3" + + "P\3P\5P\u041d\nP\3P\3P\5P\u0421\nP\3P\3P\5P\u0425\nP\3Q\3Q\3R\3R\3R\3" + + "R\3R\3R\3R\3R\3R\3R\5R\u0433\nR\3R\3R\5R\u0437\nR\3R\3R\3R\3R\3R\3R\3" + + "R\3R\3R\5R\u0442\nR\3R\3R\3R\5R\u0447\nR\3R\3R\3R\3R\3R\3R\7R\u044f\n" + + "R\fR\16R\u0452\13R\3S\3S\3S\7S\u0457\nS\fS\16S\u045a\13S\3T\3T\3T\7T\u045f" + + "\nT\fT\16T\u0462\13T\3T\2\4<\u00a2U\2\4\6\b\n\f\16\20\22\24\26\30\32\34" + + "\36 \"$&(*,.\60\62\64\668:<>@BDFHJLNPRTVXZ\\^`bdfhjlnprtvxz|~\u0080\u0082" + + "\u0084\u0086\u0088\u008a\u008c\u008e\u0090\u0092\u0094\u0096\u0098\u009a" + + "\u009c\u009e\u00a0\u00a2\u00a4\u00a6\2\r\3\2\60\61\3\2\35\36\5\2EEJJM" + + "M\4\2CDFF\4\2EEGG\4\2ABOT\3\2>?\4\2\60\60@@\4\2\3\3%%\4\2YY[\\\4\2\35" + + "\35##\2\u04e0\2\u00ab\3\2\2\2\4\u00b3\3\2\2\2\6\u00c5\3\2\2\2\b\u00cd" + + "\3\2\2\2\n\u00d7\3\2\2\2\f\u00e1\3\2\2\2\16\u00f0\3\2\2\2\20\u00fe\3\2" + + "\2\2\22\u010c\3\2\2\2\24\u0114\3\2\2\2\26\u0123\3\2\2\2\30\u012d\3\2\2" + + "\2\32\u0140\3\2\2\2\34\u0151\3\2\2\2\36\u0159\3\2\2\2 \u016c\3\2\2\2\"" + + "\u016e\3\2\2\2$\u017b\3\2\2\2&\u0183\3\2\2\2(\u018c\3\2\2\2*\u0199\3\2" + + "\2\2,\u019b\3\2\2\2.\u01a8\3\2\2\2\60\u01b0\3\2\2\2\62\u01ba\3\2\2\2\64" + + "\u01c0\3\2\2\2\66\u01cc\3\2\2\28\u01d9\3\2\2\2:\u01e1\3\2\2\2<\u0209\3" + + "\2\2\2>\u0234\3\2\2\2@\u0240\3\2\2\2B\u024b\3\2\2\2D\u0255\3\2\2\2F\u0261" + + "\3\2\2\2H\u026c\3\2\2\2J\u0270\3\2\2\2L\u0280\3\2\2\2N\u0284\3\2\2\2P" + + "\u028f\3\2\2\2R\u0296\3\2\2\2T\u0298\3\2\2\2V\u02b1\3\2\2\2X\u02b3\3\2" + + "\2\2Z\u02bb\3\2\2\2\\\u02c1\3\2\2\2^\u02ca\3\2\2\2`\u02ce\3\2\2\2b\u02d9" + + "\3\2\2\2d\u02ed\3\2\2\2f\u02f0\3\2\2\2h\u02f4\3\2\2\2j\u02fa\3\2\2\2l" + + "\u0304\3\2\2\2n\u0310\3\2\2\2p\u0316\3\2\2\2r\u031f\3\2\2\2t\u032e\3\2" + + "\2\2v\u0338\3\2\2\2x\u0341\3\2\2\2z\u0355\3\2\2\2|\u0366\3\2\2\2~\u0368" + + "\3\2\2\2\u0080\u037a\3\2\2\2\u0082\u0389\3\2\2\2\u0084\u0399\3\2\2\2\u0086" + + "\u039f\3\2\2\2\u0088\u03a5\3\2\2\2\u008a\u03ad\3\2\2\2\u008c\u03b4\3\2" + + "\2\2\u008e\u03c7\3\2\2\2\u0090\u03d7\3\2\2\2\u0092\u03dd\3\2\2\2\u0094" + + "\u03e7\3\2\2\2\u0096\u03e9\3\2\2\2\u0098\u03f5\3\2\2\2\u009a\u0403\3\2" + + "\2\2\u009c\u040f\3\2\2\2\u009e\u0424\3\2\2\2\u00a0\u0426\3\2\2\2\u00a2" + + "\u0446\3\2\2\2\u00a4\u0453\3\2\2\2\u00a6\u045b\3\2\2\2\u00a8\u00aa\5\4" + + "\3\2\u00a9\u00a8\3\2\2\2\u00aa\u00ad\3\2\2\2\u00ab\u00a9\3\2\2\2\u00ab" + + "\u00ac\3\2\2\2\u00ac\u00ae\3\2\2\2\u00ad\u00ab\3\2\2\2\u00ae\u00af\7\2" + + "\2\3\u00af\3\3\2\2\2\u00b0\u00b2\5\6\4\2\u00b1\u00b0\3\2\2\2\u00b2\u00b5" + + "\3\2\2\2\u00b3\u00b1\3\2\2\2\u00b3\u00b4\3\2\2\2\u00b4\u00c3\3\2\2\2\u00b5" + + "\u00b3\3\2\2\2\u00b6\u00c4\5\n\6\2\u00b7\u00c4\5\f\7\2\u00b8\u00c4\5\16" + + "\b\2\u00b9\u00c4\5\20\t\2\u00ba\u00c4\5\22\n\2\u00bb\u00c4\5\24\13\2\u00bc" + + "\u00c4\5\26\f\2\u00bd\u00c4\5\30\r\2\u00be\u00c4\5\32\16\2\u00bf\u00c4" + + "\5\34\17\2\u00c0\u00c4\5\"\22\2\u00c1\u00c4\5\36\20\2\u00c2\u00c4\5\b" + + "\5\2\u00c3\u00b6\3\2\2\2\u00c3\u00b7\3\2\2\2\u00c3\u00b8\3\2\2\2\u00c3" + + "\u00b9\3\2\2\2\u00c3\u00ba\3\2\2\2\u00c3\u00bb\3\2\2\2\u00c3\u00bc\3\2" + + "\2\2\u00c3\u00bd\3\2\2\2\u00c3\u00be\3\2\2\2\u00c3\u00bf\3\2\2\2\u00c3" + + "\u00c0\3\2\2\2\u00c3\u00c1\3\2\2\2\u00c3\u00c2\3\2\2\2\u00c4\5\3\2\2\2" + + "\u00c5\u00c6\7\65\2\2\u00c6\u00cb\5\u00a6T\2\u00c7\u00c8\78\2\2\u00c8" + + "\u00c9\5`\61\2\u00c9\u00ca\79\2\2\u00ca\u00cc\3\2\2\2\u00cb\u00c7\3\2" + + "\2\2\u00cb\u00cc\3\2\2\2\u00cc\7\3\2\2\2\u00cd\u00ce\7\6\2\2\u00ce\u00cf" + + "\7\65\2\2\u00cf\u00d5\5\u00a6T\2\u00d0\u00d2\78\2\2\u00d1\u00d3\5\u009c" + + "O\2\u00d2\u00d1\3\2\2\2\u00d2\u00d3\3\2\2\2\u00d3\u00d4\3\2\2\2\u00d4" + + "\u00d6\79\2\2\u00d5\u00d0\3\2\2\2\u00d5\u00d6\3\2\2\2\u00d6\t\3\2\2\2" + + "\u00d7\u00d9\7\27\2\2\u00d8\u00da\7/\2\2\u00d9\u00d8\3\2\2\2\u00d9\u00da" + + "\3\2\2\2\u00da\u00db\3\2\2\2\u00db\u00de\5\u00a6T\2\u00dc\u00dd\7\4\2" + + "\2\u00dd\u00df\7\64\2\2\u00de\u00dc\3\2\2\2\u00de\u00df\3\2\2\2\u00df" + + "\13\3\2\2\2\u00e0\u00e2\7\'\2\2\u00e1\u00e0\3\2\2\2\u00e1\u00e2\3\2\2" + + "\2\u00e2\u00e3\3\2\2\2\u00e3\u00e4\t\2\2\2\u00e4\u00e6\7\64\2\2\u00e5" + + "\u00e7\5$\23\2\u00e6\u00e5\3\2\2\2\u00e6\u00e7\3\2\2\2\u00e7\u00ea\3\2" + + "\2\2\u00e8\u00e9\7\67\2\2\u00e9\u00eb\5\u00a2R\2\u00ea\u00e8\3\2\2\2\u00ea" + + "\u00eb\3\2\2\2\u00eb\u00ee\3\2\2\2\u00ec\u00ed\7\66\2\2\u00ed\u00ef\5" + + "<\37\2\u00ee\u00ec\3\2\2\2\u00ee\u00ef\3\2\2\2\u00ef\r\3\2\2\2\u00f0\u00f1" + + "\7\r\2\2\u00f1\u00f3\7\64\2\2\u00f2\u00f4\5$\23\2\u00f3\u00f2\3\2\2\2" + + "\u00f3\u00f4\3\2\2\2\u00f4\u00f5\3\2\2\2\u00f5\u00f9\7:\2\2\u00f6\u00f8" + + "\5*\26\2\u00f7\u00f6\3\2\2\2\u00f8\u00fb\3\2\2\2\u00f9\u00f7\3\2\2\2\u00f9" + + "\u00fa\3\2\2\2\u00fa\u00fc\3\2\2\2\u00fb\u00f9\3\2\2\2\u00fc\u00fd\7;" + + "\2\2\u00fd\17\3\2\2\2\u00fe\u00ff\7-\2\2\u00ff\u0101\7\64\2\2\u0100\u0102" + + "\5$\23\2\u0101\u0100\3\2\2\2\u0101\u0102\3\2\2\2\u0102\u0103\3\2\2\2\u0103" + + "\u0107\7:\2\2\u0104\u0106\5\62\32\2\u0105\u0104\3\2\2\2\u0106\u0109\3" + + "\2\2\2\u0107\u0105\3\2\2\2\u0107\u0108\3\2\2\2\u0108\u010a\3\2\2\2\u0109" + + "\u0107\3\2\2\2\u010a\u010b\7;\2\2\u010b\21\3\2\2\2\u010c\u010d\7.\2\2" + + "\u010d\u010f\7\64\2\2\u010e\u0110\5$\23\2\u010f\u010e\3\2\2\2\u010f\u0110" + + "\3\2\2\2\u0110\u0111\3\2\2\2\u0111\u0112\7\66\2\2\u0112\u0113\5\u00a2" + + "R\2\u0113\23\3\2\2\2\u0114\u0115\7\24\2\2\u0115\u0117\7\64\2\2\u0116\u0118" + + "\5$\23\2\u0117\u0116\3\2\2\2\u0117\u0118\3\2\2\2\u0118\u0119\3\2\2\2\u0119" + + "\u011b\78\2\2\u011a\u011c\5\u009cO\2\u011b\u011a\3\2\2\2\u011b\u011c\3" + + "\2\2\2\u011c\u011d\3\2\2\2\u011d\u011e\79\2\2\u011e\u011f\7\67\2\2\u011f" + + "\u0120\5\u00a2R\2\u0120\u0121\7\66\2\2\u0121\u0122\5<\37\2\u0122\25\3" + + "\2\2\2\u0123\u0124\7\32\2\2\u0124\u0126\7\64\2\2\u0125\u0127\5$\23\2\u0126" + + "\u0125\3\2\2\2\u0126\u0127\3\2\2\2\u0127\u0128\3\2\2\2\u0128\u0129\78" + + "\2\2\u0129\u012a\5\u009cO\2\u012a\u012b\79\2\2\u012b\u012c\5> \2\u012c" + + "\27\3\2\2\2\u012d\u012e\7&\2\2\u012e\u0131\7\64\2\2\u012f\u0130\7\67\2" + + "\2\u0130\u0132\5\u00a4S\2\u0131\u012f\3\2\2\2\u0131\u0132\3\2\2\2\u0132" + + "\u0134\3\2\2\2\u0133\u0135\7\22\2\2\u0134\u0133\3\2\2\2\u0134\u0135\3" + + "\2\2\2\u0135\u0136\3\2\2\2\u0136\u013a\7:\2\2\u0137\u0139\5r:\2\u0138" + + "\u0137\3\2\2\2\u0139\u013c\3\2\2\2\u013a\u0138\3\2\2\2\u013a\u013b\3\2" + + "\2\2\u013b\u013d\3\2\2\2\u013c\u013a\3\2\2\2\u013d\u013e\7;\2\2\u013e" + + "\31\3\2\2\2\u013f\u0141\7\21\2\2\u0140\u013f\3\2\2\2\u0140\u0141\3\2\2" + + "\2\u0141\u0142\3\2\2\2\u0142\u0143\7\n\2\2\u0143\u0146\7\64\2\2\u0144" + + "\u0145\7\67\2\2\u0145\u0147\5\u00a2R\2\u0146\u0144\3\2\2\2\u0146\u0147" + + "\3\2\2\2\u0147\u0148\3\2\2\2\u0148\u014c\7:\2\2\u0149\u014b\5\66\34\2" + + "\u014a\u0149\3\2\2\2\u014b\u014e\3\2\2\2\u014c\u014a\3\2\2\2\u014c\u014d" + + "\3\2\2\2\u014d\u014f\3\2\2\2\u014e\u014c\3\2\2\2\u014f\u0150\7;\2\2\u0150" + + "\33\3\2\2\2\u0151\u0152\7\21\2\2\u0152\u0153\7\60\2\2\u0153\u0154\7\64" + + "\2\2\u0154\u0155\7\67\2\2\u0155\u0156\5\u00a2R\2\u0156\u0157\7\66\2\2" + + "\u0157\u0158\5<\37\2\u0158\35\3\2\2\2\u0159\u015a\7\21\2\2\u015a\u015b" + + "\7.\2\2\u015b\u0164\7\64\2\2\u015c\u0160\7:\2\2\u015d\u015f\5 \21\2\u015e" + + "\u015d\3\2\2\2\u015f\u0162\3\2\2\2\u0160\u015e\3\2\2\2\u0160\u0161\3\2" + + "\2\2\u0161\u0163\3\2\2\2\u0162\u0160\3\2\2\2\u0163\u0165\7;\2\2\u0164" + + "\u015c\3\2\2\2\u0164\u0165\3\2\2\2\u0165\37\3\2\2\2\u0166\u016d\58\35" + + "\2\u0167\u016d\5\f\7\2\u0168\u016a\t\3\2\2\u0169\u0168\3\2\2\2\u0169\u016a" + + "\3\2\2\2\u016a\u016b\3\2\2\2\u016b\u016d\5\"\22\2\u016c\u0166\3\2\2\2" + + "\u016c\u0167\3\2\2\2\u016c\u0169\3\2\2\2\u016d!\3\2\2\2\u016e\u016f\7" + + "\21\2\2\u016f\u0170\7\24\2\2\u0170\u0171\7\64\2\2\u0171\u0173\78\2\2\u0172" + + "\u0174\5\u009cO\2\u0173\u0172\3\2\2\2\u0173\u0174\3\2\2\2\u0174\u0175" + + "\3\2\2\2\u0175\u0176\79\2\2\u0176\u0177\7\67\2\2\u0177\u0178\5\u00a2R" + + "\2\u0178\u0179\7\66\2\2\u0179\u017a\5<\37\2\u017a#\3\2\2\2\u017b\u017c" + + "\7A\2\2\u017c\u017f\5&\24\2\u017d\u017e\7\62\2\2\u017e\u0180\5`\61\2\u017f" + + "\u017d\3\2\2\2\u017f\u0180\3\2\2\2\u0180\u0181\3\2\2\2\u0181\u0182\7B" + + "\2\2\u0182%\3\2\2\2\u0183\u0188\5(\25\2\u0184\u0185\7>\2\2\u0185\u0187" + + "\5(\25\2\u0186\u0184\3\2\2\2\u0187\u018a\3\2\2\2\u0188\u0186\3\2\2\2\u0188" + + "\u0189\3\2\2\2\u0189\'\3\2\2\2\u018a\u0188\3\2\2\2\u018b\u018d\7\60\2" + + "\2\u018c\u018b\3\2\2\2\u018c\u018d\3\2\2\2\u018d\u018e\3\2\2\2\u018e\u0191" + + "\7\64\2\2\u018f\u0190\7\67\2\2\u0190\u0192\5\u00a2R\2\u0191\u018f\3\2" + + "\2\2\u0191\u0192\3\2\2\2\u0192)\3\2\2\2\u0193\u019a\5,\27\2\u0194\u0196" + + "\t\3\2\2\u0195\u0194\3\2\2\2\u0195\u0196\3\2\2\2\u0196\u0197\3\2\2\2\u0197" + + "\u019a\5\24\13\2\u0198\u019a\58\35\2\u0199\u0193\3\2\2\2\u0199\u0195\3" + + "\2\2\2\u0199\u0198\3\2\2\2\u019a+\3\2\2\2\u019b\u019c\7\t\2\2\u019c\u01a2" + + "\7\64\2\2\u019d\u019f\78\2\2\u019e\u01a0\5.\30\2\u019f\u019e\3\2\2\2\u019f" + + "\u01a0\3\2\2\2\u01a0\u01a1\3\2\2\2\u01a1\u01a3\79\2\2\u01a2\u019d\3\2" + + "\2\2\u01a2\u01a3\3\2\2\2\u01a3\u01a6\3\2\2\2\u01a4\u01a5\7\66\2\2\u01a5" + + "\u01a7\5<\37\2\u01a6\u01a4\3\2\2\2\u01a6\u01a7\3\2\2\2\u01a7-\3\2\2\2" + + "\u01a8\u01ad\5\60\31\2\u01a9\u01aa\7>\2\2\u01aa\u01ac\5\60\31\2\u01ab" + + "\u01a9\3\2\2\2\u01ac\u01af\3\2\2\2\u01ad\u01ab\3\2\2\2\u01ad\u01ae\3\2" + + "\2\2\u01ae/\3\2\2\2\u01af\u01ad\3\2\2\2\u01b0\u01b1\7\64\2\2\u01b1\u01b2" + + "\7\67\2\2\u01b2\u01b3\5\u00a2R\2\u01b3\61\3\2\2\2\u01b4\u01bb\5\64\33" + + "\2\u01b5\u01b7\t\3\2\2\u01b6\u01b5\3\2\2\2\u01b6\u01b7\3\2\2\2\u01b7\u01b8" + + "\3\2\2\2\u01b8\u01bb\5\24\13\2\u01b9\u01bb\58\35\2\u01ba\u01b4\3\2\2\2" + + "\u01ba\u01b6\3\2\2\2\u01ba\u01b9\3\2\2\2\u01bb\u01bd\3\2\2\2\u01bc\u01be" + + "\7?\2\2\u01bd\u01bc\3\2\2\2\u01bd\u01be\3\2\2\2\u01be\63\3\2\2\2\u01bf" + + "\u01c1\t\2\2\2\u01c0\u01bf\3\2\2\2\u01c0\u01c1\3\2\2\2\u01c1\u01c2\3\2" + + "\2\2\u01c2\u01c3\7\64\2\2\u01c3\u01c4\7\67\2\2\u01c4\u01c7\5\u00a2R\2" + + "\u01c5\u01c6\7\66\2\2\u01c6\u01c8\5<\37\2\u01c7\u01c5\3\2\2\2\u01c7\u01c8" + + "\3\2\2\2\u01c8\65\3\2\2\2\u01c9\u01cb\5\6\4\2\u01ca\u01c9\3\2\2\2\u01cb" + + "\u01ce\3\2\2\2\u01cc\u01ca\3\2\2\2\u01cc\u01cd\3\2\2\2\u01cd\u01d4\3\2" + + "\2\2\u01ce\u01cc\3\2\2\2\u01cf\u01d5\5\64\33\2\u01d0\u01d5\5\f\7\2\u01d1" + + "\u01d5\5:\36\2\u01d2\u01d5\5x=\2\u01d3\u01d5\58\35\2\u01d4\u01cf\3\2\2" + + "\2\u01d4\u01d0\3\2\2\2\u01d4\u01d1\3\2\2\2\u01d4\u01d2\3\2\2\2\u01d4\u01d3" + + "\3\2\2\2\u01d5\u01d7\3\2\2\2\u01d6\u01d8\7?\2\2\u01d7\u01d6\3\2\2\2\u01d7" + + "\u01d8\3\2\2\2\u01d8\67\3\2\2\2\u01d9\u01da\7,\2\2\u01da\u01db\7\60\2" + + "\2\u01db\u01dc\7\64\2\2\u01dc\u01dd\7\67\2\2\u01dd\u01de\5\u00a2R\2\u01de" + + "\u01df\7\66\2\2\u01df\u01e0\5<\37\2\u01e09\3\2\2\2\u01e1\u01e2\7\31\2" + + "\2\u01e2\u01e4\78\2\2\u01e3\u01e5\5\u009cO\2\u01e4\u01e3\3\2\2\2\u01e4" + + "\u01e5\3\2\2\2\u01e5\u01e6\3\2\2\2\u01e6\u01e7\79\2\2\u01e7\u01e8\7\66" + + "\2\2\u01e8\u01e9\5> \2\u01e9;\3\2\2\2\u01ea\u01eb\b\37\1\2\u01eb\u020a" + + "\5\u00a0Q\2\u01ec\u01ed\7\21\2\2\u01ed\u020a\7Z\2\2\u01ee\u020a\5\"\22" + + "\2\u01ef\u01f4\5\u00a6T\2\u01f0\u01f1\7A\2\2\u01f1\u01f2\5&\24\2\u01f2" + + "\u01f3\7B\2\2\u01f3\u01f5\3\2\2\2\u01f4\u01f0\3\2\2\2\u01f4\u01f5\3\2" + + "\2\2\u01f5\u020a\3\2\2\2\u01f6\u020a\5\u0088E\2\u01f7\u01f8\t\4\2\2\u01f8" + + "\u020a\5<\37\20\u01f9\u020a\5@!\2\u01fa\u020a\5B\"\2\u01fb\u01fc\7@\2" + + "\2\u01fc\u020a\7\64\2\2\u01fd\u01fe\78\2\2\u01fe\u01ff\5`\61\2\u01ff\u0200" + + "\79\2\2\u0200\u020a\3\2\2\2\u0201\u0202\7<\2\2\u0202\u0203\5<\37\2\u0203" + + "\u0204\7=\2\2\u0204\u020a\3\2\2\2\u0205\u020a\5D#\2\u0206\u0207\7!\2\2" + + "\u0207\u020a\5<\37\4\u0208\u020a\5> \2\u0209\u01ea\3\2\2\2\u0209\u01ec" + + "\3\2\2\2\u0209\u01ee\3\2\2\2\u0209\u01ef\3\2\2\2\u0209\u01f6\3\2\2\2\u0209" + + "\u01f7\3\2\2\2\u0209\u01f9\3\2\2\2\u0209\u01fa\3\2\2\2\u0209\u01fb\3\2" + + "\2\2\u0209\u01fd\3\2\2\2\u0209\u0201\3\2\2\2\u0209\u0205\3\2\2\2\u0209" + + "\u0206\3\2\2\2\u0209\u0208\3\2\2\2\u020a\u0231\3\2\2\2\u020b\u020c\f\16" + + "\2\2\u020c\u020d\t\5\2\2\u020d\u0230\5<\37\17\u020e\u020f\f\r\2\2\u020f" + + "\u0210\t\6\2\2\u0210\u0230\5<\37\16\u0211\u0212\f\f\2\2\u0212\u0213\t" + + "\7\2\2\u0213\u0230\5<\37\r\u0214\u0215\f\13\2\2\u0215\u0216\7\66\2\2\u0216" + + "\u0230\5<\37\f\u0217\u0218\f\26\2\2\u0218\u0219\7@\2\2\u0219\u0230\7\64" + + "\2\2\u021a\u021b\f\24\2\2\u021b\u021d\78\2\2\u021c\u021e\5`\61\2\u021d" + + "\u021c\3\2\2\2\u021d\u021e\3\2\2\2\u021e\u021f\3\2\2\2\u021f\u0230\79" + + "\2\2\u0220\u0221\f\23\2\2\u0221\u0222\7<\2\2\u0222\u0223\5<\37\2\u0223" + + "\u0224\7=\2\2\u0224\u0230\3\2\2\2\u0225\u0226\f\22\2\2\u0226\u0227\7:" + + "\2\2\u0227\u0228\5F$\2\u0228\u0229\7;\2\2\u0229\u0230\3\2\2\2\u022a\u022b" + + "\f\21\2\2\u022b\u0230\7K\2\2\u022c\u022d\f\17\2\2\u022d\u022e\7\4\2\2" + + "\u022e\u0230\5\u00a2R\2\u022f\u020b\3\2\2\2\u022f\u020e\3\2\2\2\u022f" + + "\u0211\3\2\2\2\u022f\u0214\3\2\2\2\u022f\u0217\3\2\2\2\u022f\u021a\3\2" + + "\2\2\u022f\u0220\3\2\2\2\u022f\u0225\3\2\2\2\u022f\u022a\3\2\2\2\u022f" + + "\u022c\3\2\2\2\u0230\u0233\3\2\2\2\u0231\u022f\3\2\2\2\u0231\u0232\3\2" + + "\2\2\u0232=\3\2\2\2\u0233\u0231\3\2\2\2\u0234\u0238\7:\2\2\u0235\u0237" + + "\5b\62\2\u0236\u0235\3\2\2\2\u0237\u023a\3\2\2\2\u0238\u0236\3\2\2\2\u0238" + + "\u0239\3\2\2\2\u0239\u023c\3\2\2\2\u023a\u0238\3\2\2\2\u023b\u023d\5<" + + "\37\2\u023c\u023b\3\2\2\2\u023c\u023d\3\2\2\2\u023d\u023e\3\2\2\2\u023e" + + "\u023f\7;\2\2\u023f?\3\2\2\2\u0240\u0241\7\25\2\2\u0241\u0242\78\2\2\u0242" + + "\u0243\5<\37\2\u0243\u0244\79\2\2\u0244\u0247\5<\37\2\u0245\u0246\7\f" + + "\2\2\u0246\u0248\5<\37\2\u0247\u0245\3\2\2\2\u0247\u0248\3\2\2\2\u0248" + + "A\3\2\2\2\u0249\u024a\7\64\2\2\u024a\u024c\7\67\2\2\u024b\u0249\3\2\2" + + "\2\u024b\u024c\3\2\2\2\u024c\u024d\3\2\2\2\u024d\u024e\7\34\2\2\u024e" + + "\u024f\78\2\2\u024f\u0250\5<\37\2\u0250\u0251\79\2\2\u0251\u0252\7:\2" + + "\2\u0252\u0253\5N(\2\u0253\u0254\7;\2\2\u0254C\3\2\2\2\u0255\u0256\7\37" + + "\2\2\u0256\u0257\7:\2\2\u0257\u025a\5J&\2\u0258\u0259\7\"\2\2\u0259\u025b" + + "\5<\37\2\u025a\u0258\3\2\2\2\u025a\u025b\3\2\2\2\u025b\u025d\3\2\2\2\u025c" + + "\u025e\t\b\2\2\u025d\u025c\3\2\2\2\u025d\u025e\3\2\2\2\u025e\u025f\3\2" + + "\2\2\u025f\u0260\7;\2\2\u0260E\3\2\2\2\u0261\u0266\5H%\2\u0262\u0263\7" + + ">\2\2\u0263\u0265\5H%\2\u0264\u0262\3\2\2\2\u0265\u0268\3\2\2\2\u0266" + + "\u0264\3\2\2\2\u0266\u0267\3\2\2\2\u0267\u026a\3\2\2\2\u0268\u0266\3\2" + + "\2\2\u0269\u026b\7>\2\2\u026a\u0269\3\2\2\2\u026a\u026b\3\2\2\2\u026b" + + "G\3\2\2\2\u026c\u026d\7\64\2\2\u026d\u026e\7\66\2\2\u026e\u026f\5<\37" + + "\2\u026fI\3\2\2\2\u0270\u0275\5L\'\2\u0271\u0272\t\b\2\2\u0272\u0274\5" + + "L\'\2\u0273\u0271\3\2\2\2\u0274\u0277\3\2\2\2\u0275\u0273\3\2\2\2\u0275" + + "\u0276\3\2\2\2\u0276\u0279\3\2\2\2\u0277\u0275\3\2\2\2\u0278\u027a\t\b" + + "\2\2\u0279\u0278\3\2\2\2\u0279\u027a\3\2\2\2\u027aK\3\2\2\2\u027b\u027c" + + "\7\25\2\2\u027c\u027d\78\2\2\u027d\u027e\5<\37\2\u027e\u027f\79\2\2\u027f" + + "\u0281\3\2\2\2\u0280\u027b\3\2\2\2\u0280\u0281\3\2\2\2\u0281\u0282\3\2" + + "\2\2\u0282\u0283\5<\37\2\u0283M\3\2\2\2\u0284\u0289\5P)\2\u0285\u0286" + + "\t\b\2\2\u0286\u0288\5P)\2\u0287\u0285\3\2\2\2\u0288\u028b\3\2\2\2\u0289" + + "\u0287\3\2\2\2\u0289\u028a\3\2\2\2\u028a\u028d\3\2\2\2\u028b\u0289\3\2" + + "\2\2\u028c\u028e\t\b\2\2\u028d\u028c\3\2\2\2\u028d\u028e\3\2\2\2\u028e" + + "O\3\2\2\2\u028f\u0290\5R*\2\u0290\u0291\7H\2\2\u0291\u0292\5<\37\2\u0292" + + "Q\3\2\2\2\u0293\u0297\5T+\2\u0294\u0297\5\u00a0Q\2\u0295\u0297\5Z.\2\u0296" + + "\u0293\3\2\2\2\u0296\u0294\3\2\2\2\u0296\u0295\3\2\2\2\u0297S\3\2\2\2" + + "\u0298\u029e\5V,\2\u0299\u029a\7\25\2\2\u029a\u029b\78\2\2\u029b\u029c" + + "\5<\37\2\u029c\u029d\79\2\2\u029d\u029f\3\2\2\2\u029e\u0299\3\2\2\2\u029e" + + "\u029f\3\2\2\2\u029fU\3\2\2\2\u02a0\u02a5\5X-\2\u02a1\u02a2\7@\2\2\u02a2" + + "\u02a4\5X-\2\u02a3\u02a1\3\2\2\2\u02a4\u02a7\3\2\2\2\u02a5\u02a3\3\2\2" + + "\2\u02a5\u02a6\3\2\2\2\u02a6\u02b2\3\2\2\2\u02a7\u02a5\3\2\2\2\u02a8\u02a9" + + "\7@\2\2\u02a9\u02ae\5X-\2\u02aa\u02ab\7@\2\2\u02ab\u02ad\5X-\2\u02ac\u02aa" + + "\3\2\2\2\u02ad\u02b0\3\2\2\2\u02ae\u02ac\3\2\2\2\u02ae\u02af\3\2\2\2\u02af" + + "\u02b2\3\2\2\2\u02b0\u02ae\3\2\2\2\u02b1\u02a0\3\2\2\2\u02b1\u02a8\3\2" + + "\2\2\u02b2W\3\2\2\2\u02b3\u02b9\7\64\2\2\u02b4\u02b6\78\2\2\u02b5\u02b7" + + "\5\\/\2\u02b6\u02b5\3\2\2\2\u02b6\u02b7\3\2\2\2\u02b7\u02b8\3\2\2\2\u02b8" + + "\u02ba\79\2\2\u02b9\u02b4\3\2\2\2\u02b9\u02ba\3\2\2\2\u02baY\3\2\2\2\u02bb" + + "\u02bc\t\t\2\2\u02bc\u02bf\7\64\2\2\u02bd\u02be\7\67\2\2\u02be\u02c0\5" + + "\u00a2R\2\u02bf\u02bd\3\2\2\2\u02bf\u02c0\3\2\2\2\u02c0[\3\2\2\2\u02c1" + + "\u02c6\5^\60\2\u02c2\u02c3\7>\2\2\u02c3\u02c5\5^\60\2\u02c4\u02c2\3\2" + + "\2\2\u02c5\u02c8\3\2\2\2\u02c6\u02c4\3\2\2\2\u02c6\u02c7\3\2\2\2\u02c7" + + "]\3\2\2\2\u02c8\u02c6\3\2\2\2\u02c9\u02cb\7\61\2\2\u02ca\u02c9\3\2\2\2" + + "\u02ca\u02cb\3\2\2\2\u02cb\u02cc\3\2\2\2\u02cc\u02cd\7\64\2\2\u02cd_\3" + + "\2\2\2\u02ce\u02d3\5<\37\2\u02cf\u02d0\7>\2\2\u02d0\u02d2\5<\37\2\u02d1" + + "\u02cf\3\2\2\2\u02d2\u02d5\3\2\2\2\u02d3\u02d1\3\2\2\2\u02d3\u02d4\3\2" + + "\2\2\u02d4a\3\2\2\2\u02d5\u02d3\3\2\2\2\u02d6\u02d8\5\6\4\2\u02d7\u02d6" + + "\3\2\2\2\u02d8\u02db\3\2\2\2\u02d9\u02d7\3\2\2\2\u02d9\u02da\3\2\2\2\u02da" + + "\u02eb\3\2\2\2\u02db\u02d9\3\2\2\2\u02dc\u02de\5<\37\2\u02dd\u02df\7?" + + "\2\2\u02de\u02dd\3\2\2\2\u02de\u02df\3\2\2\2\u02df\u02ec\3\2\2\2\u02e0" + + "\u02e2\5\u0088E\2\u02e1\u02e3\7?\2\2\u02e2\u02e1\3\2\2\2\u02e2\u02e3\3" + + "\2\2\2\u02e3\u02ec\3\2\2\2\u02e4\u02ec\5d\63\2\u02e5\u02ec\5f\64\2\u02e6" + + "\u02ec\5h\65\2\u02e7\u02ec\5j\66\2\u02e8\u02ec\5l\67\2\u02e9\u02ec\5n" + + "8\2\u02ea\u02ec\5p9\2\u02eb\u02dc\3\2\2\2\u02eb\u02e0\3\2\2\2\u02eb\u02e4" + + "\3\2\2\2\u02eb\u02e5\3\2\2\2\u02eb\u02e6\3\2\2\2\u02eb\u02e7\3\2\2\2\u02eb" + + "\u02e8\3\2\2\2\u02eb\u02e9\3\2\2\2\u02eb\u02ea\3\2\2\2\u02ecc\3\2\2\2" + + "\u02ed\u02ee\5\f\7\2\u02ee\u02ef\7?\2\2\u02efe\3\2\2\2\u02f0\u02f1\7(" + + "\2\2\u02f1\u02f2\5<\37\2\u02f2\u02f3\7?\2\2\u02f3g\3\2\2\2\u02f4\u02f5" + + "\7\7\2\2\u02f5\u02f6\5<\37\2\u02f6\u02f7\7?\2\2\u02f7i\3\2\2\2\u02f8\u02f9" + + "\7\64\2\2\u02f9\u02fb\7\67\2\2\u02fa\u02f8\3\2\2\2\u02fa\u02fb\3\2\2\2" + + "\u02fb\u02fc\3\2\2\2\u02fc\u02fd\7\63\2\2\u02fd\u02fe\78\2\2\u02fe\u02ff" + + "\5<\37\2\u02ff\u0300\79\2\2\u0300\u0301\5> \2\u0301k\3\2\2\2\u0302\u0303" + + "\7\64\2\2\u0303\u0305\7\67\2\2\u0304\u0302\3\2\2\2\u0304\u0305\3\2\2\2" + + "\u0305\u0306\3\2\2\2\u0306\u0307\7\23\2\2\u0307\u030a\7\64\2\2\u0308\u0309" + + "\7\67\2\2\u0309\u030b\5\u00a2R\2\u030a\u0308\3\2\2\2\u030a\u030b\3\2\2" + + "\2\u030b\u030c\3\2\2\2\u030c\u030d\7\30\2\2\u030d\u030e\5<\37\2\u030e" + + "\u030f\5> \2\u030fm\3\2\2\2\u0310\u0312\7\b\2\2\u0311\u0313\7\64\2\2\u0312" + + "\u0311\3\2\2\2\u0312\u0313\3\2\2\2\u0313\u0314\3\2\2\2\u0314\u0315\7?" + + "\2\2\u0315o\3\2\2\2\u0316\u0318\7\13\2\2\u0317\u0319\7\64\2\2\u0318\u0317" + + "\3\2\2\2\u0318\u0319\3\2\2\2\u0319\u031a\3\2\2\2\u031a\u031b\7?\2\2\u031b" + + "q\3\2\2\2\u031c\u031e\5\6\4\2\u031d\u031c\3\2\2\2\u031e\u0321\3\2\2\2" + + "\u031f\u031d\3\2\2\2\u031f\u0320\3\2\2\2\u0320\u032c\3\2\2\2\u0321\u031f" + + "\3\2\2\2\u0322\u032d\5\16\b\2\u0323\u032d\5t;\2\u0324\u032d\5v<\2\u0325" + + "\u032d\5\64\33\2\u0326\u032d\5x=\2\u0327\u032d\5\30\r\2\u0328\u032d\5" + + "8\35\2\u0329\u032d\5\20\t\2\u032a\u032d\5\22\n\2\u032b\u032d\5\36\20\2" + + "\u032c\u0322\3\2\2\2\u032c\u0323\3\2\2\2\u032c\u0324\3\2\2\2\u032c\u0325" + + "\3\2\2\2\u032c\u0326\3\2\2\2\u032c\u0327\3\2\2\2\u032c\u0328\3\2\2\2\u032c" + + "\u0329\3\2\2\2\u032c\u032a\3\2\2\2\u032c\u032b\3\2\2\2\u032ds\3\2\2\2" + + "\u032e\u032f\7\24\2\2\u032f\u0330\7\64\2\2\u0330\u0332\78\2\2\u0331\u0333" + + "\5\u009cO\2\u0332\u0331\3\2\2\2\u0332\u0333\3\2\2\2\u0333\u0334\3\2\2" + + "\2\u0334\u0335\79\2\2\u0335\u0336\7\67\2\2\u0336\u0337\5\u00a2R\2\u0337" + + "u\3\2\2\2\u0338\u0339\7$\2\2\u0339\u033a\7)\2\2\u033a\u033b\7\64\2\2\u033b" + + "\u033d\78\2\2\u033c\u033e\5\u009cO\2\u033d\u033c\3\2\2\2\u033d\u033e\3" + + "\2\2\2\u033e\u033f\3\2\2\2\u033f\u0340\79\2\2\u0340w\3\2\2\2\u0341\u0343" + + "\7\33\2\2\u0342\u0344\7\64\2\2\u0343\u0342\3\2\2\2\u0343\u0344\3\2\2\2" + + "\u0344\u0347\3\2\2\2\u0345\u0346\7\67\2\2\u0346\u0348\7\64\2\2\u0347\u0345" + + "\3\2\2\2\u0347\u0348\3\2\2\2\u0348\u0349\3\2\2\2\u0349\u034d\7:\2\2\u034a" + + "\u034c\5z>\2\u034b\u034a\3\2\2\2\u034c\u034f\3\2\2\2\u034d\u034b\3\2\2" + + "\2\u034d\u034e\3\2\2\2\u034e\u0350\3\2\2\2\u034f\u034d\3\2\2\2\u0350\u0351" + + "\7;\2\2\u0351y\3\2\2\2\u0352\u0354\5\6\4\2\u0353\u0352\3\2\2\2\u0354\u0357" + + "\3\2\2\2\u0355\u0353\3\2\2\2\u0355\u0356\3\2\2\2\u0356\u0362\3\2\2\2\u0357" + + "\u0355\3\2\2\2\u0358\u0363\5\16\b\2\u0359\u0363\5\u0084C\2\u035a\u0363" + + "\5\u0086D\2\u035b\u0363\5\24\13\2\u035c\u0363\5\u0088E\2\u035d\u0363\5" + + "|?\2\u035e\u0363\58\35\2\u035f\u0363\5\22\n\2\u0360\u0363\5\f\7\2\u0361" + + "\u0363\5\u008aF\2\u0362\u0358\3\2\2\2\u0362\u0359\3\2\2\2\u0362\u035a" + + "\3\2\2\2\u0362\u035b\3\2\2\2\u0362\u035c\3\2\2\2\u0362\u035d\3\2\2\2\u0362" + + "\u035e\3\2\2\2\u0362\u035f\3\2\2\2\u0362\u0360\3\2\2\2\u0362\u0361\3\2" + + "\2\2\u0363{\3\2\2\2\u0364\u0367\5~@\2\u0365\u0367\5\u0080A\2\u0366\u0364" + + "\3\2\2\2\u0366\u0365\3\2\2\2\u0367}\3\2\2\2\u0368\u0369\7+\2\2\u0369\u036f" + + "\7\64\2\2\u036a\u036c\78\2\2\u036b\u036d\5\u009cO\2\u036c\u036b\3\2\2" + + "\2\u036c\u036d\3\2\2\2\u036d\u036e\3\2\2\2\u036e\u0370\79\2\2\u036f\u036a" + + "\3\2\2\2\u036f\u0370\3\2\2\2\u0370\u0371\3\2\2\2\u0371\u0375\7:\2\2\u0372" + + "\u0374\5\u0082B\2\u0373\u0372\3\2\2\2\u0374\u0377\3\2\2\2\u0375\u0373" + + "\3\2\2\2\u0375\u0376\3\2\2\2\u0376\u0378\3\2\2\2\u0377\u0375\3\2\2\2\u0378" + + "\u0379\7;\2\2\u0379\177\3\2\2\2\u037a\u037b\7\17\2\2\u037b\u037c\7+\2" + + "\2\u037c\u0382\7\64\2\2\u037d\u037f\78\2\2\u037e\u0380\5\u009cO\2\u037f" + + "\u037e\3\2\2\2\u037f\u0380\3\2\2\2\u0380\u0381\3\2\2\2\u0381\u0383\79" + + "\2\2\u0382\u037d\3\2\2\2\u0382\u0383\3\2\2\2\u0383\u0384\3\2\2\2\u0384" + + "\u0385\5> \2\u0385\u0081\3\2\2\2\u0386\u0388\5\6\4\2\u0387\u0386\3\2\2" + + "\2\u0388\u038b\3\2\2\2\u0389\u0387\3\2\2\2\u0389\u038a\3\2\2\2\u038a\u0397" + + "\3\2\2\2\u038b\u0389\3\2\2\2\u038c\u0398\5\16\b\2\u038d\u0398\5\u0084" + + "C\2\u038e\u0398\5\u0086D\2\u038f\u0398\5\24\13\2\u0390\u0398\5|?\2\u0391" + + "\u0398\5\u0088E\2\u0392\u0398\58\35\2\u0393\u0398\5\20\t\2\u0394\u0398" + + "\5\u008aF\2\u0395\u0398\5\22\n\2\u0396\u0398\5\f\7\2\u0397\u038c\3\2\2" + + "\2\u0397\u038d\3\2\2\2\u0397\u038e\3\2\2\2\u0397\u038f\3\2\2\2\u0397\u0390" + + "\3\2\2\2\u0397\u0391\3\2\2\2\u0397\u0392\3\2\2\2\u0397\u0393\3\2\2\2\u0397" + + "\u0394\3\2\2\2\u0397\u0395\3\2\2\2\u0397\u0396\3\2\2\2\u0398\u0083\3\2" + + "\2\2\u0399\u039a\7\16\2\2\u039a\u039b\78\2\2\u039b\u039c\79\2\2\u039c" + + "\u039d\7\66\2\2\u039d\u039e\5<\37\2\u039e\u0085\3\2\2\2\u039f\u03a0\7" + + "\20\2\2\u03a0\u03a1\78\2\2\u03a1\u03a2\79\2\2\u03a2\u03a3\7\66\2\2\u03a3" + + "\u03a4\5<\37\2\u03a4\u0087\3\2\2\2\u03a5\u03a6\7\5\2\2\u03a6\u03a7\78" + + "\2\2\u03a7\u03a8\5<\37\2\u03a8\u03a9\79\2\2\u03a9\u0089\3\2\2\2\u03aa" + + "\u03ae\5\u008cG\2\u03ab\u03ae\5\u0090I\2\u03ac\u03ae\5\u0092J\2\u03ad" + + "\u03aa\3\2\2\2\u03ad\u03ab\3\2\2\2\u03ad\u03ac\3\2\2\2\u03ae\u008b\3\2" + + "\2\2\u03af\u03b0\7\25\2\2\u03b0\u03b1\78\2\2\u03b1\u03b2\5<\37\2\u03b2" + + "\u03b3\79\2\2\u03b3\u03b5\3\2\2\2\u03b4\u03af\3\2\2\2\u03b4\u03b5\3\2" + + "\2\2\u03b5\u03bb\3\2\2\2\u03b6\u03b7\5\u008eH\2\u03b7\u03b8\7@\2\2\u03b8" + + "\u03ba\3\2\2\2\u03b9\u03b6\3\2\2\2\u03ba\u03bd\3\2\2\2\u03bb\u03b9\3\2" + + "\2\2\u03bb\u03bc\3\2\2\2\u03bc\u03be\3\2\2\2\u03bd\u03bb\3\2\2\2\u03be" + + "\u03bf\5\u00a6T\2\u03bf\u03c1\78\2\2\u03c0\u03c2\5\u009cO\2\u03c1\u03c0" + + "\3\2\2\2\u03c1\u03c2\3\2\2\2\u03c2\u03c3\3\2\2\2\u03c3\u03c4\79\2\2\u03c4" + + "\u03c5\7\66\2\2\u03c5\u03c6\5\u0094K\2\u03c6\u008d\3\2\2\2\u03c7\u03d0" + + "\7\64\2\2\u03c8\u03c9\7<\2\2\u03c9\u03cc\5R*\2\u03ca\u03cb\7L\2\2\u03cb" + + "\u03cd\5<\37\2\u03cc\u03ca\3\2\2\2\u03cc\u03cd\3\2\2\2\u03cd\u03ce\3\2" + + "\2\2\u03ce\u03cf\7=\2\2\u03cf\u03d1\3\2\2\2\u03d0\u03c8\3\2\2\2\u03d0" + + "\u03d1\3\2\2\2\u03d1\u008f\3\2\2\2\u03d2\u03d3\7\25\2\2\u03d3\u03d4\7" + + "8\2\2\u03d4\u03d5\5<\37\2\u03d5\u03d6\79\2\2\u03d6\u03d8\3\2\2\2\u03d7" + + "\u03d2\3\2\2\2\u03d7\u03d8\3\2\2\2\u03d8\u03d9\3\2\2\2\u03d9\u03da\7*" + + "\2\2\u03da\u03db\7\66\2\2\u03db\u03dc\5<\37\2\u03dc\u0091\3\2\2\2\u03dd" + + "\u03de\t\n\2\2\u03de\u03df\78\2\2\u03df\u03e0\5<\37\2\u03e0\u03e1\79\2" + + "\2\u03e1\u03e2\7\66\2\2\u03e2\u03e3\5<\37\2\u03e3\u0093\3\2\2\2\u03e4" + + "\u03e8\5<\37\2\u03e5\u03e8\7\26\2\2\u03e6\u03e8\5\u0096L\2\u03e7\u03e4" + + "\3\2\2\2\u03e7\u03e5\3\2\2\2\u03e7\u03e6\3\2\2\2\u03e8\u0095\3\2\2\2\u03e9" + + "\u03ea\7 \2\2\u03ea\u03eb\7:\2\2\u03eb\u03f1\5\u0098M\2\u03ec\u03ed\7" + + "\"\2\2\u03ed\u03ef\5\u0094K\2\u03ee\u03f0\7>\2\2\u03ef\u03ee\3\2\2\2\u03ef" + + "\u03f0\3\2\2\2\u03f0\u03f2\3\2\2\2\u03f1\u03ec\3\2\2\2\u03f1\u03f2\3\2" + + "\2\2\u03f2\u03f3\3\2\2\2\u03f3\u03f4\7;\2\2\u03f4\u0097\3\2\2\2\u03f5" + + "\u03fa\5\u009aN\2\u03f6\u03f7\7>\2\2\u03f7\u03f9\5\u009aN\2\u03f8\u03f6" + + "\3\2\2\2\u03f9\u03fc\3\2\2\2\u03fa\u03f8\3\2\2\2\u03fa\u03fb\3\2\2\2\u03fb" + + "\u03fe\3\2\2\2\u03fc\u03fa\3\2\2\2\u03fd\u03ff\7>\2\2\u03fe\u03fd\3\2" + + "\2\2\u03fe\u03ff\3\2\2\2\u03ff\u0099\3\2\2\2\u0400\u0402\5\6\4\2\u0401" + + "\u0400\3\2\2\2\u0402\u0405\3\2\2\2\u0403\u0401\3\2\2\2\u0403\u0404\3\2" + + "\2\2\u0404\u040b\3\2\2\2\u0405\u0403\3\2\2\2\u0406\u0407\7\25\2\2\u0407" + + "\u0408\78\2\2\u0408\u0409\5<\37\2\u0409\u040a\79\2\2\u040a\u040c\3\2\2" + + "\2\u040b\u0406\3\2\2\2\u040b\u040c\3\2\2\2\u040c\u040d\3\2\2\2\u040d\u040e" + + "\5\u0094K\2\u040e\u009b\3\2\2\2\u040f\u0414\5\u009eP\2\u0410\u0411\7>" + + "\2\2\u0411\u0413\5\u009eP\2\u0412\u0410\3\2\2\2\u0413\u0416\3\2\2\2\u0414" + + "\u0412\3\2\2\2\u0414\u0415\3\2\2\2\u0415\u009d\3\2\2\2\u0416\u0414\3\2" + + "\2\2\u0417\u0419\7\61\2\2\u0418\u0417\3\2\2\2\u0418\u0419\3\2\2\2\u0419" + + "\u041a\3\2\2\2\u041a\u041c\7\64\2\2\u041b\u041d\7N\2\2\u041c\u041b\3\2" + + "\2\2\u041c\u041d\3\2\2\2\u041d\u0420\3\2\2\2\u041e\u041f\7\67\2\2\u041f" + + "\u0421\5\u00a2R\2\u0420\u041e\3\2\2\2\u0420\u0421\3\2\2\2\u0421\u0425" + + "\3\2\2\2\u0422\u0423\7\64\2\2\u0423\u0425\5$\23\2\u0424\u0418\3\2\2\2" + + "\u0424\u0422\3\2\2\2\u0425\u009f\3\2\2\2\u0426\u0427\t\13\2\2\u0427\u00a1" + + "\3\2\2\2\u0428\u0429\bR\1\2\u0429\u042a\78\2\2\u042a\u042b\5\u00a2R\2" + + "\u042b\u042c\79\2\2\u042c\u0447\3\2\2\2\u042d\u0432\5\u00a6T\2\u042e\u042f" + + "\7A\2\2\u042f\u0430\5\u00a4S\2\u0430\u0431\7B\2\2\u0431\u0433\3\2\2\2" + + "\u0432\u042e\3\2\2\2\u0432\u0433\3\2\2\2\u0433\u0436\3\2\2\2\u0434\u0435" + + "\7@\2\2\u0435\u0437\7\64\2\2\u0436\u0434\3\2\2\2\u0436\u0437\3\2\2\2\u0437" + + "\u0447\3\2\2\2\u0438\u0439\78\2\2\u0439\u043a\5\u00a4S\2\u043a\u043b\7" + + "9\2\2\u043b\u043c\7I\2\2\u043c\u043d\5\u00a2R\6\u043d\u0447\3\2\2\2\u043e" + + "\u0447\5\u00a0Q\2\u043f\u0441\7J\2\2\u0440\u0442\t\f\2\2\u0441\u0440\3" + + "\2\2\2\u0441\u0442\3\2\2\2\u0442\u0443\3\2\2\2\u0443\u0447\5\u00a2R\4" + + "\u0444\u0445\7E\2\2\u0445\u0447\5\u00a2R\3\u0446\u0428\3\2\2\2\u0446\u042d" + + "\3\2\2\2\u0446\u0438\3\2\2\2\u0446\u043e\3\2\2\2\u0446\u043f\3\2\2\2\u0446" + + "\u0444\3\2\2\2\u0447\u0450\3\2\2\2\u0448\u0449\f\n\2\2\u0449\u044a\t\5" + + "\2\2\u044a\u044f\5\u00a2R\13\u044b\u044c\f\t\2\2\u044c\u044d\t\6\2\2\u044d" + + "\u044f\5\u00a2R\n\u044e\u0448\3\2\2\2\u044e\u044b\3\2\2\2\u044f\u0452" + + "\3\2\2\2\u0450\u044e\3\2\2\2\u0450\u0451\3\2\2\2\u0451\u00a3\3\2\2\2\u0452" + + "\u0450\3\2\2\2\u0453\u0458\5\u00a2R\2\u0454\u0455\7>\2\2\u0455\u0457\5" + + "\u00a2R\2\u0456\u0454\3\2\2\2\u0457\u045a\3\2\2\2\u0458\u0456\3\2\2\2" + + "\u0458\u0459\3\2\2\2\u0459\u00a5\3\2\2\2\u045a\u0458\3\2\2\2\u045b\u0460" + + "\7\64\2\2\u045c\u045d\7@\2\2\u045d\u045f\7\64\2\2\u045e\u045c\3\2\2\2" + + "\u045f\u0462\3\2\2\2\u0460\u045e\3\2\2\2\u0460\u0461\3\2\2\2\u0461\u00a7" + + "\3\2\2\2\u0462\u0460\3\2\2\2\u0086\u00ab\u00b3\u00c3\u00cb\u00d2\u00d5" + + "\u00d9\u00de\u00e1\u00e6\u00ea\u00ee\u00f3\u00f9\u0101\u0107\u010f\u0117" + + "\u011b\u0126\u0131\u0134\u013a\u0140\u0146\u014c\u0160\u0164\u0169\u016c" + + "\u0173\u017f\u0188\u018c\u0191\u0195\u0199\u019f\u01a2\u01a6\u01ad\u01b6" + + "\u01ba\u01bd\u01c0\u01c7\u01cc\u01d4\u01d7\u01e4\u01f4\u0209\u021d\u022f" + + "\u0231\u0238\u023c\u0247\u024b\u025a\u025d\u0266\u026a\u0275\u0279\u0280" + + "\u0289\u028d\u0296\u029e\u02a5\u02ae\u02b1\u02b6\u02b9\u02bf\u02c6\u02ca" + + "\u02d3\u02d9\u02de\u02e2\u02eb\u02fa\u0304\u030a\u0312\u0318\u031f\u032c" + + "\u0332\u033d\u0343\u0347\u034d\u0355\u0362\u0366\u036c\u036f\u0375\u037f" + + "\u0382\u0389\u0397\u03ad\u03b4\u03bb\u03c1\u03cc\u03d0\u03d7\u03e7\u03ef" + + "\u03f1\u03fa\u03fe\u0403\u040b\u0414\u0418\u041c\u0420\u0424\u0432\u0436" + + "\u0441\u0446\u044e\u0450\u0458\u0460"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } } diff --git a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoVisitor.java b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoVisitor.java index 46d72f6f4e2..809394d9b2c 100644 --- a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoVisitor.java +++ b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/ast/CocoVisitor.java @@ -5,6 +5,7 @@ // CHECKSTYLE:OFF // Generated from net/sourceforge/pmd/lang/coco/ast/Coco.g4 by ANTLR 4.9.3 package net.sourceforge.pmd.lang.coco.ast; + import org.antlr.v4.runtime.tree.ParseTreeVisitor; /** @@ -19,694 +20,803 @@ @Deprecated @net.sourceforge.pmd.annotation.Generated("org.antlr.v4.Tool") - public interface CocoVisitor extends ParseTreeVisitor { - /** - * Visit a parse tree produced by {@link CocoParser#module}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitModule(CocoParser.ModuleContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#declaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitDeclaration(CocoParser.DeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#attribute}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitAttribute(CocoParser.AttributeContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#attributeDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitAttributeDeclaration(CocoParser.AttributeDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#importDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitImportDeclaration(CocoParser.ImportDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#variableDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitVariableDeclaration(CocoParser.VariableDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#enumDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitEnumDeclaration(CocoParser.EnumDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#structDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStructDeclaration(CocoParser.StructDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#typeAliasDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitTypeAliasDeclaration(CocoParser.TypeAliasDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#functionDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFunctionDeclaration(CocoParser.FunctionDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#instanceDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitInstanceDeclaration(CocoParser.InstanceDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#portDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPortDeclaration(CocoParser.PortDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#componentDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitComponentDeclaration(CocoParser.ComponentDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#externalConstantDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExternalConstantDeclaration(CocoParser.ExternalConstantDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#externalTypeDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExternalTypeDeclaration(CocoParser.ExternalTypeDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#externalTypeElement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExternalTypeElement(CocoParser.ExternalTypeElementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#externalFunctionDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExternalFunctionDeclaration(CocoParser.ExternalFunctionDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#genericTypeDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitGenericTypeDeclaration(CocoParser.GenericTypeDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#genericTypes}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitGenericTypes(CocoParser.GenericTypesContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#genericType}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitGenericType(CocoParser.GenericTypeContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#enumElement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitEnumElement(CocoParser.EnumElementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#enumCase}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitEnumCase(CocoParser.EnumCaseContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#caseParameters}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitCaseParameters(CocoParser.CaseParametersContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#caseParameter}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitCaseParameter(CocoParser.CaseParameterContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#structElement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStructElement(CocoParser.StructElementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#fieldDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFieldDeclaration(CocoParser.FieldDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#componentElement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitComponentElement(CocoParser.ComponentElementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#staticMemberDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStaticMemberDeclaration(CocoParser.StaticMemberDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#constructorDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitConstructorDeclaration(CocoParser.ConstructorDeclarationContext ctx); - /** - * Visit a parse tree produced by the {@code IfExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitIfExpression(CocoParser.IfExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code TryOperatorExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitTryOperatorExpression(CocoParser.TryOperatorExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code UnaryOperatorExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitUnaryOperatorExpression(CocoParser.UnaryOperatorExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code OptionalExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitOptionalExpression(CocoParser.OptionalExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code ArithmicOrLogicalExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitArithmicOrLogicalExpression(CocoParser.ArithmicOrLogicalExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code LiteralExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitLiteralExpression(CocoParser.LiteralExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code ArrayLiteralExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitArrayLiteralExpression(CocoParser.ArrayLiteralExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code NondetExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNondetExpression(CocoParser.NondetExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code GroupedExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitGroupedExpression(CocoParser.GroupedExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code BlockExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitBlockExpression(CocoParser.BlockExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code MatchExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMatchExpression(CocoParser.MatchExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code StructLiteralExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStructLiteralExpression(CocoParser.StructLiteralExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code MemberReferenceExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMemberReferenceExpression(CocoParser.MemberReferenceExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code AssignmentExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitAssignmentExpression(CocoParser.AssignmentExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code VariableReferenceExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitVariableReferenceExpression(CocoParser.VariableReferenceExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code ImplicitMemberExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitImplicitMemberExpression(CocoParser.ImplicitMemberExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code ExternalFunction} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExternalFunction(CocoParser.ExternalFunctionContext ctx); - /** - * Visit a parse tree produced by the {@code CastExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitCastExpression(CocoParser.CastExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code StateInvariantExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStateInvariantExpression(CocoParser.StateInvariantExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code CallExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitCallExpression(CocoParser.CallExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code ExternalLiteral} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExternalLiteral(CocoParser.ExternalLiteralContext ctx); - /** - * Visit a parse tree produced by the {@code ArraySubscriptExpression} - * labeled alternative in {@link CocoParser#expression}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitArraySubscriptExpression(CocoParser.ArraySubscriptExpressionContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#blockExpression_}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitBlockExpression_(CocoParser.BlockExpression_Context ctx); - /** - * Visit a parse tree produced by {@link CocoParser#ifExpression_}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitIfExpression_(CocoParser.IfExpression_Context ctx); - /** - * Visit a parse tree produced by {@link CocoParser#matchExpression_}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMatchExpression_(CocoParser.MatchExpression_Context ctx); - /** - * Visit a parse tree produced by {@link CocoParser#nondetExpression_}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNondetExpression_(CocoParser.NondetExpression_Context ctx); - /** - * Visit a parse tree produced by {@link CocoParser#fieldAssignments}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFieldAssignments(CocoParser.FieldAssignmentsContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#fieldAssignment}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFieldAssignment(CocoParser.FieldAssignmentContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#nondetClauses}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNondetClauses(CocoParser.NondetClausesContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#nondetClause}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitNondetClause(CocoParser.NondetClauseContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#matchClauses}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMatchClauses(CocoParser.MatchClausesContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#matchClause}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitMatchClause(CocoParser.MatchClauseContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#pattern}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPattern(CocoParser.PatternContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#enumCasePattern}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitEnumCasePattern(CocoParser.EnumCasePatternContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#idParameterPatterns}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitIdParameterPatterns(CocoParser.IdParameterPatternsContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#idParameterPattern}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitIdParameterPattern(CocoParser.IdParameterPatternContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#variableDeclarationPattern}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitVariableDeclarationPattern(CocoParser.VariableDeclarationPatternContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#parameterPatterns}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitParameterPatterns(CocoParser.ParameterPatternsContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#parameterPattern}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitParameterPattern(CocoParser.ParameterPatternContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#expressions}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExpressions(CocoParser.ExpressionsContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#statement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStatement(CocoParser.StatementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#declarationStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitDeclarationStatement(CocoParser.DeclarationStatementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#returnStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitReturnStatement(CocoParser.ReturnStatementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#becomeStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitBecomeStatement(CocoParser.BecomeStatementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#whileStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitWhileStatement(CocoParser.WhileStatementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#forStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitForStatement(CocoParser.ForStatementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#breakStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitBreakStatement(CocoParser.BreakStatementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#continueStatement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitContinueStatement(CocoParser.ContinueStatementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#portElement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitPortElement(CocoParser.PortElementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#functionInterfaceDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFunctionInterfaceDeclaration(CocoParser.FunctionInterfaceDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#signalDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitSignalDeclaration(CocoParser.SignalDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#stateMachineDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStateMachineDeclaration(CocoParser.StateMachineDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#stateMachineElement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStateMachineElement(CocoParser.StateMachineElementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#stateDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStateDeclaration(CocoParser.StateDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#eventStateDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitEventStateDeclaration(CocoParser.EventStateDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#executionStateDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExecutionStateDeclaration(CocoParser.ExecutionStateDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#eventStateElement}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitEventStateElement(CocoParser.EventStateElementContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#entryFunctionDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitEntryFunctionDeclaration(CocoParser.EntryFunctionDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#exitFunctionDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitExitFunctionDeclaration(CocoParser.ExitFunctionDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#stateInvariant}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitStateInvariant(CocoParser.StateInvariantContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#transitionDeclaration}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitTransitionDeclaration(CocoParser.TransitionDeclarationContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#eventTransition}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitEventTransition(CocoParser.EventTransitionContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#eventSource}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitEventSource(CocoParser.EventSourceContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#spontaneousTransition}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitSpontaneousTransition(CocoParser.SpontaneousTransitionContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#timerTransition}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitTimerTransition(CocoParser.TimerTransitionContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#eventHandler}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitEventHandler(CocoParser.EventHandlerContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#offer}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitOffer(CocoParser.OfferContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#offerClauses}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitOfferClauses(CocoParser.OfferClausesContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#offerClause}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitOfferClause(CocoParser.OfferClauseContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#parameters}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitParameters(CocoParser.ParametersContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#parameter}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitParameter(CocoParser.ParameterContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#literalExpression_}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitLiteralExpression_(CocoParser.LiteralExpression_Context ctx); - /** - * Visit a parse tree produced by the {@code BinaryType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitBinaryType(CocoParser.BinaryTypeContext ctx); - /** - * Visit a parse tree produced by the {@code GroupType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitGroupType(CocoParser.GroupTypeContext ctx); - /** - * Visit a parse tree produced by the {@code FunctionType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitFunctionType(CocoParser.FunctionTypeContext ctx); - /** - * Visit a parse tree produced by the {@code UnaryType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitUnaryType(CocoParser.UnaryTypeContext ctx); - /** - * Visit a parse tree produced by the {@code LiteralType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitLiteralType(CocoParser.LiteralTypeContext ctx); - /** - * Visit a parse tree produced by the {@code TypeReference} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitTypeReference(CocoParser.TypeReferenceContext ctx); - /** - * Visit a parse tree produced by the {@code ReferenceType} - * labeled alternative in {@link CocoParser#type}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitReferenceType(CocoParser.ReferenceTypeContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#types}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitTypes(CocoParser.TypesContext ctx); - /** - * Visit a parse tree produced by {@link CocoParser#dotIdentifierList}. - * @param ctx the parse tree - * @return the visitor result - */ - T visitDotIdentifierList(CocoParser.DotIdentifierListContext ctx); +public interface CocoVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by {@link CocoParser#module}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitModule(CocoParser.ModuleContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#declaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDeclaration(CocoParser.DeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#attribute}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAttribute(CocoParser.AttributeContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#attributeDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAttributeDeclaration(CocoParser.AttributeDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#importDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitImportDeclaration(CocoParser.ImportDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#variableDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitVariableDeclaration(CocoParser.VariableDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#enumDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEnumDeclaration(CocoParser.EnumDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#structDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStructDeclaration(CocoParser.StructDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#typeAliasDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTypeAliasDeclaration(CocoParser.TypeAliasDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#functionDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunctionDeclaration(CocoParser.FunctionDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#instanceDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInstanceDeclaration(CocoParser.InstanceDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#portDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPortDeclaration(CocoParser.PortDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#componentDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitComponentDeclaration(CocoParser.ComponentDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#externalConstantDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExternalConstantDeclaration(CocoParser.ExternalConstantDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#externalTypeDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExternalTypeDeclaration(CocoParser.ExternalTypeDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#externalTypeElement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExternalTypeElement(CocoParser.ExternalTypeElementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#externalFunctionDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExternalFunctionDeclaration(CocoParser.ExternalFunctionDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#genericTypeDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitGenericTypeDeclaration(CocoParser.GenericTypeDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#genericTypes}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitGenericTypes(CocoParser.GenericTypesContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#genericType}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitGenericType(CocoParser.GenericTypeContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#enumElement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEnumElement(CocoParser.EnumElementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#enumCase}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEnumCase(CocoParser.EnumCaseContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#caseParameters}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCaseParameters(CocoParser.CaseParametersContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#caseParameter}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCaseParameter(CocoParser.CaseParameterContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#structElement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStructElement(CocoParser.StructElementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#fieldDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFieldDeclaration(CocoParser.FieldDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#componentElement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitComponentElement(CocoParser.ComponentElementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#staticMemberDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStaticMemberDeclaration(CocoParser.StaticMemberDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#constructorDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitConstructorDeclaration(CocoParser.ConstructorDeclarationContext ctx); + + /** + * Visit a parse tree produced by the {@code IfExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIfExpression(CocoParser.IfExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code TryOperatorExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTryOperatorExpression(CocoParser.TryOperatorExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code UnaryOperatorExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitUnaryOperatorExpression(CocoParser.UnaryOperatorExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code OptionalExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitOptionalExpression(CocoParser.OptionalExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code ArithmicOrLogicalExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArithmicOrLogicalExpression(CocoParser.ArithmicOrLogicalExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code LiteralExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLiteralExpression(CocoParser.LiteralExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code ArrayLiteralExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArrayLiteralExpression(CocoParser.ArrayLiteralExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code NondetExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNondetExpression(CocoParser.NondetExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code GroupedExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitGroupedExpression(CocoParser.GroupedExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code BlockExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBlockExpression(CocoParser.BlockExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code MatchExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMatchExpression(CocoParser.MatchExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code StructLiteralExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStructLiteralExpression(CocoParser.StructLiteralExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code MemberReferenceExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMemberReferenceExpression(CocoParser.MemberReferenceExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code AssignmentExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAssignmentExpression(CocoParser.AssignmentExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code VariableReferenceExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitVariableReferenceExpression(CocoParser.VariableReferenceExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code ImplicitMemberExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitImplicitMemberExpression(CocoParser.ImplicitMemberExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code ExternalFunction} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExternalFunction(CocoParser.ExternalFunctionContext ctx); + + /** + * Visit a parse tree produced by the {@code CastExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCastExpression(CocoParser.CastExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code StateInvariantExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStateInvariantExpression(CocoParser.StateInvariantExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code CallExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCallExpression(CocoParser.CallExpressionContext ctx); + + /** + * Visit a parse tree produced by the {@code ExternalLiteral} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExternalLiteral(CocoParser.ExternalLiteralContext ctx); + + /** + * Visit a parse tree produced by the {@code ArraySubscriptExpression} + * labeled alternative in {@link CocoParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArraySubscriptExpression(CocoParser.ArraySubscriptExpressionContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#blockExpression_}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBlockExpression_(CocoParser.BlockExpression_Context ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#ifExpression_}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIfExpression_(CocoParser.IfExpression_Context ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#matchExpression_}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMatchExpression_(CocoParser.MatchExpression_Context ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#nondetExpression_}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNondetExpression_(CocoParser.NondetExpression_Context ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#fieldAssignments}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFieldAssignments(CocoParser.FieldAssignmentsContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#fieldAssignment}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFieldAssignment(CocoParser.FieldAssignmentContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#nondetClauses}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNondetClauses(CocoParser.NondetClausesContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#nondetClause}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNondetClause(CocoParser.NondetClauseContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#matchClauses}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMatchClauses(CocoParser.MatchClausesContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#matchClause}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitMatchClause(CocoParser.MatchClauseContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#pattern}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPattern(CocoParser.PatternContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#enumCasePattern}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEnumCasePattern(CocoParser.EnumCasePatternContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#idParameterPatterns}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIdParameterPatterns(CocoParser.IdParameterPatternsContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#idParameterPattern}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIdParameterPattern(CocoParser.IdParameterPatternContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#variableDeclarationPattern}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitVariableDeclarationPattern(CocoParser.VariableDeclarationPatternContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#parameterPatterns}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParameterPatterns(CocoParser.ParameterPatternsContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#parameterPattern}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParameterPattern(CocoParser.ParameterPatternContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#expressions}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpressions(CocoParser.ExpressionsContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#statement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStatement(CocoParser.StatementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#declarationStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDeclarationStatement(CocoParser.DeclarationStatementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#returnStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitReturnStatement(CocoParser.ReturnStatementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#becomeStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBecomeStatement(CocoParser.BecomeStatementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#whileStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitWhileStatement(CocoParser.WhileStatementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#forStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitForStatement(CocoParser.ForStatementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#breakStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBreakStatement(CocoParser.BreakStatementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#continueStatement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitContinueStatement(CocoParser.ContinueStatementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#portElement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPortElement(CocoParser.PortElementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#functionInterfaceDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunctionInterfaceDeclaration(CocoParser.FunctionInterfaceDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#signalDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSignalDeclaration(CocoParser.SignalDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#stateMachineDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStateMachineDeclaration(CocoParser.StateMachineDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#stateMachineElement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStateMachineElement(CocoParser.StateMachineElementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#stateDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStateDeclaration(CocoParser.StateDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#eventStateDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEventStateDeclaration(CocoParser.EventStateDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#executionStateDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExecutionStateDeclaration(CocoParser.ExecutionStateDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#eventStateElement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEventStateElement(CocoParser.EventStateElementContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#entryFunctionDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEntryFunctionDeclaration(CocoParser.EntryFunctionDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#exitFunctionDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExitFunctionDeclaration(CocoParser.ExitFunctionDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#stateInvariant}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitStateInvariant(CocoParser.StateInvariantContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#transitionDeclaration}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTransitionDeclaration(CocoParser.TransitionDeclarationContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#eventTransition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEventTransition(CocoParser.EventTransitionContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#eventSource}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEventSource(CocoParser.EventSourceContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#spontaneousTransition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSpontaneousTransition(CocoParser.SpontaneousTransitionContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#timerTransition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTimerTransition(CocoParser.TimerTransitionContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#eventHandler}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitEventHandler(CocoParser.EventHandlerContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#offer}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitOffer(CocoParser.OfferContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#offerClauses}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitOfferClauses(CocoParser.OfferClausesContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#offerClause}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitOfferClause(CocoParser.OfferClauseContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#parameters}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParameters(CocoParser.ParametersContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#parameter}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParameter(CocoParser.ParameterContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#literalExpression_}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLiteralExpression_(CocoParser.LiteralExpression_Context ctx); + + /** + * Visit a parse tree produced by the {@code BinaryType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBinaryType(CocoParser.BinaryTypeContext ctx); + + /** + * Visit a parse tree produced by the {@code GroupType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitGroupType(CocoParser.GroupTypeContext ctx); + + /** + * Visit a parse tree produced by the {@code FunctionType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunctionType(CocoParser.FunctionTypeContext ctx); + + /** + * Visit a parse tree produced by the {@code UnaryType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitUnaryType(CocoParser.UnaryTypeContext ctx); + + /** + * Visit a parse tree produced by the {@code LiteralType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLiteralType(CocoParser.LiteralTypeContext ctx); + + /** + * Visit a parse tree produced by the {@code TypeReference} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTypeReference(CocoParser.TypeReferenceContext ctx); + + /** + * Visit a parse tree produced by the {@code ReferenceType} + * labeled alternative in {@link CocoParser#type}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitReferenceType(CocoParser.ReferenceTypeContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#types}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTypes(CocoParser.TypesContext ctx); + + /** + * Visit a parse tree produced by {@link CocoParser#dotIdentifierList}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDotIdentifierList(CocoParser.DotIdentifierListContext ctx); } diff --git a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/cpd/CocoCpdLexer.java b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/cpd/CocoCpdLexer.java index cda9ab4b7f6..ccdc5ec0329 100644 --- a/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/cpd/CocoCpdLexer.java +++ b/pmd-coco/src/main/java/net/sourceforge/pmd/lang/coco/cpd/CocoCpdLexer.java @@ -15,8 +15,7 @@ */ public class CocoCpdLexer extends AntlrCpdLexer { - @Override - protected Lexer getLexerForSource(CharStream charStream) { + @Override protected Lexer getLexerForSource(CharStream charStream) { return new CocoLexer(charStream); } } diff --git a/pmd-coco/src/test/java/net/sourceforge/pmd/lang/coco/cpd/CocoCpdLexerTest.java b/pmd-coco/src/test/java/net/sourceforge/pmd/lang/coco/cpd/CocoCpdLexerTest.java index 97e1f4d7dc0..cf15b7dc619 100644 --- a/pmd-coco/src/test/java/net/sourceforge/pmd/lang/coco/cpd/CocoCpdLexerTest.java +++ b/pmd-coco/src/test/java/net/sourceforge/pmd/lang/coco/cpd/CocoCpdLexerTest.java @@ -14,13 +14,11 @@ class CocoCpdLexerTest extends CpdTextComparisonTest { super(CocoLanguageModule.getInstance(), ".coco"); } - @Test - void testAnnotatedSource() { + @Test void testAnnotatedSource() { doTest("simple_machine"); } - @Test - void testDocstring() { + @Test void testDocstring() { doTest("enum"); } } diff --git a/pmd-core/pmd-core-checkstyle-suppressions.xml b/pmd-core/pmd-core-checkstyle-suppressions.xml deleted file mode 100644 index dba12802608..00000000000 --- a/pmd-core/pmd-core-checkstyle-suppressions.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/pmd-core/pom.xml b/pmd-core/pom.xml index c6010b9b3c1..4ddeead45b8 100644 --- a/pmd-core/pom.xml +++ b/pmd-core/pom.xml @@ -47,13 +47,6 @@
- - org.apache.maven.plugins - maven-checkstyle-plugin - - pmd-core-checkstyle-suppressions.xml - - diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java index 848203ca3b6..6aa1f846c8e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java @@ -93,7 +93,7 @@ public void setSourceEncoding(Charset sourceEncoding) { void checkLanguageIsRegistered(Language language) { if (!langRegistry.getLanguages().contains(language)) { throw new IllegalArgumentException( - "Language '" + language.getId() + "' is not registered in " + getLanguageRegistry()); + "Language '" + language.getId() + "' is not registered in " + getLanguageRegistry()); } checkLanguageIsAcceptable(language); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java index b2bf76402e6..c7e74991c9c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMDConfiguration.java @@ -405,8 +405,8 @@ void setAnalysisCache(final AnalysisCache cache) { */ public void setAnalysisCacheLocation(final String cacheLocation) { setAnalysisCache(cacheLocation == null - ? new NoopAnalysisCache() - : new FileAnalysisCache(new File(cacheLocation))); + ? new NoopAnalysisCache() + : new FileAnalysisCache(new File(cacheLocation))); } @@ -433,11 +433,10 @@ public boolean isIgnoreIncrementalAnalysis() { return ignoreIncrementalAnalysis; } - @Override - protected void checkLanguageIsAcceptable(Language lang) throws UnsupportedOperationException { + @Override protected void checkLanguageIsAcceptable(Language lang) throws UnsupportedOperationException { if (!(lang instanceof PmdCapableLanguage)) { throw new UnsupportedOperationException("Language " + lang.getId() + " does not support analysis with PMD and cannot be used in a PMDConfiguration. " - + "You may be able to use it with CPD though."); + + "You may be able to use it with CPD though."); } } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java index 985c5e233dc..64e82cf96e6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/PmdAnalysis.java @@ -164,8 +164,8 @@ private PmdAnalysis(PMDConfiguration config) { this.configuration = config; this.reporter = config.getReporter(); this.collector = newCollector( - config.getLanguageVersionDiscoverer(), - reporter + config.getLanguageVersionDiscoverer(), + reporter ); } @@ -392,16 +392,15 @@ void performAnalysisImpl(List extraListen GlobalAnalysisListener listener; try { - @SuppressWarnings("PMD.CloseResource") - AnalysisCacheListener cacheListener = new AnalysisCacheListener(configuration.getAnalysisCache(), - rulesets, - configuration.getClassLoader(), - textFiles); + @SuppressWarnings("PMD.CloseResource") AnalysisCacheListener cacheListener = new AnalysisCacheListener(configuration.getAnalysisCache(), + rulesets, + configuration.getClassLoader(), + textFiles); listener = GlobalAnalysisListener.tee(listOf(createComposedRendererListener(renderers), - GlobalAnalysisListener.tee(listeners), - GlobalAnalysisListener.tee(extraListeners), - cacheListener)); - + GlobalAnalysisListener.tee(listeners), + GlobalAnalysisListener.tee(extraListeners), + cacheListener)); + // Initialize listeners try (ListenerInitializer initializer = listener.initializer()) { initializer.setNumberOfFilesToAnalyze(textFiles.size()); @@ -425,22 +424,22 @@ void performAnalysisImpl(List extraListen encourageToUseIncrementalAnalysis(configuration); try (LanguageProcessorRegistry lpRegistry = LanguageProcessorRegistry.create( - // only start the applicable languages (and dependencies) - new LanguageRegistry(getApplicableLanguages(true)), - langProperties, - reporter + // only start the applicable languages (and dependencies) + new LanguageRegistry(getApplicableLanguages(true)), + langProperties, + reporter )) { // Note the analysis task is shared: all processors see // the same file list, which may contain files for other // languages. AnalysisTask analysisTask = InternalApiBridge.createAnalysisTask( - rulesets, - textFiles, - listener, - configuration.getThreads(), - configuration.getAnalysisCache(), - reporter, - lpRegistry + rulesets, + textFiles, + listener, + configuration.getThreads(), + configuration.getAnalysisCache(), + reporter, + lpRegistry ); List analyses = new ArrayList<>(); @@ -482,9 +481,8 @@ private GlobalAnalysisListener createComposedRendererListener(List ren isAnyIncremental |= !(renderer instanceof AbstractAccumulatingRenderer); try { - @SuppressWarnings("PMD.CloseResource") - GlobalAnalysisListener listener = - Objects.requireNonNull(renderer.newListener(), "Renderer should provide non-null listener"); + @SuppressWarnings("PMD.CloseResource") GlobalAnalysisListener listener = + Objects.requireNonNull(renderer.newListener(), "Renderer should provide non-null listener"); rendererListeners.add(listener); } catch (Exception ioe) { // close listeners so far, throw their close exception or the ioe @@ -533,8 +531,8 @@ private Set getApplicableLanguages(boolean quiet) { if (depLang == null) { // todo maybe report all then throw throw new IllegalStateException( - "Language " + lang.getId() + " has unsatisfied dependencies: " - + depId + " is not found in " + reg + "Language " + lang.getId() + " has unsatisfied dependencies: " + + depId + " is not found in " + reg ); } changed |= languages.add(depLang); @@ -568,7 +566,7 @@ private Set removeBrokenRules(final RuleSets ruleSets) { for (final Rule rule : brokenRules) { reporter.warn("Removed misconfigured rule: {0} cause: {1}", - rule.getName(), rule.dysfunctionReason()); + rule.getName(), rule.dysfunctionReason()); } return brokenRules; @@ -579,8 +577,7 @@ public PmdReporter getReporter() { return reporter; } - @Override - public void close() { + @Override public void close() { if (closed) { return; } @@ -605,8 +602,7 @@ public ReportStats runAndReturnStats() { return ReportStats.empty(); } - @SuppressWarnings("PMD.CloseResource") - ReportStatsListener listener = new ReportStatsListener(); + @SuppressWarnings("PMD.CloseResource") ReportStatsListener listener = new ReportStatsListener(); addListener(listener); @@ -642,12 +638,12 @@ private static void encourageToUseIncrementalAnalysis(final PMDConfiguration con final PmdReporter reporter = configuration.getReporter(); if (!configuration.isIgnoreIncrementalAnalysis() - && configuration.getAnalysisCache() instanceof NoopAnalysisCache - && reporter.isLoggable(Level.WARN)) { + && configuration.getAnalysisCache() instanceof NoopAnalysisCache + && reporter.isLoggable(Level.WARN)) { final String version = - PMDVersion.isUnknown() || PMDVersion.isSnapshot() ? "latest" : "pmd-doc-" + PMDVersion.VERSION; + PMDVersion.isUnknown() || PMDVersion.isSnapshot() ? "latest" : "pmd-doc-" + PMDVersion.VERSION; reporter.warn("This analysis could be faster, please consider using Incremental Analysis: " - + "https://docs.pmd-code.org/{0}/pmd_userdocs_incremental_analysis.html", version); + + "https://docs.pmd-code.org/{0}/pmd_userdocs_incremental_analysis.html", version); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TextTimingReportRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TextTimingReportRenderer.java index 088adf564aa..344cfb1f333 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TextTimingReportRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TextTimingReportRenderer.java @@ -36,8 +36,7 @@ public class TextTimingReportRenderer implements TimingReportRenderer { private static final int COLUMNS = LABEL_COLUMN_WIDTH + TIME_COLUMN_WIDTH + SELF_TIME_COLUMN_WIDTH + CALL_COLUMN_WIDTH + COUNTER_COLUMN_WIDTH; - @Override - public void render(final TimingReport report, final Writer writer0) throws IOException { + @Override public void render(final TimingReport report, final Writer writer0) throws IOException { PrintWriter writer = new PrintWriter(writer0); for (final TimedOperationCategory category : TimedOperationCategory.values()) { final Map labeledMeasurements = report.getLabeledMeasurements(category); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimeTracker.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimeTracker.java index 4c407eb41ba..e149e54f722 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimeTracker.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimeTracker.java @@ -28,14 +28,12 @@ public final class TimeTracker { private static final ConcurrentMap ACCUMULATED_RESULTS = new ConcurrentHashMap<>(); private static final TimedOperation NOOP_TIMED_OPERATION = new TimedOperation() { - @Override - public void close() { + @Override public void close() { // noop } - @Override - public void close(final int count) { - // noop + @Override public void close(final int count) { + // noop } }; @@ -183,8 +181,7 @@ private static class TimerEntry { this.start = System.nanoTime(); } - @Override - public String toString() { + @Override public String toString() { return "TimerEntry for " + operation; } } @@ -237,8 +234,7 @@ public String toString() { this.label = label; } - @Override - public int hashCode() { + @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((category == null) ? 0 : category.hashCode()); @@ -246,8 +242,7 @@ public int hashCode() { return result; } - @Override - public boolean equals(final Object obj) { + @Override public boolean equals(final Object obj) { if (this == obj) { return true; } @@ -261,8 +256,7 @@ public boolean equals(final Object obj) { return category == other.category && Objects.equals(label, other.label); } - @Override - public String toString() { + @Override public String toString() { return "TimedOperationKey [category=" + category + ", label=" + label + "]"; } } @@ -273,13 +267,11 @@ public String toString() { private static final class TimedOperationImpl implements TimedOperation { private boolean closed = false; - @Override - public void close() { + @Override public void close() { close(0); } - @Override - public void close(int extraDataCounter) { + @Override public void close(int extraDataCounter) { if (closed) { return; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperation.java b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperation.java index 74ba7fa6f3f..fea5c1edca1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/benchmark/TimedOperation.java @@ -12,8 +12,7 @@ public interface TimedOperation extends AutoCloseable { /** * Stops tracking if not already stopped. */ - @Override - void close(); + @Override void close(); /** * Stops tracking if not already stopped. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/AbstractAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/AbstractAnalysisCache.java index 76aa6141f9d..bad12a2e2a8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/AbstractAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/AbstractAnalysisCache.java @@ -60,37 +60,35 @@ abstract class AbstractAnalysisCache implements AnalysisCache { pmdVersion = PMDVersion.VERSION; } - @Override - public boolean isUpToDate(final TextDocument document) { + @Override public boolean isUpToDate(final TextDocument document) { try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.ANALYSIS_CACHE, "up-to-date check")) { final AnalysisResult cachedResult = fileResultsCache.get(document.getFileId()); final AnalysisResult updatedResult; // is this a known file? has it changed? final boolean upToDate = cachedResult != null - && cachedResult.getFileChecksum() == document.getCheckSum(); + && cachedResult.getFileChecksum() == document.getCheckSum(); if (upToDate) { LOG.trace("Incremental Analysis cache HIT"); - + // copy results over updatedResult = cachedResult; } else { LOG.trace("Incremental Analysis cache MISS - {}", - cachedResult != null ? "file changed" : "no previous result found"); - + cachedResult != null ? "file changed" : "no previous result found"); + // New file being analyzed, create new empty entry updatedResult = new AnalysisResult(document.getCheckSum(), new ArrayList<>()); } updatedResultsCache.put(document.getFileId(), updatedResult); - + return upToDate; } } - @Override - public List getCachedViolations(final TextDocument sourceFile) { + @Override public List getCachedViolations(final TextDocument sourceFile) { final AnalysisResult analysisResult = fileResultsCache.get(sourceFile.getFileId()); if (analysisResult == null) { @@ -101,8 +99,7 @@ public List getCachedViolations(final TextDocument sourceFile) { return analysisResult.getViolations(); } - @Override - public void analysisFailed(final TextDocument sourceFile) { + @Override public void analysisFailed(final TextDocument sourceFile) { updatedResultsCache.remove(sourceFile.getFileId()); } @@ -114,8 +111,7 @@ public void analysisFailed(final TextDocument sourceFile) { protected abstract boolean cacheExists(); - @Override - public void checkValidity(RuleSets ruleSets, ClassLoader auxclassPathClassLoader, Collection files) { + @Override public void checkValidity(RuleSets ruleSets, ClassLoader auxclassPathClassLoader, Collection files) { try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.ANALYSIS_CACHE, "validity check")) { boolean cacheIsValid = cacheExists(); @@ -168,9 +164,8 @@ private URL[] getClassPathEntries() { final List entries = new ArrayList<>(); final SimpleFileVisitor fileVisitor = new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(final Path file, - final BasicFileAttributes attrs) throws IOException { + @Override public FileVisitResult visitFile(final Path file, + final BasicFileAttributes attrs) throws IOException { if (!attrs.isSymbolicLink()) { // Broken link that can't be followed entries.add(file.toUri().toURL()); } @@ -178,9 +173,8 @@ public FileVisitResult visitFile(final Path file, } }; final SimpleFileVisitor jarFileVisitor = new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(final Path file, - final BasicFileAttributes attrs) throws IOException { + @Override public FileVisitResult visitFile(final Path file, + final BasicFileAttributes attrs) throws IOException { String extension = IOUtil.getFilenameExtension(file.toString()); if ("jar".equalsIgnoreCase(extension)) { fileVisitor.visitFile(file, attrs); @@ -194,12 +188,12 @@ public FileVisitResult visitFile(final Path file, final File f = new File(entry); if (isClassPathWildcard(entry)) { Files.walkFileTree(new File(entry.substring(0, entry.length() - 1)).toPath(), - EnumSet.of(FileVisitOption.FOLLOW_LINKS), 1, jarFileVisitor); + EnumSet.of(FileVisitOption.FOLLOW_LINKS), 1, jarFileVisitor); } else if (f.isFile()) { entries.add(f.toURI().toURL()); } else if (f.exists()) { // ignore non-existing directories Files.walkFileTree(f.toPath(), EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, - fileVisitor); + fileVisitor); } } } catch (final IOException e) { @@ -210,22 +204,19 @@ public FileVisitResult visitFile(final Path file, return entries.toArray(new URL[0]); } - @Override - public FileAnalysisListener startFileAnalysis(TextDocument file) { + @Override public FileAnalysisListener startFileAnalysis(TextDocument file) { final FileId fileName = file.getFileId(); return new FileAnalysisListener() { private boolean failed = false; - @Override - public void onRuleViolation(RuleViolation violation) { + @Override public void onRuleViolation(RuleViolation violation) { if (!failed) { updatedResultsCache.get(fileName).addViolation(violation); } } - @Override - public void onError(ProcessingError error) { + @Override public void onError(ProcessingError error) { failed = true; analysisFailed(file); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/AnalysisCacheListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/AnalysisCacheListener.java index fdd719c6145..f920528898a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/AnalysisCacheListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/AnalysisCacheListener.java @@ -20,19 +20,17 @@ public class AnalysisCacheListener implements GlobalAnalysisListener { private final AnalysisCache cache; public AnalysisCacheListener(AnalysisCache cache, RuleSets ruleSets, ClassLoader classLoader, - Collection textFiles) { + Collection textFiles) { this.cache = cache; cache.checkValidity(ruleSets, classLoader, textFiles); } - @Override - public FileAnalysisListener startFileAnalysis(TextFile file) { + @Override public FileAnalysisListener startFileAnalysis(TextFile file) { // AnalysisCache instances are handled specially in PmdRunnable return FileAnalysisListener.noop(); } - @Override - public void close() throws IOException { + @Override public void close() throws IOException { cache.persist(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/CachedRuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/CachedRuleViolation.java index 732be7d241a..cfa78b56c85 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/CachedRuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/CachedRuleViolation.java @@ -37,10 +37,10 @@ final class CachedRuleViolation implements RuleViolation { private final FileLocation location; private CachedRuleViolation(final CachedRuleMapper mapper, final String description, - final FileId fileFileId, final String ruleClassName, final String ruleName, - final String ruleTargetLanguage, final int beginLine, final int beginColumn, - final int endLine, final int endColumn, - final Map additionalInfo) { + final FileId fileFileId, final String ruleClassName, final String ruleName, + final String ruleTargetLanguage, final int beginLine, final int beginColumn, + final int endLine, final int endColumn, + final Map additionalInfo) { this.mapper = mapper; this.description = description; this.location = FileLocation.range(fileFileId, TextRange2d.range2d(beginLine, beginColumn, endLine, endColumn)); @@ -49,25 +49,21 @@ private CachedRuleViolation(final CachedRuleMapper mapper, final String descript this.ruleTargetLanguage = ruleTargetLanguage; this.additionalInfo = additionalInfo; } - - @Override - public Rule getRule() { + + @Override public Rule getRule() { // The mapper may be initialized after cache is loaded, so use it lazily return mapper.getRuleForClass(ruleClassName, ruleName, ruleTargetLanguage); } - @Override - public String getDescription() { + @Override public String getDescription() { return description; } - @Override - public FileLocation getLocation() { + @Override public FileLocation getLocation() { return location; } - @Override - public Map getAdditionalInfo() { + @Override public Map getAdditionalInfo() { return additionalInfo; } @@ -82,8 +78,8 @@ public Map getAdditionalInfo() { */ /* package */ static CachedRuleViolation loadFromStream( - DataInputStream stream, - FileId fileFileId, CachedRuleMapper mapper) throws IOException { + DataInputStream stream, + FileId fileFileId, CachedRuleMapper mapper) throws IOException { String description = stream.readUTF(); String ruleClassName = stream.readUTF(); @@ -95,7 +91,7 @@ static CachedRuleViolation loadFromStream( int endColumn = stream.readInt(); Map additionalInfo = readAdditionalInfo(stream); return new CachedRuleViolation(mapper, description, fileFileId, ruleClassName, ruleName, ruleTargetLanguage, - beginLine, beginColumn, endLine, endColumn, additionalInfo); + beginLine, beginColumn, endLine, endColumn, additionalInfo); } private static @NonNull Map readAdditionalInfo(DataInputStream stream) throws IOException { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/ClasspathEntryFingerprinter.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/ClasspathEntryFingerprinter.java index be77b1adfbe..f12d8f41757 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/ClasspathEntryFingerprinter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/ClasspathEntryFingerprinter.java @@ -20,7 +20,7 @@ public interface ClasspathEntryFingerprinter { * @return True if this fingerprinter applies, false otherwise */ boolean appliesTo(String fileExtension); - + /** * Adds the given entry fingerprint to the current checksum. * diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/ClasspathFingerprinter.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/ClasspathFingerprinter.java index 691bf2bf9d9..69c8ae23901 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/ClasspathFingerprinter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/ClasspathFingerprinter.java @@ -22,7 +22,7 @@ public class ClasspathFingerprinter { new ZipFileFingerprinter(), new RawFileFingerprinter(), new NoopFingerprinter() // catch-all fingerprinter, MUST be last - )); + )); public long fingerprint(final URL... classpathEntry) { final Adler32 adler32 = new Adler32(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/FileAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/FileAnalysisCache.java index 2fcd061b52e..46c2e9cb0ea 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/FileAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/FileAnalysisCache.java @@ -43,8 +43,7 @@ public FileAnalysisCache(final File cache) { this.cacheFile = cache; } - @Override - public void checkValidity(RuleSets ruleSets, ClassLoader auxclassPathClassLoader, Collection files) { + @Override public void checkValidity(RuleSets ruleSets, ClassLoader auxclassPathClassLoader, Collection files) { // load cached data before checking for validity loadFromFile(cacheFile, files); super.checkValidity(ruleSets, auxclassPathClassLoader, files); @@ -57,15 +56,15 @@ public void checkValidity(RuleSets ruleSets, ClassLoader auxclassPathClassLoader */ private void loadFromFile(final File cacheFile, Collection files) { Map idMap = - files.stream().map(TextFile::getFileId) - .collect(Collectors.toMap(FileId::getUriString, id -> id)); + files.stream().map(TextFile::getFileId) + .collect(Collectors.toMap(FileId::getUriString, id -> id)); try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.ANALYSIS_CACHE, "load")) { if (cacheExists()) { try ( DataInputStream inputStream = new DataInputStream( - new BufferedInputStream(Files.newInputStream(cacheFile.toPath()))); - ) { + new BufferedInputStream(Files.newInputStream(cacheFile.toPath()))); + ) { final String cacheVersion = inputStream.readUTF(); if (PMDVersion.VERSION.equals(cacheVersion)) { @@ -82,7 +81,7 @@ private void loadFromFile(final File cacheFile, Collection f FileId fileId = idMap.get(filePathId); if (fileId == null) { LOG.debug("File {} is in the cache but is not part of the analysis", - filePathId); + filePathId); fileId = FileId.fromURI(filePathId); } final long checksum = inputStream.readLong(); @@ -111,8 +110,7 @@ private void loadFromFile(final File cacheFile, Collection f } } - @Override - public void persist() { + @Override public void persist() { try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.ANALYSIS_CACHE, "persist")) { if (cacheFile.isDirectory()) { LOG.error("Cannot persist the cache, the given path points to a directory."); @@ -131,8 +129,8 @@ public void persist() { try ( DataOutputStream outputStream = new DataOutputStream( - new BufferedOutputStream(Files.newOutputStream(cacheFile.toPath()))) - ) { + new BufferedOutputStream(Files.newOutputStream(cacheFile.toPath()))) + ) { outputStream.writeUTF(pmdVersion); outputStream.writeLong(rulesetChecksum); @@ -161,8 +159,7 @@ public void persist() { } } - @Override - protected boolean cacheExists() { + @Override protected boolean cacheExists() { return cacheFile.exists() && cacheFile.isFile() && cacheFile.length() > 0; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/NoopAnalysisCache.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/NoopAnalysisCache.java index da030a4317e..65e42bd4a0f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/NoopAnalysisCache.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/NoopAnalysisCache.java @@ -19,33 +19,27 @@ */ public class NoopAnalysisCache implements AnalysisCache { - @Override - public void persist() { + @Override public void persist() { // noop } - @Override - public boolean isUpToDate(final TextDocument document) { + @Override public boolean isUpToDate(final TextDocument document) { return false; } - @Override - public void analysisFailed(final TextDocument sourceFile) { + @Override public void analysisFailed(final TextDocument sourceFile) { // noop } - @Override - public void checkValidity(RuleSets ruleSets, ClassLoader auxclassPathClassLoader, Collection files) { + @Override public void checkValidity(RuleSets ruleSets, ClassLoader auxclassPathClassLoader, Collection files) { // noop } - @Override - public List getCachedViolations(TextDocument sourceFile) { + @Override public List getCachedViolations(TextDocument sourceFile) { return Collections.emptyList(); } - @Override - public FileAnalysisListener startFileAnalysis(TextDocument filename) { + @Override public FileAnalysisListener startFileAnalysis(TextDocument filename) { return FileAnalysisListener.noop(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/NoopFingerprinter.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/NoopFingerprinter.java index 7cdc1eecec7..fca2664bd06 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/NoopFingerprinter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/NoopFingerprinter.java @@ -17,13 +17,11 @@ public class NoopFingerprinter implements ClasspathEntryFingerprinter { private static final Logger LOG = LoggerFactory.getLogger(NoopFingerprinter.class); - @Override - public boolean appliesTo(String fileExtension) { + @Override public boolean appliesTo(String fileExtension) { return true; } - @Override - public void fingerprint(URL entry, Checksum checksum) throws IOException { + @Override public void fingerprint(URL entry, Checksum checksum) throws IOException { // noop LOG.debug("Ignoring classpath entry {}", entry); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinter.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinter.java index 50ce1984889..ac187b40364 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinter.java @@ -22,24 +22,22 @@ * Base fingerprinter for raw files. */ public class RawFileFingerprinter implements ClasspathEntryFingerprinter { - + private static final Logger LOG = LoggerFactory.getLogger(RawFileFingerprinter.class); - + private static final Set SUPPORTED_EXTENSIONS; - + static { final Set extensions = new HashSet<>(); extensions.add("class"); // Java class files SUPPORTED_EXTENSIONS = Collections.unmodifiableSet(extensions); } - @Override - public boolean appliesTo(String fileExtension) { + @Override public boolean appliesTo(String fileExtension) { return SUPPORTED_EXTENSIONS.contains(fileExtension); } - @Override - public void fingerprint(URL entry, Checksum checksum) throws IOException { + @Override public void fingerprint(URL entry, Checksum checksum) throws IOException { try (CheckedInputStream inputStream = new CheckedInputStream(entry.openStream(), checksum)) { // Just read it, the CheckedInputStream will update the checksum on its own while (IOUtil.skipFully(inputStream, Long.MAX_VALUE) == Long.MAX_VALUE) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/ZipFileFingerprinter.java b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/ZipFileFingerprinter.java index 826ce01fc6f..a98c27be490 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/ZipFileFingerprinter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cache/internal/ZipFileFingerprinter.java @@ -37,8 +37,7 @@ public class ZipFileFingerprinter implements ClasspathEntryFingerprinter { private static final Comparator FILE_NAME_COMPARATOR = new Comparator() { - @Override - public int compare(ZipEntry o1, ZipEntry o2) { + @Override public int compare(ZipEntry o1, ZipEntry o2) { return o1.getName().compareTo(o2.getName()); } }; @@ -54,13 +53,11 @@ public int compare(ZipEntry o1, ZipEntry o2) { SUPPORTED_ENTRY_EXTENSIONS = Collections.unmodifiableSet(entryExtensions); } - @Override - public boolean appliesTo(String fileExtension) { + @Override public boolean appliesTo(String fileExtension) { return SUPPORTED_EXTENSIONS.contains(fileExtension); } - @Override - public void fingerprint(URL entry, Checksum checksum) throws IOException { + @Override public void fingerprint(URL entry, Checksum checksum) throws IOException { try (ZipFile zip = new ZipFile(new File(entry.toURI()))) { final List meaningfulEntries = getMeaningfulEntries(zip); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AnyCpdLexer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AnyCpdLexer.java index db0988c0ffd..a122b08aebf 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AnyCpdLexer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/AnyCpdLexer.java @@ -29,12 +29,12 @@ public class AnyCpdLexer implements CpdLexer { private static Pattern makePattern(String singleLineCommentStart) { return Pattern.compile( - "\\w++" // either a word - + eolCommentFragment(singleLineCommentStart) // a comment - + "|[^\"'\\s]" // a single separator char - + "|\"(?:[^\"\\\\]++|\\\\.)*+\"" // a double-quoted string - + "|'(?:[^'\\\\]++|\\\\.)*+'" // a single-quoted string - + "|\n" // or a newline (to count lines), note that sourcecode normalizes line endings + "\\w++" // either a word + + eolCommentFragment(singleLineCommentStart) // a comment + + "|[^\"'\\s]" // a single separator char + + "|\"(?:[^\"\\\\]++|\\\\.)*+\"" // a double-quoted string + + "|'(?:[^'\\\\]++|\\\\.)*+'" // a single-quoted string + + "|\n" // or a newline (to count lines), note that sourcecode normalizes line endings ); } @@ -62,8 +62,7 @@ private static String eolCommentFragment(String start) { } } - @Override - public void tokenize(TextDocument document, TokenFactory tokens) { + @Override public void tokenize(TextDocument document, TokenFactory tokens) { Chars text = document.getText(); Matcher matcher = pattern.matcher(text); int lineNo = 1; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java index 8c63ae32527..b4bf12c00d9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDConfiguration.java @@ -85,8 +85,7 @@ public CPDConfiguration(LanguageRegistry languageRegistry) { super(languageRegistry, new SimpleMessageReporter(LoggerFactory.getLogger(CpdAnalysis.class))); } - @Override - public void setSourceEncoding(Charset sourceEncoding) { + @Override public void setSourceEncoding(Charset sourceEncoding) { super.setSourceEncoding(sourceEncoding); if (cpdReportRenderer != null) { setRendererEncoding(cpdReportRenderer, sourceEncoding); @@ -233,8 +232,7 @@ public void setIgnoreIdentifierAndLiteralSequences(boolean ignoreIdentifierAndLi * @deprecated This option will be removed. With {@link #isFailOnError()}, you can * control whether lexical errors should fail the build or not. */ - @Deprecated - public boolean isSkipLexicalErrors() { + @Deprecated public boolean isSkipLexicalErrors() { return skipLexicalErrors; } @@ -242,8 +240,7 @@ public boolean isSkipLexicalErrors() { * @deprecated This option will be removed. With {@link #setFailOnError(boolean)}, you can * control whether lexical errors should fail the build or not. */ - @Deprecated - public void setSkipLexicalErrors(boolean skipLexicalErrors) { + @Deprecated public void setSkipLexicalErrors(boolean skipLexicalErrors) { this.skipLexicalErrors = skipLexicalErrors; } @@ -271,11 +268,10 @@ public void setSkipBlocksPattern(String skipBlocksPattern) { this.skipBlocksPattern = skipBlocksPattern; } - @Override - protected void checkLanguageIsAcceptable(Language lang) throws UnsupportedOperationException { + @Override protected void checkLanguageIsAcceptable(Language lang) throws UnsupportedOperationException { if (!(lang instanceof CpdCapableLanguage)) { throw new UnsupportedOperationException("Language " + lang.getId() + " does not support analysis with CPD and cannot be used in a CPDConfiguration. " - + "You may be able to use it with PMD though."); + + "You may be able to use it with PMD though."); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDNullListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDNullListener.java index 3566a9a6cf3..f93e4b8cbeb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDNullListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDNullListener.java @@ -5,13 +5,11 @@ package net.sourceforge.pmd.cpd; public class CPDNullListener implements CPDListener { - @Override - public void addedFile(int fileCount) { + @Override public void addedFile(int fileCount) { // does nothing - override it if necessary } - @Override - public void phaseUpdate(int phase) { + @Override public void phaseUpdate(int phase) { // does nothing - override it if necessary } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDReport.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDReport.java index 50bbf6ccaae..c350e4e3c79 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDReport.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CPDReport.java @@ -28,9 +28,9 @@ public class CPDReport { private final List processingErrors; CPDReport(SourceManager sourceManager, - List matches, - Map numberOfTokensPerFile, - List processingErrors) { + List matches, + Map numberOfTokensPerFile, + List processingErrors) { this.sourceManager = sourceManager; this.matches = Collections.unmodifiableList(matches); this.numberOfTokensPerFile = Collections.unmodifiableMap(new TreeMap<>(numberOfTokensPerFile)); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CSVRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CSVRenderer.java index f68e1c4c6e2..072a5293b78 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CSVRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CSVRenderer.java @@ -80,8 +80,7 @@ public CSVRenderer(char separatorChar, boolean lineCountPerFile) { this.lineCountPerFile = lineCountPerFile; } - @Override - public void render(CPDReport report, Writer writer) throws IOException { + @Override public void render(CPDReport report, Writer writer) throws IOException { if (!lineCountPerFile) { writer.append("lines").append(separator); } @@ -92,8 +91,8 @@ public void render(CPDReport report, Writer writer) throws IOException { writer.append(String.valueOf(match.getLineCount())).append(separator); } writer.append(String.valueOf(match.getTokenCount())).append(separator) - .append(String.valueOf(match.getMarkCount())).append(separator); - for (Iterator marks = match.iterator(); marks.hasNext();) { + .append(String.valueOf(match.getMarkCount())).append(separator); + for (Iterator marks = match.iterator(); marks.hasNext(); ) { Mark mark = marks.next(); FileLocation loc = mark.getLocation(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CpdAnalysis.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CpdAnalysis.java index acd2b7a5e1f..5e03310a585 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CpdAnalysis.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CpdAnalysis.java @@ -86,8 +86,8 @@ private CpdAnalysis(CPDConfiguration config) { this.configuration = config; this.reporter = config.getReporter(); this.files = InternalApiBridge.newCollector( - config.getLanguageVersionDiscoverer(), - reporter + config.getLanguageVersionDiscoverer(), + reporter ); this.renderer = config.getCPDReportRenderer(); @@ -152,7 +152,8 @@ private int doTokenize(TextDocument document, CpdLexer cpdLexer, Tokens tokens) } public void performAnalysis() { - performAnalysis(r -> { }); + performAnalysis(r -> { + }); } public void performAnalysis(Consumer consumer) { @@ -238,8 +239,7 @@ private Tokens tokenizeFiles(SourceManager sourceManager) { return tokens; } - @Override - public void close() throws IOException { + @Override public void close() throws IOException { // nothing for now } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CpdLanguageProperties.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CpdLanguageProperties.java index 3561653edf5..b71dc29704b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CpdLanguageProperties.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/CpdLanguageProperties.java @@ -18,33 +18,33 @@ private CpdLanguageProperties() { } public static final PropertyDescriptor CPD_IGNORE_LITERAL_SEQUENCES = - PropertyFactory.booleanProperty("cpdIgnoreLiteralSequences") - .defaultValue(false) - .desc("Ignore sequences of literals, eg `0, 0, 0, 0`") - .build(); + PropertyFactory.booleanProperty("cpdIgnoreLiteralSequences") + .defaultValue(false) + .desc("Ignore sequences of literals, eg `0, 0, 0, 0`") + .build(); public static final PropertyDescriptor CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES = - PropertyFactory.booleanProperty("cpdIgnoreLiteralAndIdentifierSequences") - .defaultValue(false) - .desc("Ignore sequences of literals and identifiers, eg `a, b, 0, 0`") - .build(); + PropertyFactory.booleanProperty("cpdIgnoreLiteralAndIdentifierSequences") + .defaultValue(false) + .desc("Ignore sequences of literals and identifiers, eg `a, b, 0, 0`") + .build(); public static final PropertyDescriptor CPD_ANONYMIZE_LITERALS = - PropertyFactory.booleanProperty("cpdAnonymizeLiterals") - .defaultValue(false) - .desc("Anonymize literals. They are still part of the token stream but all literals appear to have the same value.") - .build(); + PropertyFactory.booleanProperty("cpdAnonymizeLiterals") + .defaultValue(false) + .desc("Anonymize literals. They are still part of the token stream but all literals appear to have the same value.") + .build(); public static final PropertyDescriptor CPD_ANONYMIZE_IDENTIFIERS = - PropertyFactory.booleanProperty("cpdAnonymizeIdentifiers") - .defaultValue(false) - .desc("Anonymize identifiers. They are still part of the token stream but all identifiers appear to have the same value.") - .build(); + PropertyFactory.booleanProperty("cpdAnonymizeIdentifiers") + .defaultValue(false) + .desc("Anonymize identifiers. They are still part of the token stream but all identifiers appear to have the same value.") + .build(); public static final PropertyDescriptor CPD_IGNORE_IMPORTS = - PropertyFactory.booleanProperty("cpdIgnoreImports") - .defaultValue(true) - .desc("Ignore import statements and equivalent (eg using statements in C#).") - .build(); + PropertyFactory.booleanProperty("cpdIgnoreImports") + .defaultValue(true) + .desc("Ignore import statements and equivalent (eg using statements in C#).") + .build(); public static final PropertyDescriptor CPD_IGNORE_METADATA = - PropertyFactory.booleanProperty("cpdIgnoreMetadata") - .defaultValue(false) - .desc("Ignore metadata such as Java annotations or C# attributes.") - .build(); + PropertyFactory.booleanProperty("cpdIgnoreMetadata") + .defaultValue(false) + .desc("Ignore metadata such as Java annotations or C# attributes.") + .build(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/GUI.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/GUI.java index 91e1bb8fe6d..f1de6f6c9f8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/GUI.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/GUI.java @@ -77,10 +77,10 @@ public class GUI implements CPDListener { private static final Object[][] RENDERER_SETS = { - { "Text", new SimpleRenderer(), }, - { "XML", new XMLRenderer(), }, - { "CSV (comma)", new CSVRenderer(','), }, - { "CSV (tab)", new CSVRenderer('\t'), }, }; + {"Text", new SimpleRenderer(), }, + {"XML", new XMLRenderer(), }, + {"CSV (comma)", new CSVRenderer(','), }, + {"CSV (tab)", new CSVRenderer('\t'), }, }; private abstract static class LanguageConfig { @@ -126,24 +126,20 @@ public boolean canIgnoreIdentifierAndLiteralSequences() { private static final LanguageConfig CUSTOM_EXTENSION_LANG = new LanguageConfig() { private String extension = "custom_ext"; - @Override - void setExtension(String extension) { + @Override void setExtension(String extension) { this.extension = extension; } - @Override - boolean canUseCustomExtension() { + @Override boolean canUseCustomExtension() { return true; } - @Override - public Language getLanguage() { + @Override public Language getLanguage() { return new CpdOnlyLanguageModuleBase( - LanguageMetadata.withId("custom_extension") - .extensions(extension) - .name("By extension...")) { - @Override - public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { + LanguageMetadata.withId("custom_extension") + .extensions(extension) + .name("By extension...")) { + @Override public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { return new AnyCpdLexer(); } }; @@ -154,8 +150,7 @@ public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { static { List languages = new ArrayList<>(); LanguageRegistry.CPD.getLanguages().stream().map(l -> new LanguageConfig() { - @Override - public Language getLanguage() { + @Override public Language getLanguage() { return l; } }).forEach(languages::add); @@ -167,9 +162,9 @@ public Language getLanguage() { private static final int DEFAULT_CPD_MINIMUM_LENGTH = 75; private static final Map LANGUAGE_CONFIGS_BY_LABEL = - CollectionUtil.associateBy(LANGUAGE_SETS, l -> l.getLanguage().getName()); + CollectionUtil.associateBy(LANGUAGE_SETS, l -> l.getLanguage().getName()); private static final KeyStroke COPY_KEY_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, - false); + false); private static final KeyStroke DELETE_KEY_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0); private static class ColumnSpec { @@ -205,9 +200,9 @@ public Comparator sorter() { public static final Comparator LABEL_COMPARATOR = Comparator.comparing(GUI::getLabel); private final ColumnSpec[] matchColumns = { - new ColumnSpec("Source", SwingConstants.LEFT, -1, LABEL_COMPARATOR), - new ColumnSpec("Matches", SwingConstants.RIGHT, 60, Match.MATCHES_COMPARATOR), - new ColumnSpec("Lines", SwingConstants.RIGHT, 45, Match.LINES_COMPARATOR), }; + new ColumnSpec("Source", SwingConstants.LEFT, -1, LABEL_COMPARATOR), + new ColumnSpec("Matches", SwingConstants.RIGHT, 60, Match.MATCHES_COMPARATOR), + new ColumnSpec("Lines", SwingConstants.RIGHT, 45, Match.LINES_COMPARATOR), }; private static LanguageConfig languageConfigFor(String label) { return LANGUAGE_CONFIGS_BY_LABEL.get(label); @@ -222,8 +217,7 @@ private ExitAction(Runnable cleanupTask) { this.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_X); } - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { if (cleanupTask != null) { try { cleanupTask.run(); @@ -236,8 +230,7 @@ public void actionPerformed(ActionEvent e) { } private final class GoListener implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { new Thread(() -> { tokenizingFilesBar.setValue(0); tokenizingFilesBar.setString(""); @@ -257,8 +250,7 @@ private class SaveListener implements ActionListener { renderer = theRenderer; } - @Override - public void actionPerformed(ActionEvent evt) { + @Override public void actionPerformed(ActionEvent evt) { JFileChooser fcSave = new JFileChooser(); int ret = fcSave.showSaveDialog(GUI.this.frame); File f = fcSave.getSelectedFile(); @@ -290,8 +282,7 @@ private void error(String message, Exception e) { } private final class BrowseListener implements ActionListener { - @Override - public void actionPerformed(ActionEvent e) { + @Override public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(rootDirectoryField.getText()); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fc.showDialog(frame, "Select"); @@ -309,8 +300,7 @@ private static class AlignmentRenderer extends DefaultTableCellRenderer { alignments = theAlignments; } - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); @@ -410,8 +400,7 @@ public GUI() { frame.getContentPane().add(topPanel, BorderLayout.NORTH); frame.getContentPane().add(resultsPanel, BorderLayout.CENTER); frame.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { + @Override public void windowClosing(WindowEvent e) { closeSourceManager(); System.exit(0); } @@ -440,7 +429,7 @@ private void adjustLanguageControlsFor(LanguageConfig current) { private JPanel makeSettingsPanel(JButton browseButton, JButton goButton, JButton cxButton) { JPanel settingsPanel = new JPanel(); - GridBagHelper helper = new GridBagHelper(settingsPanel, new double[] { 0.2, 0.7, 0.1, 0.1 }); + GridBagHelper helper = new GridBagHelper(settingsPanel, new double[]{0.2, 0.7, 0.1, 0.1}); helper.addLabel("Root source directory:"); helper.add(rootDirectoryField); helper.add(browseButton, 2); @@ -515,7 +504,7 @@ private JPanel makeSettingsPanel(JButton browseButton, JButton goButton, JButton private JPanel makeProgressPanel() { JPanel progressPanel = new JPanel(); - final double[] weights = { 0.0, 0.8, 0.4, 0.2 }; + final double[] weights = {0.0, 0.8, 0.4, 0.2}; GridBagHelper helper = new GridBagHelper(progressPanel, weights); helper.addLabel("Tokenizing files:"); helper.add(tokenizingFilesBar, 3); @@ -606,8 +595,7 @@ private JComponent makeMatchList() { final JTableHeader header = resultsTable.getTableHeader(); header.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { + @Override public void mouseClicked(MouseEvent e) { sortOnColumn(header.columnAtPoint(new Point(e.getX(), e.getY()))); } }); @@ -642,7 +630,7 @@ private void go() { File dirPath = new File(rootDirectoryField.getText()); if (!dirPath.exists()) { JOptionPane.showMessageDialog(frame, "Can't read from that root source directory", "Error", - JOptionPane.ERROR_MESSAGE); + JOptionPane.ERROR_MESSAGE); return; } @@ -685,7 +673,7 @@ private void go() { String reportString = new SimpleRenderer().renderToString(report); if (reportString.isEmpty()) { JOptionPane.showMessageDialog(frame, - "Done. Couldn't find any duplicates longer than " + minimumLengthField.getText() + " tokens"); + "Done. Couldn't find any duplicates longer than " + minimumLengthField.getText() + " tokens"); } else { resultsTextArea.setText(reportString); } @@ -714,8 +702,7 @@ private void prepareNewSourceManager(CPDConfiguration config, Path dirPath, bool // fileCollector itself is empty, contains no closable resources. // the created sourceManager will be closed when exiting or when a new analysis is started, // see #closeSourceManager(). - @SuppressWarnings("PMD.CloseResource") - FileCollector fileCollector = InternalApiBridge.newCollector(config.getLanguageVersionDiscoverer(), config.getReporter()); + @SuppressWarnings("PMD.CloseResource") FileCollector fileCollector = InternalApiBridge.newCollector(config.getLanguageVersionDiscoverer(), config.getReporter()); fileCollector.addFileOrDirectory(dirPath, recurse); sourceManager = new SourceManager(fileCollector.getCollectedFiles()); } catch (Exception e) { @@ -770,70 +757,59 @@ private TableModel tableModelFrom(final List items) { private int sortColumn; private boolean sortDescending; - @Override - public Object getValueAt(int rowIndex, int columnIndex) { + @Override public Object getValueAt(int rowIndex, int columnIndex) { Match match = items.get(rowIndex); switch (columnIndex) { - case 0: - return getLabel(match); - case 2: - return Integer.toString(match.getLineCount()); - case 1: - return match.getMarkCount() > 2 ? Integer.toString(match.getMarkCount()) : ""; - case 99: - return match; - default: - return ""; + case 0: + return getLabel(match); + case 2: + return Integer.toString(match.getLineCount()); + case 1: + return match.getMarkCount() > 2 ? Integer.toString(match.getMarkCount()) : ""; + case 99: + return match; + default: + return ""; } } - @Override - public int getColumnCount() { + @Override public int getColumnCount() { return matchColumns.length; } - @Override - public int getRowCount() { + @Override public int getRowCount() { return items.size(); } - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { + @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } - @Override - public Class getColumnClass(int columnIndex) { + @Override public Class getColumnClass(int columnIndex) { return Object.class; } - @Override - public String getColumnName(int i) { + @Override public String getColumnName(int i) { return matchColumns[i].label(); } - @Override - public int sortColumn() { + @Override public int sortColumn() { return sortColumn; } - @Override - public void sortColumn(int column) { + @Override public void sortColumn(int column) { sortColumn = column; } - @Override - public boolean sortDescending() { + @Override public boolean sortDescending() { return sortDescending; } - @Override - public void sortDescending(boolean flag) { + @Override public void sortDescending(boolean flag) { sortDescending = flag; } - @Override - public void sort(Comparator comparator) { + @Override public void sort(Comparator comparator) { if (sortDescending) { comparator = comparator.reversed(); } @@ -875,33 +851,32 @@ private void setListDataFrom(List matches) { } // CPDListener - @Override - public void phaseUpdate(int phase) { + @Override public void phaseUpdate(int phase) { phaseLabel.setText(getPhaseText(phase)); } public String getPhaseText(int phase) { switch (phase) { - case CPDListener.INIT: - return "Initializing"; - case CPDListener.HASH: - return "Hashing"; - case CPDListener.MATCH: - return "Matching"; - case CPDListener.GROUPING: - return "Grouping"; - case CPDListener.DONE: - return "Done"; - default: - return "Unknown"; - } - } - - @Override - public void addedFile(int fileCount) { + case CPDListener.INIT: + return "Initializing"; + case CPDListener.HASH: + return "Hashing"; + case CPDListener.MATCH: + return "Matching"; + case CPDListener.GROUPING: + return "Grouping"; + case CPDListener.DONE: + return "Done"; + default: + return "Unknown"; + } + } + + @Override public void addedFile(int fileCount) { tokenizingFilesBar.setMaximum(fileCount); tokenizingFilesBar.setValue(tokenizingFilesBar.getValue() + 1); } + // CPDListener public static void main(String[] args) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Mark.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Mark.java index df163e59fc7..752f3130baa 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Mark.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Mark.java @@ -41,9 +41,9 @@ public final class Mark implements Comparable { public FileLocation getLocation() { TokenEntry endToken = getEndToken(); return FileLocation.range( - getFileId(), - TextRange2d.range2d(token.getBeginLine(), token.getBeginColumn(), - endToken.getEndLine(), endToken.getEndColumn())); + getFileId(), + TextRange2d.range2d(token.getBeginLine(), token.getBeginColumn(), + endToken.getEndLine(), endToken.getEndColumn())); } FileId getFileId() { @@ -60,21 +60,19 @@ public int getEndTokenIndex() { void setEndToken(@NonNull TokenEntry endToken) { assert endToken.getFileId().equals(token.getFileId()) - : "Tokens are not from the same file"; + : "Tokens are not from the same file"; this.endToken = endToken; } - @Override - public int hashCode() { + @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + token.hashCode(); return result; } - @Override - public boolean equals(Object obj) { + @Override public boolean equals(Object obj) { if (this == obj) { return true; } @@ -86,11 +84,10 @@ public boolean equals(Object obj) { } Mark other = (Mark) obj; return Objects.equals(token, other.token) - && Objects.equals(endToken, other.endToken); + && Objects.equals(endToken, other.endToken); } - @Override - public int compareTo(Mark other) { + @Override public int compareTo(Mark other) { return getToken().compareTo(other.getToken()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Match.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Match.java index 0480922f902..05c7f84bc92 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Match.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Match.java @@ -54,13 +54,11 @@ public Set getMarkSet() { return Collections.unmodifiableSet(markSet); } - @Override - public Iterator iterator() { + @Override public Iterator iterator() { return markSet.iterator(); } - @Override - public int compareTo(Match other) { + @Override public int compareTo(Match other) { int diff = other.getTokenCount() - getTokenCount(); if (diff != 0) { return diff; @@ -76,8 +74,7 @@ public Mark getSecondMark() { return getMark(1); } - @Override - public String toString() { + @Override public String toString() { return "Match: \ntokenCount = " + tokenCount + "\nmarks = " + markSet.size(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SimpleRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SimpleRenderer.java index d7d2e6e2290..161c3b440e5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SimpleRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SimpleRenderer.java @@ -33,8 +33,7 @@ public SimpleRenderer(String theSeparator) { separator = theSeparator; } - @Override - public void render(CPDReport report, Writer writer0) throws IOException { + @Override public void render(CPDReport report, Writer writer0) throws IOException { PrintWriter writer = new PrintWriter(writer0); Iterator matches = report.getMatches().iterator(); if (matches.hasNext()) { @@ -52,14 +51,14 @@ public void render(CPDReport report, Writer writer0) throws IOException { private void renderOn(CPDReport report, PrintWriter writer, Match match) throws IOException { writer.append("Found a ").append(String.valueOf(match.getLineCount())).append(" line (").append(String.valueOf(match.getTokenCount())) - .append(" tokens) duplication in the following files: ").println(); + .append(" tokens) duplication in the following files: ").println(); for (Mark mark : match) { FileLocation loc = mark.getLocation(); writer.append("Starting at line ") - .append(String.valueOf(loc.getStartLine())) - .append(" of ").append(report.getDisplayName(loc.getFileId())) - .println(); + .append(String.valueOf(loc.getStartLine())) + .append(" of ").append(report.getDisplayName(loc.getFileId())) + .println(); } writer.println(); // add a line to separate the source from the desc above diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SourceManager.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SourceManager.java index c7c9d469faf..933bad965d1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SourceManager.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/SourceManager.java @@ -71,16 +71,14 @@ public int size() { } - @Override - public void close() throws IOException { + @Override public void close() throws IOException { Exception exception = IOUtil.closeAll(textFiles); if (exception != null) { throw new IOException(exception); } } - @SuppressWarnings("PMD.CloseResource") - public Chars getSlice(Mark mark) { + @SuppressWarnings("PMD.CloseResource") public Chars getSlice(Mark mark) { TextFile textFile = fileByPathId.get(mark.getToken().getFileId()); assert textFile != null : "No such file " + mark.getToken().getFileId(); TextDocument doc = get(textFile); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java index c90701a0265..783685c49c4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/TokenEntry.java @@ -84,8 +84,7 @@ int getIndex() { return this.index; } - @Override - public int hashCode() { + @Override public int hashCode() { return hashCode; } @@ -93,8 +92,7 @@ void setHashCode(int hashCode) { this.hashCode = hashCode; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } else if (!(o instanceof TokenEntry)) { @@ -109,8 +107,7 @@ public boolean equals(Object o) { return other.hashCode == hashCode; } - @Override - public int compareTo(TokenEntry other) { + @Override public int compareTo(TokenEntry other) { return getIndex() - other.getIndex(); } @@ -126,8 +123,7 @@ public String getImage(Tokens tokens) { return image == null ? "--unknown--" : image; } - @Override - public String toString() { + @Override public String toString() { if (this.isEof()) { return "EOF"; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/TokenFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/TokenFactory.java index cfc2eba6385..117ab05c40d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/TokenFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/TokenFactory.java @@ -59,7 +59,6 @@ default void recordToken(@NonNull String image, @NonNull FileLocation location) * This adds the EOF token, it must be called when * {@link CpdLexer#tokenize(TextDocument, TokenFactory)} is done. */ - @Override - void close(); + @Override void close(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Tokens.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Tokens.java index 105efdcaa81..42eecf07362 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Tokens.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/Tokens.java @@ -104,31 +104,26 @@ static TokenFactory factoryForFile(TextDocument file, Tokens tokens) { final FileId fileId = file.getFileId(); final int firstToken = tokens.size(); - @Override - public void recordToken(@NonNull String image, int startLine, int startCol, int endLine, int endCol) { + @Override public void recordToken(@NonNull String image, int startLine, int startCol, int endLine, int endCol) { tokens.addToken(image, fileId, startLine, startCol, endLine, endCol); } - @Override - public void setImage(TokenEntry entry, @NonNull String newImage) { + @Override public void setImage(TokenEntry entry, @NonNull String newImage) { tokens.setImage(entry, newImage); } - @Override - public LexException makeLexException(int line, int column, String message, @Nullable Throwable cause) { + @Override public LexException makeLexException(int line, int column, String message, @Nullable Throwable cause) { return new LexException(line, column, fileId, message, cause); } - @Override - public @Nullable TokenEntry peekLastToken() { + @Override public @Nullable TokenEntry peekLastToken() { if (tokens.size() <= firstToken) { return null; // no token has been added yet in this file } return tokens.peekLastToken(); } - @Override - public void close() { + @Override public void close() { TokenEntry tok = peekLastToken(); if (tok == null) { tokens.addEof(fileId, 1, 1); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/VSRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/VSRenderer.java index 58298785ff1..42608c099eb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/VSRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/VSRenderer.java @@ -11,16 +11,15 @@ public class VSRenderer implements CPDReportRenderer { - @Override - public void render(CPDReport report, Writer writer) throws IOException { - for (Match match: report.getMatches()) { + @Override public void render(CPDReport report, Writer writer) throws IOException { + for (Match match : report.getMatches()) { for (Mark mark : match) { FileLocation loc = mark.getLocation(); writer.append(report.getDisplayName(loc.getFileId())) - .append('(').append(String.valueOf(loc.getStartLine())).append("):") - .append(" Between lines ").append(String.valueOf(loc.getStartLine())) - .append(" and ").append(String.valueOf(loc.getEndLine())) - .append(System.lineSeparator()); + .append('(').append(String.valueOf(loc.getStartLine())).append("):") + .append(" Between lines ").append(String.valueOf(loc.getStartLine())) + .append(" and ").append(String.valueOf(loc.getEndLine())) + .append(System.lineSeparator()); } } writer.flush(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLOldRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLOldRenderer.java index d5867e1399b..b57043fb5ae 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLOldRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLOldRenderer.java @@ -27,8 +27,7 @@ public XMLOldRenderer(String encoding) { this.xmlRenderer = new XMLRenderer(encoding, false); } - @Override - public void render(CPDReport report, Writer writer) throws IOException { + @Override public void render(CPDReport report, Writer writer) throws IOException { xmlRenderer.render(report, writer); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java index 8e9b8fe5b6b..91e14d9ce9d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java @@ -109,8 +109,7 @@ private void dumpDocToWriter(Document doc, Writer writer) { } - @Override - public void render(final CPDReport report, final Writer writer) throws IOException { + @Override public void render(final CPDReport report, final Writer writer) throws IOException { final Document doc = createDocument(); final Element root = createElement(doc, "pmd-cpd"); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/impl/AntlrCpdLexer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/impl/AntlrCpdLexer.java index 3c06996210d..a917702ddb8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/impl/AntlrCpdLexer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/impl/AntlrCpdLexer.java @@ -20,8 +20,7 @@ * Generic implementation of a {@link CpdLexer} useful to any Antlr grammar. */ public abstract class AntlrCpdLexer extends CpdLexerBase { - @Override - protected final TokenManager makeLexerImpl(TextDocument doc) throws IOException { + @Override protected final TokenManager makeLexerImpl(TextDocument doc) throws IOException { CharStream charStream = CharStreams.fromReader(doc.newReader(), doc.getFileId().getAbsolutePath()); return new AntlrTokenManager(getLexerForSource(charStream), doc); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/impl/BaseTokenFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/impl/BaseTokenFilter.java index 15640c2d235..420aa50dd3e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/impl/BaseTokenFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/impl/BaseTokenFilter.java @@ -35,8 +35,7 @@ public BaseTokenFilter(final TokenManager tokenManager) { this.remainingTokens = new RemainingTokens(); } - @Override - public final T getNextToken() { + @Override public final T getNextToken() { currentToken = null; if (!unprocessedTokens.isEmpty()) { currentToken = unprocessedTokens.poll(); @@ -127,8 +126,7 @@ protected boolean shouldStopProcessing(T currentToken) { private final class RemainingTokens implements Iterable { - @Override - public Iterator iterator() { + @Override public Iterator iterator() { return new RemainingTokensIterator(currentToken); } @@ -141,8 +139,7 @@ private class RemainingTokensIterator extends AbstractIterator implements Ite this.startToken = startToken; } - @Override - protected void computeNext() { + @Override protected void computeNext() { assert index >= 0; if (startToken != currentToken) { throw new ConcurrentModificationException("Using iterator after next token has been requested."); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/impl/CpdLexerBase.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/impl/CpdLexerBase.java index 22478fa3447..18de0ffa1ef 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/impl/CpdLexerBase.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/impl/CpdLexerBase.java @@ -31,8 +31,7 @@ protected String getImage(T token) { return token.getImage(); } - @Override - public final void tokenize(TextDocument document, TokenFactory tokens) throws IOException { + @Override public final void tokenize(TextDocument document, TokenFactory tokens) throws IOException { TokenManager tokenManager = filterTokenStream(makeLexerImpl(document)); T currentToken = tokenManager.getNextToken(); while (currentToken != null) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/internal/CpdLanguagePropertiesDefaults.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/internal/CpdLanguagePropertiesDefaults.java index a21cd25091b..033cff6ed10 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/internal/CpdLanguagePropertiesDefaults.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/internal/CpdLanguagePropertiesDefaults.java @@ -5,7 +5,8 @@ package net.sourceforge.pmd.cpd.internal; public final class CpdLanguagePropertiesDefaults { - private CpdLanguagePropertiesDefaults() {} + private CpdLanguagePropertiesDefaults() { + } /** * Default value for the option "cpdSkipBlocksPattern", which is only supported by the diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/LogMessages.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/LogMessages.java index bdabfdbc6e4..4e4adefb9dd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/LogMessages.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/LogMessages.java @@ -16,10 +16,10 @@ private LogMessages() { public static String errorDetectedMessage(int errors, String program) { String anError = errors == 1 ? "An error" : errors + " errors"; return anError + " occurred while executing " + program + ".\n" - + "Run in verbose mode to see a stack-trace.\n" - + "If you think this is a bug in " + program - + ", please report this issue at https://github.com/pmd/pmd/issues/new/choose\n" - + "If you do so, please include a stack-trace, the code sample\n" - + " causing the issue, and details about your run configuration."; + + "Run in verbose mode to see a stack-trace.\n" + + "If you think this is a bug in " + program + + ", please report this issue at https://github.com/pmd/pmd/issues/new/choose\n" + + "If you do so, please include a stack-trace, the code sample\n" + + " causing the issue, and details about your run configuration."; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/Slf4jSimpleConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/Slf4jSimpleConfiguration.java index 0f5ead36f5c..4022e7bc485 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/Slf4jSimpleConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/Slf4jSimpleConfiguration.java @@ -20,7 +20,8 @@ public final class Slf4jSimpleConfiguration { private static final String SIMPLE_LOGGER_CONFIGURATION = "org.slf4j.impl.SimpleLoggerConfiguration"; private static final String PMD_ROOT_LOGGER = "net.sourceforge.pmd"; - private Slf4jSimpleConfiguration() { } + private Slf4jSimpleConfiguration() { + } public static void reconfigureDefaultLogLevel(Level level) { if (!isSimpleLogger()) { @@ -69,11 +70,10 @@ public static void reconfigureDefaultLogLevel(Level level) { loggerMapField.setAccessible(true); // we checked previously, that loggerFactory instanceof SimpleLoggerFactory // see #isSimpleLogger() - @SuppressWarnings("unchecked") - Map loggerMap = (Map) loggerMapField.get(loggerFactory); + @SuppressWarnings("unchecked") Map loggerMap = (Map) loggerMapField.get(loggerFactory); for (Logger logger : loggerMap.values()) { if (logger.getName().startsWith(PMD_ROOT_LOGGER) - && simpleLoggerClass.isAssignableFrom(logger.getClass())) { + && simpleLoggerClass.isAssignableFrom(logger.getClass())) { String newConfiguredLevel = (String) levelStringMethod.invoke(logger); int newLogLevel = newDefaultLogLevel; if (newConfiguredLevel != null) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/BaseCloseable.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/BaseCloseable.java index 93b3e009ff3..590f15301f5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/BaseCloseable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/BaseCloseable.java @@ -27,8 +27,7 @@ protected final void ensureOpenIllegalState() throws IllegalStateException { /** * Noop if called several times. Thread-safe. */ - @Override - public void close() throws IOException { + @Override public void close() throws IOException { if (open) { synchronized (this) { if (open) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java index 6f23edb3ebf..8da5d8caf26 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ClasspathClassLoader.java @@ -165,7 +165,7 @@ private void initializeJrtFilesystem(Path filePath) { throw new IllegalArgumentException("Can't determine java home from " + filePath + " - please provide a complete path."); } - try (URLClassLoader loader = new URLClassLoader(new URL[] { filePath.toUri().toURL() })) { + try (URLClassLoader loader = new URLClassLoader(new URL[]{filePath.toUri().toURL()})) { Map env = new HashMap<>(); // note: providing java.home here is crucial, so that the correct runtime image is loaded. // the class loader is only used to provide an implementation of JrtFileSystemProvider, if the current @@ -197,12 +197,11 @@ private void initializeJrtFilesystem(Path filePath) { } } - @Override - public String toString() { + @Override public String toString() { return getClass().getSimpleName() - + "[[" - + StringUtils.join(getURLs(), ":") - + "] jrt-fs: " + javaHome + " parent: " + getParent() + ']'; + + "[[" + + StringUtils.join(getURLs(), ":") + + "] jrt-fs: " + javaHome + " parent: " + getParent() + ']'; } private static final String MODULE_INFO_SUFFIX = "module-info.class"; @@ -210,16 +209,14 @@ public String toString() { // this is lazily initialized on first query of a module-info.class private Map moduleNameToModuleInfoUrls; - @Nullable - private static String extractModuleName(String name) { + @Nullable private static String extractModuleName(String name) { if (!name.endsWith(MODULE_INFO_SUFFIX_SLASH)) { return null; } return name.substring(0, name.length() - MODULE_INFO_SUFFIX_SLASH.length()); } - @Override - public InputStream getResourceAsStream(String name) { + @Override public InputStream getResourceAsStream(String name) { // always first search in jrt-fs, if available // note: we can't override just getResource(String) and return a jrt:/-URL, because the URL itself // won't be connected to the correct JrtFileSystem and would just load using the system classloader. @@ -273,8 +270,7 @@ protected ModuleNameExtractor() { super(Opcodes.ASM9); } - @Override - public ModuleVisitor visitModule(String name, int access, String version) { + @Override public ModuleVisitor visitModule(String name, int access, String version) { moduleName = name; return null; } @@ -319,8 +315,7 @@ private void collectModules(Map allModules, Enumeration module } } - @Override - public URL getResource(String name) { + @Override public URL getResource(String name) { // Override to make it child-first. This is the method used by // pmd-java's type resolution to fetch classes, instead of loadClass. Objects.requireNonNull(name); @@ -342,13 +337,11 @@ public URL getResource(String name) { return url; } - @Override - protected Class loadClass(final String name, final boolean resolve) throws ClassNotFoundException { + @Override protected Class loadClass(final String name, final boolean resolve) throws ClassNotFoundException { throw new IllegalStateException("This class loader shouldn't be used to load classes"); } - @Override - public void close() throws IOException { + @Override public void close() throws IOException { if (fileSystem != null) { fileSystem.close(); // jrt created an own classloader to load the JrtFileSystemProvider class out of the diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ExceptionContextDefaultImpl.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ExceptionContextDefaultImpl.java index 00b16df1209..fb3929cd5e9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ExceptionContextDefaultImpl.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/ExceptionContextDefaultImpl.java @@ -16,39 +16,32 @@ public interface ExceptionContextDefaultImpl getContextValues(String label) { + @Override default List getContextValues(String label) { return getExceptionContext().getContextValues(label); } - @Override - default Object getFirstContextValue(String label) { + @Override default Object getFirstContextValue(String label) { return getExceptionContext().getFirstContextValue(label); } - @Override - default Set getContextLabels() { + @Override default Set getContextLabels() { return getExceptionContext().getContextLabels(); } - @Override - default List> getContextEntries() { + @Override default List> getContextEntries() { return getExceptionContext().getContextEntries(); } - @Override - default String getFormattedExceptionMessage(String baseMessage) { + @Override default String getFormattedExceptionMessage(String baseMessage) { return getExceptionContext().getFormattedExceptionMessage(baseMessage); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java index 6fef5fab9f9..b91a3b27be7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileCollectionUtil.java @@ -111,7 +111,7 @@ public static void collectFiles(FileCollector collector, List filePaths) { try { addRoot(collector, rootLocation); } catch (IOException e) { - collector.getReporter().errorEx("Error collecting {0}", new Object[]{ rootLocation }, e); + collector.getReporter().errorEx("Error collecting {0}", new Object[]{rootLocation}, e); } } } @@ -127,7 +127,7 @@ public static void collectFileList(FileCollector collector, Path fileList) { try { filePaths = FileUtil.readFilelistEntries(fileList); } catch (IOException e) { - collector.getReporter().errorEx("Error reading {0}", new Object[] { fileList }, e); + collector.getReporter().errorEx("Error reading {0}", new Object[]{fileList}, e); return; } collectFiles(collector, filePaths); @@ -170,14 +170,14 @@ public static void collectDB(FileCollector collector, URI uri) { collector.addSourceFile(FileId.fromPathLikeString(falseFilePath), source); } catch (SQLException ex) { collector.getReporter().warnEx("Cannot get SourceCode for {0} - skipping ...", - new Object[] { falseFilePath }, - ex); + new Object[]{falseFilePath}, + ex); } } } catch (ClassNotFoundException e) { collector.getReporter().errorEx("Cannot get files from DB - probably missing database JDBC driver", e); } catch (Exception e) { - collector.getReporter().errorEx("Cannot get files from DB - ''{0}''", new Object[] { uri }, e); + collector.getReporter().errorEx("Cannot get files from DB - ''{0}''", new Object[]{uri}, e); } } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileExtensionFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileExtensionFilter.java index b4432ca46ee..e212075592b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileExtensionFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileExtensionFilter.java @@ -27,14 +27,13 @@ final class FileExtensionFilter implements Predicate { } } - @Override - public boolean test(String path) { + @Override public boolean test(String path) { boolean accept = extensions == null; if (!accept) { for (String extension : extensions) { boolean matches = - ignoreCase ? StringUtils.endsWithIgnoreCase(path, extension) - : path.endsWith(extension); + ignoreCase ? StringUtils.endsWithIgnoreCase(path, extension) + : path.endsWith(extension); if (matches) { accept = true; break; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileFinder.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileFinder.java index 36a8dec0d7f..d738bb17f43 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileFinder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileFinder.java @@ -44,8 +44,7 @@ private void scanDirectory(File dir, List list, boolean recurse) { } Arrays.sort(candidates, new Comparator() { - @Override - public int compare(File o1, File o2) { + @Override public int compare(File o1, File o2) { return o1.getPath().compareToIgnoreCase(o2.getPath()); } }); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileUtil.java index b7b3fe94fd3..96fc65d9a71 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/FileUtil.java @@ -114,11 +114,11 @@ public static boolean findPatternInFile(final File file, final String pattern) { */ public static List readFilelistEntries(Path filelist) throws IOException { return Files.readAllLines(filelist).stream() - .flatMap(it -> Arrays.stream(it.split(","))) - .map(String::trim) - .filter(StringUtils::isNotBlank) - .map(Paths::get) - .collect(Collectors.toList()); + .flatMap(it -> Arrays.stream(it.split(","))) + .map(String::trim) + .filter(StringUtils::isNotBlank) + .map(Paths::get) + .collect(Collectors.toList()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IOUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IOUtil.java index 853ae6ef928..3b632f40929 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IOUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IOUtil.java @@ -71,8 +71,7 @@ public static Writer createWriter() { */ private static Charset getDefaultCharset() { String csn = AccessController.doPrivileged(new PrivilegedAction() { - @Override - public String run() { + @Override public String run() { return System.getProperty("file.encoding"); } }); @@ -113,8 +112,7 @@ public static Writer createWriter(Charset charset, @Nullable String reportFile) try { if (StringUtils.isBlank(reportFile)) { return new OutputStreamWriter(new FilterOutputStream(System.out) { - @Override - public void close() { + @Override public void close() { // avoid closing stdout, simply flush try { out.flush(); @@ -122,9 +120,8 @@ public void close() { // Nothing left to do } } - - @Override - public void write(byte[] b, int off, int len) throws IOException { + + @Override public void write(byte[] b, int off, int len) throws IOException { /* * FilterOutputStream iterates over each byte, asking subclasses to provide more efficient implementations * It therefore negates any such optimizations that the underlying stream actually may implement. @@ -181,7 +178,7 @@ public static Exception closeAll(Collection closeables) * list of the other, and throws that one. */ public static void ensureClosed(List toClose, - @Nullable Exception pendingException) throws Exception { + @Nullable Exception pendingException) throws Exception { Exception closeException = closeAll(toClose); if (closeException != null) { if (pendingException != null) { @@ -334,8 +331,7 @@ class ReaderInputStream extends InputStream { byteBuffer.flip(); // byte buffer is empty at the beginning, no bytes read yet } - @Override - public int read() throws IOException { + @Override public int read() throws IOException { if (!byteBuffer.hasRemaining()) { if (charBuffer.hasRemaining() && !eof) { int count = reader.read(charBuffer); @@ -355,13 +351,11 @@ public int read() throws IOException { return -1; } - @Override - public int available() throws IOException { + @Override public int available() throws IOException { return byteBuffer.remaining(); } - @Override - public void close() throws IOException { + @Override public void close() throws IOException { reader.close(); } } @@ -386,16 +380,14 @@ class WriterOutputStream extends OutputStream { charBuffer.clear(); } - @Override - public void write(int b) throws IOException { + @Override public void write(int b) throws IOException { if (!byteBuffer.hasRemaining()) { decodeByteBuffer(false); } byteBuffer.put((byte) b); } - @Override - public void flush() throws IOException { + @Override public void flush() throws IOException { decodeByteBuffer(false); } @@ -408,8 +400,7 @@ private void decodeByteBuffer(boolean isClosing) throws IOException { byteBuffer.compact(); } - @Override - public void close() throws IOException { + @Override public void close() throws IOException { flush(); decodeByteBuffer(true); writer.close(); @@ -452,10 +443,10 @@ private byte[] determineBom() { return new byte[0]; // skip all 3 bytes } else if (count >= 2 && bytes[0] == (byte) 0xfe && bytes[1] == (byte) 0xff) { charset = StandardCharsets.UTF_16BE.name(); - return new byte[] { bytes[2] }; + return new byte[]{bytes[2]}; } else if (count >= 2 && bytes[0] == (byte) 0xff && bytes[1] == (byte) 0xfe) { charset = StandardCharsets.UTF_16LE.name(); - return new byte[] { bytes[2] }; + return new byte[]{bytes[2]}; } else if (count == 3) { return bytes; } @@ -474,16 +465,14 @@ private byte[] determineBom() { } } - @Override - public int read() throws IOException { + @Override public int read() throws IOException { if (beginIndex < begin.length) { return begin[beginIndex++]; } return super.read(); } - @Override - public int read(byte[] b, int off, int len) throws IOException { + @Override public int read(byte[] b, int off, int len) throws IOException { if (beginIndex < begin.length) { int count = 0; for (; count < len && beginIndex < begin.length; beginIndex++) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/PredicateUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/PredicateUtil.java index 92984b94e95..1284ab085c4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/PredicateUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/PredicateUtil.java @@ -79,7 +79,7 @@ public static Predicate toNormalizedFileFilter(final Predicate buildRegexFilterIncludeOverExclude(@NonNull Collection includeRegexes, - @NonNull Collection excludeRegexes) { + @NonNull Collection excludeRegexes) { AssertionUtil.requireParamNotNull("includeRegexes", includeRegexes); AssertionUtil.requireParamNotNull("excludeRegexes", includeRegexes); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/InternalApiBridge.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/InternalApiBridge.java index 08d11470c57..50ef293136a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/InternalApiBridge.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/InternalApiBridge.java @@ -26,15 +26,16 @@ */ @InternalApi public final class InternalApiBridge { - private InternalApiBridge() {} + private InternalApiBridge() { + } public static LanguageProcessor.AnalysisTask createAnalysisTask(RuleSets rulesets, - List files, - GlobalAnalysisListener listener, - int threadCount, - AnalysisCache analysisCache, - PmdReporter messageReporter, - LanguageProcessorRegistry lpRegistry) { + List files, + GlobalAnalysisListener listener, + int threadCount, + AnalysisCache analysisCache, + PmdReporter messageReporter, + LanguageProcessorRegistry lpRegistry) { return new LanguageProcessor.AnalysisTask(rulesets, files, listener, threadCount, analysisCache, messageReporter, lpRegistry); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/JvmLanguagePropertyBundle.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/JvmLanguagePropertyBundle.java index 25ccb2e7195..53c8bdf7f20 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/JvmLanguagePropertyBundle.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/JvmLanguagePropertyBundle.java @@ -23,13 +23,13 @@ public class JvmLanguagePropertyBundle extends LanguagePropertyBundle { public static final PropertyDescriptor AUX_CLASSPATH - = PropertyFactory.stringProperty("auxClasspath") - .desc("A classpath to use to resolve references to external types in the analysed sources. " - + "Individual paths are separated by ; on Windows and : on other platforms. " - + "All classes of the analysed project should be found on this classpath, including " - + "the compiled classes corresponding to the analyzed sources themselves, and the JDK classes.") - .defaultValue("") - .build(); + = PropertyFactory.stringProperty("auxClasspath") + .desc("A classpath to use to resolve references to external types in the analysed sources. " + + "Individual paths are separated by ; on Windows and : on other platforms. " + + "All classes of the analysed project should be found on this classpath, including " + + "the compiled classes corresponding to the analyzed sources themselves, and the JDK classes.") + .defaultValue("") + .build(); private ClassLoader classLoader; @@ -38,8 +38,7 @@ public JvmLanguagePropertyBundle(Language language) { definePropertyDescriptor(AUX_CLASSPATH); } - @Override - public void setProperty(PropertyDescriptor propertyDescriptor, T value) { + @Override public void setProperty(PropertyDescriptor propertyDescriptor, T value) { super.setProperty(propertyDescriptor, value); if (propertyDescriptor == AUX_CLASSPATH) { classLoader = null; // reset it. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/Language.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/Language.java index c47312ddef9..d73d211107b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/Language.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/Language.java @@ -71,8 +71,7 @@ public interface Language extends Comparable { * for the base language can be applied files of all dialects uniformly. * @experimental Since 7.13.0. See [core] Support language dialects #5438. */ - @Experimental - default @Nullable String getBaseLanguageId() { + @Experimental default @Nullable String getBaseLanguageId() { return null; } @@ -82,9 +81,7 @@ public interface Language extends Comparable { * @param language A language (not null) * @experimental Since 7.13.0. See [core] Support language dialects #5438. */ - @Experimental - @SuppressWarnings("PMD.SimplifyBooleanReturns") - default boolean isDialectOf(Language language) { + @Experimental @SuppressWarnings("PMD.SimplifyBooleanReturns") default boolean isDialectOf(Language language) { AssertionUtil.requireParamNotNull("language", language); String base = getBaseLanguageId(); if (base == null) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageFilenameFilter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageFilenameFilter.java index 6635ac66633..9b6621d998c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageFilenameFilter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageFilenameFilter.java @@ -45,8 +45,7 @@ public LanguageFilenameFilter(Set languages) { /** * Check if a file should be checked by PMD. {@inheritDoc} */ - @Override - public boolean accept(File dir, String name) { + @Override public boolean accept(File dir, String name) { // Any source file should have a '.' in its name... int lastDotIndex = name.lastIndexOf('.'); if (lastDotIndex < 0) { @@ -64,8 +63,7 @@ public boolean accept(File dir, String name) { return false; } - @Override - public String toString() { + @Override public String toString() { StringBuilder buffer = new StringBuilder("(Extension is one of: "); for (Language language : languages) { List extensions = language.getExtensions(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageModuleBase.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageModuleBase.java index b3d095c123f..4d5b63adae3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageModuleBase.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageModuleBase.java @@ -57,8 +57,7 @@ protected LanguageModuleBase(LanguageMetadata metadata) { /** * @experimental Since 7.13.0. See [core] Support language dialects #5438. */ - @Experimental - protected LanguageModuleBase(DialectLanguageMetadata metadata) { + @Experimental protected LanguageModuleBase(DialectLanguageMetadata metadata) { this(metadata.metadata, metadata.baseLanguageId); } @@ -99,7 +98,7 @@ private LanguageModuleBase(LanguageMetadata metadata, String baseLanguageId) { if (versionId.isDefault) { if (defaultVersion != null) { throw new IllegalStateException( - "Default version already set to " + defaultVersion + ", cannot set it to " + languageVersion); + "Default version already set to " + defaultVersion + ", cannot set it to " + languageVersion); } defaultVersion = languageVersion; } @@ -116,73 +115,59 @@ private static void checkNotPresent(Map map, String alias) { } } - @Override - public @Nullable String getBaseLanguageId() { + @Override public @Nullable String getBaseLanguageId() { return baseLanguageId; } - @Override - public List getVersions() { + @Override public List getVersions() { return distinctVersions; } - @Override - public @NonNull LanguageVersion getDefaultVersion() { + @Override public @NonNull LanguageVersion getDefaultVersion() { return defaultVersion; } - @Override - public LanguageVersion getVersion(String version) { + @Override public LanguageVersion getVersion(String version) { return byName.get(version); } - @Override - public Set getVersionNamesAndAliases() { + @Override public Set getVersionNamesAndAliases() { return Collections.unmodifiableSet(byName.keySet()); } - @Override - public Set getDependencies() { + @Override public Set getDependencies() { return dependencies; } - @Override - public String getName() { + @Override public String getName() { return meta.name; } - @Override - public String getShortName() { + @Override public String getShortName() { return meta.getShortName(); } - @Override - public String getId() { + @Override public String getId() { return meta.id; } - @Override - public @NonNull List getExtensions() { + @Override public @NonNull List getExtensions() { return Collections.unmodifiableList(meta.extensions); } - @Override - public String toString() { + @Override public String toString() { return getId(); } - @Override - public int compareTo(Language o) { + @Override public int compareTo(Language o) { return getName().compareTo(o.getName()); } - @Override - public int hashCode() { + @Override public int hashCode() { return getId().hashCode(); } - @Override - public boolean equals(Object obj) { + @Override public boolean equals(Object obj) { if (this == obj) { return true; } @@ -228,7 +213,7 @@ private LanguageMetadata(@NonNull String id) { void validate() { AssertionUtil.validateState(name != null, "Language " + id + " should have a name"); AssertionUtil.validateState( - extensions != null, "Language " + id + " has not registered any file extensions"); + extensions != null, "Language " + id + " has not registered any file extensions"); } String getShortName() { @@ -364,8 +349,8 @@ public LanguageMetadata addDefaultVersion(String name, String... aliases) { public LanguageMetadata addAllVersionsOf(Language language) { for (LanguageVersion version : language.getVersions()) { versionMetadata.add(new LangVersionMetadata(version.getVersion(), - version.getAliases(), - version.equals(language.getDefaultVersion()))); + version.getAliases(), + version.equals(language.getDefaultVersion()))); } return this; } @@ -377,8 +362,7 @@ public LanguageMetadata addAllVersionsOf(Language language) { * @return A new dialect language metadata model. * @experimental Since 7.13.0. See [core] Support language dialects #5438. */ - @Experimental - public DialectLanguageMetadata asDialectOf(String baseLanguageId) { + @Experimental public DialectLanguageMetadata asDialectOf(String baseLanguageId) { checkValidLangId(baseLanguageId); dependsOnLanguage(baseLanguageId); // a dialect automatically depends on it's base language at runtime return new DialectLanguageMetadata(this, baseLanguageId); @@ -387,7 +371,7 @@ public DialectLanguageMetadata asDialectOf(String baseLanguageId) { private static void checkValidLangId(String id) { if (!VALID_LANG_ID.matcher(id).matches()) { throw new IllegalArgumentException( - "ID '" + id + "' is not a valid language ID (should match " + VALID_LANG_ID + ")."); + "ID '" + id + "' is not a valid language ID (should match " + VALID_LANG_ID + ")."); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessor.java index 48bcdbcce83..15d9cba3656 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessor.java @@ -75,12 +75,12 @@ class AnalysisTask { * @apiNote Internal API */ AnalysisTask(RuleSets rulesets, - List files, - GlobalAnalysisListener listener, - int threadCount, - AnalysisCache analysisCache, - PmdReporter messageReporter, - LanguageProcessorRegistry lpRegistry) { + List files, + GlobalAnalysisListener listener, + int threadCount, + AnalysisCache analysisCache, + PmdReporter messageReporter, + LanguageProcessorRegistry lpRegistry) { this.rulesets = rulesets; this.files = files; this.listener = listener; @@ -125,13 +125,13 @@ public LanguageProcessorRegistry getLpRegistry() { */ AnalysisTask withFiles(List newFiles) { return new AnalysisTask( - rulesets, - newFiles, - listener, - threadCount, - analysisCache, - messageReporter, - lpRegistry + rulesets, + newFiles, + listener, + threadCount, + analysisCache, + messageReporter, + lpRegistry ); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessorRegistry.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessorRegistry.java index eb9fd9a5c53..fb49713cf48 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessorRegistry.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageProcessorRegistry.java @@ -41,7 +41,7 @@ public final class LanguageProcessorRegistry implements AutoCloseable { private LanguageProcessorRegistry(Set processors) { this.processors = Collections.unmodifiableMap( - CollectionUtil.associateBy(processors, LanguageProcessor::getLanguage) + CollectionUtil.associateBy(processors, LanguageProcessor::getLanguage) ); this.languages = new LanguageRegistry(this.processors.keySet()); @@ -49,7 +49,7 @@ private LanguageProcessorRegistry(Set processors) { for (String id : language.getDependencies()) { if (languages.getLanguageById(id) == null) { throw new IllegalStateException( - "Language " + language.getId() + " has unsatisfied dependencies: " + id + " is not loaded" + "Language " + language.getId() + " has unsatisfied dependencies: " + id + " is not loaded" ); } } @@ -83,8 +83,7 @@ public LanguageRegistry getLanguages() { * * @throws LanguageTerminationException If closing any of the processors threw something */ - @Override - public void close() throws LanguageTerminationException { + @Override public void close() throws LanguageTerminationException { Exception e = IOUtil.closeAll(processors.values()); if (e != null) { throw new LanguageTerminationException(e); @@ -115,16 +114,16 @@ public static LanguageProcessorRegistry singleton(@NonNull LanguageProcessor lp) * to an incompatible property bundle */ public static LanguageProcessorRegistry create(LanguageRegistry registry, - Map languageProperties, - PmdReporter messageReporter) { + Map languageProperties, + PmdReporter messageReporter) { return create(registry, languageProperties, messageReporter, System.getenv()); } // overload for testing to allow mocking the system env vars. static LanguageProcessorRegistry create(LanguageRegistry registry, - Map languageProperties, - PmdReporter messageReporter, - Map env) { + Map languageProperties, + PmdReporter messageReporter, + Map env) { Set processors = new HashSet<>(); for (Language language : registry) { if (!(language instanceof PmdCapableLanguage)) { @@ -151,8 +150,8 @@ static LanguageProcessorRegistry create(LanguageRegistry registry, // TODO this should be reused when implementing the CLI - see https://github.com/pmd/pmd/issues/2947 public static Map derivePropertiesFromStrings( - Map stringProperties, - PmdReporter reporter + Map stringProperties, + PmdReporter reporter ) { Map typedProperties = new HashMap<>(); stringProperties.forEach((l, props) -> { @@ -180,17 +179,17 @@ private static void setLanguageProperties(Map languageProp private static void trySetPropertyCapture(PropertySource source, - PropertyDescriptor propertyDescriptor, - String propertyValue, - PmdReporter reporter) { + PropertyDescriptor propertyDescriptor, + String propertyValue, + PmdReporter reporter) { try { T value = propertyDescriptor.serializer().fromString(propertyValue); source.setProperty(propertyDescriptor, value); } catch (IllegalArgumentException e) { reporter.error("Cannot set property {0} to {1}: {2}", - propertyDescriptor.name(), - propertyValue, - e.getMessage()); + propertyDescriptor.name(), + propertyValue, + e.getMessage()); } } @@ -205,19 +204,19 @@ private static void readLanguagePropertiesFromEnv(LanguagePropertyBundle props, // Env vars are a default, they don't override other ways to set properties. // If the property has already been set, don't set it. LOG.debug( - "Property {} for lang {} is already set, ignoring environment variable {}={}", - propertyDescriptor.name(), - props.getLanguage().getId(), - envVarName, - propertyValue + "Property {} for lang {} is already set, ignoring environment variable {}={}", + propertyDescriptor.name(), + props.getLanguage().getId(), + envVarName, + propertyValue ); } else { LOG.debug( - "Property {} for lang {} is not yet set, using environment variable {}={}", - propertyDescriptor.name(), - props.getLanguage().getId(), - envVarName, - propertyValue + "Property {} for lang {} is not yet set, using environment variable {}={}", + propertyDescriptor.name(), + props.getLanguage().getId(), + envVarName, + propertyValue ); trySetPropertyCapture(props, propertyDescriptor, propertyValue, reporter); } @@ -230,15 +229,14 @@ private static void readLanguagePropertiesFromEnv(LanguagePropertyBundle props, */ private static String getEnvironmentVariableName(Language lang, PropertyDescriptor propertyDescriptor) { return "PMD_" + lang.getId().toUpperCase(Locale.ROOT) + "_" - + CaseConvention.CAMEL_CASE.convertTo(SCREAMING_SNAKE_CASE, propertyDescriptor.name()); + + CaseConvention.CAMEL_CASE.convertTo(SCREAMING_SNAKE_CASE, propertyDescriptor.name()); } - @Override - public String toString() { + @Override public String toString() { return "LanguageProcessorRegistry(" - + new LanguageRegistry(processors.keySet()).commaSeparatedList(Language::getId) - + ")"; + + new LanguageRegistry(processors.keySet()).commaSeparatedList(Language::getId) + + ")"; } /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguagePropertyBundle.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguagePropertyBundle.java index bb39b83646a..c7bcd091fb1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguagePropertyBundle.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguagePropertyBundle.java @@ -25,11 +25,11 @@ public class LanguagePropertyBundle extends AbstractPropertySource { // as a suppression. I think it should disable suppression comments. // #4846 public static final PropertyDescriptor SUPPRESS_MARKER - = PropertyFactory.stringProperty("suppressMarker") - .desc("Marker to identify suppression comments. " - + "Eg a value of NOPMD will make `// NOPMD` a suppression comment in Java or JavaScript.") - .defaultValue(PMDConfiguration.DEFAULT_SUPPRESS_MARKER) - .build(); + = PropertyFactory.stringProperty("suppressMarker") + .desc("Marker to identify suppression comments. " + + "Eg a value of NOPMD will make `// NOPMD` a suppression comment in Java or JavaScript.") + .defaultValue(PMDConfiguration.DEFAULT_SUPPRESS_MARKER) + .build(); public static final String LANGUAGE_VERSION = "version"; private final PropertyDescriptor languageVersion; @@ -44,14 +44,14 @@ public LanguagePropertyBundle(@NonNull Language language) { definePropertyDescriptor(SUPPRESS_MARKER); languageVersion = - PropertyFactory.enumProperty( - LANGUAGE_VERSION, - CollectionUtil.associateBy(language.getVersions(), LanguageVersion::getVersion) - ) - .desc("Language version to use for this language. See the --use-version CLI switch as well.") + PropertyFactory.enumProperty( + LANGUAGE_VERSION, + CollectionUtil.associateBy(language.getVersions(), LanguageVersion::getVersion) + ) + .desc("Language version to use for this language. See the --use-version CLI switch as well.") - .defaultValue(language.getDefaultVersion()) - .build(); + .defaultValue(language.getDefaultVersion()) + .build(); definePropertyDescriptor(languageVersion); } @@ -60,13 +60,11 @@ public void setLanguageVersion(String string) { setProperty(languageVersion, languageVersion.serializer().fromString(string)); } - @Override - protected String getPropertySourceType() { + @Override protected String getPropertySourceType() { return "Language"; } - @Override - public String getName() { + @Override public String getName() { return language.getName(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageRegistry.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageRegistry.java index a4773f52334..79d071d5859 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageRegistry.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageRegistry.java @@ -37,7 +37,7 @@ public final class LanguageRegistry implements Iterable { // test only static final LanguageRegistry ALL_LANGUAGES = - loadLanguages(LanguageRegistry.class.getClassLoader()); + loadLanguages(LanguageRegistry.class.getClassLoader()); /** * Contains the languages that support PMD and are found on the classpath @@ -62,8 +62,8 @@ public final class LanguageRegistry implements Iterable { */ public LanguageRegistry(Set languages) { this.languages = languages.stream() - .sorted(Comparator.comparing(Language::getId, String::compareToIgnoreCase)) - .collect(CollectionUtil.toUnmodifiableSet()); + .sorted(Comparator.comparing(Language::getId, String::compareToIgnoreCase)) + .collect(CollectionUtil.toUnmodifiableSet()); this.languagesById = CollectionUtil.associateBy(languages, Language::getId); this.languagesByFullName = CollectionUtil.associateBy(languages, Language::getName); } @@ -73,7 +73,7 @@ public LanguageRegistry(Set languages) { */ public LanguageRegistry filter(Predicate filterFun) { return new LanguageRegistry(languages.stream().filter(filterFun) - .collect(Collectors.toSet())); + .collect(Collectors.toSet())); } /** @@ -104,7 +104,7 @@ private void addDepsOrThrow(Language l, Set languages) { Language dep = getLanguageById(depId); if (dep == null) { throw new IllegalStateException( - "Cannot find language " + depId + " in " + this); + "Cannot find language " + depId + " in " + this); } if (languages.add(dep)) { addDepsOrThrow(dep, languages); @@ -112,8 +112,7 @@ private void addDepsOrThrow(Language l, Set languages) { } } - @Override - public @NonNull Iterator iterator() { + @Override public @NonNull Iterator iterator() { return languages.iterator(); } @@ -183,7 +182,7 @@ public Set getLanguages() { return null; } return version == null ? lang.getDefaultVersion() - : lang.getVersion(version); + : lang.getVersion(version); } /** @@ -206,8 +205,7 @@ public Set getLanguages() { return getLanguages().stream().map(languageToString).sorted().collect(Collectors.joining(", ")); } - @Override - public String toString() { + @Override public String toString() { return "LanguageRegistry(" + commaSeparatedList(Language::getId) + ")"; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java index 5e9d787fd06..ab16180c84b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersion.java @@ -98,13 +98,12 @@ public int compareToVersion(String versionString) { LanguageVersion otherVersion = language.getVersion(versionString); if (otherVersion == null) { throw new IllegalArgumentException( - "No such version '" + versionString + "' for language " + language.getName()); + "No such version '" + versionString + "' for language " + language.getName()); } return this.compareTo(otherVersion); } - @Override - public int compareTo(LanguageVersion o) { + @Override public int compareTo(LanguageVersion o) { int cmp = language.compareTo(o.getLanguage()); if (cmp != 0) { return cmp; @@ -113,8 +112,7 @@ public int compareTo(LanguageVersion o) { } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } @@ -125,13 +123,11 @@ public boolean equals(Object o) { return language.equals(that.language) && version.equals(that.version); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(language, version); } - @Override - public String toString() { + @Override public String toString() { return language.toString() + "+version:" + version; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java index 4edb42c5057..f5e57e3edc5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageVersionDiscoverer.java @@ -131,8 +131,8 @@ public void setForcedVersion(LanguageVersion forceLanguageVersion) { public List getLanguagesForFile(String fileName) { String extension = getExtension(fileName); List matching = languageRegistry.getLanguages().stream() - .filter(it -> it.hasExtension(extension)) - .collect(CollectionUtil.toMutableList()); + .filter(it -> it.hasExtension(extension)) + .collect(CollectionUtil.toMutableList()); if (matching.size() > 1) { // Remove all languages that have a more specific dialect that matched. @@ -160,8 +160,7 @@ public void onlyRecognizeLanguages(LanguageRegistry lang) { this.languageRegistry = Objects.requireNonNull(lang); } - @Override - public String toString() { + @Override public String toString() { return "LanguageVersionDiscoverer(" + languageRegistry + (forcedVersion != null ? ",forcedVersion=" + forcedVersion : "") + ")"; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/PlainTextLanguage.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/PlainTextLanguage.java index 54a1e91a2d5..af0bb566e03 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/PlainTextLanguage.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/PlainTextLanguage.java @@ -32,9 +32,9 @@ public final class PlainTextLanguage extends SimpleLanguageModuleBase implements private PlainTextLanguage() { super(LanguageMetadata.withId(ID).name("Plain text") - .extensions("plain-text-file-goo-extension") - .addDefaultVersion("default"), - new TextLvh()); + .extensions("plain-text-file-goo-extension") + .addDefaultVersion("default"), + new TextLvh()); } /** @@ -44,14 +44,12 @@ public static PlainTextLanguage getInstance() { return INSTANCE; // note: this language is _not_ exposed via LanguageRegistry (no entry in META-INF/services) } - @Override - public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { + @Override public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { return new AnyCpdLexer(); } private static final class TextLvh implements LanguageVersionHandler { - @Override - public Parser getParser() { + @Override public Parser getParser() { return PlainTextFile::new; } } @@ -68,28 +66,23 @@ public static class PlainTextFile extends AbstractNode(task, this); } - @Override - public TextRegion getTextRegion() { + @Override public TextRegion getTextRegion() { return getTextDocument().getEntireRegion(); } - @Override - public String getXPathNodeName() { + @Override public String getXPathNodeName() { return "TextFile"; } - @Override - public String getImage() { + @Override public String getImage() { return null; } - @Override - public String toString() { + @Override public String toString() { return "Plain text file (" + getEndLine() + " lines)"; } - @Override - public AstInfo getAstInfo() { + @Override public AstInfo getAstInfo() { return astInfo; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstInfo.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstInfo.java index 718aa16b3b7..4a6cd2fcb50 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstInfo.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstInfo.java @@ -47,9 +47,9 @@ public AstInfo(ParserTask task, T rootNode) { } private AstInfo(TextDocument textDocument, - T rootNode, - LanguageProcessorRegistry lpReg, - Map suppressionComments) { + T rootNode, + LanguageProcessorRegistry lpReg, + Map suppressionComments) { this.textDocument = AssertionUtil.requireParamNotNull("text document", textDocument); this.rootNode = AssertionUtil.requireParamNotNull("root node", rootNode); this.lpReg = lpReg; @@ -88,8 +88,7 @@ public LanguageProcessor getLanguageProcessor() { * @return map of the suppressed lines with the corresponding review comments. * @deprecated Since 7.14.0. Use {@link #getAllSuppressionComments()} or {@link #getSuppressionComment(int)} */ - @Deprecated - public Map getSuppressionComments() { + @Deprecated public Map getSuppressionComments() { return CollectionUtil.mapView(suppressionComments, ViolationSuppressor.SuppressionCommentWrapper::getUserMessage); } @@ -130,20 +129,17 @@ public Collection getAllSuppressionComments() { /** * @deprecated Since 7.14.0. Use {@link #withSuppressionComments(Collection)} */ - @Deprecated - public AstInfo withSuppressMap(Map map) { + @Deprecated public AstInfo withSuppressMap(Map map) { Set comments = new HashSet<>(); for (Map.Entry entry : map.entrySet()) { String comment = entry.getValue(); int line = entry.getKey(); comments.add(new SuppressionCommentWrapper() { - @Override - public String getUserMessage() { + @Override public String getUserMessage() { return comment; } - @Override - public Reportable getLocation() { + @Override public Reportable getLocation() { return () -> FileLocation.caret(textDocument.getFileId(), line, 1); } }); @@ -161,10 +157,10 @@ public AstInfo withSuppressionComments(Collection( - textDocument, - rootNode, - lpReg, - Collections.unmodifiableMap(suppressMap) + textDocument, + rootNode, + lpReg, + Collections.unmodifiableMap(suppressMap) ); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstVisitorBase.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstVisitorBase.java index 6c974184e62..720ab4245f2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstVisitorBase.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/AstVisitorBase.java @@ -33,8 +33,7 @@ protected R visitChildren(Node node, P data) { return null; } - @Override - public R visitNode(Node node, P param) { + @Override public R visitNode(Node node, P param) { return visitChildren(node, param); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/FileAnalysisException.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/FileAnalysisException.java index d0bdcc0a475..37d51d520e3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/FileAnalysisException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/FileAnalysisException.java @@ -61,8 +61,7 @@ protected boolean hasFileName() { return fileId; } - @Override - public final String getMessage() { + @Override public final String getMessage() { return errorKind() + StringUtils.uncapitalize(positionToString()) + ": " + super.getMessage(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java index 4f4ecc79730..e963fc14440 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/GenericToken.java @@ -94,8 +94,7 @@ default boolean isImplicit() { * If they start at the same index, then the smaller token comes before * the other. */ - @Override - default int compareTo(T o) { + @Override default int compareTo(T o) { return getRegion().compareTo(o.getRegion()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/InternalApiBridge.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/InternalApiBridge.java index 460ae0dd37b..f8dc6e6ca88 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/InternalApiBridge.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/InternalApiBridge.java @@ -19,7 +19,8 @@ */ @InternalApi public final class InternalApiBridge { - private InternalApiBridge() {} + private InternalApiBridge() { + } public static LexException newLexException(boolean eofSeen, String lexStateName, int errorLine, int errorColumn, String errorAfter, char curChar) { return new LexException(eofSeen, lexStateName, errorLine, errorColumn, errorAfter, curChar); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/LexException.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/LexException.java index 6331d798c9c..5d9010fc39b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/LexException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/LexException.java @@ -60,13 +60,11 @@ public int getColumn() { return column; } - @Override - protected @NonNull FileLocation location() { + @Override protected @NonNull FileLocation location() { return FileLocation.caret(getFileId(), line, column); } - @Override - protected String errorKind() { + @Override protected String errorKind() { return "Lexical error"; } @@ -77,8 +75,7 @@ protected String errorKind() { * * @return A new exception */ - @Override - public LexException setFileId(FileId fileId) { + @Override public LexException setFileId(FileId fileId) { super.setFileId(fileId); return this; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Node.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Node.java index ab33921c7ef..49ed3da3315 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Node.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Node.java @@ -57,7 +57,7 @@ public interface Node extends Reportable { * (see {@link Comparator}) as some nodes have the same location. */ Comparator COORDS_COMPARATOR = - Comparator.comparing(Node::getReportLocation, FileLocation.COMPARATOR); + Comparator.comparing(Node::getReportLocation, FileLocation.COMPARATOR); /** * Returns a string token, usually filled-in by the parser, which describes some textual characteristic of this @@ -112,8 +112,7 @@ default int compareLocation(Node other) { * *

Use this instead of {@link #getBeginColumn()}/{@link #getBeginLine()}, etc. */ - @Override - default FileLocation getReportLocation() { + @Override default FileLocation getReportLocation() { return getAstInfo().getTextDocument().toLocation(getTextRegion()); } @@ -157,8 +156,7 @@ default int getEndColumn() { * * @see DescendantNodeStream#crossFindBoundaries(boolean) */ - @NoAttribute - default boolean isFindBoundary() { + @NoAttribute default boolean isFindBoundary() { return false; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/NodeStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/NodeStream.java index 45f73d08823..660d34ea4bf 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/NodeStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/NodeStream.java @@ -203,7 +203,6 @@ public interface NodeStream<@NonNull T extends Node> extends Iterable<@NonNull T NodeStream peek(Consumer action); - /** * Returns a new node stream that contains all the elements of this stream, then * all the elements of the given stream. @@ -573,8 +572,7 @@ default NodeStream filterMatching(Function NodeStream filterIs(Class rClass) { + @SuppressWarnings("unchecked") default NodeStream filterIs(Class rClass) { return (NodeStream) filter(rClass::isInstance); } @@ -599,8 +597,7 @@ default NodeStream filterNotMatching(Function action); + @Override void forEach(Consumer action); /** @@ -776,8 +773,7 @@ default boolean isEmpty() { * @see #first(Class) * @see #firstOpt() */ - @NonNull - default T firstOrThrow() { + @NonNull default T firstOrThrow() { T first = first(); if (first == null) { throw new NoSuchElementException("Empty node stream"); @@ -1016,8 +1012,7 @@ static NodeStream ofOptional(Optional optNode) * * @return A new node stream */ - @SafeVarargs - static NodeStream of(T... nodes) { + @SafeVarargs static NodeStream of(T... nodes) { return fromIterable(Arrays.asList(nodes)); } @@ -1031,8 +1026,7 @@ static NodeStream of(T... nodes) { * * @return the concatenation of the input streams */ - @SafeVarargs - static NodeStream union(NodeStream... streams) { + @SafeVarargs static NodeStream union(NodeStream... streams) { return union(Arrays.asList(streams)); } @@ -1078,9 +1072,9 @@ static NodeStream empty() { */ @SafeVarargs // this method is static because of the generic varargs static NodeStream forkJoin(NodeStream upstream, - Function> fst, - Function> snd, - Function>... rest) { + Function> fst, + Function> snd, + Function>... rest) { Objects.requireNonNull(fst); Objects.requireNonNull(snd); @@ -1090,7 +1084,7 @@ static NodeStream forkJoin(NodeStream> aggregate = - t -> NodeStream.union(mappers.stream().map(f -> f.apply(t)).collect(Collectors.toList())); + t -> NodeStream.union(mappers.stream().map(f -> f.apply(t)).collect(Collectors.toList())); // with forkJoin we know that the stream will be iterated more than twice so we cache the values return upstream.cached().flatMap(aggregate); @@ -1134,8 +1128,7 @@ static NodeStream forkJoin(NodeStream Function<@Nullable Object, @Nullable O> asInstanceOf(Class c1, Class... rest) { + @SuppressWarnings("unchecked") static Function<@Nullable Object, @Nullable O> asInstanceOf(Class c1, Class... rest) { if (rest.length == 0) { return obj -> c1.isInstance(obj) ? (O) obj : null; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/ParseException.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/ParseException.java index 1cbf565158a..90d409676c8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/ParseException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/ParseException.java @@ -40,7 +40,7 @@ public ParseException(Throwable cause) { * This constructor is called by Javacc. */ public ParseException(@NonNull JavaccToken currentTokenVal, - int[][] expectedTokenSequencesVal) { + int[][] expectedTokenSequencesVal) { super(makeMessage(currentTokenVal, expectedTokenSequencesVal)); location = currentTokenVal.getNext().getReportLocation(); } @@ -56,13 +56,11 @@ public ParseException withLocation(Reportable reportable) { } - @Override - protected String errorKind() { + @Override protected String errorKind() { return "Parse exception"; } - @Override - protected @Nullable FileLocation location() { + @Override protected @Nullable FileLocation location() { return location; } @@ -74,7 +72,7 @@ protected String errorKind() { * gets displayed. */ private static String makeMessage(@NonNull JavaccToken currentToken, - int[][] expectedTokenSequences) { + int[][] expectedTokenSequences) { JavaccTokenDocument document = currentToken.getDocument(); String eol = System.lineSeparator(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Parser.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Parser.java index f577dc04b70..b50adec4f29 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Parser.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/Parser.java @@ -90,9 +90,9 @@ public LanguageProcessor getLanguageProcessor() { public ParserTask withTextDocument(TextDocument textDocument) { return new ParserTask( - textDocument, - this.reporter, - this.lpRegistry + textDocument, + this.reporter, + this.lpRegistry ); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/RootNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/RootNode.java index 973d2d5748d..e3f4bfa8dc8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/RootNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/RootNode.java @@ -13,7 +13,6 @@ public interface RootNode extends Node { - @Override - AstInfo getAstInfo(); + @Override AstInfo getAstInfo(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporter.java index dd33f4f002d..e3a464f4aca 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporter.java @@ -69,13 +69,11 @@ static SemanticErrorReporter noop() { private SemanticException exception; - @Override - public void warning(Node location, String message, Object... formatArgs) { + @Override public void warning(Node location, String message, Object... formatArgs) { // noop } - @Override - public SemanticException error(Node location, String message, Object... formatArgs) { + @Override public SemanticException error(Node location, String message, Object... formatArgs) { SemanticException ex = new SemanticException(MessageFormat.format(message, formatArgs)); ex.setReported(); if (this.exception == null) { @@ -86,8 +84,7 @@ public SemanticException error(Node location, String message, Object... formatAr return ex; } - @Override - public @Nullable SemanticException getFirstError() { + @Override public @Nullable SemanticException getFirstError() { return exception; } }; @@ -105,7 +102,7 @@ static SemanticErrorReporter reportToLogger(PmdReporter reporter) { private String locPrefix(Node loc) { return "at " + loc.getReportLocation().startPosToStringWithFile() - + ": "; + + ": "; } private String makeMessage(Node location, String message, Object[] args) { @@ -118,13 +115,11 @@ private String logMessage(Level level, Node location, String message, Object[] a return fullMessage; } - @Override - public void warning(Node location, String message, Object... args) { + @Override public void warning(Node location, String message, Object... args) { logMessage(Level.DEBUG, location, message, args); } - @Override - public SemanticException error(Node location, String message, Object... args) { + @Override public SemanticException error(Node location, String message, Object... args) { String fullMessage = logMessage(Level.ERROR, location, message, args); SemanticException ex = new SemanticException(fullMessage); ex.setReported(); @@ -140,8 +135,7 @@ private void updateException(SemanticException ex) { } } - @Override - public void acceptError(SemanticException e) { + @Override public void acceptError(SemanticException e) { if (!e.wasReported()) { e.setReported(); reporter.log(Level.ERROR, StringUtil.quoteMessageFormat(e.getMessage())); @@ -149,8 +143,7 @@ public void acceptError(SemanticException e) { } } - @Override - public @Nullable SemanticException getFirstError() { + @Override public @Nullable SemanticException getFirstError() { return exception; } }; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SemanticException.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SemanticException.java index 99586a12ef8..eb42c6096c3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SemanticException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/SemanticException.java @@ -29,8 +29,7 @@ public SemanticException(String message, Throwable cause) { super(message, cause); } - @InternalApi - public void setReported() { + @InternalApi public void setReported() { reported = true; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/TextAvailableNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/TextAvailableNode.java index 8f400cbfb67..d638e944b2a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/TextAvailableNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/TextAvailableNode.java @@ -26,8 +26,7 @@ public interface TextAvailableNode extends Node { * the translated coordinate system, ie the coordinate system of * {@link #getTextDocument()}. */ - @Override - TextRegion getTextRegion(); + @Override TextRegion getTextRegion(); /** * Returns the original source code underlying this node, before @@ -36,8 +35,7 @@ public interface TextAvailableNode extends Node { * * @see TextDocument#sliceOriginalText(TextRegion) */ - @NoAttribute - default Chars getOriginalText() { + @NoAttribute default Chars getOriginalText() { return getTextDocument().sliceOriginalText(getTextRegion()); } @@ -48,8 +46,7 @@ default Chars getOriginalText() { * * @see TextDocument#sliceTranslatedText(TextRegion) */ - @NoAttribute - default Chars getText() { + @NoAttribute default Chars getText() { return getTextDocument().sliceTranslatedText(getTextRegion()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/AbstractNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/AbstractNode.java index 26be5e5240b..78ae90f3c92 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/AbstractNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/AbstractNode.java @@ -27,8 +27,8 @@ * in the java module). */ public abstract class AbstractNode, - // node the Node as first bound here is to make casts from Node to N noops at runtime. - N extends Node & GenericNode> implements GenericNode { + // node the Node as first bound here is to make casts from Node to N noops at runtime. + N extends Node & GenericNode> implements GenericNode { private static final Node[] EMPTY_ARRAY = new Node[0]; @@ -44,23 +44,19 @@ protected AbstractNode() { // only for subclassing } - @Override - public final N getParent() { + @Override public final N getParent() { return (N) parent; } - @Override - public final int getIndexInParent() { + @Override public final int getIndexInParent() { return childIndex; } - @Override - public final N getChild(final int index) { + @Override public final N getChild(final int index) { return (N) children[index]; } - @Override - public final int getNumChildren() { + @Override public final int getNumChildren() { return children.length; } @@ -68,8 +64,7 @@ protected void setParent(final B parent) { this.parent = parent; } - @SuppressWarnings("unchecked") - private B asSelf(Node n) { + @SuppressWarnings("unchecked") private B asSelf(Node n) { return (B) n; } @@ -123,7 +118,7 @@ protected void setChild(final B child, final int index) { */ protected void insertChild(final B child, final int index) { assert index >= 0 && index <= children.length - : "Invalid index for insertion into array of length " + children.length + ": " + index; + : "Invalid index for insertion into array of length " + children.length + ": " + index; Node[] newChildren = new Node[children.length + 1]; if (index != 0) { @@ -173,8 +168,7 @@ void setChildIndex(final int index) { childIndex = index; } - @Override - public DataMap> getUserMap() { + @Override public DataMap> getUserMap() { if (userData == null) { userData = DataMap.newDataMap(); } @@ -182,13 +176,11 @@ void setChildIndex(final int index) { } - @Override - public String toString() { + @Override public String toString() { return getXPathNodeName(); } - @Override - public final NodeStream children() { + @Override public final NodeStream children() { // Since this is used as a core part of tree traversal, the implementation // here is optimized. Importantly, this method is final and the // implementation returns always an instance of the same type, so @@ -196,9 +188,7 @@ public final NodeStream children() { return StreamImpl.childrenArray(this, children); } - @Override - @SuppressWarnings("unchecked") - public final @Nullable R firstChild(Class rClass) { + @Override @SuppressWarnings("unchecked") public final @Nullable R firstChild(Class rClass) { // This operation is extremely common so we give it an optimal // implementation, based directly on the array. This will never // create a node stream object, and array bounds are not checked. diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/GenericNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/GenericNode.java index 4b15afabd09..c69dfc3dbd8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/GenericNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/GenericNode.java @@ -31,61 +31,47 @@ @SuppressWarnings("unchecked") public interface GenericNode> extends Node { - @Override - N getChild(int index); + @Override N getChild(int index); - @Override - N getParent(); + @Override N getParent(); - @Override - @Nullable - default N getFirstChild() { + @Override @Nullable default N getFirstChild() { return getNumChildren() > 0 ? getChild(0) : null; } - @Override - @Nullable - default N getLastChild() { + @Override @Nullable default N getLastChild() { return getNumChildren() > 0 ? getChild(getNumChildren() - 1) : null; } - @Override - default NodeStream asStream() { + @Override default NodeStream asStream() { return StreamImpl.singleton((N) this); } - @Override - default NodeStream children() { + @Override default NodeStream children() { return (NodeStream) Node.super.children(); } - @Override - default DescendantNodeStream descendants() { + @Override default DescendantNodeStream descendants() { return (DescendantNodeStream) Node.super.descendants(); } - @Override - default DescendantNodeStream descendantsOrSelf() { + @Override default DescendantNodeStream descendantsOrSelf() { return (DescendantNodeStream) Node.super.descendantsOrSelf(); } - @Override - default NodeStream ancestorsOrSelf() { + @Override default NodeStream ancestorsOrSelf() { return (NodeStream) Node.super.ancestorsOrSelf(); } - @Override - default NodeStream ancestors() { + @Override default NodeStream ancestors() { return (NodeStream) Node.super.ancestors(); } - @Override - default @Nullable N getPreviousSibling() { + @Override default @Nullable N getPreviousSibling() { return (N) Node.super.getPreviousSibling(); } - @Override - default @Nullable N getNextSibling() { + @Override default @Nullable N getNextSibling() { return (N) Node.super.getNextSibling(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/SuppressionCommentImpl.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/SuppressionCommentImpl.java index b38d06597c4..f19143cba26 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/SuppressionCommentImpl.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/SuppressionCommentImpl.java @@ -33,13 +33,11 @@ public SuppressionCommentImpl(T token, String message) { this(token, t -> message); } - @Override - public String getUserMessage() { + @Override public String getUserMessage() { return messageGetter.apply(token); } - @Override - public Reportable getLocation() { + @Override public Reportable getLocation() { return token; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrBaseParser.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrBaseParser.java index e09a1613d8b..7b8f7552666 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrBaseParser.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrBaseParser.java @@ -20,12 +20,11 @@ * @param Type of the root node */ public abstract class AntlrBaseParser< - N extends AntlrNode, - R extends BaseAntlrInnerNode & RootNode - > implements Parser { + N extends AntlrNode, + R extends BaseAntlrInnerNode & RootNode +> implements Parser { - @Override - public R parse(ParserTask task) throws ParseException { + @Override public R parse(ParserTask task) throws ParseException { CharStream cs = CharStreams.fromString(task.getSourceText(), task.getTextDocument().getFileId().getAbsolutePath()); return parse(getLexer(cs), task); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrGeneratedParserBase.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrGeneratedParserBase.java index 6f2750966ad..db5338b1a44 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrGeneratedParserBase.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrGeneratedParserBase.java @@ -41,13 +41,11 @@ public AntlrGeneratedParserBase(TokenStream input) { } - @Override - public TerminalNode createTerminalNode(ParserRuleContext parent, Token t) { + @Override public TerminalNode createTerminalNode(ParserRuleContext parent, Token t) { return createPmdTerminal(parent, t).asAntlrNode(); } - @Override - public ErrorNode createErrorNode(ParserRuleContext parent, Token t) { + @Override public ErrorNode createErrorNode(ParserRuleContext parent, Token t) { return createPmdError(parent, t).asAntlrNode(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrNameDictionary.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrNameDictionary.java index ffbf2e29ccc..5dc40e947b8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrNameDictionary.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrNameDictionary.java @@ -79,7 +79,7 @@ public AntlrNameDictionary(Vocabulary vocab, String[] ruleNames) { assert Stream.of(terminalXPathNames).distinct().count() == terminalXPathNames.length - : "Duplicate names in " + Arrays.toString(terminalXPathNames); + : "Duplicate names in " + Arrays.toString(terminalXPathNames); } public Vocabulary getVocabulary() { @@ -95,76 +95,76 @@ public Vocabulary getVocabulary() { */ protected @Nullable String nonAlphaNumName(String name) { switch (name) { - case "!": return "bang"; - case "!!": return "double-bang"; - - case "?": return "question"; - case "??": return "double-question"; - case "?:": return "elvis"; - case "?.": return "question-dot"; - - case ":": return "colon"; - case ";": return "semi"; - case ",": return "comma"; - - case "(": return "lparen"; - case ")": return "rparen"; - case "[": return "lbracket"; - case "]": return "rbracket"; - case "{": return "lbrace"; - case "}": return "rbrace"; - - case "_": return "underscore"; - - case ".": return "dot"; - case "..": return "double-dot"; - case "...": return "ellipsis"; - - case "@": return "at-symbol"; - case "$": return "dollar"; - case "#": return "hash"; - - case "\\": return "backslash"; - case "/": return "slash"; - case "//": return "double-slash"; - case "`": return "backtick"; - case "'": return "squote"; - case "\"": return "dquote"; - case "\"\"\"": return "triple-quote"; - - case ">": return "gt"; - case ">=": return "ge"; - case "<": return "lt"; - case "<=": return "le"; - - case ">>": return "double-gt"; - case "<<": return "double-lt"; - case ">>>": return "triple-gt"; - case "<<<": return "triple-lt"; - - case "=": return "eq"; - case "==": return "double-eq"; - case "===": return "triple-eq"; - case "!=": return "not-eq"; - - case "&": return "amp"; - case "&&": return "double-amp"; - case "|": return "pipe"; - case "||": return "double-pipe"; - - case "*": return "star"; - case "**": return "double-star"; - - case "+": return "plus"; - case "++": return "double-plus"; - case "-": return "minus"; - case "--": return "double-minus"; - - case "->": return "rarrow"; - case "<-": return "larrow"; - - default: - return null; + case "!": return "bang"; + case "!!": return "double-bang"; + + case "?": return "question"; + case "??": return "double-question"; + case "?:": return "elvis"; + case "?.": return "question-dot"; + + case ":": return "colon"; + case ";": return "semi"; + case ",": return "comma"; + + case "(": return "lparen"; + case ")": return "rparen"; + case "[": return "lbracket"; + case "]": return "rbracket"; + case "{": return "lbrace"; + case "}": return "rbrace"; + + case "_": return "underscore"; + + case ".": return "dot"; + case "..": return "double-dot"; + case "...": return "ellipsis"; + + case "@": return "at-symbol"; + case "$": return "dollar"; + case "#": return "hash"; + + case "\\": return "backslash"; + case "/": return "slash"; + case "//": return "double-slash"; + case "`": return "backtick"; + case "'": return "squote"; + case "\"": return "dquote"; + case "\"\"\"": return "triple-quote"; + + case ">": return "gt"; + case ">=": return "ge"; + case "<": return "lt"; + case "<=": return "le"; + + case ">>": return "double-gt"; + case "<<": return "double-lt"; + case ">>>": return "triple-gt"; + case "<<<": return "triple-lt"; + + case "=": return "eq"; + case "==": return "double-eq"; + case "===": return "triple-eq"; + case "!=": return "not-eq"; + + case "&": return "amp"; + case "&&": return "double-amp"; + case "|": return "pipe"; + case "||": return "double-pipe"; + + case "*": return "star"; + case "**": return "double-star"; + + case "+": return "plus"; + case "++": return "double-plus"; + case "-": return "minus"; + case "--": return "double-minus"; + + case "->": return "rarrow"; + case "<-": return "larrow"; + + default: + return null; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrToken.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrToken.java index 4a12e8388d5..ad7334d9c1e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrToken.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrToken.java @@ -36,8 +36,7 @@ public class AntlrToken implements GenericToken { * * @deprecated Don't create antlr tokens directly, use an {@link AntlrTokenManager} */ - @Deprecated - public AntlrToken(final Token token, final AntlrToken previousComment, TextDocument textDoc) { + @Deprecated public AntlrToken(final Token token, final AntlrToken previousComment, TextDocument textDoc) { this.previousComment = previousComment; this.textDoc = textDoc; this.image = token.getText(); @@ -47,44 +46,36 @@ public AntlrToken(final Token token, final AntlrToken previousComment, TextDocum this.kind = token.getType(); } - @Override - public AntlrToken getNext() { + @Override public AntlrToken getNext() { return next; } - @Override - public AntlrToken getPreviousComment() { + @Override public AntlrToken getPreviousComment() { return previousComment; } - @Override - public CharSequence getImageCs() { + @Override public CharSequence getImageCs() { return image; } /** Returns a text region with the coordinates of this token. */ - @Override - public TextRegion getRegion() { + @Override public TextRegion getRegion() { return TextRegion.fromBothOffsets(startOffset, endOffset); } - @Override - public FileLocation getReportLocation() { + @Override public FileLocation getReportLocation() { return textDoc.toLocation(getRegion()); } - @Override - public boolean isEof() { + @Override public boolean isEof() { return getKind() == Token.EOF; } - @Override - public int compareTo(AntlrToken o) { + @Override public int compareTo(AntlrToken o) { return getRegion().compareTo(o.getRegion()); } - @Override - public int getKind() { + @Override public int getKind() { return kind; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrTokenManager.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrTokenManager.java index 5828195850f..16438487734 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrTokenManager.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/AntlrTokenManager.java @@ -29,8 +29,7 @@ public AntlrTokenManager(final Lexer lexer, final TextDocument textDocument) { resetListeners(); } - @Override - public AntlrToken getNextToken() { + @Override public AntlrToken getNextToken() { AntlrToken nextToken = getNextTokenFromAnyChannel(); while (!nextToken.isDefault()) { nextToken = getNextTokenFromAnyChannel(); @@ -56,13 +55,12 @@ private void resetListeners() { private final class ErrorHandler extends BaseErrorListener { - @Override - public void syntaxError(final Recognizer recognizer, - final Object offendingSymbol, - final int line, - final int charPositionInLine, - final String msg, - final RecognitionException ex) { + @Override public void syntaxError(final Recognizer recognizer, + final Object offendingSymbol, + final int line, + final int charPositionInLine, + final String msg, + final RecognitionException ex) { throw new LexException(line, charPositionInLine, textDoc.getFileId(), msg, ex); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrErrorNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrErrorNode.java index 33babb7eacc..05502ab3af3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrErrorNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrErrorNode.java @@ -13,19 +13,16 @@ protected BaseAntlrErrorNode(Token symbol) { super(symbol, true); } - @Override - protected final AntlrErrorPmdAdapter asAntlrNode() { + @Override protected final AntlrErrorPmdAdapter asAntlrNode() { return (AntlrErrorPmdAdapter) super.asAntlrNode(); } - @Override - public @NonNull String getText() { + @Override public @NonNull String getText() { return getFirstAntlrToken().getText(); } - @Override - public final String getXPathNodeName() { + @Override public final String getXPathNodeName() { return "Error"; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrInnerNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrInnerNode.java index 03c37ca2471..ff7e125d6b9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrInnerNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrInnerNode.java @@ -37,9 +37,7 @@ protected BaseAntlrInnerNode(ParserRuleContext parent, int invokingStateNumber) antlrNode = new PmdAsAntlrInnerNode<>(this, (PmdAsAntlrInnerNode) parent, invokingStateNumber); } - @Override - @SuppressWarnings("unchecked") - public N getChild(int index) { + @Override @SuppressWarnings("unchecked") public N getChild(int index) { if (0 <= index && index < getNumChildren()) { N pmdNode = (N) antlrNode.getChild(index).getPmdNode(); assert pmdNode.getIndexInParent() == index; @@ -48,26 +46,22 @@ public N getChild(int index) { throw new IndexOutOfBoundsException("Index " + index + ", numChildren " + getNumChildren()); } - @Override - public int getNumChildren() { + @Override public int getNumChildren() { return antlrNode.getChildCount(); } - @Override - protected PmdAsAntlrInnerNode asAntlrNode() { + @Override protected PmdAsAntlrInnerNode asAntlrNode() { return antlrNode; } protected abstract int getRuleIndex(); - @Override - public Token getFirstAntlrToken() { + @Override public Token getFirstAntlrToken() { return asAntlrNode().start; } - @Override - public Token getLastAntlrToken() { + @Override public Token getLastAntlrToken() { return asAntlrNode().stop; } @@ -80,18 +74,17 @@ protected > List getRuleContexts(Class kla } protected TerminalNode getToken(int kind, int idx) { - @SuppressWarnings("rawtypes") - BaseAntlrTerminalNode pmdWrapper = - children(BaseAntlrTerminalNode.class) - .filter(it -> it.getTokenKind() == kind) - .get(idx); + @SuppressWarnings("rawtypes") BaseAntlrTerminalNode pmdWrapper = + children(BaseAntlrTerminalNode.class) + .filter(it -> it.getTokenKind() == kind) + .get(idx); return pmdWrapper != null ? pmdWrapper.asAntlrNode() : null; } protected List getTokens(int kind) { return children(BaseAntlrTerminalNode.class) - .filter(it -> it.getTokenKind() == kind) - .toList(BaseAntlrTerminalNode::asAntlrNode); + .filter(it -> it.getTokenKind() == kind) + .toList(BaseAntlrTerminalNode::asAntlrNode); } protected void copyFrom(BaseAntlrInnerNode other) { @@ -121,39 +114,31 @@ protected static class PmdAsAntlrInnerNode> extends Parse this.pmdNode = node; } - @Override - public BaseAntlrInnerNode getPmdNode() { + @Override public BaseAntlrInnerNode getPmdNode() { return pmdNode; } - @Override - @SuppressWarnings("unchecked") - public PmdAsAntlrInnerNode getParent() { + @Override @SuppressWarnings("unchecked") public PmdAsAntlrInnerNode getParent() { return (PmdAsAntlrInnerNode) super.getParent(); } - @Override - @SuppressWarnings("unchecked") - public AntlrToPmdParseTreeAdapter getChild(int i) { + @Override @SuppressWarnings("unchecked") public AntlrToPmdParseTreeAdapter getChild(int i) { return (AntlrToPmdParseTreeAdapter) super.getChild(i); } - @Override - public T addAnyChild(T t) { + @Override public T addAnyChild(T t) { assert t instanceof AntlrToPmdParseTreeAdapter; BaseAntlrNode pmdNode = ((AntlrToPmdParseTreeAdapter) t).getPmdNode(); pmdNode.setIndexInParent(getChildCount()); return super.addAnyChild(t); } - @Override - public void setParent(RuleContext parent) { + @Override public void setParent(RuleContext parent) { assert parent instanceof PmdAsAntlrInnerNode; super.setParent(parent); } - @Override - public T accept(ParseTreeVisitor visitor) { + @Override public T accept(ParseTreeVisitor visitor) { throw new UnsupportedOperationException("Cannot visit the underlying antlr nodes"); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrNode.java index 6ef7ab6d9ab..89b032b1f37 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrNode.java @@ -56,52 +56,44 @@ protected BaseAntlrNode() { public abstract Token getLastAntlrToken(); - @Override - public TextRegion getTextRegion() { + @Override public TextRegion getTextRegion() { return TextRegion.fromBothOffsets(getFirstAntlrToken().getStartIndex(), - getLastAntlrToken().getStopIndex() + 1); + getLastAntlrToken().getStopIndex() + 1); } void setIndexInParent(int indexInParent) { this.indexInParent = indexInParent; } - @Override - public N getParent() { + @Override public N getParent() { AntlrToPmdParseTreeAdapter parent = asAntlrNode().getParent(); return parent == null ? null : (N) parent.getPmdNode(); } - @Override - public int getBeginLine() { + @Override public int getBeginLine() { return getFirstAntlrToken().getLine(); // This goes from 1 to n } - @Override - public int getEndLine() { + @Override public int getEndLine() { // FIXME this is not the end line if the stop token spans several lines return getLastAntlrToken().getLine(); } - @Override - public int getBeginColumn() { + @Override public int getBeginColumn() { return getFirstAntlrToken().getCharPositionInLine() + 1; } - @Override - public int getEndColumn() { + @Override public int getEndColumn() { Token tok = getLastAntlrToken(); return tok.getCharPositionInLine() + tok.getStopIndex() - tok.getStartIndex() + 1; } - @Override - public int getIndexInParent() { + @Override public int getIndexInParent() { assert getParent() == null || indexInParent >= 0 : "Index not set"; return indexInParent; } - @Override - public DataMap> getUserMap() { + @Override public DataMap> getUserMap() { if (userMap == null) { userMap = DataMap.newDataMap(); } @@ -116,7 +108,6 @@ protected interface AntlrToPmdParseTreeAdapter> extends P BaseAntlrNode getPmdNode(); - @Override - AntlrToPmdParseTreeAdapter getParent(); + @Override AntlrToPmdParseTreeAdapter getParent(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrTerminalNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrTerminalNode.java index 3f7b574edbf..d256dce9ab0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrTerminalNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/antlr4/BaseAntlrTerminalNode.java @@ -18,7 +18,7 @@ * Base class for terminal nodes (they wrap a {@link TerminalNode}). */ public abstract class BaseAntlrTerminalNode> - extends BaseAntlrNode, N> { + extends BaseAntlrNode, N> { private final AntlrTerminalPmdAdapter antlrNode; @@ -42,23 +42,19 @@ protected BaseAntlrTerminalNode(Token symbol) { */ public abstract @NonNull String getText(); - @Override - protected AntlrTerminalPmdAdapter asAntlrNode() { + @Override protected AntlrTerminalPmdAdapter asAntlrNode() { return antlrNode; } - @Override - public Token getFirstAntlrToken() { + @Override public Token getFirstAntlrToken() { return antlrNode.symbol; } - @Override - public Token getLastAntlrToken() { + @Override public Token getLastAntlrToken() { return antlrNode.symbol; } - @Override - public int getNumChildren() { + @Override public int getNumChildren() { return 0; } @@ -66,8 +62,7 @@ protected int getTokenKind() { return antlrNode.symbol.getTokenIndex(); } - @Override - public N getChild(int index) { + @Override public N getChild(int index) { throw new IndexOutOfBoundsException("Index " + index + " for terminal node"); } @@ -80,19 +75,16 @@ public AntlrTerminalPmdAdapter(BaseAntlrTerminalNode pmdNode, Token symbol) { this.pmdNode = pmdNode; } - @Override - public AntlrToPmdParseTreeAdapter getParent() { + @Override public AntlrToPmdParseTreeAdapter getParent() { return (AntlrToPmdParseTreeAdapter) super.getParent(); } - @Override - public void setParent(RuleContext parent) { + @Override public void setParent(RuleContext parent) { assert parent instanceof BaseAntlrNode.AntlrToPmdParseTreeAdapter; super.setParent(parent); } - @Override - public BaseAntlrNode getPmdNode() { + @Override public BaseAntlrNode getPmdNode() { return pmdNode; } } @@ -103,8 +95,7 @@ public AntlrErrorPmdAdapter(BaseAntlrTerminalNode pmdNode, Token symbol) { super(pmdNode, symbol); } - @Override - public T accept(ParseTreeVisitor visitor) { + @Override public T accept(ParseTreeVisitor visitor) { return visitor.visitErrorNode(this); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/AbstractJjtreeNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/AbstractJjtreeNode.java index 6c9394246dd..21ff93574ad 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/AbstractJjtreeNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/AbstractJjtreeNode.java @@ -42,14 +42,12 @@ protected void setImage(String image) { this.image = image; } - @Override - public final TextRegion getTextRegion() { + @Override public final TextRegion getTextRegion() { return TextRegion.fromBothOffsets(getFirstToken().getStartOffset(), - getLastToken().getEndOffset()); + getLastToken().getEndOffset()); } - @Override - public final int compareLocation(Node other) { + @Override public final int compareLocation(Node other) { if (other instanceof JjtreeNode) { return getTextRegion().compareTo(((JjtreeNode) other).getTextRegion()); } @@ -77,8 +75,7 @@ protected void addChild(B child, int index) { } - @Override - protected void insertChild(B child, int index) { + @Override protected void insertChild(B child, int index) { super.insertChild(child, index); fitTokensToChildren(index); } @@ -113,13 +110,11 @@ private void enlargeRight(JavaccToken childLast) { } } - @Override - public JavaccToken getFirstToken() { + @Override public JavaccToken getFirstToken() { return firstToken; } - @Override - public JavaccToken getLastToken() { + @Override public JavaccToken getLastToken() { return lastToken; } @@ -136,10 +131,9 @@ protected void setFirstToken(JavaccToken token) { /** * This toString implementation is only meant for debugging purposes. */ - @Override - public String toString() { + @Override public String toString() { FileLocation loc = getReportLocation(); return "!debug only! [" + getXPathNodeName() + ":" + loc.getStartPos().toDisplayStringWithColon() + "]" - + StringUtil.elide(getText().toString(), 150, "(truncated)"); + + StringUtil.elide(getText().toString(), 150, "(truncated)"); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/AbstractTokenManager.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/AbstractTokenManager.java index 7d22db054c3..db3a0d9107f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/AbstractTokenManager.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/AbstractTokenManager.java @@ -24,8 +24,7 @@ public abstract class AbstractTokenManager implements TokenManager /** * @deprecated Since 7.14.0. Don't use this map directly anymore. Instead, use {@link #getSuppressionComments()}. */ - @Deprecated - protected Map suppressMap = new HashMap<>(); + @Deprecated protected Map suppressMap = new HashMap<>(); protected String suppressMarker = PMDConfiguration.DEFAULT_SUPPRESS_MARKER; public void setSuppressMarker(String marker) { @@ -35,8 +34,7 @@ public void setSuppressMarker(String marker) { /** * @deprecated since 7.14.0. Use {@link #getSuppressionComments()} instead. */ - @Deprecated - public Map getSuppressMap() { + @Deprecated public Map getSuppressMap() { return suppressMap; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/BackslashEscapeTranslator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/BackslashEscapeTranslator.java index 5ed965f9ae4..f455e814d91 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/BackslashEscapeTranslator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/BackslashEscapeTranslator.java @@ -29,8 +29,7 @@ public BackslashEscapeTranslator(TextDocument builder) { super(builder); } - @Override - protected int gobbleMaxWithoutEscape(final int maxOff) throws MalformedSourceException { + @Override protected int gobbleMaxWithoutEscape(final int maxOff) throws MalformedSourceException { int notEscapeEnd = this.savedNotEscapeSpecialEnd; int off = input.indexOf(BACKSLASH, bufpos, min(maxOff, notEscapeEnd)); if (off == -1) { @@ -43,8 +42,7 @@ protected int gobbleMaxWithoutEscape(final int maxOff) throws MalformedSourceExc protected abstract int handleBackslash(int maxOff, int firstBackslashOff) throws MalformedSourceException; - @Override - protected int recordEscape(int startOffsetInclusive, int endOffsetExclusive, Chars translation) { + @Override protected int recordEscape(int startOffsetInclusive, int endOffsetExclusive, Chars translation) { this.savedNotEscapeSpecialEnd = Integer.MAX_VALUE; return super.recordEscape(startOffsetInclusive, endOffsetExclusive, translation); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaEscapeTranslator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaEscapeTranslator.java index 3a6d99e4bd6..e21a924dce3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaEscapeTranslator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaEscapeTranslator.java @@ -17,8 +17,7 @@ public JavaEscapeTranslator(TextDocument input) { super(input); } - @Override - protected int handleBackslash(final int maxOff, final int firstBackslashOff) throws MalformedSourceException { + @Override protected int handleBackslash(final int maxOff, final int firstBackslashOff) throws MalformedSourceException { int off = firstBackslashOff; while (off < input.length() && input.charAt(off) == '\\') { off++; @@ -27,7 +26,7 @@ protected int handleBackslash(final int maxOff, final int firstBackslashOff) thr int bslashCount = off - firstBackslashOff; // is there an escape at offset firstBslashOff? if ((bslashCount & 1) == 1 // odd number of backslashes - && off < input.length() && input.charAt(off) == 'u') { // at least one 'u' + && off < input.length() && input.charAt(off) == 'u') { // at least one 'u' // this is enough to expect an escape or throw an exception while (off < input.length() && input.charAt(off) == 'u') { // consume all the 'u's @@ -45,11 +44,11 @@ private Chars escapeValue(int posOfFirstBackSlash, final int offOfTheU) throws M int off = offOfTheU; try { char c = (char) - ( hexVal(input.charAt(++off)) << 12 // SUPPRESS CHECKSTYLE paren pad - | hexVal(input.charAt(++off)) << 8 - | hexVal(input.charAt(++off)) << 4 - | hexVal(input.charAt(++off)) - ); + ( hexVal(input.charAt(++off)) << 12 // SUPPRESS CHECKSTYLE paren pad + | hexVal(input.charAt(++off)) << 8 + | hexVal(input.charAt(++off)) << 4 + | hexVal(input.charAt(++off)) + ); return Chars.wrap(Character.toString(c)); } catch (NumberFormatException | IndexOutOfBoundsException e) { @@ -61,33 +60,33 @@ private Chars escapeValue(int posOfFirstBackSlash, final int offOfTheU) throws M private static int hexVal(char c) { switch (c) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return c - '0'; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - return c - ('A' - 10); - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - return c - ('a' - 10); - default: - throw new NumberFormatException("Character '" + c + "' is not a valid hexadecimal digit"); + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return c - '0'; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + return c - ('A' - 10); + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + return c - ('a' - 10); + default: + throw new NumberFormatException("Character '" + c + "' is not a valid hexadecimal digit"); } } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaccToken.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaccToken.java index 70bbc59b8a6..7000ad9df6b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaccToken.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaccToken.java @@ -116,34 +116,28 @@ public final JavaccTokenDocument getDocument() { return document; } - @Override - public boolean isEof() { + @Override public boolean isEof() { return kind == EOF; } - @Override - public int getKind() { + @Override public int getKind() { return kind; } - @Override - public JavaccToken getNext() { + @Override public JavaccToken getNext() { return next; } - @Override - public JavaccToken getPreviousComment() { + @Override public JavaccToken getPreviousComment() { return specialToken; } - @Override - public Chars getImageCs() { + @Override public Chars getImageCs() { // wrap it: it's zero cost (images are either Chars or String) and Chars has a nice API return Chars.wrap(image); } - @Override - public String getImage() { + @Override public String getImage() { return image.toString(); } @@ -157,8 +151,7 @@ public Chars getText() { return document.getTextDocument().sliceOriginalText(getRegion()); } - @Override - public final TextRegion getRegion() { + @Override public final TextRegion getRegion() { return TextRegion.fromBothOffsets(startOffset, endOffset); } @@ -170,18 +163,15 @@ int getEndOffset() { return endOffset; } - @Override - public FileLocation getReportLocation() { + @Override public FileLocation getReportLocation() { return document.getTextDocument().toLocation(getRegion()); } - @Override - public boolean isImplicit() { + @Override public boolean isImplicit() { return kind == IMPLICIT_TOKEN; } - @Override - public String toString() { + @Override public String toString() { return document.describeKind(kind) + ": " + getImage(); } @@ -195,11 +185,11 @@ public String toString() { */ public JavaccToken replaceImage(CharStream charStream) { return new JavaccToken( - this.kind, - charStream.getTokenImageCs(), - this.startOffset, - charStream.getEndOffset(), - this.document + this.kind, + charStream.getTokenImageCs(), + this.startOffset, + charStream.getEndOffset(), + this.document ); } @@ -214,11 +204,11 @@ public JavaccToken replaceImage(CharStream charStream) { */ public JavaccToken withKind(int newKind) { JavaccToken tok = new JavaccToken( - newKind, - this.image, - this.startOffset, - this.endOffset, - this.document + newKind, + this.image, + this.startOffset, + this.endOffset, + this.document ); tok.specialToken = this.specialToken; tok.next = this.next; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaccTokenDocument.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaccTokenDocument.java index 4de99f4118d..19eec46652a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaccTokenDocument.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaccTokenDocument.java @@ -122,11 +122,11 @@ public TextDocument translate(TextDocument text) throws MalformedSourceException */ public JavaccToken createToken(JavaccTokenDocument self, int kind, CharStream cs, @Nullable String image) { return new JavaccToken( - kind, - image == null ? cs.getTokenImageCs() : image, - cs.getStartOffset(), - cs.getEndOffset(), - self + kind, + image == null ? cs.getTokenImageCs() : image, + cs.getStartOffset(), + cs.getEndOffset(), + self ); } } @@ -155,8 +155,7 @@ public JavaccToken open() { } - @Override - public JavaccToken getFirstToken() { + @Override public JavaccToken getFirstToken() { if (first == null || first.next == null) { throw new IllegalStateException("Document has not been opened"); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JjtreeParserAdapter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JjtreeParserAdapter.java index 3838c48655a..bfd4ead0cff 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JjtreeParserAdapter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/JjtreeParserAdapter.java @@ -24,8 +24,7 @@ protected JjtreeParserAdapter() { protected abstract JavaccTokenDocument.TokenDocumentBehavior tokenBehavior(); - @Override - public final R parse(ParserTask task) throws ParseException { + @Override public final R parse(ParserTask task) throws ParseException { try { // First read the source file and interpret escapes CharStream charStream = CharStream.create(task.getTextDocument(), tokenBehavior()); @@ -42,8 +41,7 @@ public final R parse(ParserTask task) throws ParseException { protected abstract R parseImpl(CharStream cs, ParserTask task) throws ParseException; - @Override - public String toString() { + @Override public String toString() { return getClass().getSimpleName(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/MalformedSourceException.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/MalformedSourceException.java index 05927d6d907..e6a2f84a7b2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/MalformedSourceException.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/impl/javacc/MalformedSourceException.java @@ -25,13 +25,11 @@ public MalformedSourceException(String message, Throwable cause, FileLocation fi setFileId(fileLocation.getFileId()); } - @Override - protected @NonNull FileLocation location() { + @Override protected @NonNull FileLocation location() { return location; } - @Override - protected String errorKind() { + @Override protected String errorKind() { return "Source format error"; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AncestorOrSelfIterator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AncestorOrSelfIterator.java index 09446e2d600..2c22a3edf5a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AncestorOrSelfIterator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AncestorOrSelfIterator.java @@ -21,14 +21,12 @@ class AncestorOrSelfIterator implements Iterator<@NonNull Node> { next = top; } - @Override - public boolean hasNext() { + @Override public boolean hasNext() { return next != null; } - @Override - public Node next() { + @Override public Node next() { Node n = next; if (n == null) { throw new NoSuchElementException(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AxisStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AxisStream.java index 815c49d253f..9caeab4f02f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AxisStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/AxisStream.java @@ -39,27 +39,22 @@ abstract class AxisStream extends IteratorBasedNStream { this.filter = filter; } - @Override - @SuppressWarnings("unchecked") - public final Iterator iterator() { + @Override @SuppressWarnings("unchecked") public final Iterator iterator() { return (Iterator) filter.filterMap(baseIterator()); } protected abstract Iterator baseIterator(); - @Override - public NodeStream<@NonNull R> map(Function mapper) { + @Override public NodeStream<@NonNull R> map(Function mapper) { return copyWithFilter(filter.thenApply(mapper)); } - @Override - public NodeStream filter(Predicate predicate) { + @Override public NodeStream filter(Predicate predicate) { return copyWithFilter(filter.thenFilter(predicate)); } - @Override - public NodeStream filterIs(Class r1Class) { + @Override public NodeStream filterIs(Class r1Class) { return copyWithFilter(filter.thenCast(r1Class)); } @@ -82,44 +77,35 @@ protected List toListImpl(Filtermap filter) { return IteratorUtil.toList(iter); } - @Override - public @Nullable T first() { + @Override public @Nullable T first() { return firstImpl(filter); } - @Override - public @Nullable R first(Class r1Class) { + @Override public @Nullable R first(Class r1Class) { return firstImpl(filter.thenCast(r1Class)); } - @Override - public @Nullable T first(Predicate predicate) { + @Override public @Nullable T first(Predicate predicate) { return firstImpl(filter.thenFilter(predicate)); } - @Nullable - @Override - public T last() { + @Nullable @Override public T last() { return lastImpl(filter); } - @Override - public List toList() { + @Override public List toList() { return toListImpl(this.filter); } - @Override - public List toList(Function mapper) { + @Override public List toList(Function mapper) { return toListImpl(this.filter.thenApply(mapper)); } - @Override - public @Nullable R last(Class rClass) { + @Override public @Nullable R last(Class rClass) { return lastImpl(filter.thenCast(rClass)); } - @Override - public String toString() { + @Override public String toString() { return getClass().getSimpleName() + "[" + node + "] -> " + toList(); } @@ -137,13 +123,11 @@ static class FilteredAncestorOrSelfStream extends AxisStream super(node, target); } - @Override - protected Iterator baseIterator() { + @Override protected Iterator baseIterator() { return new AncestorOrSelfIterator(node); } - @Override - public NodeStream drop(int n) { + @Override public NodeStream drop(int n) { AssertionUtil.requireNonNegative("n", n); if (n == 0) { return this; @@ -153,8 +137,7 @@ public NodeStream drop(int n) { return StreamImpl.ancestorsOrSelf(nth, filter); // c.ancestorsOrSelf() == [c] } - @Override - protected NodeStream copyWithFilter(Filtermap filterMap) { + @Override protected NodeStream copyWithFilter(Filtermap filterMap) { S newFirst = TraversalUtils.getFirstParentOrSelfMatching(node, filterMap); if (newFirst == null) { return StreamImpl.empty(); @@ -163,18 +146,15 @@ protected NodeStream copyWithFilter(Filtermap @Nullable O firstImpl(Filtermap filter) { + @Override protected @Nullable O firstImpl(Filtermap filter) { return TraversalUtils.getFirstParentOrSelfMatching(node, filter); } } @@ -185,19 +165,15 @@ static class AncestorOrSelfStream extends FilteredAncestorOrSelfStream { super(node, Filtermap.NODE_IDENTITY); } - @Nullable - @Override - public Node first() { + @Nullable @Override public Node first() { return node; } - @Override - public boolean nonEmpty() { + @Override public boolean nonEmpty() { return true; } - @Override - public @Nullable Node last() { + @Override public @Nullable Node last() { Node last = node; while (last.getParent() != null) { last = last.getParent(); @@ -211,23 +187,21 @@ abstract static class DescendantStreamBase extends AxisStream final TreeWalker walker; DescendantStreamBase(@NonNull Node root, - TreeWalker walker, - Filtermap filter) { + TreeWalker walker, + Filtermap filter) { super(root, filter); this.walker = walker; } protected abstract DescendantNodeStream copyWithWalker(Filtermap filterMap, TreeWalker walker); - @Override - public DescendantNodeStream crossFindBoundaries(boolean cross) { + @Override public DescendantNodeStream crossFindBoundaries(boolean cross) { return walker.isCrossFindBoundaries() == cross - ? this - : copyWithWalker(this.filter, walker.crossFindBoundaries(cross)); + ? this + : copyWithWalker(this.filter, walker.crossFindBoundaries(cross)); } - @Override - protected NodeStream copyWithFilter(Filtermap filterMap) { + @Override protected NodeStream copyWithFilter(Filtermap filterMap) { return copyWithWalker(filterMap, walker); } } @@ -235,33 +209,28 @@ protected NodeStream copyWithFilter(Filtermap extends DescendantStreamBase { FilteredDescendantStream(Node node, - TreeWalker walker, - Filtermap target) { + TreeWalker walker, + Filtermap target) { super(node, walker, target); } - @Override - protected Iterator baseIterator() { + @Override protected Iterator baseIterator() { return walker.descendantIterator(node); } - @Override - protected DescendantNodeStream copyWithWalker(Filtermap filterMap, TreeWalker walker) { + @Override protected DescendantNodeStream copyWithWalker(Filtermap filterMap, TreeWalker walker) { return new FilteredDescendantStream<>(node, walker, filterMap); } - @Override - protected @Nullable O firstImpl(Filtermap filter) { + @Override protected @Nullable O firstImpl(Filtermap filter) { return walker.getFirstDescendantOfType(node, filter); } - @Override - public boolean nonEmpty() { + @Override public boolean nonEmpty() { return walker.getFirstDescendantOfType(node, filter) != null; } - @Override - protected List toListImpl(Filtermap filter) { + @Override protected List toListImpl(Filtermap filter) { return walker.findDescendantsMatching(node, filter); } } @@ -272,14 +241,12 @@ static class DescendantStream extends FilteredDescendantStream { super(node, walker, Filtermap.NODE_IDENTITY); } - @Override - public DescendantNodeStream crossFindBoundaries(boolean cross) { + @Override public DescendantNodeStream crossFindBoundaries(boolean cross) { return new DescendantStream(node, walker.crossFindBoundaries(cross)); } - @Override - public boolean nonEmpty() { + @Override public boolean nonEmpty() { return node.getNumChildren() > 0; } } @@ -287,23 +254,20 @@ public boolean nonEmpty() { static class FilteredDescendantOrSelfStream extends DescendantStreamBase { FilteredDescendantOrSelfStream(Node node, - TreeWalker walker, - Filtermap filtermap) { + TreeWalker walker, + Filtermap filtermap) { super(node, walker, filtermap); } - @Override - public Iterator baseIterator() { + @Override public Iterator baseIterator() { return walker.descendantOrSelfIterator(node); } - @Override - protected DescendantNodeStream copyWithWalker(Filtermap filterMap, TreeWalker walker) { + @Override protected DescendantNodeStream copyWithWalker(Filtermap filterMap, TreeWalker walker) { return new FilteredDescendantOrSelfStream<>(node, walker, filterMap); } - @Override - protected List toListImpl(Filtermap filter) { + @Override protected List toListImpl(Filtermap filter) { List result = new ArrayList<>(); O top = filter.apply(node); if (top != null) { @@ -320,19 +284,15 @@ static final class DescendantOrSelfStream extends FilteredDescendantOrSelfStream super(node, walker, Filtermap.NODE_IDENTITY); } - @Override - public DescendantNodeStream crossFindBoundaries(boolean cross) { + @Override public DescendantNodeStream crossFindBoundaries(boolean cross) { return new DescendantOrSelfStream(node, walker.crossFindBoundaries(cross)); } - @Nullable - @Override - public Node first() { + @Nullable @Override public Node first() { return node; } - @Override - public boolean nonEmpty() { + @Override public boolean nonEmpty() { return true; } } @@ -353,56 +313,46 @@ static class FilteredChildrenStream extends AxisStream { } - @Override - public NodeStream flatMap(Function> mapper) { + @Override public NodeStream flatMap(Function> mapper) { // all operations like #children, #followingSiblings, etc // operate on an eagerly evaluated stream. May be empty or // singleton return StreamImpl.fromNonNullList(toList()).flatMap(mapper); } - @Override - protected NodeStream copyWithFilter(Filtermap filterMap) { + @Override protected NodeStream copyWithFilter(Filtermap filterMap) { return new FilteredChildrenStream<>(node, filterMap, low, len); } - @Override - public Spliterator spliterator() { + @Override public Spliterator spliterator() { return Spliterators.spliterator(iterator(), count(), Spliterator.SIZED | Spliterator.ORDERED); } - @Override - protected Iterator baseIterator() { + @Override protected Iterator baseIterator() { return TraversalUtils.childrenIterator(node, low, low + len); } - @Override - protected @Nullable O firstImpl(Filtermap filter) { + @Override protected @Nullable O firstImpl(Filtermap filter) { return TraversalUtils.getFirstChildMatching(node, filter, low, len); } - @Override - protected @Nullable O lastImpl(Filtermap filter) { + @Override protected @Nullable O lastImpl(Filtermap filter) { return TraversalUtils.getLastChildMatching(node, filter, low, len); } - @Override - public int count() { + @Override public int count() { return TraversalUtils.countChildrenMatching(node, filter, low, len); } - @Override - public boolean nonEmpty() { + @Override public boolean nonEmpty() { return first() != null; } - @Override - protected List toListImpl(Filtermap filter) { + @Override protected List toListImpl(Filtermap filter) { return TraversalUtils.findChildrenMatching(node, filter, low, len); } - @Override - public NodeStream take(int maxSize) { + @Override public NodeStream take(int maxSize) { AssertionUtil.requireNonNegative("maxSize", maxSize); // eager evaluation if (maxSize == 1) { @@ -412,8 +362,7 @@ public NodeStream take(int maxSize) { return StreamImpl.fromNonNullList(matching); } - @Override - public NodeStream drop(int n) { + @Override public NodeStream drop(int n) { AssertionUtil.requireNonNegative("n", n); if (n == 0) { return this; @@ -421,8 +370,7 @@ public NodeStream drop(int n) { return StreamImpl.fromNonNullList(toList()).drop(n); } - @Override - public String toString() { + @Override public String toString() { return "FilteredSlice[" + node + ", " + low + ".." + (low + len) + "] -> " + toList(); } } @@ -435,34 +383,26 @@ static class ChildrenStream extends FilteredChildrenStream { super(root, Filtermap.NODE_IDENTITY, low, len); } - @Nullable - @Override - public Node first() { + @Nullable @Override public Node first() { return len > 0 ? node.getChild(low) : null; } - @Nullable - @Override - public Node last() { + @Nullable @Override public Node last() { return len > 0 ? node.getChild(low + len - 1) : null; } - @Nullable - @Override - public Node get(int n) { + @Nullable @Override public Node get(int n) { AssertionUtil.requireNonNegative("n", n); return len > 0 && n < len ? node.getChild(low + n) : null; } - @Override - public NodeStream take(int maxSize) { + @Override public NodeStream take(int maxSize) { AssertionUtil.requireNonNegative("maxSize", maxSize); return StreamImpl.sliceChildren(node, filter, low, min(maxSize, len)); } - @Override - public NodeStream drop(int n) { + @Override public NodeStream drop(int n) { AssertionUtil.requireNonNegative("n", n); if (n == 0) { return this; @@ -472,8 +412,7 @@ public NodeStream drop(int n) { return StreamImpl.sliceChildren(node, filter, newLow, newLen); } - @Override - public NodeStream dropLast(int n) { + @Override public NodeStream dropLast(int n) { AssertionUtil.requireNonNegative("n", n); if (n == 0) { return this; @@ -481,18 +420,15 @@ public NodeStream dropLast(int n) { return take(max(len - n, 0)); } - @Override - public boolean nonEmpty() { + @Override public boolean nonEmpty() { return len > 0; } - @Override - public int count() { + @Override public int count() { return len; } - @Override - public String toString() { + @Override public String toString() { return "Slice[" + node + ", " + low + ".." + (low + len) + "] -> " + toList(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/Filtermap.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/Filtermap.java index 1fdebf708ff..774abce539c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/Filtermap.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/Filtermap.java @@ -33,12 +33,10 @@ interface Filtermap extends Function<@NonNull I, @Nullable O>, Predicate<@ * Returns a null value if the filter accepts the value. Otherwise * returns the transformed value. MUST return null for null parameter. */ - @Override - @Nullable O apply(@Nullable I i); + @Override @Nullable O apply(@Nullable I i); - @Override - default boolean test(@Nullable I i) { + @Override default boolean test(@Nullable I i) { return apply(i) != null; } @@ -72,25 +70,19 @@ default Filtermap thenFilter(Predicate rClass) { static Filtermap identityFilter() { return new Filtermap() { - @Override - public I apply(@Nullable I i) { + @Override public I apply(@Nullable I i) { return i; } - @Override - @SuppressWarnings("unchecked") - public Filtermap thenApply(Function<@NonNull ? super I, @Nullable ? extends R> then) { + @Override @SuppressWarnings("unchecked") public Filtermap thenApply(Function<@NonNull ? super I, @Nullable ? extends R> then) { return then instanceof Filtermap ? (Filtermap) then : Filtermap.super.thenApply(then); } - @Override - @SuppressWarnings("unchecked") - public Iterator filterMap(Iterator iter) { + @Override @SuppressWarnings("unchecked") public Iterator filterMap(Iterator iter) { return (Iterator) iter; } - @Override - public String toString() { + @Override public String toString() { return "IdentityFilter"; } }; @@ -108,14 +100,11 @@ static Filtermap isInstance(Class oClass) { } return new Filtermap() { - @Override - @SuppressWarnings("unchecked") - public @Nullable O apply(@Nullable I i) { + @Override @SuppressWarnings("unchecked") public @Nullable O apply(@Nullable I i) { return oClass.isInstance(i) ? (O) i : null; } - @Override - public String toString() { + @Override public String toString() { return "IsInstance[" + oClass + "]"; } }; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/GreedyNStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/GreedyNStream.java index 98f7eee9361..f66d9a3bc54 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/GreedyNStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/GreedyNStream.java @@ -25,61 +25,51 @@ */ abstract class GreedyNStream extends IteratorBasedNStream { - @Override - protected NodeStream mapIter(Function, Iterator> fun) { + @Override protected NodeStream mapIter(Function, Iterator> fun) { return StreamImpl.fromNonNullList(IteratorUtil.toNonNullList(fun.apply(iterator()))); } - @Override - public T first() { + @Override public T first() { return toList().get(0); } - @Override - public @Nullable T get(int n) { + @Override public @Nullable T get(int n) { AssertionUtil.requireNonNegative("n", n); List tList = toList(); return n < tList.size() ? tList.get(n) : null; } - @Override - public Iterator iterator() { + @Override public Iterator iterator() { return toList().iterator(); } - @Override - public int count() { + @Override public int count() { return toList().size(); } - @Override - public NodeStream drop(int n) { + @Override public NodeStream drop(int n) { if (n == 0) { return this; } return StreamImpl.fromNonNullList(CollectionUtil.drop(toList(), n)); } - @Override - public NodeStream take(int maxSize) { + @Override public NodeStream take(int maxSize) { if (maxSize >= count()) { return this; } return StreamImpl.fromNonNullList(CollectionUtil.take(toList(), maxSize)); } - @Override - public abstract List toList(); + @Override public abstract List toList(); - @Override - public Spliterator spliterator() { + @Override public Spliterator spliterator() { Spliterator spliter = toList().spliterator(); return Spliterators.spliterator(iterator(), spliter.estimateSize(), - spliter.characteristics() | Spliterator.NONNULL); + spliter.characteristics() | Spliterator.NONNULL); } - @Override - public NodeStream cached() { + @Override public NodeStream cached() { return this; } @@ -91,8 +81,7 @@ static class GreedyKnownNStream extends GreedyNStream { this.coll = coll; } - @Override - public List toList() { + @Override public List toList() { return coll; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/IteratorBasedNStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/IteratorBasedNStream.java index 0319e8e9747..a4f6f431fd2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/IteratorBasedNStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/IteratorBasedNStream.java @@ -35,21 +35,17 @@ */ abstract class IteratorBasedNStream implements NodeStream { - @Override - public abstract Iterator iterator(); + @Override public abstract Iterator iterator(); - @Override - public Spliterator spliterator() { + @Override public Spliterator spliterator() { return Spliterators.spliteratorUnknownSize(iterator(), Spliterator.ORDERED); } - @Override - public Stream toStream() { + @Override public Stream toStream() { return StreamSupport.stream(spliterator(), false); } - @Override - public NodeStream flatMap(Function> mapper) { + @Override public NodeStream flatMap(Function> mapper) { // Note temporary function is complete typing is needed so that it compiles with ejc // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=561482 Function> mapped = mapper.andThen(IteratorBasedNStream::safeMap); @@ -60,151 +56,124 @@ public NodeStream flatMap(Function NodeStream<@NonNull R> map(Function mapper) { + @Override public NodeStream<@NonNull R> map(Function mapper) { return mapIter(iter -> IteratorUtil.mapNotNull(iter, mapper)); } - @Override - public NodeStream filter(Predicate predicate) { + @Override public NodeStream filter(Predicate predicate) { return mapIter(it -> IteratorUtil.mapNotNull(it, Filtermap.filter(predicate))); } - @Override - public NodeStream filterIs(Class rClass) { + @Override public NodeStream filterIs(Class rClass) { return mapIter(it -> IteratorUtil.mapNotNull(it, Filtermap.isInstance(rClass))); } - @Override - public DescendantNodeStream descendants() { + @Override public DescendantNodeStream descendants() { return flatMapDescendants(Node::descendants); } - @Override - public DescendantNodeStream descendantsOrSelf() { + @Override public DescendantNodeStream descendantsOrSelf() { return flatMapDescendants(Node::descendantsOrSelf); } - @Override - public DescendantNodeStream descendants(Class rClass) { + @Override public DescendantNodeStream descendants(Class rClass) { return flatMapDescendants(node -> node.descendants(rClass)); } - @NonNull - protected DescendantNodeStream flatMapDescendants(Function> mapper) { + @NonNull protected DescendantNodeStream flatMapDescendants(Function> mapper) { return new DescendantMapping<>(this, mapper); } - @Override - public void forEach(Consumer action) { + @Override public void forEach(Consumer action) { iterator().forEachRemaining(action); } - @Override - public @Nullable T get(int n) { + @Override public @Nullable T get(int n) { if (n == 0) { return first(); } return IteratorUtil.getNth(iterator(), n); } - @Override - public NodeStream drop(int n) { + @Override public NodeStream drop(int n) { AssertionUtil.requireNonNegative("n", n); return n == 0 ? this : mapIter(iter -> IteratorUtil.drop(iter, n)); } - @Override - public NodeStream take(int maxSize) { + @Override public NodeStream take(int maxSize) { AssertionUtil.requireNonNegative("maxSize", maxSize); return maxSize == 0 ? NodeStream.empty() : mapIter(iter -> IteratorUtil.take(iter, maxSize)); } - @Override - public NodeStream dropLast(int n) { + @Override public NodeStream dropLast(int n) { AssertionUtil.requireNonNegative("n", n); return n == 0 ? this : mapIter(iter -> IteratorUtil.dropLast(iter, n)); } - @Override - public NodeStream takeWhile(Predicate predicate) { + @Override public NodeStream takeWhile(Predicate predicate) { return mapIter(iter -> IteratorUtil.takeWhile(iter, predicate)); } - @Override - public final R collect(Collector collector) { + @Override public final R collect(Collector collector) { A container = collector.supplier().get(); BiConsumer accumulator = collector.accumulator(); forEach(u -> accumulator.accept(container, u)); return CollectionUtil.finish(collector, container); } - @Override - public NodeStream distinct() { + @Override public NodeStream distinct() { return mapIter(IteratorUtil::distinct); } - @Override - public NodeStream peek(Consumer action) { + @Override public NodeStream peek(Consumer action) { return mapIter(iter -> IteratorUtil.peek(iter, action)); } - @Override - public NodeStream append(NodeStream right) { + @Override public NodeStream append(NodeStream right) { return mapIter(iter -> IteratorUtil.concat(iter, right.iterator())); } - @Override - public NodeStream prepend(NodeStream right) { + @Override public NodeStream prepend(NodeStream right) { return mapIter(iter -> IteratorUtil.concat(right.iterator(), iter)); } - @Override - public boolean any(Predicate predicate) { + @Override public boolean any(Predicate predicate) { return IteratorUtil.anyMatch(iterator(), predicate); } - @Override - public boolean none(Predicate predicate) { + @Override public boolean none(Predicate predicate) { return IteratorUtil.noneMatch(iterator(), predicate); } - @Override - public boolean all(Predicate predicate) { + @Override public boolean all(Predicate predicate) { return IteratorUtil.allMatch(iterator(), predicate); } - @Override - public int count() { + @Override public int count() { return IteratorUtil.count(iterator()); } - @Override - public boolean nonEmpty() { + @Override public boolean nonEmpty() { return iterator().hasNext(); } - @Override - public @Nullable T first() { + @Override public @Nullable T first() { Iterator iter = iterator(); return iter.hasNext() ? iter.next() : null; } - @Override - public @Nullable T last() { + @Override public @Nullable T last() { return IteratorUtil.last(iterator()); } - @Override - public List toList() { + @Override public List toList() { return IteratorUtil.toList(iterator()); } - @Override - public @Nullable R first(Class r1Class) { + @Override public @Nullable R first(Class r1Class) { for (T t : this) { if (r1Class.isInstance(t)) { return r1Class.cast(t); @@ -213,8 +182,7 @@ public List toList() { return null; } - @Override - public @Nullable T first(Predicate predicate) { + @Override public @Nullable T first(Predicate predicate) { for (T t : this) { if (predicate.test(t)) { return t; @@ -223,8 +191,7 @@ public List toList() { return null; } - @Override - public NodeStream cached() { + @Override public NodeStream cached() { return StreamImpl.fromNonNullList(toList()); } @@ -233,11 +200,10 @@ protected NodeStream mapIter(Function, Iterator< } - @Override - public String toString() { + @Override public String toString() { return getClass().getSimpleName() + " [" - + toStream().map(Objects::toString).collect(Collectors.joining(", ")) - + "]"; + + toStream().map(Objects::toString).collect(Collectors.joining(", ")) + + "]"; } private final class IteratorMapping extends IteratorBasedNStream { @@ -250,8 +216,7 @@ private IteratorMapping(Function, Iterator> fun) { } - @Override - public Iterator iterator() { + @Override public Iterator iterator() { return fun.apply(IteratorBasedNStream.this.iterator()); } } @@ -274,21 +239,19 @@ private DescendantMapping(IteratorBasedNStream upstream, Function iterator() { + @Override public Iterator iterator() { return IteratorUtil.flatMap( - upstream.iterator(), - t -> { - DescendantNodeStream app = fun.apply(t); - return walker.apply(app).iterator(); - }); + upstream.iterator(), + t -> { + DescendantNodeStream app = fun.apply(t); + return walker.apply(app).iterator(); + }); } - @Override - public DescendantNodeStream crossFindBoundaries(boolean cross) { + @Override public DescendantNodeStream crossFindBoundaries(boolean cross) { return walker.isCrossFindBoundaries() == cross - ? this - : new DescendantMapping<>(upstream, fun, walker.crossFindBoundaries(cross)); + ? this + : new DescendantMapping<>(upstream, fun, walker.crossFindBoundaries(cross)); } } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/SingletonNodeStream.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/SingletonNodeStream.java index ff1f4acca8d..095ae008940 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/SingletonNodeStream.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/SingletonNodeStream.java @@ -42,107 +42,86 @@ final class SingletonNodeStream extends IteratorBasedNStream this.node = node; } - @Override - public Stream toStream() { + @Override public Stream toStream() { return Stream.of(node); } - @Override - public List toList() { + @Override public List toList() { return Collections.singletonList(node); } - @Override - public List toList(Function mapper) { + @Override public List toList(Function mapper) { return Collections.singletonList(mapper.apply(node)); } - @Override - public int count() { + @Override public int count() { return 1; } - @Override - public T first() { + @Override public T first() { return node; } - @Override - public T last() { + @Override public T last() { return node; } - @Override - public boolean nonEmpty() { + @Override public boolean nonEmpty() { return true; } - @Override - public Iterator iterator() { + @Override public Iterator iterator() { return IteratorUtil.singletonIterator(node); } - @Override - public void forEach(Consumer action) { + @Override public void forEach(Consumer action) { action.accept(node); } - @Override - public NodeStream filter(Predicate predicate) { + @Override public NodeStream filter(Predicate predicate) { return predicate.test(node) ? this : NodeStream.empty(); } - @Override - public NodeStream drop(int n) { + @Override public NodeStream drop(int n) { AssertionUtil.requireNonNegative("n", n); return n == 0 ? this : NodeStream.empty(); } - @Override - public NodeStream take(int maxSize) { + @Override public NodeStream take(int maxSize) { AssertionUtil.requireNonNegative("maxSize", maxSize); return maxSize >= 1 ? this : NodeStream.empty(); } - @Override - public NodeStream cached() { + @Override public NodeStream cached() { return this; } - @Override - public NodeStream distinct() { + @Override public NodeStream distinct() { return this; } - @Override - public NodeStream takeWhile(Predicate predicate) { + @Override public NodeStream takeWhile(Predicate predicate) { return filter(predicate); } - @Override - public NodeStream<@NonNull R> map(Function mapper) { + @Override public NodeStream<@NonNull R> map(Function mapper) { return NodeStream.of(mapper.apply(node)); } - @Override - @SuppressWarnings("unchecked") - public NodeStream flatMap(Function> mapper) { + @Override @SuppressWarnings("unchecked") public NodeStream flatMap(Function> mapper) { return (NodeStream) mapper.apply(node); } - @Override - public boolean any(Predicate predicate) { + @Override public boolean any(Predicate predicate) { return predicate.test(node); } - @Override - public boolean all(Predicate predicate) { + @Override public boolean all(Predicate predicate) { return predicate.test(node); } - @Override - public boolean none(Predicate predicate) { + @Override public boolean none(Predicate predicate) { return !predicate.test(node); } @@ -150,68 +129,55 @@ public boolean none(Predicate predicate) { tree navigation */ - @Override - public NodeStream children() { + @Override public NodeStream children() { return StreamImpl.children(node); } - @Override - public NodeStream children(Class rClass) { + @Override public NodeStream children(Class rClass) { return StreamImpl.children(node, rClass); } - @Override - public NodeStream firstChild(Class rClass) { + @Override public NodeStream firstChild(Class rClass) { return NodeStream.of(node.firstChild(rClass)); } - @Override - public NodeStream parents() { + @Override public NodeStream parents() { return NodeStream.of(node.getParent()); } - @Override - public NodeStream ancestors() { + @Override public NodeStream ancestors() { return StreamImpl.ancestors(node); } - @Override - public NodeStream ancestors(Class rClass) { + @Override public NodeStream ancestors(Class rClass) { return StreamImpl.ancestors(node, rClass); } - @Override - public NodeStream ancestorsOrSelf() { + @Override public NodeStream ancestorsOrSelf() { return StreamImpl.ancestorsOrSelf(node); } - @Override - public DescendantNodeStream descendants() { + @Override public DescendantNodeStream descendants() { return StreamImpl.descendants(node); } - @Override - public DescendantNodeStream descendants(Class rClass) { + @Override public DescendantNodeStream descendants(Class rClass) { return StreamImpl.descendants(node, rClass); } - @Override - public DescendantNodeStream descendantsOrSelf() { + @Override public DescendantNodeStream descendantsOrSelf() { return StreamImpl.descendantsOrSelf(node); } - @Override - public NodeStream followingSiblings() { + @Override public NodeStream followingSiblings() { return StreamImpl.followingSiblings(node); } - @Override - public NodeStream precedingSiblings() { + @Override public NodeStream precedingSiblings() { return StreamImpl.precedingSiblings(node); } - @Override - public DescendantNodeStream crossFindBoundaries(boolean cross) { + @Override public DescendantNodeStream crossFindBoundaries(boolean cross) { return this; // doesn't mean anything } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/StreamImpl.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/StreamImpl.java index 8a356d18aa2..7f128245504 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/StreamImpl.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/StreamImpl.java @@ -35,8 +35,7 @@ public final class StreamImpl { - @SuppressWarnings({"rawtypes", "PMD.UseDiamondOperator"}) - private static final DescendantNodeStream EMPTY = new EmptyNodeStream(); + @SuppressWarnings({"rawtypes", "PMD.UseDiamondOperator"}) private static final DescendantNodeStream EMPTY = new EmptyNodeStream(); private StreamImpl() { // utility class @@ -61,16 +60,14 @@ public static NodeStream fromIterable(Iterable NodeStream union(Iterable> streams) { return new IteratorBasedNStream() { - @Override - public Iterator iterator() { + @Override public Iterator iterator() { return IteratorUtil.flatMap(streams.iterator(), NodeStream::iterator); } }; } - @SuppressWarnings("unchecked") - public static DescendantNodeStream empty() { + @SuppressWarnings("unchecked") public static DescendantNodeStream empty() { return EMPTY; } @@ -88,12 +85,10 @@ public static NodeStream children(@NonNull Node node) { * same node stream type and makes no effort to pick an empty or singleton * stream if possible. That allows the JVM to devirtualize calls. */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - public static > NodeStream childrenArray(GenericNode parent, - Node @NonNull [] array) { + @SuppressWarnings({"unchecked", "rawtypes"}) public static > NodeStream childrenArray(GenericNode parent, + Node @NonNull [] array) { return (NodeStream) new ChildrenStream(parent, 0, parent.getNumChildren()) { - @Override - public void forEach(Consumer action) { + @Override public void forEach(Consumer action) { // Looping on the array directly is about twice faster than // the default implementation. for (Node child : array) { @@ -101,13 +96,11 @@ public void forEach(Consumer action) { } } - @Override - public List toList() { + @Override public List toList() { return Collections.unmodifiableList(Arrays.asList(array)); } - @Override - protected Iterator baseIterator() { + @Override protected Iterator baseIterator() { return Arrays.asList(array).iterator(); } }; @@ -119,7 +112,7 @@ public static DescendantNodeStream descendants(@NonNull Node node) { public static DescendantNodeStream descendants(@NonNull Node node, Class rClass) { return node.getNumChildren() == 0 ? empty() - : new FilteredDescendantStream<>(node, TreeWalker.DEFAULT, Filtermap.isInstance(rClass)); + : new FilteredDescendantStream<>(node, TreeWalker.DEFAULT, Filtermap.isInstance(rClass)); } public static DescendantNodeStream descendantsOrSelf(@NonNull Node node) { @@ -132,8 +125,8 @@ public static NodeStream followingSiblings(@NonNull Node node) { return NodeStream.empty(); } return sliceChildren(parent, Filtermap.NODE_IDENTITY, - node.getIndexInParent() + 1, - parent.getNumChildren() - node.getIndexInParent() - 1 + node.getIndexInParent() + 1, + parent.getNumChildren() - node.getIndexInParent() - 1 ); } @@ -155,9 +148,8 @@ static NodeStream sliceChildren(Node parent, Filtermap res = length == 1 ? (NodeStream) singleton(parent.getChild(from)) - : (NodeStream) new ChildrenStream(parent, from, length); + @SuppressWarnings("unchecked") NodeStream res = length == 1 ? (NodeStream) singleton(parent.getChild(from)) + : (NodeStream) new ChildrenStream(parent, from, length); return res; } else { if (length == 1) { @@ -216,48 +208,39 @@ static NodeStream fromNonNullList(List<@NonNull T> coll) { private static final class EmptyNodeStream extends IteratorBasedNStream implements DescendantNodeStream { - @Override - protected NodeStream mapIter(Function, Iterator> fun) { + @Override protected NodeStream mapIter(Function, Iterator> fun) { return StreamImpl.empty(); } - @Override - protected @NonNull DescendantNodeStream flatMapDescendants(Function> mapper) { + @Override protected @NonNull DescendantNodeStream flatMapDescendants(Function> mapper) { return StreamImpl.empty(); } - @Override - public DescendantNodeStream crossFindBoundaries(boolean cross) { + @Override public DescendantNodeStream crossFindBoundaries(boolean cross) { return this; } - @Override - public Iterator iterator() { + @Override public Iterator iterator() { return Collections.emptyIterator(); } - @Override - public List toList() { + @Override public List toList() { return Collections.emptyList(); } - @Override - public List toList(Function mapper) { + @Override public List toList(Function mapper) { return Collections.emptyList(); } - @Override - public Spliterator spliterator() { + @Override public Spliterator spliterator() { return Spliterators.emptySpliterator(); } - @Override - public NodeStream cached() { + @Override public NodeStream cached() { return this; } - @Override - public String toString() { + @Override public String toString() { return "EmptyStream"; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/TraversalUtils.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/TraversalUtils.java index 5f82a10c65b..a56cea598b4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/TraversalUtils.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/TraversalUtils.java @@ -108,13 +108,11 @@ static Iterator childrenIterator(Node parent, final int from, final int to private int i = from; - @Override - public boolean hasNext() { + @Override public boolean hasNext() { return i < to; } - @Override - public @NonNull + @Override public @NonNull Node next() { return parent.getChild(i++); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/TreeWalker.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/TreeWalker.java index 64b2a96482c..bc7984e7ad3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/TreeWalker.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/internal/TreeWalker.java @@ -57,8 +57,8 @@ DescendantNodeStream apply(DescendantNodeStream stream) { } void findDescendantsMatching(final Node node, - final Filtermap filtermap, - final List results) { + final Filtermap filtermap, + final List results) { for (int i = 0; i < node.getNumChildren(); i++) { final Node child = node.getChild(i); @@ -121,14 +121,12 @@ private static class DescendantOrSelfIterator implements Iterator<@NonNull Node> queue.addFirst(top); } - @Override - public boolean hasNext() { + @Override public boolean hasNext() { return !queue.isEmpty(); } - @Override - public @NonNull Node next() { + @Override public @NonNull Node next() { Node node = queue.removeFirst(); enqueueChildren(node); isFirst = false; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/BaseMappedDocument.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/BaseMappedDocument.java index 6976f38a689..e6d9c30f1f5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/BaseMappedDocument.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/BaseMappedDocument.java @@ -20,39 +20,32 @@ abstract class BaseMappedDocument implements TextDocument { this.base = base; } - @Override - public long getCheckSum() { + @Override public long getCheckSum() { return base.getCheckSum(); } - @Override - public FileId getFileId() { + @Override public FileId getFileId() { return base.getFileId(); } - @Override - public Chars sliceOriginalText(TextRegion region) { + @Override public Chars sliceOriginalText(TextRegion region) { return base.sliceOriginalText(inputRegion(region)); } - @Override - public FileLocation toLocation(TextRegion region) { + @Override public FileLocation toLocation(TextRegion region) { return base.toLocation(inputRegion(region)); } - @Override - public TextRegion createLineRange(int startLineInclusive, int endLineInclusive) { + @Override public TextRegion createLineRange(int startLineInclusive, int endLineInclusive) { // see the doc, lines do not need to be translated return base.createLineRange(startLineInclusive, endLineInclusive); } - @Override - public TextPos2d lineColumnAtOffset(int offset, boolean inclusive) { + @Override public TextPos2d lineColumnAtOffset(int offset, boolean inclusive) { return base.lineColumnAtOffset(inputOffset(offset, inclusive)); } - @Override - public int offsetAtLineColumn(TextPos2d position) { + @Override public int offsetAtLineColumn(TextPos2d position) { // Here there is no translation happening, because // TextPos2d is always in the coordinate system of the root document. return base.offsetAtLineColumn(position); @@ -74,7 +67,7 @@ public int offsetAtLineColumn(TextPos2d position) { return TextRegion.caretAt(inputOffset(outputRegion.getStartOffset(), true)); } return TextRegion.fromBothOffsets(inputOffset(outputRegion.getStartOffset(), true), - inputOffset(outputRegion.getEndOffset(), false)); + inputOffset(outputRegion.getEndOffset(), false)); } /** @@ -111,8 +104,7 @@ protected final int inputOffset(int outOffset, boolean inclusive) { protected abstract int localOffsetTransform(int outOffset, boolean inclusive); - @Override - public void close() throws IOException { + @Override public void close() throws IOException { base.close(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java index 86865c7ffc6..7c0fb4ebb12 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileCollector.java @@ -119,8 +119,7 @@ public PmdReporter getReporter() { /** * Close registered resources like zip files. */ - @Override - public void close() { + @Override public void close() { if (closed) { return; } @@ -149,9 +148,9 @@ public boolean addFile(Path file) { } LanguageVersion languageVersion = discoverLanguage(file.toString()); return languageVersion != null - && addFileImpl(TextFile.builderForPath(file, charset, languageVersion) - .setParentFsPath(outerFsPath) - .build()); + && addFileImpl(TextFile.builderForPath(file, charset, languageVersion) + .setParentFsPath(outerFsPath) + .build()); } /** @@ -173,8 +172,8 @@ public boolean addFile(Path file, Language language) { LanguageVersion lv = discoverer.getDefaultLanguageVersion(language); Objects.requireNonNull(lv); return addFileImpl(TextFile.builderForPath(file, charset, lv) - .setParentFsPath(outerFsPath) - .build()); + .setParentFsPath(outerFsPath) + .build()); } /** @@ -201,9 +200,9 @@ public boolean addSourceFile(FileId fileId, String sourceContents) { LanguageVersion version = discoverLanguage(fileId.getFileName()); return version != null - && addFileImpl(TextFile.builderForCharSeq(sourceContents, fileId, version) - .setParentFsPath(outerFsPath) - .build()); + && addFileImpl(TextFile.builderForCharSeq(sourceContents, fileId, version) + .setParentFsPath(outerFsPath) + .build()); } private boolean addFileImpl(TextFile textFile) { @@ -249,10 +248,10 @@ private boolean checkContextualVersion(TextFile textFile) { LanguageVersion contextVersion = discoverer.getDefaultLanguageVersion(language); if (!fileVersion.equals(contextVersion)) { reporter.error( - "Cannot add file {0}: version ''{1}'' does not match ''{2}''", - textFile.getFileId(), - fileVersion, - contextVersion + "Cannot add file {0}: version ''{1}'' does not match ''{2}''", + textFile.getFileId(), + fileVersion, + contextVersion ); return false; } @@ -279,8 +278,7 @@ public boolean addDirectory(Path dir, boolean recurse) throws IOException { } int maxDepth = recurse ? Integer.MAX_VALUE : 1; Files.walkFileTree(dir, EnumSet.of(FileVisitOption.FOLLOW_LINKS), maxDepth, new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (attrs.isRegularFile()) { FileCollector.this.addFile(file); } @@ -404,7 +402,7 @@ public void setFileFilter(Predicate fileFilter) { */ public void exclude(FileCollector excludeCollector) { Set toExclude = new HashSet<>(excludeCollector.allFilesToProcess); - for (Iterator iterator = allFilesToProcess.iterator(); iterator.hasNext();) { + for (Iterator iterator = allFilesToProcess.iterator(); iterator.hasNext(); ) { TextFile file = iterator.next(); if (toExclude.contains(file)) { LOG.trace("Excluding file {}", file.getFileId().getAbsolutePath()); @@ -429,7 +427,7 @@ public void absorb(FileCollector otherCollector) { * collection. */ public void filterLanguages(Set languages) { - for (Iterator iterator = allFilesToProcess.iterator(); iterator.hasNext();) { + for (Iterator iterator = allFilesToProcess.iterator(); iterator.hasNext(); ) { TextFile file = iterator.next(); Language lang = file.getLanguageVersion().getLanguage(); if (!languages.contains(lang)) { @@ -440,8 +438,7 @@ public void filterLanguages(Set languages) { } - @Override - public String toString() { + @Override public String toString() { return "FileCollector{filesToProcess=" + allFilesToProcess + '}'; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileId.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileId.java index c2e34e622e2..1c40bd099ff 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileId.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileId.java @@ -36,66 +36,54 @@ public interface FileId extends Comparable { * relevant for unit tests. */ FileId UNKNOWN = new FileId() { - @Override - public String getFileName() { + @Override public String getFileName() { return "(unknown)"; } - @Override - public String getOriginalPath() { + @Override public String getOriginalPath() { return "(unknown)"; } - @Override - public String getAbsolutePath() { + @Override public String getAbsolutePath() { return getOriginalPath(); } - @Override - public String getUriString() { + @Override public String getUriString() { return "file://" + getOriginalPath(); } - @Override - public @Nullable FileId getParentFsPath() { + @Override public @Nullable FileId getParentFsPath() { return null; } - @Override - public String toString() { + @Override public String toString() { return "FileId(unknown)"; } }; /** The virtual file ID for standard input. */ FileId STDIN = new FileId() { - @Override - public String getAbsolutePath() { + @Override public String getAbsolutePath() { return "stdin"; } - @Override - public String getUriString() { + @Override public String getUriString() { return "stdin"; } - @Override - public String getFileName() { + @Override public String getFileName() { return "stdin"; } - @Override - public String getOriginalPath() { + @Override public String getOriginalPath() { return "stdin"; } - @Override - public @Nullable FileId getParentFsPath() { + @Override public @Nullable FileId getParentFsPath() { return null; } - @Override - public String toString() { + @Override public String toString() { return "FileId(STDIN)"; } }; @@ -138,12 +126,10 @@ public String toString() { * * @param o Object */ - @Override - boolean equals(Object o); + @Override boolean equals(Object o); - @Override - default int compareTo(FileId o) { + @Override default int compareTo(FileId o) { return this.getAbsolutePath().compareTo(o.getAbsolutePath()); } @@ -152,8 +138,7 @@ default int compareTo(FileId o) { * is unspecified. Code that needs a string representation should use one * of the named string conversion methods. */ - @Override - String toString(); + @Override String toString(); /** * Return a path ID for the given string. The string is interpreted @@ -175,46 +160,38 @@ static FileId fromPathLikeString(String str) { final String absPathStr = absPath.toString(); - @Override - public String getAbsolutePath() { + @Override public String getAbsolutePath() { return absPathStr; } - @Override - public String getUriString() { + @Override public String getUriString() { // pretend... return "file://" + str; } - @Override - public String getFileName() { + @Override public String getFileName() { return fileName; } - @Override - public String getOriginalPath() { + @Override public String getOriginalPath() { return str; } - @Override - public boolean equals(Object obj) { + @Override public boolean equals(Object obj) { return obj instanceof FileId - && ((FileId) obj).getUriString().equals(this.getUriString()); + && ((FileId) obj).getUriString().equals(this.getUriString()); } - @Override - public int hashCode() { + @Override public int hashCode() { return getUriString().hashCode(); } - @Override - public @Nullable FileId getParentFsPath() { + @Override public @Nullable FileId getParentFsPath() { return null; } - @Override - public String toString() { + @Override public String toString() { return "FileId(fromPathLike=" + str + ")"; } }; @@ -239,44 +216,36 @@ static FileId fromPath(Path path, @Nullable FileId fsPath) { final String fileName = path.getFileName().toString(); final String origPath = path.toString(); - @Override - public String getAbsolutePath() { + @Override public String getAbsolutePath() { return absPath; } - @Override - public String getUriString() { + @Override public String getUriString() { return uriString; } - @Override - public String getFileName() { + @Override public String getFileName() { return fileName; } - @Override - public String getOriginalPath() { + @Override public String getOriginalPath() { return origPath; } - @Override - public @Nullable FileId getParentFsPath() { + @Override public @Nullable FileId getParentFsPath() { return fsPath; } - @Override - public boolean equals(Object obj) { + @Override public boolean equals(Object obj) { return obj instanceof FileId - && ((FileId) obj).getUriString().equals(this.getUriString()); + && ((FileId) obj).getUriString().equals(this.getUriString()); } - @Override - public int hashCode() { + @Override public int hashCode() { return getUriString().hashCode(); } - @Override - public String toString() { + @Override public String toString() { return "FileId(fromPath=" + path + ")"; } }; @@ -303,44 +272,36 @@ static FileId asChildOf(FileId self, FileId parentFsPath) { return self; } return new FileId() { - @Override - public @Nullable FileId getParentFsPath() { + @Override public @Nullable FileId getParentFsPath() { return parentFsPath; } - @Override - public String getUriString() { + @Override public String getUriString() { return self.getUriString(); } - @Override - public String getFileName() { + @Override public String getFileName() { return self.getFileName(); } - @Override - public String getOriginalPath() { + @Override public String getOriginalPath() { return self.getOriginalPath(); } - @Override - public String getAbsolutePath() { + @Override public String getAbsolutePath() { return self.getAbsolutePath(); } - @Override - public boolean equals(Object obj) { + @Override public boolean equals(Object obj) { return obj instanceof FileId - && getUriString().equals(((FileId) obj).getUriString()); + && getUriString().equals(((FileId) obj).getUriString()); } - @Override - public int hashCode() { + @Override public int hashCode() { return getUriString().hashCode(); } - @Override - public String toString() { + @Override public String toString() { return "FileId(" + self + ",asChildOf=" + parentFsPath + ")"; } }; @@ -363,46 +324,38 @@ static FileId fromAbsolutePath(String absPath, @Nullable FileId outer) { // we know this one uses / (for URIs) String uriAbsPath = platformAbsPath.replace(File.separatorChar, '/'); String uriStr = outer != null ? "jar:" + outer.getUriString() + "!" + uriAbsPath - : "file://" + uriAbsPath; + : "file://" + uriAbsPath; // zip file return new FileId() { - @Override - public String getFileName() { + @Override public String getFileName() { return fileName.toString(); } - @Override - public String getOriginalPath() { + @Override public String getOriginalPath() { return absPath; } - @Override - public String getAbsolutePath() { + @Override public String getAbsolutePath() { return platformAbsPath; } - @Override - public String getUriString() { + @Override public String getUriString() { return uriStr; } - @Override - public @Nullable FileId getParentFsPath() { + @Override public @Nullable FileId getParentFsPath() { return outer; } - @Override - public boolean equals(Object obj) { + @Override public boolean equals(Object obj) { return obj instanceof FileId && getUriString().equals(((FileId) obj).getUriString()); } - @Override - public int hashCode() { + @Override public int hashCode() { return getUriString().hashCode(); } - @Override - public String toString() { + @Override public String toString() { return "FileId(fromAbsolutePath=" + absPath + ",outer=" + outer + ")"; } }; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java index e860c9f5b01..4c4b418ef46 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FileLocation.java @@ -26,12 +26,12 @@ public final class FileLocation { public static final Comparator COORDS_COMPARATOR = - Comparator.comparing(FileLocation::getStartPos) - .thenComparing(FileLocation::getEndPos); + Comparator.comparing(FileLocation::getStartPos) + .thenComparing(FileLocation::getEndPos); public static final Comparator COMPARATOR = - Comparator.comparing(FileLocation::getFileId).thenComparing(COORDS_COMPARATOR); + Comparator.comparing(FileLocation::getFileId).thenComparing(COORDS_COMPARATOR); private final int beginLine; private final int endLine; @@ -148,10 +148,10 @@ public static FileLocation range(FileId fileName, TextRange2d range2d) { TextPos2d start = range2d.getStartPos(); TextPos2d end = range2d.getEndPos(); return new FileLocation(fileName, - start.getLine(), - start.getColumn(), - end.getLine(), - end.getColumn()); + start.getLine(), + start.getColumn(), + end.getLine(), + end.getColumn()); } /** @@ -170,8 +170,7 @@ public static FileLocation caret(FileId fileName, int line, int column) { } - @Override - public String toString() { + @Override public String toString() { return "!debug only! " + startPosToStringWithFile(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FragmentedTextDocument.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FragmentedTextDocument.java index d92404eeb4f..af4d5547fb0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FragmentedTextDocument.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/FragmentedTextDocument.java @@ -34,19 +34,16 @@ private static Chars toChars(Fragment firstFragment, Fragment lastFragment) { return Chars.wrap(sb); } - @Override - public Chars getText() { + @Override public Chars getText() { return text; } - @Override - public LanguageVersion getLanguageVersion() { + @Override public LanguageVersion getLanguageVersion() { return base.getLanguageVersion(); } - @Override - protected int localOffsetTransform(int outOffset, boolean inclusive) { + @Override protected int localOffsetTransform(int outOffset, boolean inclusive) { // caching the last accessed fragment instead of doing // a linear search is critical for performance. Fragment f = this.lastAccessedFragment; @@ -57,7 +54,7 @@ protected int localOffsetTransform(int outOffset, boolean inclusive) { // Whether the fragment contains the offset we're looking for. // Will be true most of the time. boolean containsOffset = - f.outStart() <= outOffset && outOffset < f.outEnd(); + f.outStart() <= outOffset && outOffset < f.outEnd(); if (!containsOffset) { // Slow path, we must search for the fragment @@ -153,8 +150,7 @@ int inToOut(int inOffset) { return inOffset - inStart() + outStart(); } - @Override - public String toString() { + @Override public String toString() { return "Fragment[" + inStart() + ".." + inEnd() + " -> " + outStart() + ".." + outEnd() + "]" + chars; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/InternalApiBridge.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/InternalApiBridge.java index 7c602331797..4afac7c9e04 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/InternalApiBridge.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/InternalApiBridge.java @@ -21,7 +21,8 @@ */ @InternalApi public final class InternalApiBridge { - private InternalApiBridge() {} + private InternalApiBridge() { + } public static FileCollector newCollector(LanguageVersionDiscoverer discoverer, PmdReporter reporter) { return FileCollector.newCollector(discoverer, reporter); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java index f563043238b..fb45784d149 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/NioTextFile.java @@ -30,10 +30,10 @@ class NioTextFile extends BaseCloseable implements TextFile { private boolean readOnly; NioTextFile(Path path, - @Nullable FileId parentFsPath, - Charset charset, - LanguageVersion languageVersion, - boolean readOnly) { + @Nullable FileId parentFsPath, + Charset charset, + LanguageVersion languageVersion, + boolean readOnly) { AssertionUtil.requireParamNotNull("path", path); AssertionUtil.requireParamNotNull("charset", charset); AssertionUtil.requireParamNotNull("language version", languageVersion); @@ -45,23 +45,19 @@ class NioTextFile extends BaseCloseable implements TextFile { this.fileId = FileId.fromPath(path, parentFsPath); } - @Override - public @NonNull LanguageVersion getLanguageVersion() { + @Override public @NonNull LanguageVersion getLanguageVersion() { return languageVersion; } - @Override - public FileId getFileId() { + @Override public FileId getFileId() { return fileId; } - @Override - public boolean isReadOnly() { + @Override public boolean isReadOnly() { return readOnly || !Files.isWritable(path); } - @Override - public void writeContents(TextFileContent content) throws IOException { + @Override public void writeContents(TextFileContent content) throws IOException { ensureOpen(); if (isReadOnly()) { throw new ReadOnlyFileException(this); @@ -78,8 +74,7 @@ public void writeContents(TextFileContent content) throws IOException { } } - @Override - public TextFileContent readContents() throws IOException { + @Override public TextFileContent readContents() throws IOException { ensureOpen(); if (!Files.isRegularFile(path)) { @@ -90,13 +85,11 @@ public TextFileContent readContents() throws IOException { } - @Override - protected void doClose() throws IOException { + @Override protected void doClose() throws IOException { // nothing to do. } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } @@ -107,13 +100,11 @@ public boolean equals(Object o) { return path.equals(that.path); } - @Override - public int hashCode() { + @Override public int hashCode() { return path.hashCode(); } - @Override - public String toString() { + @Override public String toString() { return "NioTextFile[charset=" + charset + ", path=" + path + ']'; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/ReaderTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/ReaderTextFile.java index e7407f541ca..77b139ae759 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/ReaderTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/ReaderTextFile.java @@ -31,28 +31,23 @@ class ReaderTextFile implements TextFile { this.fileId = fileId; } - @Override - public FileId getFileId() { + @Override public FileId getFileId() { return fileId; } - @Override - public @NonNull LanguageVersion getLanguageVersion() { + @Override public @NonNull LanguageVersion getLanguageVersion() { return languageVersion; } - @Override - public TextFileContent readContents() throws IOException { + @Override public TextFileContent readContents() throws IOException { return TextFileContent.fromReader(reader); // this closes the reader } - @Override - public void close() throws IOException { + @Override public void close() throws IOException { reader.close(); } - @Override - public String toString() { + @Override public String toString() { return "ReaderTextFile[" + fileId.getAbsolutePath() + "]"; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/RootTextDocument.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/RootTextDocument.java index deec24e4a27..2f40fbdac9c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/RootTextDocument.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/RootTextDocument.java @@ -39,28 +39,23 @@ final class RootTextDocument extends BaseCloseable implements TextDocument { Objects.requireNonNull(fileId, "Null path id for file " + backend); } - @Override - public LanguageVersion getLanguageVersion() { + @Override public LanguageVersion getLanguageVersion() { return langVersion; } - @Override - public FileId getFileId() { + @Override public FileId getFileId() { return fileId; } - @Override - protected void doClose() throws IOException { + @Override protected void doClose() throws IOException { backend.close(); } - @Override - public Chars getText() { + @Override public Chars getText() { return content.getNormalizedText(); } - @Override - public FileLocation toLocation(TextRegion region) { + @Override public FileLocation toLocation(TextRegion region) { checkInRange(region, this.getLength()); SourceCodePositioner positioner = content.getPositioner(); @@ -68,35 +63,32 @@ public FileLocation toLocation(TextRegion region) { // This limits us to 2 billion lines or columns, which is FINE TextPos2d bpos = positioner.lineColFromOffset(region.getStartOffset(), true); TextPos2d epos = region.isEmpty() ? bpos - : positioner.lineColFromOffset(region.getEndOffset(), false); + : positioner.lineColFromOffset(region.getEndOffset(), false); return new FileLocation( - fileId, - bpos.getLine(), - bpos.getColumn(), - epos.getLine(), - epos.getColumn(), - region + fileId, + bpos.getLine(), + bpos.getColumn(), + epos.getLine(), + epos.getColumn(), + region ); } - @Override - public TextPos2d lineColumnAtOffset(int offset, boolean inclusive) { + @Override public TextPos2d lineColumnAtOffset(int offset, boolean inclusive) { return content.getPositioner().lineColFromOffset(offset, inclusive); } - @Override - public int offsetAtLineColumn(TextPos2d position) { + @Override public int offsetAtLineColumn(TextPos2d position) { return content.getPositioner().offsetFromLineColumn(position.getLine(), position.getColumn()); } - @Override - public TextRegion createLineRange(int startLineInclusive, int endLineInclusive) { + @Override public TextRegion createLineRange(int startLineInclusive, int endLineInclusive) { SourceCodePositioner positioner = content.getPositioner(); if (!positioner.isValidLine(startLineInclusive) - || !positioner.isValidLine(endLineInclusive) - || startLineInclusive > endLineInclusive) { + || !positioner.isValidLine(endLineInclusive) + || startLineInclusive > endLineInclusive) { throw invalidLineRange(startLineInclusive, endLineInclusive, positioner.getLastLine()); } @@ -111,13 +103,11 @@ static void checkInRange(TextRegion region, int length) { } } - @Override - public long getCheckSum() { + @Override public long getCheckSum() { return content.getCheckSum(); } - @Override - public Chars sliceOriginalText(TextRegion region) { + @Override public Chars sliceOriginalText(TextRegion region) { return getText().subSequence(region.getStartOffset(), region.getEndOffset()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/SourceCodePositioner.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/SourceCodePositioner.java index 0e098aacb56..039b8dd2b39 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/SourceCodePositioner.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/SourceCodePositioner.java @@ -145,7 +145,7 @@ public int offsetFromLineColumn(final int line, final int column) { public int offsetOfEndOfLine(final int line) { if (!isValidLine(line)) { throw new IndexOutOfBoundsException( - line + " is not a valid line number, expected at most " + lineOffsets.length); + line + " is not a valid line number, expected at most " + lineOffsets.length); } return lineOffsets[line]; @@ -235,7 +235,7 @@ public void addLineEndAtOffset(int offset) { private void addLineImpl(int offset, boolean isEof) { if (offset < 0 || offset < lastLineOffset || offset == lastLineOffset && !isEof) { throw new IllegalArgumentException( - "Invalid offset " + offset + " (last offset " + lastLineOffset + ")" + "Invalid offset " + offset + " (last offset " + lastLineOffset + ")" ); } lastLineOffset = offset; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java index d95f7e5ffa2..8afccd14024 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/StringTextFile.java @@ -29,28 +29,23 @@ class StringTextFile implements TextFile { this.fileId = fileId; } - @Override - public @NonNull LanguageVersion getLanguageVersion() { + @Override public @NonNull LanguageVersion getLanguageVersion() { return languageVersion; } - @Override - public FileId getFileId() { + @Override public FileId getFileId() { return fileId; } - @Override - public TextFileContent readContents() { + @Override public TextFileContent readContents() { return content; } - @Override - public void close() { + @Override public void close() { // nothing to do } - @Override - public String toString() { + @Override public String toString() { return "ReadOnlyString[" + StringUtil.elide(content.getNormalizedText().toString(), 40, "...") + "]"; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextDocument.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextDocument.java index 355bc1dd22d..bea63c91b65 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextDocument.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextDocument.java @@ -238,8 +238,7 @@ default TextPos2d lineColumnAtOffset(int offset) { * exception is thrown. This indicates a programming * mistake. */ - @Override - void close() throws IOException; + @Override void close() throws IOException; /** * Create a new text document for the given text file. The document's diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFile.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFile.java index ed03ac65724..415a116ff29 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFile.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFile.java @@ -41,8 +41,7 @@ public interface TextFile extends Closeable { * * @return A language version */ - @NonNull - LanguageVersion getLanguageVersion(); + @NonNull LanguageVersion getLanguageVersion(); /** @@ -97,8 +96,7 @@ default void writeContents(TextFileContent content) throws IOException { * * @throws IOException If an IO exception occurs */ - @Override - void close() throws IOException; + @Override void close() throws IOException; /** @@ -109,8 +107,7 @@ default void writeContents(TextFileContent content) throws IOException { // currently: // - Path-based TextFiles compare their path for equality, where the path is not normalized. // - Reader- and String-based TextFiles use identity semantics. - @Override - boolean equals(Object o); + @Override boolean equals(Object o); // factory methods diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileBuilder.java index d1d16fcf2c1..d5efd83a1ba 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextFileBuilder.java @@ -60,14 +60,12 @@ static class ForNio extends TextFileBuilder { this.charset = AssertionUtil.requireParamNotNull("charset", charset); } - @Override - public TextFileBuilder asReadOnly() { + @Override public TextFileBuilder asReadOnly() { readOnly = true; return this; } - @Override - public TextFile build() { + @Override public TextFile build() { return new NioTextFile(path, parentFsId, charset, languageVersion, readOnly); } } @@ -83,14 +81,12 @@ static class ForCharSeq extends TextFileBuilder { this.fileId = AssertionUtil.requireParamNotNull("path ID", fileId); } - @Override - public TextFileBuilder setParentFsPath(@Nullable FileId fileId) { + @Override public TextFileBuilder setParentFsPath(@Nullable FileId fileId) { this.fileId = FileId.asChildOf(this.fileId, fileId); return super.setParentFsPath(fileId); } - @Override - public TextFile build() { + @Override public TextFile build() { return new StringTextFile(charSequence, fileId, languageVersion); } } @@ -106,15 +102,13 @@ static class ForReader extends TextFileBuilder { this.fileId = AssertionUtil.requireParamNotNull("path ID", fileId); } - @Override - public TextFileBuilder setParentFsPath(@Nullable FileId fileId) { + @Override public TextFileBuilder setParentFsPath(@Nullable FileId fileId) { this.fileId = FileId.asChildOf(this.fileId, fileId); return super.setParentFsPath(fileId); } - @Override - public TextFile build() { + @Override public TextFile build() { return new ReaderTextFile(reader, fileId, languageVersion); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextPos2d.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextPos2d.java index d7e1c2b83a3..b15fa5ee0d6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextPos2d.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextPos2d.java @@ -47,8 +47,7 @@ public static TextPos2d pos2d(int line, int column) { /** Compares the start offset, then the length of a region. */ - @Override - public int compareTo(@NonNull TextPos2d that) { + @Override public int compareTo(@NonNull TextPos2d that) { int cmp = Integer.compare(this.getLine(), that.getLine()); if (cmp != 0) { return cmp; @@ -77,13 +76,11 @@ public String toDisplayStringWithColon() { return line + ":" + column; } - @Override - public String toString() { + @Override public String toString() { return "!debug only! Pos2d(line=" + line + ", column=" + column + ")"; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } @@ -92,11 +89,10 @@ public boolean equals(Object o) { } TextPos2d that = (TextPos2d) o; return line == that.getLine() - && column == that.getColumn(); + && column == that.getColumn(); } - @Override - public int hashCode() { + @Override public int hashCode() { return line * 31 + column; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextRange2d.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextRange2d.java index 14519896a98..8dc772a5db7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextRange2d.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextRange2d.java @@ -12,10 +12,10 @@ */ public final class TextRange2d implements Comparable { private static final Comparator COMPARATOR = - Comparator.comparingInt(TextRange2d::getStartLine) - .thenComparingInt(TextRange2d::getStartColumn) - .thenComparingInt(TextRange2d::getEndLine) - .thenComparingInt(TextRange2d::getEndColumn); + Comparator.comparingInt(TextRange2d::getStartLine) + .thenComparingInt(TextRange2d::getStartColumn) + .thenComparingInt(TextRange2d::getEndLine) + .thenComparingInt(TextRange2d::getEndColumn); private final int startLine; private final int startCol; @@ -28,7 +28,7 @@ public TextRange2d(int startLine, int startCol, int endLine, int endCol) { this.endLine = endLine; this.endCol = endCol; assert startCol >= 1 && startLine >= 1 && endLine >= 1 && endCol >= 1 - : "Not a valid range " + toDisplayStringWithColon(); + : "Not a valid range " + toDisplayStringWithColon(); } @@ -42,7 +42,7 @@ public TextPos2d getEndPos() { public String toDisplayStringWithColon() { return getStartPos().toDisplayStringWithColon() + "-" - + getEndPos().toDisplayStringWithColon(); + + getEndPos().toDisplayStringWithColon(); } public int getStartLine() { @@ -73,8 +73,7 @@ public static TextRange2d fullLine(int line, int lineLength) { return new TextRange2d(line, 1, line, 1 + lineLength); } - @Override - public int compareTo(TextRange2d o) { + @Override public int compareTo(TextRange2d o) { return COMPARATOR.compare(this, o); } @@ -86,8 +85,7 @@ public boolean contains(TextPos2d pos) { return getStartPos().compareTo(pos) <= 0 && getEndPos().compareTo(pos) >= 0; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } @@ -96,18 +94,16 @@ public boolean equals(Object o) { } TextRange2d that = (TextRange2d) o; return this.getStartPos().equals(that.getStartPos()) - && this.getEndPos().equals(that.getEndPos()); + && this.getEndPos().equals(that.getEndPos()); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(getStartPos(), getEndPos()); } - @Override - public String toString() { + @Override public String toString() { return "!debug only! [" + getStartPos().toTupleString() - + " - " + getEndPos().toTupleString() + ']'; + + " - " + getEndPos().toTupleString() + ']'; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextRegion.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextRegion.java index 5a1e2d19c3f..d411482a809 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextRegion.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/document/TextRegion.java @@ -40,8 +40,8 @@ public final class TextRegion implements Comparable { private static final Comparator COMPARATOR = - Comparator.comparingInt(TextRegion::getStartOffset) - .thenComparingInt(TextRegion::getLength); + Comparator.comparingInt(TextRegion::getStartOffset) + .thenComparingInt(TextRegion::getLength); private final int startOffset; private final int length; @@ -100,7 +100,7 @@ public boolean contains(int offset) { */ public boolean contains(TextRegion other) { return this.getStartOffset() <= other.getStartOffset() - && other.getEndOffset() <= this.getEndOffset(); + && other.getEndOffset() <= this.getEndOffset(); } /** @@ -152,7 +152,7 @@ public TextRegion growRight(int delta) { int end = Math.min(r1.getEndOffset(), r2.getEndOffset()); return start <= end ? fromBothOffsets(start, end) - : null; + : null; } /** @@ -223,18 +223,15 @@ private String parThis() { /** Compares the start offset, then the length of a region. */ - @Override - public int compareTo(@NonNull TextRegion o) { + @Override public int compareTo(@NonNull TextRegion o) { return COMPARATOR.compare(this, o); } - @Override - public String toString() { + @Override public String toString() { return "Region(start=" + startOffset + ", len=" + length + ", end=" + getEndOffset() + ")"; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } @@ -243,11 +240,10 @@ public boolean equals(Object o) { } TextRegion that = (TextRegion) o; return startOffset == that.getStartOffset() - && length == that.getLength(); + && length == that.getLength(); } - @Override - public int hashCode() { + @Override public int hashCode() { return startOffset * 31 + length; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessor.java index 7c2c0313b3b..4f7111cc43e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessor.java @@ -29,8 +29,7 @@ abstract class AbstractPMDProcessor implements AutoCloseable { * Joins tasks and await completion of the analysis. After this, all * {@link TextFile}s must have been closed. */ - @Override - public abstract void close(); + @Override public abstract void close(); /** * Returns a new file processor. The strategy used for threading is @@ -40,8 +39,8 @@ abstract class AbstractPMDProcessor implements AutoCloseable { */ public static AbstractPMDProcessor newFileProcessor(AnalysisTask analysisTask) { return analysisTask.getThreadCount() > 0 - ? new MultiThreadProcessor(analysisTask) - : new MonoThreadProcessor(analysisTask); + ? new MultiThreadProcessor(analysisTask) + : new MonoThreadProcessor(analysisTask); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/BasePmdDialectLanguageVersionHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/BasePmdDialectLanguageVersionHandler.java index 2fe55b0f615..44e162af031 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/BasePmdDialectLanguageVersionHandler.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/BasePmdDialectLanguageVersionHandler.java @@ -19,8 +19,7 @@ @Experimental public class BasePmdDialectLanguageVersionHandler extends AbstractPmdLanguageVersionHandler { - @Override - public final Parser getParser() { + @Override public final Parser getParser() { return null; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/BatchLanguageProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/BatchLanguageProcessor.java index 72877527116..a03bb462b60 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/BatchLanguageProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/BatchLanguageProcessor.java @@ -34,7 +34,7 @@ public abstract class BatchLanguageProcessor

i protected BatchLanguageProcessor(P bundle) { if (!(bundle.getLanguage() instanceof PmdCapableLanguage)) { throw new IllegalArgumentException( - "Cannot create a processor for a language which does not support PMD: " + bundle.getLanguage() + "Cannot create a processor for a language which does not support PMD: " + bundle.getLanguage() ); } this.language = (PmdCapableLanguage) bundle.getLanguage(); @@ -46,18 +46,15 @@ public P getProperties() { return bundle; } - @Override - public @NonNull LanguageVersion getLanguageVersion() { + @Override public @NonNull LanguageVersion getLanguageVersion() { return version; } - @Override - public final @NonNull PmdCapableLanguage getLanguage() { + @Override public final @NonNull PmdCapableLanguage getLanguage() { return language; } - @Override - public @NonNull AutoCloseable launchAnalysis(@NonNull AnalysisTask task) { + @Override public @NonNull AutoCloseable launchAnalysis(@NonNull AnalysisTask task) { // The given analysis task has all files to analyse, not only the ones for this language. List files = new ArrayList<>(task.getFiles()); files.removeIf(it -> !it.getLanguageVersion().getLanguage().equals(getLanguage())); @@ -73,8 +70,7 @@ public P getProperties() { return processor; } - @Override - public void close() throws Exception { + @Override public void close() throws Exception { // no additional resources } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/CpdOnlyLanguageModuleBase.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/CpdOnlyLanguageModuleBase.java index 5da636b7413..c7900daa3c9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/CpdOnlyLanguageModuleBase.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/CpdOnlyLanguageModuleBase.java @@ -26,6 +26,5 @@ protected CpdOnlyLanguageModuleBase(LanguageMetadata metadata) { super(metadata); } - @Override - public abstract CpdLexer createCpdLexer(LanguagePropertyBundle bundle); + @Override public abstract CpdLexer createCpdLexer(LanguagePropertyBundle bundle); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java index 001dee94592..b0869bf39b0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessor.java @@ -20,16 +20,14 @@ final class MonoThreadProcessor extends AbstractPMDProcessor { task.getMessageReporter().log(Level.DEBUG, "Using main thread for analysis"); } - @Override - @SuppressWarnings("PMD.CloseResource") // closed by the PMDRunnable + @Override @SuppressWarnings("PMD.CloseResource") // closed by the PMDRunnable public void processFiles() { for (TextFile file : task.getFiles()) { new MonothreadRunnable(file, task).run(); } } - @Override - public void close() { + @Override public void close() { // nothing to do } @@ -43,8 +41,7 @@ static final class MonothreadRunnable extends PmdRunnable { } - @Override - protected RuleSets getRulesets() { + @Override protected RuleSets getRulesets() { return ruleSets; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessor.java index 9d279ec4c62..ca884a88c56 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessor.java @@ -40,8 +40,7 @@ final class MultiThreadProcessor extends AbstractPMDProcessor { futureList = new LinkedList<>(); } - @Override - @SuppressWarnings("PMD.CloseResource") // closed by the PMDRunnable + @Override @SuppressWarnings("PMD.CloseResource") // closed by the PMDRunnable public void processFiles() { // The thread-local is not static, but analysis-global // This means we don't have to reset it manually, every analysis is isolated. @@ -56,16 +55,14 @@ public void processFiles() { for (final TextFile textFile : task.getFiles()) { futureList.add(executor.submit(new PmdRunnable(textFile, task) { - @Override - protected RuleSets getRulesets() { + @Override protected RuleSets getRulesets() { return ruleSetCopy.get(); } })); } } - @Override - public void close() { + @Override public void close() { try { try { for (Future task : futureList) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java index dfb7b042b7c..f636dab4900 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdRunnable.java @@ -51,8 +51,7 @@ abstract class PmdRunnable implements Runnable { */ protected abstract RuleSets getRulesets(); - @Override - public void run() throws FileAnalysisException { + @Override public void run() throws FileAnalysisException { TimeTracker.initThread(); try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.FILE_PROCESSING); @@ -66,8 +65,7 @@ public void run() throws FileAnalysisException { try (TextDocument textDocument = TextDocument.create(textFile); FileAnalysisListener cacheListener = analysisCache.startFileAnalysis(textDocument)) { - @SuppressWarnings("PMD.CloseResource") - FileAnalysisListener completeListener = FileAnalysisListener.tee(listOf(listener, cacheListener)); + @SuppressWarnings("PMD.CloseResource") FileAnalysisListener completeListener = FileAnalysisListener.tee(listOf(listener, cacheListener)); if (analysisCache.isUpToDate(textDocument)) { LOG.trace("Skipping file (lang: {}) because it was found in the cache: {}", textFile.getLanguageVersion(), textFile.getFileId().getAbsolutePath()); @@ -115,15 +113,14 @@ private RootNode parse(Parser parser, ParserTask task) { private void processSource(FileAnalysisListener listener, - TextDocument textDocument, - RuleSets ruleSets) throws FileAnalysisException { + TextDocument textDocument, + RuleSets ruleSets) throws FileAnalysisException { SemanticErrorReporter reporter = SemanticErrorReporter.reportToLogger(task.getMessageReporter()); - @SuppressWarnings("PMD.CloseResource") - LanguageProcessor processor = task.getLpRegistry().getProcessor(textDocument.getLanguageVersion().getLanguage()); + @SuppressWarnings("PMD.CloseResource") LanguageProcessor processor = task.getLpRegistry().getProcessor(textDocument.getLanguageVersion().getLanguage()); ParserTask parserTask = new ParserTask(textDocument, - reporter, - task.getLpRegistry()); + reporter, + task.getLpRegistry()); LanguageVersionHandler handler = processor.services(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdThreadFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdThreadFactory.java index 4d10948229b..176f3cd4c51 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdThreadFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/PmdThreadFactory.java @@ -11,8 +11,7 @@ class PmdThreadFactory implements ThreadFactory { private final AtomicInteger counter = new AtomicInteger(); - @Override - public Thread newThread(Runnable r) { + @Override public Thread newThread(Runnable r) { return new Thread(r, "PmdThread " + counter.incrementAndGet()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/SimpleDialectLanguageModuleBase.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/SimpleDialectLanguageModuleBase.java index 4b703e4db38..aaf4b90de9c 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/SimpleDialectLanguageModuleBase.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/SimpleDialectLanguageModuleBase.java @@ -80,8 +80,7 @@ protected SimpleDialectLanguageModuleBase(DialectLanguageMetadata metadata, Func * To define dialect-specific properties to be added to this bundle, override {@link #newDialectPropertyBundle()} * @return A new set of properties */ - @Override - public final LanguagePropertyBundle newPropertyBundle() { + @Override public final LanguagePropertyBundle newPropertyBundle() { LanguagePropertyBundle baseBundle = getBaseLanguageFromRegistry(LanguageRegistry.PMD).newPropertyBundle(); LanguagePropertyBundle dialectBundle = newDialectPropertyBundle(); @@ -98,16 +97,14 @@ public final LanguagePropertyBundle newPropertyBundle() { return new LanguagePropertyBundle(this); } - @Override - public final LanguageProcessor createProcessor(LanguagePropertyBundle bundle) { + @Override public final LanguageProcessor createProcessor(LanguagePropertyBundle bundle) { final PmdCapableLanguage baseLanguage = (PmdCapableLanguage) getBaseLanguageFromRegistry(LanguageRegistry.PMD); final BasePmdDialectLanguageVersionHandler dialectHandler = handler.apply(bundle); return new DialectLanguageProcessor(baseLanguage, dialectHandler, bundle); } - @Override - public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { + @Override public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { final CpdCapableLanguage baseLanguage = (CpdCapableLanguage) getBaseLanguageFromRegistry(LanguageRegistry.CPD); return baseLanguage.createCpdLexer(bundle); } @@ -126,18 +123,15 @@ private DialectLanguageProcessor(PmdCapableLanguage baseLanguage, BasePmdDialect this.combinedHandler = new SimpleDialectLanguageVersionHandler(baseLanguageProcessor.services(), dialectHandler); } - @Override - public @NonNull LanguageVersionHandler services() { + @Override public @NonNull LanguageVersionHandler services() { return combinedHandler; } - @Override - public @NonNull AutoCloseable launchAnalysis(@NonNull AnalysisTask analysisTask) { + @Override public @NonNull AutoCloseable launchAnalysis(@NonNull AnalysisTask analysisTask) { return baseLanguageProcessor.launchAnalysis(analysisTask); } - @Override - public void close() throws Exception { + @Override public void close() throws Exception { super.close(); baseLanguageProcessor.close(); } @@ -156,35 +150,30 @@ private static class SimpleDialectLanguageVersionHandler extends AbstractPmdLang this.dialectLanguageVersionHandler = dialectLanguageVersionHandler; } - @Override - public XPathHandler getXPathHandler() { + @Override public XPathHandler getXPathHandler() { // Add dialect-specific XPath functions return baseLanguageVersionHandler.getXPathHandler() .combine(dialectLanguageVersionHandler.getXPathHandler()); } - @Override - public Parser getParser() { + @Override public Parser getParser() { // Always the base language parser for full compatibility (same AST) return baseLanguageVersionHandler.getParser(); } - @Override - public ViolationDecorator getViolationDecorator() { + @Override public ViolationDecorator getViolationDecorator() { return ViolationDecorator.chain( Arrays.asList(baseLanguageVersionHandler.getViolationDecorator(), dialectLanguageVersionHandler.getViolationDecorator())); } - @Override - public List getExtraViolationSuppressors() { + @Override public List getExtraViolationSuppressors() { return CollectionUtil.concatView( baseLanguageVersionHandler.getExtraViolationSuppressors(), dialectLanguageVersionHandler.getExtraViolationSuppressors()); } - @Override - public LanguageMetricsProvider getLanguageMetricsProvider() { + @Override public LanguageMetricsProvider getLanguageMetricsProvider() { if (baseLanguageVersionHandler.getLanguageMetricsProvider() == null) { return dialectLanguageVersionHandler.getLanguageMetricsProvider(); } @@ -202,8 +191,7 @@ public LanguageMetricsProvider getLanguageMetricsProvider() { }; } - @Override - public DesignerBindings getDesignerBindings() { + @Override public DesignerBindings getDesignerBindings() { // if the dialect set something it has priority if (DesignerBindings.DefaultDesignerBindings.getInstance().equals(dialectLanguageVersionHandler.getDesignerBindings())) { return baseLanguageVersionHandler.getDesignerBindings(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/SimpleLanguageModuleBase.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/SimpleLanguageModuleBase.java index 0cb3368f5f0..c0398a76ef4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/SimpleLanguageModuleBase.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/impl/SimpleLanguageModuleBase.java @@ -36,12 +36,10 @@ public SimpleLanguageModuleBase(LanguageMetadata metadata, Function(bundle) { - @Override - public @NonNull LanguageVersionHandler services() { + @Override public @NonNull LanguageVersionHandler services() { return services; } }; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/Metric.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/Metric.java index 735c3ef6c93..645dd720efb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/Metric.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/Metric.java @@ -123,9 +123,9 @@ default boolean supports(Node node) { * @throws NullPointerException If either parameter is null */ static Metric of(BiFunction compute, - Function cast, - @NonNull String fullName, - String... aliases) { + Function cast, + @NonNull String fullName, + String... aliases) { AssertionUtil.requireParamNotNull("compute", compute); AssertionUtil.requireParamNotNull("cast", cast); AssertionUtil.requireParamNotNull("fullName", fullName); @@ -134,23 +134,19 @@ static Metric of(BiFunction allNames = listOf(fullName, aliases); return new Metric() { - @Override - public String displayName() { + @Override public String displayName() { return fullName; } - @Override - public List nameAliases() { + @Override public List nameAliases() { return allNames; } - @Override - public @Nullable T castIfSupported(@NonNull Node node) { + @Override public @Nullable T castIfSupported(@NonNull Node node) { return cast.apply(node); } - @Override - public R computeFor(T node, MetricOptions options) { + @Override public R computeFor(T node, MetricOptions options) { return compute.apply(node, options); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/MetricOptions.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/MetricOptions.java index 99e844851bc..bff4dd4766b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/MetricOptions.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/MetricOptions.java @@ -38,21 +38,20 @@ private MetricOptions() { private MetricOptions(Set opts) { switch (opts.size()) { - case 0: - options = Collections.emptySet(); - break; - case 1: - options = Collections.singleton(opts.iterator().next()); - break; - default: - options = Collections.unmodifiableSet(opts); - break; + case 0: + options = Collections.emptySet(); + break; + case 1: + options = Collections.singleton(opts.iterator().next()); + break; + default: + options = Collections.unmodifiableSet(opts); + break; } } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } @@ -66,8 +65,7 @@ public boolean equals(Object o) { } - @Override - public int hashCode() { + @Override public int hashCode() { return options.hashCode(); } @@ -92,11 +90,10 @@ public boolean contains(MetricOption option) { } - @Override - public String toString() { + @Override public String toString() { return "MetricOptions{" - + "options=" + options - + '}'; + + "options=" + options + + '}'; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/MetricsUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/MetricsUtil.java index 1feb5afd50e..0341ca91ee8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/MetricsUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/MetricsUtil.java @@ -56,8 +56,8 @@ public static DoubleSummaryStatistics computeStatistics(Metric< * @return Statistics for the value of the metric over all the nodes */ public static DoubleSummaryStatistics computeStatistics(Metric key, - Iterable ops, - MetricOptions options) { + Iterable ops, + MetricOptions options) { Objects.requireNonNull(key, NULL_KEY_MESSAGE); @@ -65,8 +65,8 @@ public static DoubleSummaryStatistics computeStatistics(Metric< Objects.requireNonNull(ops, NULL_NODE_MESSAGE); return StreamSupport.stream(ops.spliterator(), false) - .filter(key::supports) - .collect(Collectors.summarizingDouble(op -> computeMetric(key, op, options).doubleValue())); + .filter(key::supports) + .collect(Collectors.summarizingDouble(op -> computeMetric(key, op, options).doubleValue())); } /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/ParameterizedMetricKey.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/ParameterizedMetricKey.java index 230c8a033bb..02e6daf4303 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/ParameterizedMetricKey.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/metrics/ParameterizedMetricKey.java @@ -35,22 +35,19 @@ private ParameterizedMetricKey(Metric metric, MetricOptions options) { } - @Override - public String toString() { + @Override public String toString() { return "ParameterizedMetricKey{key=" + metric.displayName() + ", options=" + options + '}'; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { return o instanceof ParameterizedMetricKey - && ((ParameterizedMetricKey) o).metric.equals(metric) - && ((ParameterizedMetricKey) o).options.equals(options); + && ((ParameterizedMetricKey) o).metric.equals(metric) + && ((ParameterizedMetricKey) o).options.equals(options); } - @Override - public int hashCode() { + @Override public int hashCode() { return 31 * metric.hashCode() + options.hashCode(); } @@ -64,14 +61,12 @@ public int hashCode() { * * @return An instance of parameterized metric key corresponding to the parameters */ - @SuppressWarnings("PMD.SingletonClassReturningNewInstance") - public static ParameterizedMetricKey getInstance(Metric key, MetricOptions options) { + @SuppressWarnings("PMD.SingletonClassReturningNewInstance") public static ParameterizedMetricKey getInstance(Metric key, MetricOptions options) { // sharing instances allows using DataMap, which uses reference identity ParameterizedMetricKey tmp = new ParameterizedMetricKey<>(key, options); POOL.putIfAbsent(tmp, tmp); - @SuppressWarnings("unchecked") - ParameterizedMetricKey result = (ParameterizedMetricKey) POOL.get(tmp); + @SuppressWarnings("unchecked") ParameterizedMetricKey result = (ParameterizedMetricKey) POOL.get(tmp); return result; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java index d00fca4b095..5b1a990b51f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractRule.java @@ -54,18 +54,15 @@ public AbstractRule() { definePropertyDescriptor(Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR); } - @Override - protected String getPropertySourceType() { + @Override protected String getPropertySourceType() { return "rule"; } - @Override - public Language getLanguage() { + @Override public Language getLanguage() { return language; } - @Override - public void setLanguage(Language language) { + @Override public void setLanguage(Language language) { if (this.language != null && !this.language.equals(language)) { throw new UnsupportedOperationException("The Language for Rule class " + this.getClass().getName() + " is immutable and cannot be changed."); @@ -73,130 +70,106 @@ public void setLanguage(Language language) { this.language = language; } - @Override - public LanguageVersion getMinimumLanguageVersion() { + @Override public LanguageVersion getMinimumLanguageVersion() { return minimumLanguageVersion; } - @Override - public void setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion) { + @Override public void setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion) { if (minimumLanguageVersion != null && !minimumLanguageVersion.getLanguage().equals(getLanguage())) { throw new IllegalArgumentException("Version " + minimumLanguageVersion + " does not belong to language " + getLanguage()); } this.minimumLanguageVersion = minimumLanguageVersion; } - @Override - public LanguageVersion getMaximumLanguageVersion() { + @Override public LanguageVersion getMaximumLanguageVersion() { return maximumLanguageVersion; } - @Override - public void setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion) { + @Override public void setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion) { if (maximumLanguageVersion != null && !maximumLanguageVersion.getLanguage().equals(getLanguage())) { throw new IllegalArgumentException("Version " + maximumLanguageVersion + " does not belong to language " + getLanguage()); } this.maximumLanguageVersion = maximumLanguageVersion; } - @Override - public boolean isDeprecated() { + @Override public boolean isDeprecated() { return deprecated; } - @Override - public void setDeprecated(boolean deprecated) { + @Override public void setDeprecated(boolean deprecated) { this.deprecated = deprecated; } - @Override - public String getName() { + @Override public String getName() { return name; } - @Override - public void setName(String name) { + @Override public void setName(String name) { this.name = name; } - @Override - public String getSince() { + @Override public String getSince() { return since; } - @Override - public void setSince(String since) { + @Override public void setSince(String since) { this.since = since; } - @Override - public String getRuleClass() { + @Override public String getRuleClass() { return ruleClass; } - @Override - public void setRuleClass(String ruleClass) { + @Override public void setRuleClass(String ruleClass) { this.ruleClass = ruleClass; } - @Override - public String getRuleSetName() { + @Override public String getRuleSetName() { return ruleSetName; } - @Override - public void setRuleSetName(String ruleSetName) { + @Override public void setRuleSetName(String ruleSetName) { this.ruleSetName = ruleSetName; } - @Override - public String getMessage() { + @Override public String getMessage() { return message; } - @Override - public void setMessage(String message) { + @Override public void setMessage(String message) { this.message = message; } - @Override - public String getDescription() { + @Override public String getDescription() { return description; } - @Override - public void setDescription(String description) { + @Override public void setDescription(String description) { this.description = description; } - @Override - public List getExamples() { + @Override public List getExamples() { // TODO Needs to be externally immutable return examples; } - @Override - public void addExample(String example) { + @Override public void addExample(String example) { examples.add(example); } - @Override - public String getExternalInfoUrl() { + @Override public String getExternalInfoUrl() { return externalInfoUrl; } - @Override - public void setExternalInfoUrl(String externalInfoUrl) { + @Override public void setExternalInfoUrl(String externalInfoUrl) { this.externalInfoUrl = externalInfoUrl; } - @Override - public RulePriority getPriority() { + @Override public RulePriority getPriority() { return priority; } - @Override - public void setPriority(RulePriority priority) { + @Override public void setPriority(RulePriority priority) { this.priority = priority; } @@ -208,8 +181,7 @@ private Set> getClassRuleChainVisits() { return classRuleChainVisits; } - @Override - public final RuleTargetSelector getTargetSelector() { + @Override public final RuleTargetSelector getTargetSelector() { if (myStrategy == null) { myStrategy = buildTargetSelector(); } @@ -220,20 +192,17 @@ public final RuleTargetSelector getTargetSelector() { * Create the targeting strategy for this rule. * Use the factory methods of {@link RuleTargetSelector}. */ - @NonNull - protected RuleTargetSelector buildTargetSelector() { + @NonNull protected RuleTargetSelector buildTargetSelector() { Set> crvs = getClassRuleChainVisits(); return crvs.isEmpty() ? RuleTargetSelector.forRootOnly() - : RuleTargetSelector.forTypes(crvs); + : RuleTargetSelector.forTypes(crvs); } - @Override - public void start(RuleContext ctx) { + @Override public void start(RuleContext ctx) { // Override as needed } - @Override - public void end(RuleContext ctx) { + @Override public void end(RuleContext ctx) { // Override as needed } @@ -254,7 +223,7 @@ public void end(RuleContext ctx) { protected final RuleContext asCtx(Object ctx) { if (ctx instanceof RuleContext) { assert isThisRule(InternalApiBridge.getRule((RuleContext) ctx)) - : "not an appropriate rule context!"; + : "not an appropriate rule context!"; return (RuleContext) ctx; } else { throw new ClassCastException("Unexpected context object! " + ctx); @@ -263,7 +232,7 @@ assert isThisRule(InternalApiBridge.getRule((RuleContext) ctx)) private boolean isThisRule(Rule rule) { return rule == this // NOPMD CompareObjectsWithEquals - || rule instanceof RuleReference && this.isThisRule(((RuleReference) rule).getRule()); + || rule instanceof RuleReference && this.isThisRule(((RuleReference) rule).getRule()); } /** @@ -275,8 +244,7 @@ private boolean isThisRule(Rule rule) { *

  • They share the same properties.
  • * */ - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; // trivial } @@ -290,14 +258,11 @@ public boolean equals(Object o) { && super.equals(o); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(getName(), getPriority(), super.hashCode()); } - @SuppressWarnings("unchecked") - @Override - public Rule deepCopy() { + @SuppressWarnings("unchecked") @Override public Rule deepCopy() { Rule result; try { Constructor declaredConstructor = getClass().getDeclaredConstructor(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractVisitorRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractVisitorRule.java index f633fe66f5b..b1f02d2a89e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractVisitorRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/AbstractVisitorRule.java @@ -9,8 +9,7 @@ import net.sourceforge.pmd.reporting.RuleContext; public abstract class AbstractVisitorRule extends AbstractRule { - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { AstVisitor visitor = buildVisitor(); assert visitor != null : "Rule should provide a non-null visitor"; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/InternalApiBridge.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/InternalApiBridge.java index 802d07ccad9..6fc3b06c7df 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/InternalApiBridge.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/InternalApiBridge.java @@ -26,7 +26,8 @@ */ @InternalApi public final class InternalApiBridge { - private InternalApiBridge() {} + private InternalApiBridge() { + } public static boolean ruleSetApplies(Rule rule, LanguageVersion languageVersion) { return RuleSet.applies(rule, languageVersion); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java index 6123fc07bd9..6cd7785bb26 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/Rule.java @@ -35,22 +35,22 @@ public interface Rule extends PropertySource { * matching a regular expression. */ PropertyDescriptor> VIOLATION_SUPPRESS_REGEX_DESCRIPTOR = - PropertyFactory.regexProperty("violationSuppressRegex") - .desc("Suppress violations with messages matching a regular expression") - .toOptional("") - .defaultValue(Optional.empty()) - .build(); + PropertyFactory.regexProperty("violationSuppressRegex") + .desc("Suppress violations with messages matching a regular expression") + .toOptional("") + .defaultValue(Optional.empty()) + .build(); /** * Name of the property to universally suppress violations on nodes which * match a given relative XPath expression. */ PropertyDescriptor> VIOLATION_SUPPRESS_XPATH_DESCRIPTOR = - PropertyFactory.stringProperty("violationSuppressXPath") - .desc("Suppress violations on nodes which match a given relative XPath expression.") - .toOptional("") - .defaultValue(Optional.empty()) - .build(); + PropertyFactory.stringProperty("violationSuppressXPath") + .desc("Suppress violations on nodes which match a given relative XPath expression.") + .toOptional("") + .defaultValue(Optional.empty()) + .build(); /** * Get the Language of this Rule. @@ -126,8 +126,7 @@ public interface Rule extends PropertySource { * * @return the name */ - @Override - String getName(); + @Override String getName(); /** * Set the name of this Rule. @@ -273,7 +272,7 @@ public interface Rule extends PropertySource { * @param languageProcessor The processor for the rule's language */ default void initialize(LanguageProcessor languageProcessor) { - // by default do nothing + // by default do nothing } /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleFactory.java index 0c4cd635344..8878ddb5695 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleFactory.java @@ -80,7 +80,7 @@ class RuleFactory { * @param resourceLoader The resource loader to load the rule from jar */ RuleFactory(ResourceLoader resourceLoader, - LanguageRegistry languageRegistry) { + LanguageRegistry languageRegistry) { this.resourceLoader = resourceLoader; this.languageRegistry = languageRegistry; } @@ -130,9 +130,9 @@ public RuleReference decorateRule(Rule referencedRule, RuleSetReference ruleSetR } else { err.at(node).error( - XmlErrorMessages.ERR__UNEXPECTED_ELEMENT_IN, - node.getTagName(), - "rule " + ruleReference.getName() + XmlErrorMessages.ERR__UNEXPECTED_ELEMENT_IN, + node.getTagName(), + "rule " + ruleReference.getName() ); } } @@ -203,8 +203,8 @@ public Rule buildRule(Element ruleElement, PmdXmlReporter err) { } else { throw err.at(node).error( - XmlErrorMessages.ERR__UNEXPECTED_ELEMENT_IN, - "rule " + NAME.getAttributeOrNull(ruleElement)); + XmlErrorMessages.ERR__UNEXPECTED_ELEMENT_IN, + "rule " + NAME.getAttributeOrNull(ruleElement)); } } @@ -213,13 +213,13 @@ public Rule buildRule(Element ruleElement, PmdXmlReporter err) { private void checkVersionsAreOrdered(Element ruleElement, PmdXmlReporter err, Rule rule) { if (rule.getMinimumLanguageVersion() != null && rule.getMaximumLanguageVersion() != null - && rule.getMinimumLanguageVersion().compareTo(rule.getMaximumLanguageVersion()) > 0) { + && rule.getMinimumLanguageVersion().compareTo(rule.getMaximumLanguageVersion()) > 0) { throw err.at(MINIMUM_LANGUAGE_VERSION.getAttributeNode(ruleElement)) - .error( - XmlErrorMessages.ERR__INVALID_VERSION_RANGE, - rule.getMinimumLanguageVersion(), - rule.getMaximumLanguageVersion() - ); + .error( + XmlErrorMessages.ERR__INVALID_VERSION_RANGE, + rule.getMinimumLanguageVersion(), + rule.getMaximumLanguageVersion() + ); } } @@ -243,20 +243,20 @@ private LanguageVersion getLanguageVersion(Element ruleElement, PmdXmlReporter e LanguageVersion version = language.getVersion(attrValue); if (version == null) { String supportedVersions = language.getVersions().stream() - .map(LanguageVersion::getVersion) - .filter(it -> !it.isEmpty()) - .map(StringUtil::inSingleQuotes) - .collect(Collectors.joining(", ")); + .map(LanguageVersion::getVersion) + .filter(it -> !it.isEmpty()) + .map(StringUtil::inSingleQuotes) + .collect(Collectors.joining(", ")); String message = supportedVersions.isEmpty() - ? ERR__INVALID_LANG_VERSION_NO_NAMED_VERSION - : ERR__INVALID_LANG_VERSION; + ? ERR__INVALID_LANG_VERSION_NO_NAMED_VERSION + : ERR__INVALID_LANG_VERSION; throw err.at(attrName.getAttributeNode(ruleElement)) - .error( - message, - attrValue, - language.getId(), - supportedVersions - ); + .error( + message, + attrValue, + language.getId(), + supportedVersions + ); } return version; } @@ -269,7 +269,7 @@ private void setLanguage(Element ruleElement, PmdXmlReporter err, Rule rule) { if (lang == null) { Attr node = LANGUAGE.getAttributeNode(ruleElement); throw err.at(node) - .error("Invalid language ''{0}'', possible values are {1}", langId, supportedLanguages()); + .error("Invalid language ''{0}'', possible values are {1}", langId, supportedLanguages()); } rule.setLanguage(lang); } @@ -362,25 +362,25 @@ private static PropertyDescriptor parsePropertyDefinition(Element propertyEle PropertyTypeId factory = PropertyTypeId.lookupMnemonic(typeId); if (factory == null) { throw err.at(PROPERTY_TYPE.getAttributeNode(propertyElement)) - .error(XmlErrorMessages.ERR__UNSUPPORTED_PROPERTY_TYPE, typeId); + .error(XmlErrorMessages.ERR__UNSUPPORTED_PROPERTY_TYPE, typeId); } return propertyDefCapture(propertyElement, err, factory.getBuilderUtils()); } private static PropertyDescriptor propertyDefCapture(Element propertyElement, - PmdXmlReporter err, - BuilderAndMapper factory) { + PmdXmlReporter err, + BuilderAndMapper factory) { String name = NAME.getNonBlankAttributeOrThrow(propertyElement, err); String description = DESCRIPTION.getNonBlankAttributeOrThrow(propertyElement, err); try { PropertyBuilder builder = factory.newBuilder(name) - .desc(description); + .desc(description); if (DELIMITER.hasAttribute(propertyElement)) { err.at(DELIMITER.getAttributeNode(propertyElement)) - .warn(XmlErrorMessages.WARN__DELIMITER_DEPRECATED); + .warn(XmlErrorMessages.WARN__DELIMITER_DEPRECATED); } parseConstraints(propertyElement, factory, builder, err); @@ -400,26 +400,24 @@ private static void parseConstraints(Element propertyElement, BuilderAndMapp if (min.isPresent() && max.isPresent()) { if (min.get().compareTo((T) max.get()) > 0) { throw err.at(PROPERTY_MIN.getAttributeNode(propertyElement)) - .error(XmlErrorMessages.ERR__INVALID_VALUE_RANGE); + .error(XmlErrorMessages.ERR__INVALID_VALUE_RANGE); } - @SuppressWarnings({ "unchecked", "rawtypes" }) - PropertyConstraint constraint = NumericConstraints.inRange((Comparable) min.get(), (Comparable) max.get()); + @SuppressWarnings({"unchecked", "rawtypes"}) PropertyConstraint constraint = NumericConstraints.inRange((Comparable) min.get(), (Comparable) max.get()); builder.require(constraint); } else if (min.isPresent() || max.isPresent()) { Comparable minOrMax = min.orElse(max.orElse(null)); - @SuppressWarnings({ "unchecked", "rawtypes" }) - PropertyConstraint constraint = min.isPresent() ? NumericConstraints.above((Comparable) minOrMax) - : NumericConstraints.below((Comparable) minOrMax); + @SuppressWarnings({"unchecked", "rawtypes"}) PropertyConstraint constraint = min.isPresent() ? NumericConstraints.above((Comparable) minOrMax) + : NumericConstraints.below((Comparable) minOrMax); builder.require(constraint); } } private static Optional> parseIntoComparable(Element propertyElement, BuilderAndMapper factory, PmdXmlReporter err, SchemaConstant schemaConstant) { return schemaConstant - .getAttributeOpt(propertyElement) - .map(s -> tryParsePropertyValue(factory, s, err.at(schemaConstant.getAttributeNode(propertyElement)))) - .map(s -> asComparableOrThrow(s, err.at(schemaConstant.getAttributeNode(propertyElement)))); + .getAttributeOpt(propertyElement) + .map(s -> tryParsePropertyValue(factory, s, err.at(schemaConstant.getAttributeNode(propertyElement)))) + .map(s -> asComparableOrThrow(s, err.at(schemaConstant.getAttributeNode(propertyElement)))); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RulePriority.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RulePriority.java index 2007fcf0aa1..3f5d255f1ff 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RulePriority.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RulePriority.java @@ -73,8 +73,7 @@ public String getName() { * @return descriptive name of the priority * @see #getName() */ - @Override - public String toString() { + @Override public String toString() { return name; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java index 54021e50208..ac7c6cb668f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleReference.java @@ -80,8 +80,7 @@ public LanguageVersion getOverriddenMinimumLanguageVersion() { return minimumLanguageVersion; } - @Override - public void setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion) { + @Override public void setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion) { // Only override if different than current value, or if already // overridden. if (!Objects.equals(minimumLanguageVersion, rule.getMinimumLanguageVersion()) || this.minimumLanguageVersion != null) { @@ -94,8 +93,7 @@ public LanguageVersion getOverriddenMaximumLanguageVersion() { return maximumLanguageVersion; } - @Override - public void setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion) { + @Override public void setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion) { // Only override if different than current value, or if already // overridden. if (!Objects.equals(maximumLanguageVersion, rule.getMaximumLanguageVersion()) || this.maximumLanguageVersion != null) { @@ -108,13 +106,11 @@ public Boolean isOverriddenDeprecated() { return deprecated; } - @Override - public boolean isDeprecated() { + @Override public boolean isDeprecated() { return deprecated != null && deprecated; } - @Override - public void setDeprecated(boolean deprecated) { + @Override public void setDeprecated(boolean deprecated) { // Deprecation does not propagate to the underlying Rule. It is the // Rule reference itself which is being deprecated. this.deprecated = deprecated ? deprecated : null; @@ -128,8 +124,7 @@ public String getOriginalName() { return rule.getName(); } - @Override - public void setName(String name) { + @Override public void setName(String name) { // Only override if different than current value, or if already // overridden. if (!isSame(name, rule.getName()) || this.name != null) { @@ -137,8 +132,7 @@ public void setName(String name) { } } - @Override - public String getName() { + @Override public String getName() { if (this.name != null) { return this.name; } @@ -149,8 +143,7 @@ public String getOverriddenMessage() { return message; } - @Override - public void setMessage(String message) { + @Override public void setMessage(String message) { // Only override if different than current value, or if already // overridden. if (!isSame(message, rule.getMessage()) || this.message != null) { @@ -163,8 +156,7 @@ public String getOverriddenDescription() { return description; } - @Override - public void setDescription(String description) { + @Override public void setDescription(String description) { // Only override if different than current value, or if already // overridden. if (!isSame(description, rule.getDescription()) || this.description != null) { @@ -177,8 +169,7 @@ public List getOverriddenExamples() { return examples; } - @Override - public void addExample(String example) { + @Override public void addExample(String example) { // TODO Intuitively, if some examples are overridden (even with empty value), then // I think we should discard the previous ones. If the rule needs new examples, // then the previous ones are not relevant. @@ -209,8 +200,7 @@ public String getOverriddenExternalInfoUrl() { return externalInfoUrl; } - @Override - public void setExternalInfoUrl(String externalInfoUrl) { + @Override public void setExternalInfoUrl(String externalInfoUrl) { // Only override if different than current value, or if already // overridden. if (!isSame(externalInfoUrl, rule.getExternalInfoUrl()) || this.externalInfoUrl != null) { @@ -223,8 +213,7 @@ public RulePriority getOverriddenPriority() { return priority; } - @Override - public void setPriority(RulePriority priority) { + @Override public void setPriority(RulePriority priority) { // Only override if different than current value, or if already // overridden. if (priority != rule.getPriority() || this.priority != null) { @@ -234,13 +223,11 @@ public void setPriority(RulePriority priority) { } - @Override - public List> getOverriddenPropertyDescriptors() { + @Override public List> getOverriddenPropertyDescriptors() { return new ArrayList<>(getOverriddenPropertiesByPropertyDescriptor().keySet()); } - @Override - public void definePropertyDescriptor(PropertyDescriptor propertyDescriptor) throws IllegalArgumentException { + @Override public void definePropertyDescriptor(PropertyDescriptor propertyDescriptor) throws IllegalArgumentException { // Define on the underlying Rule, where it is impossible to have two // property descriptors with the same name. Therefore, there is no need // to check if the property is already overridden at this level. @@ -252,13 +239,11 @@ public void definePropertyDescriptor(PropertyDescriptor propertyDescriptor) t } - @Override - public Map, Object> getOverriddenPropertiesByPropertyDescriptor() { + @Override public Map, Object> getOverriddenPropertiesByPropertyDescriptor() { return propertyValues == null ? new HashMap<>() : new HashMap<>(propertyValues); } - @Override - public void setProperty(PropertyDescriptor propertyDescriptor, T value) { + @Override public void setProperty(PropertyDescriptor propertyDescriptor, T value) { // Only override if different than current value. if (!Objects.equals(rule.getProperty(propertyDescriptor), value)) { if (propertyValues == null) { @@ -289,19 +274,16 @@ private static boolean contains(Collection collection, String s1) { return false; } - @Override - public boolean hasDescriptor(PropertyDescriptor descriptor) { + @Override public boolean hasDescriptor(PropertyDescriptor descriptor) { return propertyDescriptors != null && propertyDescriptors.contains(descriptor) || rule.hasDescriptor(descriptor); } - @Override - public boolean isPropertyOverridden(PropertyDescriptor descriptor) { + @Override public boolean isPropertyOverridden(PropertyDescriptor descriptor) { return propertyValues != null && propertyValues.containsKey(descriptor); } - @Override - public Rule deepCopy() { + @Override public Rule deepCopy() { return new RuleReference(this); } @@ -318,128 +300,103 @@ public boolean hasOverriddenAttributes() { || propertyDescriptors != null || propertyValues != null; } - @Override - public Language getLanguage() { + @Override public Language getLanguage() { return rule.getLanguage(); } - @Override - public void setLanguage(Language language) { + @Override public void setLanguage(Language language) { rule.setLanguage(language); } - @Override - public LanguageVersion getMinimumLanguageVersion() { + @Override public LanguageVersion getMinimumLanguageVersion() { return rule.getMinimumLanguageVersion(); } - @Override - public LanguageVersion getMaximumLanguageVersion() { + @Override public LanguageVersion getMaximumLanguageVersion() { return rule.getMaximumLanguageVersion(); } - @Override - public String getSince() { + @Override public String getSince() { return rule.getSince(); } - @Override - public void setSince(String since) { + @Override public void setSince(String since) { rule.setSince(since); } - @Override - public String getRuleClass() { + @Override public String getRuleClass() { return rule.getRuleClass(); } - @Override - public void setRuleClass(String ruleClass) { + @Override public void setRuleClass(String ruleClass) { rule.setRuleClass(ruleClass); } - @Override - public String getRuleSetName() { + @Override public String getRuleSetName() { return rule.getRuleSetName(); } - @Override - public void setRuleSetName(String name) { + @Override public void setRuleSetName(String name) { rule.setRuleSetName(name); } - @Override - public String getMessage() { + @Override public String getMessage() { return rule.getMessage(); } - @Override - public String getDescription() { + @Override public String getDescription() { return rule.getDescription(); } - @Override - public List getExamples() { + @Override public List getExamples() { return rule.getExamples(); } - @Override - public String getExternalInfoUrl() { + @Override public String getExternalInfoUrl() { return rule.getExternalInfoUrl(); } - @Override - public RulePriority getPriority() { + @Override public RulePriority getPriority() { return rule.getPriority(); } - @Override - public RuleTargetSelector getTargetSelector() { + @Override public RuleTargetSelector getTargetSelector() { return rule.getTargetSelector(); } - @Override - public void initialize(LanguageProcessor languageProcessor) { + @Override public void initialize(LanguageProcessor languageProcessor) { rule.initialize(languageProcessor); } - @Override - public void start(RuleContext ctx) { + @Override public void start(RuleContext ctx) { rule.start(ctx); } - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { rule.apply(target, ctx); } - @Override - public void end(RuleContext ctx) { + @Override public void end(RuleContext ctx) { rule.end(ctx); } - @Override - public PropertyDescriptor getPropertyDescriptor(String name) { + @Override public PropertyDescriptor getPropertyDescriptor(String name) { return rule.getPropertyDescriptor(name); } - @Override - public List> getPropertyDescriptors() { + @Override public List> getPropertyDescriptors() { return rule.getPropertyDescriptors(); } - @Override - public T getProperty(PropertyDescriptor propertyDescriptor) { + @Override public T getProperty(PropertyDescriptor propertyDescriptor) { return rule.getProperty(propertyDescriptor); } - @Override - public Map, Object> getPropertiesByPropertyDescriptor() { + @Override public Map, Object> getPropertiesByPropertyDescriptor() { return rule.getPropertiesByPropertyDescriptor(); } - @Override - public String dysfunctionReason() { + @Override public String dysfunctionReason() { return rule.dysfunctionReason(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSet.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSet.java index 9b580c206a7..8f66f662ad5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSet.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSet.java @@ -110,9 +110,9 @@ public static RuleSet forSingleRule(final Rule rule) { } final RuleSetBuilder builder = - new RuleSetBuilder(checksum) - .withName(rule.getName()) - .withDescription("RuleSet for " + rule.getName()); + new RuleSetBuilder(checksum) + .withName(rule.getName()) + .withDescription("RuleSet for " + rule.getName()); builder.addRule(rule); return builder.build(); } @@ -141,17 +141,17 @@ public static RuleSet forSingleRule(final Rule rule) { * @throws NullPointerException If any parameter is null, or the collections contain null elements */ public static RuleSet create(String name, - String description, - String fileName, - Collection excludePatterns, - Collection includePatterns, - Iterable rules) { + String description, + String fileName, + Collection excludePatterns, + Collection includePatterns, + Iterable rules) { RuleSetBuilder builder = new RuleSetBuilder(0L); // TODO: checksum missing builder.withName(name) - .withDescription(description) - .withFileName(fileName) - .replaceFileExclusions(excludePatterns) - .replaceFileInclusions(includePatterns); + .withDescription(description) + .withFileName(fileName) + .replaceFileExclusions(excludePatterns) + .replaceFileInclusions(includePatterns); for (Rule rule : rules) { builder.addRule(rule); } @@ -207,10 +207,10 @@ public static class RuleSetBuilder { /* package */ RuleSetBuilder(final RuleSet original) { checksum = original.getChecksum(); this.withName(original.getName()) - .withDescription(original.getDescription()) - .withFileName(original.getFileName()) - .replaceFileExclusions(original.getFileExclusions()) - .replaceFileInclusions(original.getFileInclusions()); + .withDescription(original.getDescription()) + .withFileName(original.getFileName()) + .replaceFileExclusions(original.getFileExclusions()) + .replaceFileInclusions(original.getFileInclusions()); addRuleSet(original); } @@ -289,7 +289,7 @@ public RuleSetBuilder addRuleReplaceIfExists(final Rule rule) { throw new IllegalArgumentException(MISSING_RULE); } - for (final Iterator it = rules.iterator(); it.hasNext();) { + for (final Iterator it = rules.iterator(); it.hasNext(); ) { final Rule r = it.next(); if (r.getName().equals(rule.getName()) && r.getLanguage().equals(rule.getLanguage())) { it.remove(); @@ -675,8 +675,7 @@ static boolean applies(Rule rule, LanguageVersion languageVersion) { * @return true if o is a ruleset with the same name and rules, * false otherwise */ - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (!(o instanceof RuleSet)) { return false; // Trivial } @@ -689,8 +688,7 @@ public boolean equals(Object o) { return getName().equals(ruleSet.getName()) && getRules().equals(ruleSet.getRules()); } - @Override - public int hashCode() { + @Override public int hashCode() { return getName().hashCode() + 13 * getRules().hashCode(); } @@ -742,8 +740,7 @@ public void removeDysfunctionalRules(Collection collector) { } } - @Override - public long getChecksum() { + @Override public long getChecksum() { return checksum; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetFactory.java index 7332924ac2d..d0dff4cfeea 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetFactory.java @@ -87,11 +87,11 @@ final class RuleSetFactory { private final Map parsedRulesets = new HashMap<>(); RuleSetFactory(ResourceLoader resourceLoader, - LanguageRegistry languageRegistry, - RulePriority minimumPriority, - boolean warnDeprecated, - boolean includeDeprecatedRuleReferences, - PmdReporter reporter) { + LanguageRegistry languageRegistry, + RulePriority minimumPriority, + boolean warnDeprecated, + boolean includeDeprecatedRuleReferences, + PmdReporter reporter) { this.resourceLoader = resourceLoader; this.languageRegistry = Objects.requireNonNull(languageRegistry); this.minimumPriority = minimumPriority; @@ -115,7 +115,7 @@ final class RuleSetFactory { } private @NonNull RuleSet createRuleSet(RuleSetReferenceId ruleSetReferenceId, boolean withDeprecatedRuleReferences) - throws RuleSetLoadException { + throws RuleSetLoadException { return readDocument(ruleSetReferenceId, withDeprecatedRuleReferences); } @@ -138,7 +138,7 @@ private Rule createRule(RuleSetReferenceId ruleSetReferenceId, boolean withDepre RuleSetReferenceId parentRuleset = ruleSetReferenceId.getParentRulesetIfThisIsARule(); if (parentRuleset == null) { throw new IllegalArgumentException( - "Cannot parse a single Rule from an all Rule RuleSet reference: <" + ruleSetReferenceId + ">."); + "Cannot parse a single Rule from an all Rule RuleSet reference: <" + ruleSetReferenceId + ">."); } // can't use computeIfAbsent as creating a ruleset may add more entries to the map. RuleSet ruleSet = parsedRulesets.get(parentRuleset); @@ -165,7 +165,7 @@ private Rule createRule(RuleSetReferenceId ruleSetReferenceId, boolean withDepre try (CheckedInputStream inputStream = new CheckedInputStream(ruleSetReferenceId.getInputStream(resourceLoader), new Adler32())) { if (!ruleSetReferenceId.isAbsolute()) { throw new IllegalArgumentException( - "Cannot parse a RuleSet from a non-absolute reference: <" + ruleSetReferenceId + ">."); + "Cannot parse a RuleSet from a non-absolute reference: <" + ruleSetReferenceId + ">."); } XmlMessageHandler printer = getXmlMessagePrinter(); @@ -174,12 +174,11 @@ private Rule createRule(RuleSetReferenceId ruleSetReferenceId, boolean withDepre inputSource.setSystemId(ruleSetReferenceId.getRuleSetFileName()); OoxmlFacade ooxml = new OoxmlFacade() - .withPrinter(printer) - .withAnsiColors(false); + .withPrinter(printer) + .withAnsiColors(false); PositionedXmlDoc parsed = ooxml.parse(builder, inputSource); - @SuppressWarnings("PMD.CloseResource") - PmdXmlReporterImpl err = new PmdXmlReporterImpl(reporter, ooxml, parsed.getPositioner()); + @SuppressWarnings("PMD.CloseResource") PmdXmlReporterImpl err = new PmdXmlReporterImpl(reporter, ooxml, parsed.getPositioner()); try { RuleSetBuilder ruleSetBuilder = new RuleSetBuilder(inputStream.getChecksum().getValue()).withFileName(ruleSetReferenceId.getRuleSetFileName()); @@ -206,10 +205,10 @@ private Rule createRule(RuleSetReferenceId ruleSetReferenceId, boolean withDepre private RuleSet parseRulesetNode(RuleSetReferenceId ruleSetReferenceId, - boolean withDeprecatedRuleReferences, - PositionedXmlDoc parsed, - RuleSetBuilder builder, - PmdXmlReporter err) { + boolean withDeprecatedRuleReferences, + PositionedXmlDoc parsed, + RuleSetBuilder builder, + PmdXmlReporter err) { Element ruleSetElement = parsed.getDocument().getDocumentElement(); if (ruleSetElement.hasAttribute("name")) { @@ -246,8 +245,8 @@ private RuleSet parseRulesetNode(RuleSetReferenceId ruleSetReferenceId, } } else { err.at(node).error(XmlErrorMessages.ERR__UNEXPECTED_ELEMENT_IN, - node.getTagName(), - RULESET); + node.getTagName(), + RULESET); } } @@ -322,11 +321,11 @@ private DocumentBuilder createDocumentBuilder() throws ParserConfigurationExcept * a warning */ private void parseRuleNode(RuleSetReferenceId ruleSetReferenceId, - RuleSetBuilder ruleSetBuilder, - Element ruleNode, - boolean withDeprecatedRuleReferences, - Set rulesetReferences, - PmdXmlReporter err) { + RuleSetBuilder ruleSetBuilder, + Element ruleNode, + boolean withDeprecatedRuleReferences, + Set rulesetReferences, + PmdXmlReporter err) { if (REF.hasAttribute(ruleNode)) { String ref = REF.getAttributeOrThrow(ruleNode, err); RuleSetReferenceId refId = parseReferenceAndWarn(ref, REF.getAttributeNode(ruleNode), err); @@ -357,10 +356,10 @@ private void parseRuleNode(RuleSetReferenceId ruleSetReferenceId, * @param rulesetReferences keeps track of already processed complete ruleset references in order to log a warning */ private void parseRuleSetReferenceNode(RuleSetBuilder ruleSetBuilder, - Element ruleElement, - String ref, - RuleSetReferenceId ruleSetReferenceId, Set rulesetReferences, - PmdXmlReporter err) { + Element ruleElement, + String ref, + RuleSetReferenceId ruleSetReferenceId, Set rulesetReferences, + PmdXmlReporter err) { RulePriority priority = null; Map excludedRulesCheck = new HashMap<>(); for (Element child : XmlUtil.getElementChildrenList(ruleElement)) { @@ -410,8 +409,8 @@ private void parseRuleSetReferenceNode(RuleSetBuilder ruleSetBuilder, // all rules in the ruleset have been deprecated - the ruleset itself is considered to be deprecated rulesetDeprecated = true; err.at(REF.getAttributeNode(ruleElement)) - .warn("The RuleSet {0} has been deprecated and will be removed in PMD {1}", - ref, PMDVersion.getNextMajorRelease()); + .warn("The RuleSet {0} has been deprecated and will be removed in PMD {1}", + ref, PMDVersion.getNextMajorRelease()); } for (RuleReference r : potentialRules) { @@ -425,8 +424,8 @@ private void parseRuleSetReferenceNode(RuleSetBuilder ruleSetBuilder, if (!excludedRulesCheck.isEmpty()) { excludedRulesCheck.forEach( - (name, elt) -> - err.at(elt).warn("Exclude pattern ''{0}'' did not match any rule in ruleset ''{1}''", name, ref)); + (name, elt) -> + err.at(elt).warn("Exclude pattern ''{0}'' did not match any rule in ruleset ''{1}''", name, ref)); } if (rulesetReferences.contains(ref)) { @@ -436,8 +435,8 @@ private void parseRuleSetReferenceNode(RuleSetBuilder ruleSetBuilder, } private RuleSetReferenceId parseReferenceAndWarn(String ref, - Node xmlPlace, - PmdXmlReporter err) { + Node xmlPlace, + PmdXmlReporter err) { if (ref == null) { err.at(xmlPlace).warn("Rule reference references a deleted rule, ignoring"); return null; // deleted rule @@ -446,7 +445,7 @@ private RuleSetReferenceId parseReferenceAndWarn(String ref, List references = RuleSetReferenceId.parse(ref); if (references.size() > 1 && warnDeprecated) { err.at(xmlPlace).warn("Using a comma separated list as a ref attribute is deprecated. " - + "All references but the first are ignored."); + + "All references but the first are ignored."); } else if (references.isEmpty()) { err.at(xmlPlace).warn("Empty ref attribute"); return null; @@ -464,14 +463,14 @@ private RuleSetReferenceId parseReferenceAndWarn(String ref, * @param err Error reporter */ private void parseSingleRuleNode(RuleSetReferenceId ruleSetReferenceId, - RuleSetBuilder ruleSetBuilder, - Element ruleNode, - PmdXmlReporter err) { + RuleSetBuilder ruleSetBuilder, + Element ruleNode, + PmdXmlReporter err) { // Stop if we're looking for a particular Rule, and this element is not // it. if (StringUtils.isNotBlank(ruleSetReferenceId.getRuleName()) - && !isRuleName(ruleNode, ruleSetReferenceId.getRuleName())) { + && !isRuleName(ruleNode, ruleSetReferenceId.getRuleName())) { return; } Rule rule = new RuleFactory(resourceLoader, languageRegistry).buildRule(ruleNode, err); @@ -479,10 +478,10 @@ private void parseSingleRuleNode(RuleSetReferenceId ruleSetReferenceId, if (warnDeprecated && StringUtils.isBlank(ruleNode.getAttribute("language"))) { err.at(ruleNode).warn( - "Rule {0}/{1} does not mention attribute language='{2}'," - + " please mention it explicitly to be compatible with PMD 7", - ruleSetReferenceId.getRuleSetFileName(), rule.getName(), - rule.getLanguage().getId()); + "Rule {0}/{1} does not mention attribute language='{2}'," + + " please mention it explicitly to be compatible with PMD 7", + ruleSetReferenceId.getRuleSetFileName(), rule.getName(), + rule.getLanguage().getId()); } ruleSetBuilder.addRule(rule); @@ -502,17 +501,17 @@ private void parseSingleRuleNode(RuleSetReferenceId ruleSetReferenceId, * @param err Error reporter */ private void parseRuleReferenceNode(RuleSetReferenceId ruleSetReferenceId, - RuleSetBuilder ruleSetBuilder, - Element ruleNode, - String ref, - RuleSetReferenceId otherRuleSetReferenceId, - boolean withDeprecatedRuleReferences, - PmdXmlReporter err) { + RuleSetBuilder ruleSetBuilder, + Element ruleNode, + String ref, + RuleSetReferenceId otherRuleSetReferenceId, + boolean withDeprecatedRuleReferences, + PmdXmlReporter err) { // Stop if we're looking for a particular Rule, and this element is not // it. if (StringUtils.isNotBlank(ruleSetReferenceId.getRuleName()) - && !isRuleName(ruleNode, ruleSetReferenceId.getRuleName())) { + && !isRuleName(ruleNode, ruleSetReferenceId.getRuleName())) { return; } @@ -522,11 +521,11 @@ private void parseRuleReferenceNode(RuleSetReferenceId ruleSetReferenceId, boolean isSameRuleSet = false; if (!otherRuleSetReferenceId.isAbsolute() - && containsRule(ruleSetReferenceId, otherRuleSetReferenceId.getRuleName())) { + && containsRule(ruleSetReferenceId, otherRuleSetReferenceId.getRuleName())) { otherRuleSetReferenceId = new RuleSetReferenceId(ref, ruleSetReferenceId); isSameRuleSet = true; } else if (otherRuleSetReferenceId.isAbsolute() - && otherRuleSetReferenceId.getRuleSetFileName().equals(ruleSetReferenceId.getRuleSetFileName())) { + && otherRuleSetReferenceId.getRuleSetFileName().equals(ruleSetReferenceId.getRuleSetFileName())) { otherRuleSetReferenceId = new RuleSetReferenceId(otherRuleSetReferenceId.getRuleName(), ruleSetReferenceId); isSameRuleSet = true; } @@ -535,25 +534,25 @@ && containsRule(ruleSetReferenceId, otherRuleSetReferenceId.getRuleName())) { if (referencedRule == null) { throw err.at(ruleNode).error( - "Unable to find referenced rule {0}" - + "; perhaps the rule name is misspelled?", - otherRuleSetReferenceId.getRuleName()); + "Unable to find referenced rule {0}" + + "; perhaps the rule name is misspelled?", + otherRuleSetReferenceId.getRuleName()); } if (warnDeprecated && referencedRule.isDeprecated()) { if (referencedRule instanceof RuleReference) { RuleReference ruleReference = (RuleReference) referencedRule; err.at(ruleNode).warn( - "Use Rule name {0}/{1} instead of the deprecated Rule name {2}. PMD {3}" - + " will remove support for this deprecated Rule name usage.", - ruleReference.getRuleSetReference().getRuleSetFileName(), - ruleReference.getOriginalName(), otherRuleSetReferenceId, - PMDVersion.getNextMajorRelease()); + "Use Rule name {0}/{1} instead of the deprecated Rule name {2}. PMD {3}" + + " will remove support for this deprecated Rule name usage.", + ruleReference.getRuleSetReference().getRuleSetFileName(), + ruleReference.getOriginalName(), otherRuleSetReferenceId, + PMDVersion.getNextMajorRelease()); } else { err.at(ruleNode).warn( - "Discontinue using Rule name {0} as it is scheduled for removal from PMD." - + " PMD {1} will remove support for this Rule.", - otherRuleSetReferenceId, PMDVersion.getNextMajorRelease()); + "Discontinue using Rule name {0} as it is scheduled for removal from PMD." + + " PMD {1} will remove support for this Rule.", + otherRuleSetReferenceId, PMDVersion.getNextMajorRelease()); } } @@ -568,13 +567,13 @@ && containsRule(ruleSetReferenceId, otherRuleSetReferenceId.getRuleName())) { if (warnDeprecated && ruleReference.isDeprecated() && !isSameRuleSet) { err.at(ruleNode).warn( - "Use Rule name {0}/{1} instead of the deprecated Rule name {2}/{3}. PMD {4}" - + " will remove support for this deprecated Rule name usage.", - ruleReference.getRuleSetReference().getRuleSetFileName(), - ruleReference.getOriginalName(), - ruleSetReferenceId.getRuleSetFileName(), - ruleReference.getName(), - PMDVersion.getNextMajorRelease()); + "Use Rule name {0}/{1} instead of the deprecated Rule name {2}/{3}. PMD {4}" + + " will remove support for this deprecated Rule name usage.", + ruleReference.getRuleSetReference().getRuleSetFileName(), + ruleReference.getOriginalName(), + ruleSetReferenceId.getRuleSetFileName(), + ruleReference.getName(), + PMDVersion.getNextMajorRelease()); } if (withDeprecatedRuleReferences || !isSameRuleSet || !ruleReference.isDeprecated()) { @@ -586,10 +585,10 @@ && containsRule(ruleSetReferenceId, otherRuleSetReferenceId.getRuleName())) { // for all other cases, we should log a warning if (existingRuleReference.hasOverriddenAttributes() || !ruleReference.hasOverriddenAttributes()) { err.at(ruleNode).warn( - "The rule {0} is referenced multiple times in ruleset ''{1}''. " - + "Only the last rule configuration is used.", - ruleReference.getName(), - ruleSetBuilder.getName()); + "The rule {0} is referenced multiple times in ruleset ''{1}''. " + + "Only the last rule configuration is used.", + ruleReference.getName(), + ruleSetBuilder.getName()); } } @@ -656,11 +655,11 @@ private boolean isRuleName(Element ruleElement, String ruleName) { */ public RuleSetLoader toLoader() { return new RuleSetLoader().loadResourcesWith(resourceLoader) - .filterAbovePriority(minimumPriority) - .warnDeprecated(warnDeprecated) - .includeDeprecatedRuleReferences(includeDeprecatedRuleReferences) - .withReporter(reporter) - .withLanguages(languageRegistry); + .filterAbovePriority(minimumPriority) + .warnDeprecated(warnDeprecated) + .includeDeprecatedRuleReferences(includeDeprecatedRuleReferences) + .withReporter(reporter) + .withLanguages(languageRegistry); } private @NonNull XmlMessageHandler getXmlMessagePrinter() { @@ -672,8 +671,8 @@ public RuleSetLoader toLoader() { } private static final class PmdXmlReporterImpl - extends XmlMessageReporterBase - implements PmdXmlReporter { + extends XmlMessageReporterBase + implements PmdXmlReporter { private final PmdReporter pmdReporter; private int errCount; @@ -683,43 +682,37 @@ private static final class PmdXmlReporterImpl this.pmdReporter = pmdReporter; } - @Override - protected PmdReporter create2ndStage(XmlPosition position, XmlPositioner positioner) { + @Override protected PmdReporter create2ndStage(XmlPosition position, XmlPositioner positioner) { return new PmdReporter() { - @Override - public boolean isLoggable(Level level) { + @Override public boolean isLoggable(Level level) { return pmdReporter.isLoggable(level); } - @Override - public void log(Level level, String message, Object... formatArgs) { + @Override public void log(Level level, String message, Object... formatArgs) { logEx(level, message, formatArgs, null); } - @Override - public void logEx(Level level, String message, Object[] formatArgs, @Nullable Throwable error) { + @Override public void logEx(Level level, String message, Object[] formatArgs, @Nullable Throwable error) { newException(level, error, message, formatArgs); } - @Override - public XmlException error(@Nullable Throwable cause, @Nullable String contextMessage, Object... formatArgs) { + @Override public XmlException error(@Nullable Throwable cause, @Nullable String contextMessage, Object... formatArgs) { return newException(Level.ERROR, cause, contextMessage, formatArgs); } - @Override - public XmlException newException(Level level, Throwable cause, String message, Object... formatArgs) { + @Override public XmlException newException(Level level, Throwable cause, String message, Object... formatArgs) { XmlSeverity severity; switch (level) { - case WARN: - severity = XmlSeverity.WARNING; - break; - case ERROR: - errCount++; - severity = XmlSeverity.ERROR; - break; - default: - throw new IllegalArgumentException("unexpected level " + level); + case WARN: + severity = XmlSeverity.WARNING; + break; + case ERROR: + errCount++; + severity = XmlSeverity.ERROR; + break; + default: + throw new IllegalArgumentException("unexpected level " + level); } if (message == null && formatArgs.length != 0) { @@ -727,19 +720,18 @@ public XmlException newException(Level level, Throwable cause, String message, O } String actualMessage = message == null ? cause.getMessage() - : MessageFormat.format(message, formatArgs); + : MessageFormat.format(message, formatArgs); NiceXmlMessageSpec spec = - new NiceXmlMessageSpec(position, actualMessage) - .withSeverity(severity) - .withCause(cause); + new NiceXmlMessageSpec(position, actualMessage) + .withSeverity(severity) + .withCause(cause); String fullMessage = ooxml.getFormatter().formatSpec(ooxml, spec, positioner); XmlException ex = new XmlException(spec, fullMessage); ooxml.getPrinter().accept(ex); // spec of newException is also to log. return ex; } - @Override - public int numErrors() { + @Override public int numErrors() { return pmdReporter.numErrors(); } }; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetLoader.java index 9d0cc5aa4f4..76bf72aab09 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetLoader.java @@ -118,12 +118,12 @@ public RuleSetLoader includeDeprecatedRuleReferences(boolean enable) { */ RuleSetFactory toFactory() { return new RuleSetFactory( - this.resourceLoader, - this.languageRegistry, - this.minimumPriority, - this.warnDeprecated, - this.includeDeprecatedRuleReferences, - this.reporter + this.resourceLoader, + this.languageRegistry, + this.minimumPriority, + this.warnDeprecated, + this.includeDeprecatedRuleReferences, + this.reporter ); } @@ -155,8 +155,7 @@ public RuleSet loadFromString(String filename, final String rulesetXmlContent) { ResourceLoader oldLoader = this.resourceLoader; try { loadResourcesWith(new ResourceLoader() { - @Override - public @NonNull InputStream loadResourceAsStream(String name) throws IOException { + @Override public @NonNull InputStream loadResourceAsStream(String name) throws IOException { if (Objects.equals(name, filename)) { return new ByteArrayInputStream(rulesetXmlContent.getBytes(StandardCharsets.UTF_8)); } @@ -210,7 +209,7 @@ List loadRuleSetsWithoutException(List rulesetPaths) { } if (!anyRules && !error) { reporter.warn("No rules found. Maybe you misspelled a rule name? ({0})", - StringUtils.join(rulesetPaths, ',')); + StringUtils.join(rulesetPaths, ',')); } return ruleSets; } @@ -260,8 +259,8 @@ RuleSet loadFromResource(RuleSetReferenceId ruleSetReferenceId) { */ public static RuleSetLoader fromPmdConfig(PMDConfiguration configuration) { return new RuleSetLoader().filterAbovePriority(configuration.getMinimumPriority()) - .withLanguages(configuration.getLanguageRegistry()) - .withReporter(configuration.getReporter()); + .withLanguages(configuration.getLanguageRegistry()) + .withReporter(configuration.getReporter()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetWriter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetWriter.java index 3a043326559..32266c315fa 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetWriter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleSetWriter.java @@ -185,17 +185,17 @@ private Element createRuleElement(Rule rule) { List examples = ruleReference.getOverriddenExamples(); return createSingleRuleElement(null, minimumLanguageVersion, maximumLanguageVersion, deprecated, - name, null, ref, message, externalInfoUrl, null, description, priority, - ruleReference, examples); + name, null, ref, message, externalInfoUrl, null, description, priority, + ruleReference, examples); } } else { return createSingleRuleElement(rule.getLanguage(), - rule.getMinimumLanguageVersion(), rule.getMaximumLanguageVersion(), rule.isDeprecated(), - rule.getName(), rule.getSince(), null, rule.getMessage(), rule.getExternalInfoUrl(), - rule.getRuleClass(), - rule.getDescription(), - rule.getPriority(), rule, - rule.getExamples()); + rule.getMinimumLanguageVersion(), rule.getMaximumLanguageVersion(), rule.isDeprecated(), + rule.getName(), rule.getSince(), null, rule.getMessage(), rule.getExternalInfoUrl(), + rule.getRuleClass(), + rule.getDescription(), + rule.getPriority(), rule, + rule.getExamples()); } } @@ -206,9 +206,9 @@ private void setIfNonNull(Object value, Element target, String id) { } private Element createSingleRuleElement(Language language, LanguageVersion minimumLanguageVersion, - LanguageVersion maximumLanguageVersion, Boolean deprecated, String name, String since, String ref, - String message, String externalInfoUrl, String clazz, - String description, RulePriority priority, PropertySource propertySource, List examples) { + LanguageVersion maximumLanguageVersion, Boolean deprecated, String name, String since, String ref, + String message, String externalInfoUrl, String clazz, + String description, RulePriority priority, PropertySource propertySource, List examples) { Element ruleElement = createRuleElement(); // language is now a required attribute, unless this is a rule reference if (clazz != null) { @@ -260,8 +260,7 @@ private Element createRuleSetReferenceElement(RuleSetReference ruleSetReference) return ruleSetReferenceElement; } - @Nullable - private Element createPropertiesElement(PropertySource propertySource) { + @Nullable private Element createPropertiesElement(PropertySource propertySource) { Element propertiesElement = null; List> overridden = propertySource.getOverriddenPropertyDescriptors(); @@ -293,8 +292,7 @@ private Element createPropertiesElement(PropertySource propertySource) { return propertiesElement; } - @NonNull - private Element propertyElementWithValueAttribute(PropertySource propertySource, PropertyDescriptor propertyDescriptor) { + @NonNull private Element propertyElementWithValueAttribute(PropertySource propertySource, PropertyDescriptor propertyDescriptor) { Element element = document.createElementNS(RULESET_2_0_0_NS_URI, "property"); SchemaConstants.NAME.setOn(element, propertyDescriptor.name()); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleTargetSelector.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleTargetSelector.java index 0fabbdc1c09..20fc88a1827 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleTargetSelector.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/RuleTargetSelector.java @@ -72,8 +72,7 @@ public static RuleTargetSelector forTypes(Collection> type * * @throws NullPointerException if any of the arguments is null */ - @SafeVarargs - public static RuleTargetSelector forTypes(Class first, Class... types) { + @SafeVarargs public static RuleTargetSelector forTypes(Class first, Class... types) { return forTypes(CollectionUtil.listOf(first, types)); } @@ -92,18 +91,15 @@ private static final class StringRulechainVisits extends RuleTargetSelector { this.visits = new HashSet<>(visits); } - @Override - protected void prepare(ApplicatorBuilder builder) { + @Override protected void prepare(ApplicatorBuilder builder) { builder.registerXPathNames(visits); } - @Override - protected Iterator getVisitedNodes(TreeIndex index) { + @Override protected Iterator getVisitedNodes(TreeIndex index) { return index.getByName(visits); } - @Override - public String toString() { + @Override public String toString() { return "XPathNameVisits" + visits; } } @@ -121,18 +117,15 @@ private static final class ClassRulechainVisits extends RuleTargetSelector { this.visits = new LinkedHashSet<>(visits); } - @Override - protected void prepare(ApplicatorBuilder builder) { + @Override protected void prepare(ApplicatorBuilder builder) { builder.registerClasses(visits); } - @Override - protected Iterator getVisitedNodes(TreeIndex index) { + @Override protected Iterator getVisitedNodes(TreeIndex index) { return index.getByClass(visits); } - @Override - public String toString() { + @Override public String toString() { return "ClassVisits" + visits; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/impl/UnnecessaryPmdSuppressionRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/impl/UnnecessaryPmdSuppressionRule.java index 0ef159e7072..b7eb6cbe48a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/impl/UnnecessaryPmdSuppressionRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/impl/UnnecessaryPmdSuppressionRule.java @@ -32,23 +32,22 @@ @Experimental public class UnnecessaryPmdSuppressionRule extends AbstractRule { - @Override - public void apply(Node rootNode, RuleContext ctx) { + @Override public void apply(Node rootNode, RuleContext ctx) { assert rootNode instanceof RootNode; LanguageVersionHandler handler = rootNode.getAstInfo().getLanguageProcessor().services(); List suppressors = CollectionUtil.concatView( - handler.getExtraViolationSuppressors(), - InternalApiBridge.DEFAULT_SUPPRESSORS + handler.getExtraViolationSuppressors(), + InternalApiBridge.DEFAULT_SUPPRESSORS ); for (ViolationSuppressor suppressor : suppressors) { Set unusedSuppressors = suppressor.getUnusedSuppressors((RootNode) rootNode); for (UnusedSuppressorNode unusedSuppressor : unusedSuppressors) { ctx.addViolationNoSuppress( - unusedSuppressor.getLocation(), - rootNode.getAstInfo(), - unusedSuppressor.unusedReason() + unusedSuppressor.getLocation(), + rootNode.getAstInfo(), + unusedSuppressor.unusedReason() ); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelation.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelation.java index 91ac6c5a773..cc19b90e47f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelation.java @@ -74,9 +74,9 @@ class LatticeRelation { * @param Internal accumulator type of the collector */ LatticeRelation(TopoOrder keyOrder, - Predicate queryKeySelector, - Function keyToString, - Collector collector) { + Predicate queryKeySelector, + Function keyToString, + Collector collector) { this.keyOrder = keyOrder; this.queryKeySelector = queryKeySelector; this.keyToString = keyToString; @@ -93,9 +93,9 @@ LatticeRelation(TopoOrder keyOrder, * @throws IllegalStateException If the topo order generates a cycle */ LatticeRelation(TopoOrder keyOrder, - Set querySet, - Function keyToString, - Collector collector) { + Set querySet, + Function keyToString, + Collector collector) { this.keyOrder = keyOrder; this.queryKeySelector = querySet::contains; this.keyToString = keyToString; @@ -156,8 +156,7 @@ private void link(@Nullable Iterable preds, LNode n, @Nullable V val) { n.addValueTransitive(val); } - @NonNull - private IllegalStateException cycleError(@NonNull Deque preds, K k) { + @NonNull private IllegalStateException cycleError(@NonNull Deque preds, K k) { List toStrings = map(toMutableList(), preds, n -> keyToString.apply(n.key)); toStrings.add(keyToString.apply(k)); return new IllegalStateException("Cycle in graph: " + String.join(" -> ", toStrings)); @@ -201,8 +200,7 @@ private void putDontCheckParams(@NonNull K key, @Nullable V value) { * * @throws NullPointerException If the key is null */ - @NonNull - public C get(@NonNull K key) { + @NonNull public C get(@NonNull K key) { AssertionUtil.requireParamNotNull("key", key); LNode n = nodes.get(key); return n == null ? emptyValue : n.computeValue(); @@ -214,15 +212,14 @@ public void clearValues() { } } - @Override - public String toString() { + @Override public String toString() { // generates a DOT representation of the lattice // Visualize eg at http://webgraphviz.com/ return GraphUtil.toDot( - nodes.values(), - n -> n.transitiveSuccs, - n -> n.getClass() == QueryNode.class ? DotColor.GREEN : DotColor.BLACK, - n -> keyToString.apply(n.key) + nodes.values(), + n -> n.transitiveSuccs, + n -> n.getClass() == QueryNode.class ? DotColor.GREEN : DotColor.BLACK, + n -> keyToString.apply(n.key) ); } @@ -274,8 +271,7 @@ void resetValue() { // do nothing } - @Override - public String toString() { + @Override public String toString() { return "node(" + key + ')'; } @@ -298,8 +294,7 @@ private final class QueryNode extends LNode { resetValue(); } - @Override - void addAsSuccessorTo(Iterable preds) { + @Override void addAsSuccessorTo(Iterable preds) { preds.forEach(n -> { if (n.transitiveSuccs.add(this)) { // otherwise the transitive successors are also already here @@ -308,32 +303,27 @@ void addAsSuccessorTo(Iterable preds) { }); } - @Override - void addValue(@NonNull V v) { + @Override void addValue(@NonNull V v) { collector().accumulator().accept(accumulator, v); } - @Override - @NonNull C computeValue() { + @Override @NonNull C computeValue() { if (finished == null) { this.finished = finish(collector(), accumulator); } return this.finished; } - @Override - void resetValue() { + @Override void resetValue() { accumulator = collector().supplier().get(); finished = null; } - @Override - public String toString() { + @Override public String toString() { return "qnode(" + key + ')'; } - @SuppressWarnings("unchecked") - private Collector collector() { + @SuppressWarnings("unchecked") private Collector collector() { return (Collector) collector; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java index 52e53783696..a4451df9dec 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleApplicator.java @@ -62,7 +62,7 @@ private void applyOnIndex(TreeIndex idx, Collection rules, FileA if (!ruleSetApplies(rule, currentLangVer)) { continue; // No point in even trying to apply the rule } - + RuleContext ctx = InternalApiBridge.createRuleContext(listener, rule); rule.start(ctx); try (TimedOperation rcto = TimeTracker.startOperation(TimedOperationCategory.RULE, rule.getName())) { @@ -83,7 +83,7 @@ private void applyOnIndex(TreeIndex idx, Collection rules, FileA reportOrRethrow(listener, rule, node, AssertionUtil.contexted(e), SystemProps.isErrorRecoveryMode()); } } - + rcto.close(nodeCounter); } finally { rule.end(ctx); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceId.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceId.java index b0ce233400f..f7471caea75 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceId.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceId.java @@ -337,8 +337,7 @@ public String toNormalizedReference() { * String representation of this reference. Do not rely on the format of this method, * instead use {@link #toNormalizedReference()}. */ - @Override - public String toString() { + @Override public String toString() { return toNormalizedReference(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSets.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSets.java index 1c8b2b956c4..f39ade14cdd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSets.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/RuleSets.java @@ -92,13 +92,13 @@ public RuleSets(RuleSet ruleSet) { public void initializeRules(LanguageProcessorRegistry lpReg, PmdReporter reporter) { // this is abusing the mutability of RuleSet, will go away eventually. for (RuleSet rset : ruleSets) { - for (Iterator iterator = rset.getRules().iterator(); iterator.hasNext();) { + for (Iterator iterator = rset.getRules().iterator(); iterator.hasNext(); ) { Rule rule = iterator.next(); try { rule.initialize(lpReg.getProcessor(rule.getLanguage())); } catch (Exception e) { reporter.errorEx( - "Exception while initializing rule " + rule.getName() + ", the rule will not be run", e); + "Exception while initializing rule " + rule.getName() + ", the rule will not be run", e); iterator.remove(); } } @@ -197,7 +197,7 @@ public void apply(RootNode root, FileAnalysisListener listener) { */ public Rule getRuleByName(String ruleName) { Rule rule = null; - for (Iterator i = ruleSets.iterator(); i.hasNext() && rule == null;) { + for (Iterator i = ruleSets.iterator(); i.hasNext() && rule == null; ) { RuleSet ruleSet = i.next(); rule = ruleSet.getRuleByName(ruleName); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/TreeIndex.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/TreeIndex.java index d7ba9652fc9..d7031311333 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/TreeIndex.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/internal/TreeIndex.java @@ -28,13 +28,13 @@ public class TreeIndex { public TreeIndex(Set namesToIndex, - Set> classesToIndex) { + Set> classesToIndex) { byClass = new LatticeRelation<>( - TopoOrder.TYPE_HIERARCHY_ORDERING, - classesToIndex, - Class::getSimpleName, - Collectors.toSet() + TopoOrder.TYPE_HIERARCHY_ORDERING, + classesToIndex, + Class::getSimpleName, + Collectors.toSet() ); this.interestingNames = namesToIndex; byName = new HashMap<>(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/Attribute.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/Attribute.java index 3bf41f5f4e9..9f4ede73589 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/Attribute.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/Attribute.java @@ -106,10 +106,10 @@ String replacementIfDeprecated() { } else { DeprecatedAttribute annot = method.getAnnotation(DeprecatedAttribute.class); return annot != null - ? annot.replaceWith() - : method.isAnnotationPresent(Deprecated.class) - ? DeprecatedAttribute.NO_REPLACEMENT - : null; + ? annot.replaceWith() + : method.isAnnotationPresent(Deprecated.class) + ? DeprecatedAttribute.NO_REPLACEMENT + : null; } } @@ -166,8 +166,7 @@ public Object getValue() { } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } @@ -176,17 +175,15 @@ public boolean equals(Object o) { } Attribute attribute = (Attribute) o; return Objects.equals(parent, attribute.parent) - && Objects.equals(name, attribute.name); + && Objects.equals(name, attribute.name); } - @Override - public int hashCode() { + @Override public int hashCode() { return parent.hashCode() * 31 + name.hashCode(); } - @Override - public String toString() { + @Override public String toString() { return parent.getXPathNodeName() + "/@" + name + " = " + getValue(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/CommentNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/CommentNode.java index 7d700481edd..4d55193abf7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/CommentNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/CommentNode.java @@ -10,8 +10,7 @@ public interface CommentNode extends Node { String getData(); - @Override - default String getXPathNodeName() { + @Override default String getXPathNodeName() { return "#comment"; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/InternalApiBridge.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/InternalApiBridge.java index 60519103428..bfbdee7b7e3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/InternalApiBridge.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/InternalApiBridge.java @@ -19,7 +19,8 @@ */ @InternalApi public final class InternalApiBridge { - private InternalApiBridge() {} + private InternalApiBridge() { + } public static String replacementIfDeprecated(Attribute attribute) { return attribute.replacementIfDeprecated(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/TextNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/TextNode.java index 00d2b5e6c16..44aa51bd0e9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/TextNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/TextNode.java @@ -9,8 +9,7 @@ public interface TextNode extends Node { String getText(); - @Override - default String getXPathNodeName() { + @Override default String getXPathNodeName() { return "#text"; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java index 1b89b1766f1..24cc43b81ff 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathRule.java @@ -36,10 +36,10 @@ public final class XPathRule extends AbstractRule { private static final Logger LOG = LoggerFactory.getLogger(XPathRule.class); private static final PropertyDescriptor XPATH_DESCRIPTOR = - PropertyFactory.stringProperty("xpath") - .desc("XPath expression") - .defaultValue("") - .build(); + PropertyFactory.stringProperty("xpath") + .desc("XPath expression") + .defaultValue("") + .build(); /** * This is initialized only once when calling {@link #apply(Node, RuleContext)} or {@link #getTargetSelector()}. @@ -77,8 +77,7 @@ public XPathRule(XPathVersion version, String expression) { } - @Override - public Rule deepCopy() { + @Override public Rule deepCopy() { XPathRule rule = (XPathRule) super.deepCopy(); rule.attrLogger = this.attrLogger; return rule; @@ -92,8 +91,7 @@ public String getXPathExpression() { } - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { SaxonXPathRuleQuery query = getQueryMaybeInitialize(); List nodesWithViolation; @@ -128,17 +126,16 @@ private ContextedRuntimeException addExceptionContext(PmdXPathException e) { return e.addRuleName(getName()); } - @Override - public void initialize(LanguageProcessor languageProcessor) { + @Override public void initialize(LanguageProcessor languageProcessor) { String xpath = getXPathExpression(); XPathVersion version = XPathVersion.DEFAULT; try { xpathRuleQuery = new SaxonXPathRuleQuery(xpath, - version, - getPropertiesByPropertyDescriptor(), - languageProcessor.services().getXPathHandler(), - attrLogger); + version, + getPropertiesByPropertyDescriptor(), + languageProcessor.services().getXPathHandler(), + attrLogger); } catch (PmdXPathException e) { throw addExceptionContext(e); } @@ -152,15 +149,14 @@ private SaxonXPathRuleQuery getQueryMaybeInitialize() throws PmdXPathException { } - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { List visits = getQueryMaybeInitialize().getRuleChainVisits(); logXPathRuleChainUsage(!visits.isEmpty()); return visits.isEmpty() ? RuleTargetSelector.forRootOnly() - : RuleTargetSelector.forXPathNames(visits); + : RuleTargetSelector.forXPathNames(visits); } @@ -172,8 +168,7 @@ private void logXPathRuleChainUsage(boolean usesRuleChain) { } - @Override - public String dysfunctionReason() { + @Override public String dysfunctionReason() { if (StringUtils.isBlank(getXPathExpression())) { return "Missing XPath expression"; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathVersion.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathVersion.java index a2010234092..40fa3f152e7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathVersion.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/XPathVersion.java @@ -45,8 +45,7 @@ public String getXmlName() { return version; } - @Override - public String toString() { + @Override public String toString() { return getXmlName(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/AttributeAxisIterator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/AttributeAxisIterator.java index 3ca70f06861..016a7bb7d95 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/AttributeAxisIterator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/AttributeAxisIterator.java @@ -51,24 +51,24 @@ public class AttributeAxisIterator implements Iterator { /* Constants used to determine which methods are accessors */ private static final Set> CONSIDERED_RETURN_TYPES = setOf(Integer.TYPE, Boolean.TYPE, Double.TYPE, String.class, - Long.TYPE, Character.TYPE, Float.TYPE, Chars.class); + Long.TYPE, Character.TYPE, Float.TYPE, Chars.class); private static final Set FILTERED_OUT_NAMES - = setOf("toString", - "getNumChildren", - "getIndexInParent", - "getParent", - "getClass", - "getSourceCodeFile", - "isFindBoundary", - "getRuleIndex", - "getXPathNodeName", - "altNumber", - "toStringTree", - "getTypeNameNode", - "hashCode", - "getImportedNameNode", - "getScope"); + = setOf("toString", + "getNumChildren", + "getIndexInParent", + "getParent", + "getClass", + "getSourceCodeFile", + "isFindBoundary", + "getRuleIndex", + "getXPathNodeName", + "altNumber", + "toStringTree", + "getTypeNameNode", + "hashCode", + "getImportedNameNode", + "getScope"); /* Iteration variables */ private final Iterator iterator; @@ -87,15 +87,15 @@ public AttributeAxisIterator(@NonNull Node contextNode) { private List getWrappersForClass(Class nodeClass) { return Arrays.stream(nodeClass.getMethods()) - .filter(m -> isAttributeAccessor(nodeClass, m)) - .map(m -> { - try { - return new MethodWrapper(m); - } catch (ReflectiveOperationException e) { - throw AssertionUtil.shouldNotReachHere("Method '" + m + "' should be accessible, but: " + e, e); - } - }) - .collect(Collectors.toList()); + .filter(m -> isAttributeAccessor(nodeClass, m)) + .map(m -> { + try { + return new MethodWrapper(m); + } catch (ReflectiveOperationException e) { + throw AssertionUtil.shouldNotReachHere("Method '" + m + "' should be accessible, but: " + e, e); + } + }) + .collect(Collectors.toList()); } /** @@ -109,15 +109,15 @@ protected boolean isAttributeAccessor(Class nodeClass, Method method) { String methodName = method.getName(); return !methodName.startsWith("jjt") - && !FILTERED_OUT_NAMES.contains(methodName) - && method.getParameterTypes().length == 0 - && isConsideredReturnType(method) - // filter out methods declared in supertypes like the - // Antlr ones, unless they're opted-in - && Node.class.isAssignableFrom(method.getDeclaringClass()) - // Methods of package-private classes are not accessible. - && Modifier.isPublic(method.getModifiers()) - && !isIgnored(nodeClass, method); + && !FILTERED_OUT_NAMES.contains(methodName) + && method.getParameterTypes().length == 0 + && isConsideredReturnType(method) + // filter out methods declared in supertypes like the + // Antlr ones, unless they're opted-in + && Node.class.isAssignableFrom(method.getDeclaringClass()) + // Methods of package-private classes are not accessible. + && Modifier.isPublic(method.getModifiers()) + && !isIgnored(nodeClass, method); } private boolean isConsideredReturnType(Method method) { @@ -182,15 +182,13 @@ private boolean isIgnored(Class nodeClass, Method method) { } - @Override - public Attribute next() { + @Override public Attribute next() { MethodWrapper m = iterator.next(); return new Attribute(node, m.name, m.methodHandle, m.method); } - @Override - public boolean hasNext() { + @Override public boolean hasNext() { return iterator.hasNext(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java index e8411eb3b6d..b6342a3df27 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/impl/XPathFunctionDefinition.java @@ -68,13 +68,11 @@ public boolean dependsOnContext() { */ public abstract FunctionCall makeCallExpression(); - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hashCode(qname); } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstAttributeNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstAttributeNode.java index 4b6f7f077f9..c1666b92f58 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstAttributeNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstAttributeNode.java @@ -40,34 +40,28 @@ class AstAttributeNode extends BaseNodeInfo implements SiblingCountingNode { this.treeInfo = parent.getTreeInfo(); } - @Override - List getChildren() { + @Override List getChildren() { return Collections.emptyList(); } - @Override - public int getSiblingPosition() { + @Override public int getSiblingPosition() { return siblingPosition; } - @Override - protected AxisIterator iterateAttributes(NodeTest nodeTest) { + @Override protected AxisIterator iterateAttributes(NodeTest nodeTest) { return EmptyIterator.ofNodes(); } - @Override - protected AxisIterator iterateChildren(NodeTest nodeTest) { + @Override protected AxisIterator iterateChildren(NodeTest nodeTest) { return EmptyIterator.ofNodes(); } - @Override - protected AxisIterator iterateSiblings(NodeTest nodeTest, boolean forwards) { + @Override protected AxisIterator iterateSiblings(NodeTest nodeTest, boolean forwards) { return EmptyIterator.ofNodes(); } - @Override - public AtomicSequence atomize() { + @Override public AtomicSequence atomize() { getTreeInfo().getLogger().recordUsageOf(attribute); if (value == null) { value = DomainConversion.convert(attribute.getValue()); @@ -75,19 +69,16 @@ public AtomicSequence atomize() { return value; } - @Override - public SchemaType getSchemaType() { + @Override public SchemaType getSchemaType() { return schemaType; } - @Override - public Attribute getUnderlyingNode() { + @Override public Attribute getUnderlyingNode() { return attribute; } - @Override - public int compareOrder(NodeInfo other) { + @Override public int compareOrder(NodeInfo other) { if (other instanceof SiblingCountingNode) { return Navigator.compareOrder(this, (SiblingCountingNode) other); } @@ -95,20 +86,17 @@ public int compareOrder(NodeInfo other) { } - @Override - public String getLocalPart() { + @Override public String getLocalPart() { return attribute.getName(); } - @Override - public void generateId(StringBuilder buffer) { + @Override public void generateId(StringBuilder buffer) { buffer.append(hashCode()); } - @Override - public String getStringValue() { + @Override public String getStringValue() { getTreeInfo().getLogger().recordUsageOf(attribute); return attribute.getStringValue(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstDocumentNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstDocumentNode.java index 5b4a2e41c68..e18aa92fe86 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstDocumentNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstDocumentNode.java @@ -28,16 +28,15 @@ class AstDocumentNode extends BaseNodeInfo implements AstNodeOwner { private final List children; AstDocumentNode(AstTreeInfo document, - MutableInt idGenerator, - RootNode wrappedNode, - Configuration configuration) { + MutableInt idGenerator, + RootNode wrappedNode, + Configuration configuration) { super(Type.DOCUMENT, configuration.getNamePool(), "", null); this.rootElement = new AstElementNode(document, idGenerator, this, wrappedNode, configuration); this.children = Collections.singletonList(rootElement); } - @Override - List getChildren() { + @Override List getChildren() { return children; } @@ -45,55 +44,45 @@ public AstElementNode getRootElement() { return rootElement; } - @Override - protected AxisIterator iterateAttributes(NodeTest nodeTest) { + @Override protected AxisIterator iterateAttributes(NodeTest nodeTest) { return EmptyIterator.ofNodes(); } - @Override - protected AxisIterator iterateChildren(NodeTest nodeTest) { + @Override protected AxisIterator iterateChildren(NodeTest nodeTest) { return filter(nodeTest, iterateList(children)); } - @Override - protected AxisIterator iterateSiblings(NodeTest nodeTest, boolean forwards) { + @Override protected AxisIterator iterateSiblings(NodeTest nodeTest, boolean forwards) { return EmptyIterator.ofNodes(); } - @Override - public int getSiblingPosition() { + @Override public int getSiblingPosition() { return 0; } - @Override - public Node getUnderlyingNode() { + @Override public Node getUnderlyingNode() { // this is a concession to the model, so that the expression "/" // may be interpreted as the root node return rootElement.getUnderlyingNode(); } - @Override - public int compareOrder(NodeInfo other) { + @Override public int compareOrder(NodeInfo other) { return other == this ? 0 : -1; // NOPMD CompareObjectsWithEquals - only a single root per tree } - @Override - public boolean hasChildNodes() { + @Override public boolean hasChildNodes() { return true; } - @Override - public String getLocalPart() { + @Override public String getLocalPart() { return ""; } - @Override - public void generateId(StringBuilder buffer) { + @Override public void generateId(StringBuilder buffer) { buffer.append("0"); } - @Override - public String getStringValue() { + @Override public String getStringValue() { return ""; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstElementNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstElementNode.java index f1e98304dca..f358a9e53bf 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstElementNode.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstElementNode.java @@ -51,10 +51,10 @@ public final class AstElementNode extends BaseNodeInfo implements SiblingCountin AstElementNode(AstTreeInfo document, - MutableInt idGenerator, - BaseNodeInfo parent, - Node wrappedNode, - Configuration configuration) { + MutableInt idGenerator, + BaseNodeInfo parent, + Node wrappedNode, + Configuration configuration) { super(determineType(wrappedNode), configuration.getNamePool(), wrappedNode.getXPathNodeName(), parent); this.treeInfo = document; @@ -102,40 +102,34 @@ public Map getLightAttributes() { if (lightAttributes == null) { lightAttributes = new HashMap<>(); getUnderlyingNode().getXPathAttributesIterator() - .forEachRemaining(it -> lightAttributes.put(it.getName(), it)); + .forEachRemaining(it -> lightAttributes.put(it.getName(), it)); } return lightAttributes; } - @Override - public boolean hasChildNodes() { + @Override public boolean hasChildNodes() { return !children.isEmpty(); } - @Override - List getChildren() { + @Override List getChildren() { return children; } - @Override - public Node getUnderlyingNode() { + @Override public Node getUnderlyingNode() { return wrappedNode; } - @Override - public int getColumnNumber() { + @Override public int getColumnNumber() { return wrappedNode.getBeginColumn(); } - @Override - public int getSiblingPosition() { + @Override public int getSiblingPosition() { BaseNodeInfo parent = getParent(); return !(parent instanceof AstElementNode) ? 0 - : id - ((AstElementNode) parent).id; + : id - ((AstElementNode) parent).id; } - @Override - public int compareOrder(NodeInfo other) { + @Override public int compareOrder(NodeInfo other) { if (other instanceof AstElementNode) { return Integer.compare(this.id, ((AstElementNode) other).id); } else if (other instanceof SiblingCountingNode) { @@ -144,8 +138,7 @@ public int compareOrder(NodeInfo other) { throw new UnsupportedOperationException(); } - @Override - protected AxisIterator iterateAttributes(NodeTest predicate) { + @Override protected AxisIterator iterateAttributes(NodeTest predicate) { if (predicate instanceof NameTest) { String local = ((NameTest) predicate).getLocalPart(); return SingleNodeIterator.makeIterator(getAttributes().get(local)); @@ -154,8 +147,7 @@ protected AxisIterator iterateAttributes(NodeTest predicate) { return filter(predicate, new IteratorAdapter(getAttributes().values().iterator())); } - @Override - protected AxisIterator iterateChildren(NodeTest nodeTest) { + @Override protected AxisIterator iterateChildren(NodeTest nodeTest) { return filter(nodeTest, iterateList(children)); } @@ -166,14 +158,13 @@ protected AxisIterator iterateSiblings(NodeTest nodeTest, boolean forwards) { } List siblingsList = - forwards ? CollectionUtil.drop(parent.getChildren(), wrappedNode.getIndexInParent() + 1) - : CollectionUtil.take(parent.getChildren(), wrappedNode.getIndexInParent()); + forwards ? CollectionUtil.drop(parent.getChildren(), wrappedNode.getIndexInParent() + 1) + : CollectionUtil.take(parent.getChildren(), wrappedNode.getIndexInParent()); return filter(nodeTest, iterateList(siblingsList, forwards)); } - @Override - public String getAttributeValue(NamespaceUri uri, String local) { + @Override public String getAttributeValue(NamespaceUri uri, String local) { Attribute attribute = getLightAttributes().get(local); if (attribute != null) { getTreeInfo().getLogger().recordUsageOf(attribute); @@ -183,30 +174,25 @@ public String getAttributeValue(NamespaceUri uri, String local) { } - @Override - public int getLineNumber() { + @Override public int getLineNumber() { return wrappedNode.getBeginLine(); } - @Override - public NodeInfo getRoot() { + @Override public NodeInfo getRoot() { return getTreeInfo().getRootNode(); } - @Override - public void generateId(StringBuilder buffer) { + @Override public void generateId(StringBuilder buffer) { buffer.append(id); } - @Override - public String getLocalPart() { + @Override public String getLocalPart() { return wrappedNode.getXPathNodeName(); } - @Override - public String getStringValue() { + @Override public String getStringValue() { Node node = getUnderlyingNode(); if (node instanceof TextNode) { return ((TextNode) node).getText(); @@ -229,13 +215,11 @@ public String getStringValue() { .collect(Collectors.joining("")); } - @Override - public String toString() { + @Override public String toString() { return "Wrapper[" + getLocalPart() + "]@" + hashCode(); } - private static class IteratorAdapter implements AxisIterator, LookaheadIterator { private final Iterator it; @@ -244,23 +228,19 @@ private static class IteratorAdapter implements AxisIterator, LookaheadIterator this.it = it; } - @Override - public boolean hasNext() { + @Override public boolean hasNext() { return it.hasNext(); } - @Override - public NodeInfo next() { + @Override public NodeInfo next() { return it.hasNext() ? it.next() : null; } - @Override - public void close() { + @Override public void close() { // nothing to do } - @Override - public boolean supportsHasNext() { + @Override public boolean supportsHasNext() { return true; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstTreeInfo.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstTreeInfo.java index 1fe728ea958..266e0b6053d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstTreeInfo.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/AstTreeInfo.java @@ -26,8 +26,7 @@ public final class AstTreeInfo extends GenericTreeInfo { private DeprecatedAttrLogger logger; private final Map wrapperCache = new LinkedHashMap() { - @Override - protected boolean removeEldestEntry(Entry eldest) { + @Override protected boolean removeEldestEntry(Entry eldest) { /* hit ratio depending on cache size: 512: 61% @@ -102,8 +101,7 @@ private AstElementNode findWrapperImpl(Node node) { * child of element type. Both the document and this element child have * the {@link RootNode} as {@link AstElementNode#getUnderlyingNode()}. */ - @Override - public AstDocumentNode getRootNode() { + @Override public AstDocumentNode getRootNode() { return (AstDocumentNode) super.getRootNode(); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/BaseNodeInfo.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/BaseNodeInfo.java index 2ad543c2362..72bb7c81bde 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/BaseNodeInfo.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/BaseNodeInfo.java @@ -42,58 +42,47 @@ abstract class BaseNodeInfo extends AbstractNodeWrapper implements SiblingCounti abstract List getChildren(); - @Override - public AstTreeInfo getTreeInfo() { + @Override public AstTreeInfo getTreeInfo() { return (AstTreeInfo) treeInfo; } - @Override - public final String getURI() { + @Override public final String getURI() { return ""; } - @Override - public final String getBaseURI() { + @Override public final String getBaseURI() { return ""; } - @Override - public String getPrefix() { + @Override public String getPrefix() { return ""; } - @Override - public final BaseNodeInfo getParent() { + @Override public final BaseNodeInfo getParent() { return parent; } - @Override - public final int getFingerprint() { + @Override public final int getFingerprint() { return fingerprint; } - @Override - public final boolean hasFingerprint() { + @Override public final boolean hasFingerprint() { return true; } - @Override - public final NamePool getNamePool() { + @Override public final NamePool getNamePool() { return namePool; } - @Override - public final int getNodeKind() { + @Override public final int getNodeKind() { return nodeKind; } - @Override - public UnicodeString getUnicodeStringValue() { + @Override public UnicodeString getUnicodeStringValue() { return StringView.of(getStringValue()); } - @Override - public NamespaceUri getNamespaceUri() { + @Override public NamespaceUri getNamespaceUri() { return NamespaceUri.NULL; } @@ -108,7 +97,7 @@ static AxisIterator iterateList(List nodes) { static AxisIterator iterateList(List nodes, boolean forwards) { return forwards ? new NodeListIterator(Collections.unmodifiableList(nodes)) - : new RevListAxisIterator<>(nodes); + : new RevListAxisIterator<>(nodes); } private static class RevListAxisIterator implements AxisIterator { @@ -118,8 +107,7 @@ private static class RevListAxisIterator implements AxisIter iter = list.listIterator(list.size()); } - @Override - public NodeInfo next() { + @Override public NodeInfo next() { return this.iter.hasPrevious() ? this.iter.previous() : null; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/CoordinateXPathFunction.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/CoordinateXPathFunction.java index 59a4e83b8ea..2b5ba872c3b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/CoordinateXPathFunction.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/CoordinateXPathFunction.java @@ -18,15 +18,15 @@ public final class CoordinateXPathFunction extends XPathFunctionDefinition { public static final CoordinateXPathFunction START_LINE = - new CoordinateXPathFunction("startLine", Node::getBeginLine); + new CoordinateXPathFunction("startLine", Node::getBeginLine); public static final CoordinateXPathFunction END_LINE = - new CoordinateXPathFunction("endLine", Node::getEndLine); + new CoordinateXPathFunction("endLine", Node::getEndLine); public static final CoordinateXPathFunction START_COLUMN = - new CoordinateXPathFunction("startColumn", Node::getBeginColumn); + new CoordinateXPathFunction("startColumn", Node::getBeginColumn); public static final CoordinateXPathFunction END_COLUMN = - new CoordinateXPathFunction("endColumn", Node::getEndColumn); + new CoordinateXPathFunction("endColumn", Node::getEndColumn); - private static final Type[] A_SINGLE_ELEMENT = { Type.SINGLE_ELEMENT }; + private static final Type[] A_SINGLE_ELEMENT = {Type.SINGLE_ELEMENT}; public static final String PMD_NODE_USER_DATA = "pmd.node"; private final ToIntFunction getter; @@ -35,24 +35,21 @@ private CoordinateXPathFunction(String localName, ToIntFunction getter) { this.getter = getter; } - @Override - public Type[] getArgumentTypes() { + @Override public Type[] getArgumentTypes() { return A_SINGLE_ELEMENT; } - @Override - public Type getResultType() { + @Override public Type getResultType() { return Type.SINGLE_INTEGER; } - @Override - public FunctionCall makeCallExpression() { + @Override public FunctionCall makeCallExpression() { return (contextNode, arguments) -> { Node node = XPathElementToNodeHelper.itemToNode(arguments[0]); if (node == null) { throw new XPathFunctionException( - "Cannot call function '" + getQName().getLocalPart() - + "' on argument " + arguments[0] + "Cannot call function '" + getQName().getLocalPart() + + "' on argument " + arguments[0] ); } return getter.applyAsInt(node); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DefaultXPathFunctions.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DefaultXPathFunctions.java index fddc9bc8e63..3b91574b73e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DefaultXPathFunctions.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DefaultXPathFunctions.java @@ -16,13 +16,13 @@ public final class DefaultXPathFunctions { private static final Set DEFAULTS = - CollectionUtil.immutableSetOf( - FileNameXPathFunction.INSTANCE, - CoordinateXPathFunction.START_LINE, - CoordinateXPathFunction.START_COLUMN, - CoordinateXPathFunction.END_LINE, - CoordinateXPathFunction.END_COLUMN - ); + CollectionUtil.immutableSetOf( + FileNameXPathFunction.INSTANCE, + CoordinateXPathFunction.START_LINE, + CoordinateXPathFunction.START_COLUMN, + CoordinateXPathFunction.END_LINE, + CoordinateXPathFunction.END_COLUMN + ); private DefaultXPathFunctions() { // utility class diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java index 96199993b97..e3911acab37 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DeprecatedAttrLogger.java @@ -66,8 +66,7 @@ private static final class Noop extends DeprecatedAttrLogger { static final Noop INSTANCE = new Noop(); - @Override - public void recordUsageOf(Attribute attribute) { + @Override public void recordUsageOf(Attribute attribute) { // do nothing } } @@ -83,8 +82,7 @@ private AttrLoggerImpl(Rule rule, boolean isSuppressionQuery) { this.isSuppressionQuery = isSuppressionQuery; } - @Override - public void recordUsageOf(Attribute attribute) { + @Override public void recordUsageOf(Attribute attribute) { String replacement = InternalApiBridge.replacementIfDeprecated(attribute); if (replacement != null) { String name = getLoggableAttributeName(attribute); @@ -93,7 +91,7 @@ public void recordUsageOf(Attribute attribute) { // this message needs to be kept in sync with PMDCoverageTest / BinaryDistributionIT String user = isSuppressionQuery ? "violationSuppressXPath for rule " + ruleToString() - : "XPath rule " + ruleToString(); + : "XPath rule " + ruleToString(); String msg = "Use of deprecated attribute '" + name + "' by " + user; if (!replacement.isEmpty()) { msg += ", please use " + replacement + " instead"; @@ -115,8 +113,7 @@ public String ruleToString() { } private static final class AdhocLoggerImpl extends DeprecatedAttrLogger { - @Override - public void recordUsageOf(Attribute attribute) { + @Override public void recordUsageOf(Attribute attribute) { String replacement = InternalApiBridge.replacementIfDeprecated(attribute); if (replacement != null) { String name = getLoggableAttributeName(attribute); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DomainConversion.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DomainConversion.java index 2e692ee992f..6105578cad3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DomainConversion.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/DomainConversion.java @@ -38,24 +38,23 @@ private DomainConversion() { public static SchemaType buildType(java.lang.reflect.Type type) { switch (type.getTypeName()) { - case "java.lang.Integer": - case "java.lang.Long": - return BuiltInAtomicType.INTEGER; - case "java.lang.Double": - case "java.lang.Float": - return BuiltInAtomicType.DOUBLE; - case "java.lang.String": - case "java.lang.Character": - case "java.lang.Class": - case "java.util.regex.Pattern": - return BuiltInAtomicType.STRING; - default: - return BuiltInAtomicType.UNTYPED_ATOMIC; + case "java.lang.Integer": + case "java.lang.Long": + return BuiltInAtomicType.INTEGER; + case "java.lang.Double": + case "java.lang.Float": + return BuiltInAtomicType.DOUBLE; + case "java.lang.String": + case "java.lang.Character": + case "java.lang.Class": + case "java.util.regex.Pattern": + return BuiltInAtomicType.STRING; + default: + return BuiltInAtomicType.UNTYPED_ATOMIC; } } - @NonNull - public static AtomicSequence convert(Object obj) { + @NonNull public static AtomicSequence convert(Object obj) { if (obj instanceof Collection) { return getSequenceRepresentation((Collection) obj); } @@ -122,8 +121,7 @@ private static void flattenInto(Collection list, List values) { * * @return The converted AtomicValue */ - @NonNull - public static AtomicValue getAtomicRepresentation(final Object value) { + @NonNull public static AtomicValue getAtomicRepresentation(final Object value) { /* FUTURE When supported, we should consider refactor this implementation to use Pattern Matching diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/ExpressionPrinter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/ExpressionPrinter.java index ef20dd376dc..c0087cb1754 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/ExpressionPrinter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/ExpressionPrinter.java @@ -30,26 +30,22 @@ private void print(String s) { System.out.println(s); } - @Override - public Expression visit(AxisExpression e) { + @Override public Expression visit(AxisExpression e) { print("axis=" + AxisInfo.axisName[e.getAxis()] + "(test=" + e.getNodeTest() + ")"); return super.visit(e); } - @Override - public Expression visit(RootExpression e) { + @Override public Expression visit(RootExpression e) { print("/"); return super.visit(e); } - @Override - public Expression visit(VennExpression e) { + @Override public Expression visit(VennExpression e) { print("venn=" + Token.tokens[e.getOperator()]); return super.visit(e); } - @Override - public Expression visit(Expression expr) { + @Override public Expression visit(Expression expr) { depth++; print(expr.getClass().getSimpleName()); Expression result = super.visit(expr); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/FileNameXPathFunction.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/FileNameXPathFunction.java index 1f170aee12b..88eeacab134 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/FileNameXPathFunction.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/FileNameXPathFunction.java @@ -23,23 +23,20 @@ private FileNameXPathFunction() { super("fileName"); } - @Override - public Type getResultType() { + @Override public Type getResultType() { return Type.SINGLE_STRING; } - @Override - public boolean dependsOnContext() { + @Override public boolean dependsOnContext() { return true; } - @Override - public FunctionCall makeCallExpression() { + @Override public FunctionCall makeCallExpression() { return (node, arguments) -> { if (node == null) { throw new XPathFunctionException( - "Cannot call function '" + getQName().getLocalPart() - + "' without context item" + "Cannot call function '" + getQName().getLocalPart() + + "' without context item" ); } RootNode root = node.getRoot(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/PmdDocumentSorter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/PmdDocumentSorter.java index b8a27c9fa26..78f17089eea 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/PmdDocumentSorter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/PmdDocumentSorter.java @@ -21,8 +21,7 @@ private PmdDocumentSorter() { } - @Override - public int compare(Node node1, Node node2) { + @Override public int compare(Node node1, Node node2) { if (node1 == node2) { return 0; } else if (node1 == null) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/RuleChainAnalyzer.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/RuleChainAnalyzer.java index afaf60ff6b6..347dd434d3f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/RuleChainAnalyzer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/RuleChainAnalyzer.java @@ -61,8 +61,7 @@ public List getRootElements() { return Collections.emptyList(); } - @Override - public Expression visit(DocumentSorter e) { + @Override public Expression visit(DocumentSorter e) { DocumentSorter result = (DocumentSorter) super.visit(e); // sorting of the nodes must be done after all nodes have been found return result.getBaseExpression(); @@ -86,8 +85,7 @@ public Expression visitSlashPreserveRootElement(SlashExpression e) { return new SlashExpression(start, step); } - @Override - public Expression visit(SlashExpression e) { + @Override public Expression visit(SlashExpression e) { if (!insideExpensiveExpr && rootElement == null) { Expression result = visitSlashPreserveRootElement(e); if (rootElement != null && !rootElementReplaced) { @@ -136,8 +134,7 @@ public Expression visit(SlashExpression e) { } } - @Override - public Expression visit(AxisExpression e) { + @Override public Expression visit(AxisExpression e) { if (rootElement == null && e.getNodeTest() instanceof NameTest && !foundCombinedNodeTest) { NameTest test = (NameTest) e.getNodeTest(); if (test.getPrimitiveType() == Type.ELEMENT && e.getAxis() == AxisInfo.DESCENDANT) { @@ -151,8 +148,7 @@ public Expression visit(AxisExpression e) { return super.visit(e); } - @Override - public Expression visit(LetExpression e) { + @Override public Expression visit(LetExpression e) { // lazy expressions are not a thing in saxon HE // instead saxon hoists expensive subexpressions into LetExpressions // Eg //A[//B] @@ -174,8 +170,7 @@ public Expression visit(LetExpression e) { } } - @Override - public Expression visit(VennExpression e) { + @Override public Expression visit(VennExpression e) { // stop visiting subtree. We assume all unions were at the root // and flattened, here we find one that couldn't be flattened return e; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExprTransformations.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExprTransformations.java index 27906974f39..b9428e1c791 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExprTransformations.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExprTransformations.java @@ -28,8 +28,7 @@ private SaxonExprTransformations() { private static final SaxonExprVisitor FILTER_HOISTER = new SaxonExprVisitor() { - @Override - public Expression visit(SlashExpression e) { + @Override public Expression visit(SlashExpression e) { Expression left = super.visit(e.getLhsExpression()); Expression right = super.visit(e.getRhsExpression()); if (right instanceof FilterExpression) { @@ -43,21 +42,20 @@ public Expression visit(SlashExpression e) { private static final SaxonExprVisitor ROOT_REDUCER = new SaxonExprVisitor() { - @Override - public Expression visit(SlashExpression e) { + @Override public Expression visit(SlashExpression e) { Expression left = super.visit(e.getLhsExpression()); Expression right = super.visit(e.getRhsExpression()); if (right instanceof AxisExpression - && ((AxisExpression) right).getAxis() == AxisInfo.CHILD - && left instanceof SlashExpression) { + && ((AxisExpression) right).getAxis() == AxisInfo.CHILD + && left instanceof SlashExpression) { Expression leftLeft = ((SlashExpression) left).getLhsExpression(); Expression leftRight = ((SlashExpression) left).getRhsExpression(); if (leftLeft instanceof RootExpression && leftRight instanceof AxisExpression) { if (((AxisExpression) leftRight).getAxis() == AxisInfo.DESCENDANT_OR_SELF - && isAnyNode(((AxisExpression) leftRight).getNodeTest())) { + && isAnyNode(((AxisExpression) leftRight).getNodeTest())) { // ok! left = leftLeft; // the root expression right = new AxisExpression(AxisInfo.DESCENDANT, ((AxisExpression) right).getNodeTest()); @@ -131,16 +129,15 @@ static Expression copyTopLevelLets(Expression subexpr, Expression original) { return subexpr; } } - + final SaxonExprVisitor topLevelLetCopier = new SaxonExprVisitor() { - - @Override - public Expression visit(LetExpression e) { + + @Override public Expression visit(LetExpression e) { // keep copying if (e.getAction() instanceof LetExpression) { return super.visit(e); } - + // Manually craft the inner-most LetExpression Expression sequence = visit(e.getSequence()); LetExpression result = new LetExpression(); @@ -152,11 +149,11 @@ public Expression visit(LetExpression e) { return result; } }; - + if (original instanceof LetExpression) { return topLevelLetCopier.visit(original); } - + return subexpr; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExprVisitor.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExprVisitor.java index 8a55cd1309a..1ec091e74e1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExprVisitor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExprVisitor.java @@ -78,7 +78,7 @@ public Expression visit(BooleanExpression e) { Expression operand1 = visit(e.getRhsExpression()); return e instanceof AndExpression ? new AndExpression(operand0, operand1) - : new OrExpression(operand0, operand1); + : new OrExpression(operand0, operand1); } public Expression visit(Expression expr) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExtensionFunctionDefinitionAdapter.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExtensionFunctionDefinitionAdapter.java index 85926ad7e6b..774890a5954 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExtensionFunctionDefinitionAdapter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonExtensionFunctionDefinitionAdapter.java @@ -46,15 +46,15 @@ public SaxonExtensionFunctionDefinitionAdapter(XPathFunctionDefinition definitio private SequenceType convertToSequenceType(XPathFunctionDefinition.Type type) { switch (type) { - case SINGLE_STRING: return SequenceType.SINGLE_STRING; - case SINGLE_BOOLEAN: return SequenceType.SINGLE_BOOLEAN; - case SINGLE_ELEMENT: return SINGLE_ELEMENT_SEQUENCE_TYPE; - case SINGLE_INTEGER: return SequenceType.SINGLE_INTEGER; - case STRING_SEQUENCE: return SequenceType.STRING_SEQUENCE; - case OPTIONAL_STRING: return SequenceType.OPTIONAL_STRING; - case OPTIONAL_DECIMAL: return SequenceType.OPTIONAL_DECIMAL; - default: - throw new UnsupportedOperationException("Type " + type + " is not supported"); + case SINGLE_STRING: return SequenceType.SINGLE_STRING; + case SINGLE_BOOLEAN: return SequenceType.SINGLE_BOOLEAN; + case SINGLE_ELEMENT: return SINGLE_ELEMENT_SEQUENCE_TYPE; + case SINGLE_INTEGER: return SequenceType.SINGLE_INTEGER; + case STRING_SEQUENCE: return SequenceType.STRING_SEQUENCE; + case OPTIONAL_STRING: return SequenceType.OPTIONAL_STRING; + case OPTIONAL_DECIMAL: return SequenceType.OPTIONAL_DECIMAL; + default: + throw new UnsupportedOperationException("Type " + type + " is not supported"); } } @@ -66,33 +66,27 @@ private SequenceType[] convertToSequenceTypes(XPathFunctionDefinition.Type[] typ return result; } - @Override - public StructuredQName getFunctionQName() { + @Override public StructuredQName getFunctionQName() { QName qName = definition.getQName(); return new StructuredQName(qName.getPrefix(), qName.getNamespaceURI(), qName.getLocalPart()); } - @Override - public SequenceType[] getArgumentTypes() { + @Override public SequenceType[] getArgumentTypes() { return convertToSequenceTypes(definition.getArgumentTypes()); } - @Override - public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { + @Override public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) { return convertToSequenceType(definition.getResultType()); } - @Override - public boolean dependsOnFocus() { + @Override public boolean dependsOnFocus() { return definition.dependsOnContext(); } - @Override - public ExtensionFunctionCall makeCallExpression() { + @Override public ExtensionFunctionCall makeCallExpression() { XPathFunctionDefinition.FunctionCall call = definition.makeCallExpression(); return new ExtensionFunctionCall() { - @Override - public Expression rewrite(StaticContext context, Expression[] arguments) throws XPathException { + @Override public Expression rewrite(StaticContext context, Expression[] arguments) throws XPathException { Object[] convertedArguments = new Object[definition.getArgumentTypes().length]; for (int i = 0; i < convertedArguments.length; i++) { if (arguments[i] instanceof StringLiteral) { @@ -109,8 +103,7 @@ public Expression rewrite(StaticContext context, Expression[] arguments) throws return null; } - @Override - public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { + @Override public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException { Node contextNode = null; if (definition.dependsOnContext()) { contextNode = XPathElementToNodeHelper.itemToNode(context.getContextItem()); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java index 616f6f12697..94088088be6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQuery.java @@ -83,10 +83,10 @@ public class SaxonXPathRuleQuery { public SaxonXPathRuleQuery(String xpathExpr, - XPathVersion version, - Map, Object> properties, - XPathHandler xPathHandler, - DeprecatedAttrLogger logger) throws PmdXPathException { + XPathVersion version, + Map, Object> properties, + XPathHandler xPathHandler, + DeprecatedAttrLogger logger) throws PmdXPathException { this.xpathExpr = xpathExpr; this.version = version; this.properties = properties; @@ -122,8 +122,7 @@ public List evaluate(final Node node) { final Set results = new LinkedHashSet<>(); List expressions = getExpressionsForLocalNameOrDefault(node.getXPathNodeName()); for (Expression expression : expressions) { - @SuppressWarnings("PMD.CloseResource") - SequenceIterator iterator = expression.iterate(xpathDynamicContext.getXPathContextObject()); + @SuppressWarnings("PMD.CloseResource") SequenceIterator iterator = expression.iterate(xpathDynamicContext.getXPathContextObject()); Item current = iterator.next(); while (current != null) { if (current instanceof AstNodeOwner) { @@ -224,7 +223,7 @@ private void analyzeXPathForRuleChain(final XPathEvaluator xpathEvaluator) { Iterable subexpressions = SaxonExprTransformations.splitUnions(expr); // Second step: Analyze each expression separately - for (final Expression subexpression : subexpressions) { // final because of checkstyle + for (Expression subexpression : subexpressions) { Expression modified = subexpression; modified = SaxonExprTransformations.hoistFilters(modified); modified = SaxonExprTransformations.reduceRoot(modified); @@ -272,8 +271,7 @@ public void declareProperty(PropertyDescriptor prop) { propertiesByName.put(var.getVariableQName(), prop); } - @Override - public Expression bindVariable(StructuredQName qName) throws XPathException { + @Override public Expression bindVariable(StructuredQName qName) throws XPathException { LocalVariableReference local = (LocalVariableReference) super.bindVariable(qName); PropertyDescriptor prop = propertiesByName.get(qName); if (prop == null || prop.defaultValue() == null) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SplitUnions.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SplitUnions.java index 592049b3f54..75a2cf78ba3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SplitUnions.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/internal/SplitUnions.java @@ -25,8 +25,7 @@ class SplitUnions extends SaxonExprVisitor { private final List expressions = new ArrayList<>(); - @Override - public Expression visit(VennExpression e) { + @Override public Expression visit(VennExpression e) { if (e.getOperator() == Token.UNION) { for (Expression operand : listOf(e.getLhsExpression(), e.getRhsExpression())) { if (operand instanceof VennExpression) { @@ -39,8 +38,7 @@ public Expression visit(VennExpression e) { return e; } - @Override - public Expression visit(Expression e) { + @Override public Expression visit(Expression e) { // only flatten top level unions - skip sorters and let around it if (e instanceof VennExpression || e instanceof DocumentSorter || e instanceof LetExpression) { return super.visit(e); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/AbstractNameDeclaration.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/AbstractNameDeclaration.java index be0b8c566ff..7e3722f4cc7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/AbstractNameDeclaration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/AbstractNameDeclaration.java @@ -15,23 +15,19 @@ public AbstractNameDeclaration(ScopedNode node) { this.node = node; } - @Override - public ScopedNode getNode() { + @Override public ScopedNode getNode() { return node; } - @Override - public String getImage() { + @Override public String getImage() { return node.getImage(); } - @Override - public Scope getScope() { + @Override public Scope getScope() { return node.getScope(); } - @Override - public String getName() { + @Override public String getName() { return getImage(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/AbstractScope.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/AbstractScope.java index d5433344897..c8eec5917ae 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/AbstractScope.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/AbstractScope.java @@ -21,18 +21,15 @@ public abstract class AbstractScope implements Scope { /** Stores the name declaration already sorted by class. */ private Map, Map>> nameDeclarations = new LinkedHashMap<>(); - @Override - public Scope getParent() { + @Override public Scope getParent() { return parent; } - @Override - public void setParent(Scope parent) { + @Override public void setParent(Scope parent) { this.parent = parent; } - @Override - public Map> getDeclarations() { + @Override public Map> getDeclarations() { Map> result = new LinkedHashMap<>(); for (Map> e : nameDeclarations.values()) { result.putAll(e); @@ -40,18 +37,15 @@ public Map> getDeclarations() { return result; } - @Override - public Map> getDeclarations(Class clazz) { - @SuppressWarnings("unchecked") - Map> result = (Map>) nameDeclarations.get(clazz); + @Override public Map> getDeclarations(Class clazz) { + @SuppressWarnings("unchecked") Map> result = (Map>) nameDeclarations.get(clazz); if (result == null) { result = Collections.emptyMap(); } return result; } - @Override - public boolean contains(NameOccurrence occ) { + @Override public boolean contains(NameOccurrence occ) { for (NameDeclaration d : getDeclarations().keySet()) { if (d.getImage().equals(occ.getImage())) { return true; @@ -60,8 +54,7 @@ public boolean contains(NameOccurrence occ) { return false; } - @Override - public void addDeclaration(NameDeclaration declaration) { + @Override public void addDeclaration(NameDeclaration declaration) { Map> declarationsPerClass = nameDeclarations.get(declaration.getClass()); if (declarationsPerClass == null) { declarationsPerClass = new LinkedHashMap<>(); @@ -70,9 +63,7 @@ public void addDeclaration(NameDeclaration declaration) { declarationsPerClass.put(declaration, new ArrayList<>()); } - @SuppressWarnings("unchecked") - @Override - public T getEnclosingScope(Class clazz) { + @SuppressWarnings("unchecked") @Override public T getEnclosingScope(Class clazz) { Scope current = this; while (current != null) { if (clazz.isAssignableFrom(current.getClass())) { @@ -83,8 +74,7 @@ public T getEnclosingScope(Class clazz) { return null; } - @Override - public Set addNameOccurrence(NameOccurrence occurrence) { + @Override public Set addNameOccurrence(NameOccurrence occurrence) { Set result = new HashSet<>(); for (Map.Entry> e : getDeclarations().entrySet()) { if (e.getKey().getImage().equals(occurrence.getImage())) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/ImageFinderFunction.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/ImageFinderFunction.java index 5b8dcfd9449..a149a0e7ab0 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/ImageFinderFunction.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/symboltable/ImageFinderFunction.java @@ -23,8 +23,7 @@ public ImageFinderFunction(List imageList) { images = new HashSet<>(imageList); } - @Override - public boolean test(NameDeclaration nameDeclaration) { + @Override public boolean test(NameDeclaration nameDeclaration) { if (images.contains(nameDeclaration.getImage())) { decl = nameDeclaration; return false; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractPropertySource.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractPropertySource.java index 5b4939b29f3..50be499e736 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractPropertySource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractPropertySource.java @@ -37,12 +37,11 @@ public abstract class AbstractPropertySource implements PropertySource { private final Map, Object> propertyValuesByDescriptor = new HashMap<>(); - @Override - public void definePropertyDescriptor(PropertyDescriptor propertyDescriptor) { + @Override public void definePropertyDescriptor(PropertyDescriptor propertyDescriptor) { // Check to ensure the property does not already exist. if (getPropertyDescriptor(propertyDescriptor.name()) != null) { throw new IllegalArgumentException("There is already a PropertyDescriptor with name '" - + propertyDescriptor.name() + "' defined on " + getPropertySourceType() + " " + getName() + "."); + + propertyDescriptor.name() + "' defined on " + getPropertySourceType() + " " + getName() + "."); } propertyDescriptors.add(propertyDescriptor); @@ -51,8 +50,7 @@ public void definePropertyDescriptor(PropertyDescriptor propertyDescriptor) { protected abstract String getPropertySourceType(); - @Override - public PropertyDescriptor getPropertyDescriptor(String name) { + @Override public PropertyDescriptor getPropertyDescriptor(String name) { for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { if (name.equals(propertyDescriptor.name())) { return propertyDescriptor; @@ -62,45 +60,38 @@ public PropertyDescriptor getPropertyDescriptor(String name) { } - @Override - public boolean hasDescriptor(PropertyDescriptor descriptor) { + @Override public boolean hasDescriptor(PropertyDescriptor descriptor) { return propertyDescriptors.contains(descriptor); } - @Override - public final List> getOverriddenPropertyDescriptors() { + @Override public final List> getOverriddenPropertyDescriptors() { return new ArrayList<>(propertyValuesByDescriptor.keySet()); } - @Override - public List> getPropertyDescriptors() { + @Override public List> getPropertyDescriptors() { return Collections.unmodifiableList(propertyDescriptors); } - @Override - public T getProperty(PropertyDescriptor propertyDescriptor) { + @Override public T getProperty(PropertyDescriptor propertyDescriptor) { checkValidPropertyDescriptor(propertyDescriptor); T result = propertyDescriptor.defaultValue(); if (propertyValuesByDescriptor.containsKey(propertyDescriptor)) { - @SuppressWarnings("unchecked") - T value = (T) propertyValuesByDescriptor.get(propertyDescriptor); + @SuppressWarnings("unchecked") T value = (T) propertyValuesByDescriptor.get(propertyDescriptor); result = value; } return result; } - @Override - public boolean isPropertyOverridden(PropertyDescriptor propertyDescriptor) { + @Override public boolean isPropertyOverridden(PropertyDescriptor propertyDescriptor) { return propertyValuesByDescriptor.containsKey(propertyDescriptor); } - @Override - public void setProperty(PropertyDescriptor propertyDescriptor, T value) { + @Override public void setProperty(PropertyDescriptor propertyDescriptor, T value) { checkValidPropertyDescriptor(propertyDescriptor); if (value instanceof List) { propertyValuesByDescriptor.put(propertyDescriptor, Collections.unmodifiableList((List) value)); @@ -122,14 +113,12 @@ private void checkValidPropertyDescriptor(PropertyDescriptor propertyDescript } - @Override - public final Map, Object> getOverriddenPropertiesByPropertyDescriptor() { + @Override public final Map, Object> getOverriddenPropertiesByPropertyDescriptor() { return new HashMap<>(propertyValuesByDescriptor); } - @Override - public Map, Object> getPropertiesByPropertyDescriptor() { + @Override public Map, Object> getPropertiesByPropertyDescriptor() { if (propertyDescriptors.isEmpty()) { return Collections.emptyMap(); } @@ -149,8 +138,7 @@ public Map, Object> getPropertiesByPropertyDescriptor() { } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } @@ -168,22 +156,19 @@ public boolean equals(Object o) { Map propertiesWithValues = new HashMap<>(); propertyDescriptors.forEach(propertyDescriptor -> { Object value = propertyValuesByDescriptor.getOrDefault(propertyDescriptor, propertyDescriptor.defaultValue()); - @SuppressWarnings({"unchecked", "rawtypes"}) - String valueString = ((PropertyDescriptor) propertyDescriptor).serializer().toString(value); + @SuppressWarnings({"unchecked", "rawtypes"}) String valueString = ((PropertyDescriptor) propertyDescriptor).serializer().toString(value); propertiesWithValues.put(propertyDescriptor.name(), valueString); }); Map thatPropertiesWithValues = new HashMap<>(); that.propertyDescriptors.forEach(propertyDescriptor -> { Object value = that.propertyValuesByDescriptor.getOrDefault(propertyDescriptor, propertyDescriptor.defaultValue()); - @SuppressWarnings({"unchecked", "rawtypes"}) - String valueString = ((PropertyDescriptor) propertyDescriptor).serializer().toString(value); + @SuppressWarnings({"unchecked", "rawtypes"}) String valueString = ((PropertyDescriptor) propertyDescriptor).serializer().toString(value); thatPropertiesWithValues.put(propertyDescriptor.name(), valueString); }); return Objects.equals(propertiesWithValues, thatPropertiesWithValues); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(propertyDescriptors, propertyValuesByDescriptor); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/ConstraintDecorator.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/ConstraintDecorator.java index 802c20ef612..390f3d0a49d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/ConstraintDecorator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/ConstraintDecorator.java @@ -27,34 +27,29 @@ class ConstraintDecorator extends PropertySerializer { this.constraints = constraints; } - @Override - public List> getConstraints() { + @Override public List> getConstraints() { return constraints; } - @Override - public PropertySerializer withConstraint(PropertyConstraint t) { + @Override public PropertySerializer withConstraint(PropertyConstraint t) { return new ConstraintDecorator<>(this.propertySerializer, CollectionUtil.plus(this.constraints, t)); } - @Override - public T fromString(@NonNull String attributeData) { + @Override public T fromString(@NonNull String attributeData) { T t = propertySerializer.fromString(attributeData); // perform constraint validation PropertyParsingUtil.checkConstraintsThrow(t, constraints); return t; } - @Override - public @NonNull String toString(T value) { + @Override public @NonNull String toString(T value) { return propertySerializer.toString(value); } - @Override - public String toString() { + @Override public String toString() { return "ConstraintDecorator{" - + "propertySerializer=" + propertySerializer - + ", constraints=" + constraints - + '}'; + + "propertySerializer=" + propertySerializer + + ", constraints=" + constraints + + '}'; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/InternalApiBridge.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/InternalApiBridge.java index b9647e6554f..aa8659f6dbe 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/InternalApiBridge.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/InternalApiBridge.java @@ -22,7 +22,8 @@ */ @InternalApi public final class InternalApiBridge { - private InternalApiBridge() {} + private InternalApiBridge() { + } public static > B withTypeId(PropertyBuilder builder, PropertyTypeId typeId) { return builder.typeId(typeId); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericConstraints.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericConstraints.java index acbe594138a..21fda2cd76d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericConstraints.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericConstraints.java @@ -34,8 +34,8 @@ private NumericConstraints() { */ public static > PropertyConstraint inRange(final N minInclusive, final N maxInclusive) { return PropertyConstraint.fromPredicate( - t -> minInclusive.compareTo(t) <= 0 && maxInclusive.compareTo(t) >= 0, - "Should be between " + minInclusive + " and " + maxInclusive, + t -> minInclusive.compareTo(t) <= 0 && maxInclusive.compareTo(t) >= 0, + "Should be between " + minInclusive + " and " + maxInclusive, mapOf(SchemaConstants.PROPERTY_MIN.xmlName(), String.valueOf(minInclusive), SchemaConstants.PROPERTY_MAX.xmlName(), String.valueOf(maxInclusive)) ); @@ -51,8 +51,8 @@ public static > PropertyConstraint inRange(final N mi */ public static > PropertyConstraint above(final N minInclusive) { return PropertyConstraint.fromPredicate( - t -> minInclusive.compareTo(t) <= 0, - "Should be greater or equal to " + minInclusive, + t -> minInclusive.compareTo(t) <= 0, + "Should be greater or equal to " + minInclusive, mapOf(SchemaConstants.PROPERTY_MIN.xmlName(), String.valueOf(minInclusive)) ); } @@ -66,8 +66,8 @@ public static > PropertyConstraint above(final N minI */ public static > PropertyConstraint below(final N maxInclusive) { return PropertyConstraint.fromPredicate( - t -> maxInclusive.compareTo(t) >= 0, - "Should be smaller or equal to " + maxInclusive, + t -> maxInclusive.compareTo(t) >= 0, + "Should be smaller or equal to " + maxInclusive, mapOf(SchemaConstants.PROPERTY_MAX.xmlName(), String.valueOf(maxInclusive)) ); } @@ -87,7 +87,7 @@ public static > PropertyConstraint below(final N maxI */ public static PropertyConstraint positive() { return PropertyConstraint.fromPredicate( - t -> t.intValue() > 0, + t -> t.intValue() > 0, "Should be positive" ); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyBuilder.java index b1b1b748e27..b853133e35d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyBuilder.java @@ -114,8 +114,7 @@ boolean isDefaultValueSet() { * * @throws IllegalArgumentException If the description is null or whitespace */ - @SuppressWarnings("unchecked") - public B desc(String desc) { + @SuppressWarnings("unchecked") public B desc(String desc) { if (StringUtils.isBlank(desc)) { throw new IllegalArgumentException("Description must be provided"); } @@ -123,8 +122,7 @@ public B desc(String desc) { return (B) this; } - @SuppressWarnings("unchecked") - B typeId(PropertyTypeId typeId) { + @SuppressWarnings("unchecked") B typeId(PropertyTypeId typeId) { this.typeId = typeId; return (B) this; } @@ -159,8 +157,7 @@ public B availableInXPath(boolean b) { * * @see NumericConstraints */ - @SuppressWarnings("unchecked") - public abstract B require(PropertyConstraint constraint); + @SuppressWarnings("unchecked") public abstract B require(PropertyConstraint constraint); /** @@ -176,8 +173,7 @@ public B availableInXPath(boolean b) { * * @throws IllegalArgumentException If the argument is null */ - @SuppressWarnings("unchecked") - public B defaultValue(@NonNull T val) { + @SuppressWarnings("unchecked") public B defaultValue(@NonNull T val) { //noinspection ConstantConditions if (val == null) { throw new IllegalArgumentException("Property values may not be null."); @@ -228,9 +224,7 @@ protected PropertySerializer getParser() { return parser; } - @SuppressWarnings("unchecked") - @Override - public B require(PropertyConstraint constraint) { + @SuppressWarnings("unchecked") @Override public B require(PropertyConstraint constraint) { parser = parser.withConstraint(constraint); return (B) this; } @@ -303,9 +297,9 @@ public GenericPropertyBuilder> toOptional(String missingValue) { AssertionUtil.requireParamNotNull("missingValue", missingValue); PropertySerializer> serializer = - PropertyParsingUtil.toOptional(getParser(), missingValue); + PropertyParsingUtil.toOptional(getParser(), missingValue); GenericPropertyBuilder> result = - new GenericPropertyBuilder<>(this.getName(), serializer); + new GenericPropertyBuilder<>(this.getName(), serializer); if (isDefaultValueSet()) { result.defaultValue(Optional.of(getDefaultValue())); @@ -319,15 +313,14 @@ public GenericPropertyBuilder> toOptional(String missingValue) { } - @Override - public PropertyDescriptor build() { + @Override public PropertyDescriptor build() { return new PropertyDescriptor<>( - getName(), - getDescription(), - getDefaultValue(), - parser, - typeId, - isXPathAvailable); + getName(), + getDescription(), + getDefaultValue(), + parser, + typeId, + isXPathAvailable); } } @@ -424,8 +417,8 @@ public static final class GenericCollectionPropertyBuilder itemParser, - Collector collector) { + PropertySerializer itemParser, + Collector collector) { super(name); this.itemParser = itemParser; this.collector = collector; @@ -436,8 +429,7 @@ private C getDefaultValue(Iterable list) { return IteratorUtil.toStream(list).collect(collector); } - @Override - public GenericCollectionPropertyBuilder require(PropertyConstraint constraint) { + @Override public GenericCollectionPropertyBuilder require(PropertyConstraint constraint) { collectionConstraints.add(constraint); return this; } @@ -465,8 +457,7 @@ public GenericCollectionPropertyBuilder defaultValue(Iterable * * @return The same builder */ - @SuppressWarnings("unchecked") - public GenericCollectionPropertyBuilder defaultValues(V head, V... tail) { + @SuppressWarnings("unchecked") public GenericCollectionPropertyBuilder defaultValues(V head, V... tail) { return this.defaultValue(listOf(head, tail)); } @@ -495,19 +486,18 @@ public GenericCollectionPropertyBuilder requireEach(PropertyConstraint build() { + @Override public PropertyDescriptor build() { PropertySerializer syntax = PropertyParsingUtil.delimitedString(itemParser, collector); syntax = PropertyParsingUtil.withAllConstraints(syntax, CollectionUtil.map(itemParser.getConstraints(), PropertyConstraint::toCollectionConstraint)); syntax = PropertyParsingUtil.withAllConstraints(syntax, collectionConstraints); return new PropertyDescriptor<>( - getName(), - getDescription(), - getDefaultValue(), - syntax, - typeId, - isXPathAvailable); + getName(), + getDescription(), + getDefaultValue(), + syntax, + typeId, + isXPathAvailable); } } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyConstraint.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyConstraint.java index 37d9556b859..5717ad5583a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyConstraint.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyConstraint.java @@ -69,13 +69,11 @@ default Map getXmlConstraint() { */ default PropertyConstraint> toOptionalConstraint() { return new PropertyConstraint>() { - @Override - public void validate(Optional value) { + @Override public void validate(Optional value) { value.ifPresent(PropertyConstraint.this::validate); } - @Override - public String getConstraintDescription() { + @Override public String getConstraintDescription() { return PropertyConstraint.this.getConstraintDescription(); } }; @@ -90,15 +88,13 @@ public String getConstraintDescription() { */ default PropertyConstraint> toCollectionConstraint() { return new PropertyConstraint>() { - @Override - public void validate(Iterable value) { + @Override public void validate(Iterable value) { for (T t : value) { PropertyConstraint.this.validate(t); } } - @Override - public String getConstraintDescription() { + @Override public String getConstraintDescription() { return "Components " + StringUtils.uncapitalize(PropertyConstraint.this.getConstraintDescription()); } }; @@ -129,28 +125,24 @@ static PropertyConstraint fromPredicate(final Predicate pred, * @see #fromPredicate(Predicate, String) */ static PropertyConstraint fromPredicate(final Predicate pred, final String constraintDescription, - final Map xmlConstraint) { + final Map xmlConstraint) { return new PropertyConstraint() { - @Override - public void validate(U value) { + @Override public void validate(U value) { if (!pred.test(value)) { throw new ConstraintViolatedException(this, value); } } - @Override - public String getConstraintDescription() { + @Override public String getConstraintDescription() { return StringUtils.capitalize(constraintDescription); } - @Override - public String toString() { + @Override public String toString() { return "PropertyConstraint(" + constraintDescription + ")"; } - @Override - public Map getXmlConstraint() { + @Override public Map getXmlConstraint() { return xmlConstraint; } }; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java index e640284f727..cc5decfc3c3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java @@ -40,11 +40,11 @@ public final class PropertyDescriptor { private final boolean isXPathAvailable; PropertyDescriptor(String name, - String description, - T defaultValue, - PropertySerializer parser, - @Nullable PropertyTypeId typeId, - boolean isXPathAvailable) { + String description, + T defaultValue, + PropertySerializer parser, + @Nullable PropertyTypeId typeId, + boolean isXPathAvailable) { this.name = name; this.description = description; @@ -54,8 +54,8 @@ public final class PropertyDescriptor { this.isXPathAvailable = isXPathAvailable; PropertyParsingUtil.checkConstraintsThrow( - defaultValue, - parser.getConstraints() + defaultValue, + parser.getConstraints() ); } @@ -120,19 +120,17 @@ public boolean isXPathAvailable() { } - @Override - public String toString() { + @Override public String toString() { return "PropertyDescriptor{ " - + "name='" + name + '\'' - + ", parser=" + parser - + ", typeId=" + typeId - + ", description='" + description + '\'' - + ", defaultValue=" + defaultValue + '}'; + + "name='" + name + '\'' + + ", parser=" + parser + + ", typeId=" + typeId + + ", description='" + description + '\'' + + ", defaultValue=" + defaultValue + '}'; } // TODO these equality routines needs to go away, should be implemented in Rule::equals - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } @@ -141,11 +139,10 @@ public boolean equals(Object o) { } PropertyDescriptor that = (PropertyDescriptor) o; return name.equals(that.name) - && description.equals(that.description); + && description.equals(that.description); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(name, description); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyFactory.java index d7466254f68..a12753d3368 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyFactory.java @@ -309,8 +309,8 @@ public static GenericPropertyBuilder booleanProperty(String name) { */ public static GenericPropertyBuilder enumProperty(String name, Map nameToValue) { PropertySerializer parser = enumerationParser( - nameToValue, - t -> Objects.requireNonNull(CollectionUtil.getKeyOfValue(nameToValue, t)) + nameToValue, + t -> Objects.requireNonNull(CollectionUtil.getKeyOfValue(nameToValue, t)) ); return new GenericPropertyBuilder<>(name, parser); } @@ -346,12 +346,12 @@ public static > GenericPropertyBuilder enumProperty(String * @throws IllegalStateException If the label maker maps two constants to the same label */ public static > GenericPropertyBuilder enumProperty(String name, - Class enumClass, - Function labelMaker) { + Class enumClass, + Function labelMaker) { // don't use a merge function, so that it throws if multiple // values have the same key Map labelsToValues = Arrays.stream(enumClass.getEnumConstants()) - .collect(Collectors.toMap(labelMaker, t -> t)); + .collect(Collectors.toMap(labelMaker, t -> t)); return new GenericPropertyBuilder<>(name, enumerationParser(labelsToValues, labelMaker)); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/PropertyParsingUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/PropertyParsingUtil.java index 7966886f59a..63ac1fc05c5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/PropertyParsingUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/PropertyParsingUtil.java @@ -29,13 +29,13 @@ public final class PropertyParsingUtil { public static final ValueSyntax STRING = ValueSyntax.withDefaultToString(String::trim); public static final ValueSyntax CHARACTER = - ValueSyntax.partialFunction( - c -> Character.toString(c), - s -> s.charAt(0), - PropertyConstraint.fromPredicate( - s -> s.length() == 1, - "Should be exactly one character in length" - )); + ValueSyntax.partialFunction( + c -> Character.toString(c), + s -> s.charAt(0), + PropertyConstraint.fromPredicate( + s -> s.length() == 1, + "Should be exactly one character in length" + )); public static final ValueSyntax REGEX = ValueSyntax.withDefaultToString(Pattern::compile); public static final ValueSyntax INTEGER = ValueSyntax.withDefaultToString(preTrim(Integer::valueOf)); @@ -70,13 +70,13 @@ private static PropertySerializer> otherList(ValueSyntax valueSyn public static PropertySerializer> toOptional(PropertySerializer itemSyntax, String missingValue) { return ValueSyntax.create( - opt -> opt.map(itemSyntax::toString).orElse(missingValue), - str -> { - if (str.equals(missingValue)) { - return Optional.empty(); + opt -> opt.map(itemSyntax::toString).orElse(missingValue), + str -> { + if (str.equals(missingValue)) { + return Optional.empty(); + } + return Optional.of(itemSyntax.fromString(str)); } - return Optional.of(itemSyntax.fromString(str)); - } ); } @@ -124,11 +124,11 @@ public static PropertySerializer withAllConstraints(PropertySerializer * @throws IllegalArgumentException If the item syntax doesn't support string mapping */ public static > PropertySerializer delimitedString(PropertySerializer itemSyntax, - Collector collector) { + Collector collector) { String delim = "" + PropertyFactory.DEFAULT_DELIMITER; return ValueSyntax.create( - coll -> IteratorUtil.toStream(coll.iterator()).map(itemSyntax::toString).collect(Collectors.joining(delim)), - string -> parseListWithEscapes(string, PropertyFactory.DEFAULT_DELIMITER, itemSyntax::fromString).stream().collect(collector) + coll -> IteratorUtil.toStream(coll.iterator()).map(itemSyntax::toString).collect(Collectors.joining(delim)), + string -> parseListWithEscapes(string, PropertyFactory.DEFAULT_DELIMITER, itemSyntax::fromString).stream().collect(collector) ); } @@ -190,12 +190,12 @@ public static ValueSyntax enumerationParser(final Map mappings } return ValueSyntax.partialFunction( - reverseFun, - mappings::get, - PropertyConstraint.fromPredicate( - mappings::containsKey, - "Should be " + XmlUtil.formatPossibleNames(XmlUtil.toConstants(mappings.keySet())) - ) + reverseFun, + mappings::get, + PropertyConstraint.fromPredicate( + mappings::containsKey, + "Should be " + XmlUtil.formatPossibleNames(XmlUtil.toConstants(mappings.keySet())) + ) ); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/PropertyTypeId.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/PropertyTypeId.java index 0b6f6f21849..e95172eb6e4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/PropertyTypeId.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/PropertyTypeId.java @@ -92,16 +92,13 @@ public interface BuilderAndMapper { * Returns the object used to create new properties with the type * of this constant. */ - @SuppressWarnings("rawtypes") - public BuilderAndMapper getBuilderUtils() { + @SuppressWarnings("rawtypes") public BuilderAndMapper getBuilderUtils() { return new BuilderAndMapper() { - @Override - public PropertySerializer getXmlMapper() { + @Override public PropertySerializer getXmlMapper() { return propertySerializer; } - @Override - public PropertyBuilder newBuilder(String name) { + @Override public PropertyBuilder newBuilder(String name) { PropertyBuilder builder = factory.apply(name); builder = InternalApiBridge.withTypeId(builder, PropertyTypeId.this); return builder.availableInXPath(true); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/ValueSyntax.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/ValueSyntax.java index 61f37251dd7..a0d55905ed5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/ValueSyntax.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/internal/ValueSyntax.java @@ -38,25 +38,22 @@ class ValueSyntax extends InternalApiBridge.InternalPropertySerializer { private final List> docConstraints; ValueSyntax(Function toString, - Function<@NonNull String, ? extends T> fromString, - List> docConstraints) { + Function<@NonNull String, ? extends T> fromString, + List> docConstraints) { this.toString = toString; this.fromString = fromString; this.docConstraints = docConstraints; } - @Override - public List> getConstraints() { + @Override public List> getConstraints() { return docConstraints; } - @Override - public T fromString(@NonNull String attributeData) { + @Override public T fromString(@NonNull String attributeData) { return fromString.apply(attributeData); } - @Override - public @NonNull String toString(T data) { + @Override public @NonNull String toString(T data) { return toString.apply(data); } @@ -67,20 +64,20 @@ public T fromString(@NonNull String attributeData) { * is documented as a constraint on the returned XML mapper. */ static ValueSyntax partialFunction(Function toString, - Function<@NonNull String, ? extends T> fromString, - PropertyConstraint checker) { + Function<@NonNull String, ? extends T> fromString, + PropertyConstraint checker) { PropertyConstraint docConstraint = PropertyConstraint.fromPredicate( - PredicateUtil.always(), - checker.getConstraintDescription() + PredicateUtil.always(), + checker.getConstraintDescription() ); return new ValueSyntax<>( - toString, - s -> { - checker.validate(s); - return fromString.apply(s); - }, - listOf(docConstraint) + toString, + s -> { + checker.validate(s); + return fromString.apply(s); + }, + listOf(docConstraint) ); } @@ -89,7 +86,7 @@ static ValueSyntax withDefaultToString(Function from } static ValueSyntax create(Function toString, - Function fromString) { + Function fromString) { return new ValueSyntax<>(toString, fromString, Collections.emptyList()); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.java index 9e66aa84773..cda10184c0a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractAccumulatingRenderer.java @@ -36,18 +36,15 @@ public AbstractAccumulatingRenderer(String name, String description) { super(name, description); } - @Override - public void start() throws IOException { + @Override public void start() throws IOException { // do nothing } - @Override - public void end() throws IOException { + @Override public void end() throws IOException { // do nothing } - @Override - public void startFileAnalysis(TextFile dataSource) { + @Override public void startFileAnalysis(TextFile dataSource) { Objects.requireNonNull(dataSource); } @@ -59,8 +56,7 @@ public void startFileAnalysis(TextFile dataSource) { * end. Subclasses of {@link AbstractAccumulatingRenderer} cannot override this method * anymore. */ - @Override - public final void renderFileReport(Report report) throws IOException { + @Override public final void renderFileReport(Report report) throws IOException { // do nothing, final because it will never be called by the listener Objects.requireNonNull(report); } @@ -73,8 +69,7 @@ public final void renderFileReport(Report report) throws IOException { protected abstract void outputReport(Report report) throws IOException; - @Override - public GlobalAnalysisListener newListener() throws IOException { + @Override public GlobalAnalysisListener newListener() throws IOException { try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.REPORTING)) { this.start(); } @@ -82,19 +77,16 @@ public GlobalAnalysisListener newListener() throws IOException { return new GlobalAnalysisListener() { final GlobalReportBuilderListener reportBuilder = new GlobalReportBuilderListener(); - @Override - public FileAnalysisListener startFileAnalysis(TextFile file) { + @Override public FileAnalysisListener startFileAnalysis(TextFile file) { AbstractAccumulatingRenderer.this.startFileAnalysis(file); return reportBuilder.startFileAnalysis(file); } - @Override - public void onConfigError(ConfigurationError error) { + @Override public void onConfigError(ConfigurationError error) { reportBuilder.onConfigError(error); } - @Override - public void close() throws Exception { + @Override public void close() throws Exception { reportBuilder.close(); try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.REPORTING)) { outputReport(reportBuilder.getResult()); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractIncrementingRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractIncrementingRenderer.java index f17c5cfd426..82b398b5af9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractIncrementingRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractIncrementingRenderer.java @@ -45,18 +45,15 @@ public AbstractIncrementingRenderer(String name, String description) { super(name, description); } - @Override - public void start() throws IOException { + @Override public void start() throws IOException { // does nothing - override if necessary } - @Override - public void startFileAnalysis(TextFile dataSource) { + @Override public void startFileAnalysis(TextFile dataSource) { // does nothing - override if necessary } - @Override - public void renderFileReport(Report report) throws IOException { + @Override public void renderFileReport(Report report) throws IOException { Iterator violations = report.getViolations().iterator(); if (violations.hasNext()) { renderFileViolations(violations); @@ -81,8 +78,7 @@ public void renderFileReport(Report report) throws IOException { */ public abstract void renderFileViolations(Iterator violations) throws IOException; - @Override - public void end() throws IOException { + @Override public void end() throws IOException { // does nothing - override if necessary } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java index 29804ac1e37..eb6689ad47f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java @@ -30,43 +30,35 @@ public AbstractRenderer(String name, String description) { this.description = description; } - @Override - protected String getPropertySourceType() { + @Override protected String getPropertySourceType() { return "renderer"; } - @Override - public String getName() { + @Override public String getName() { return name; } - @Override - public void setName(String name) { + @Override public void setName(String name) { this.name = name; } - @Override - public String getDescription() { + @Override public String getDescription() { return description; } - @Override - public void setDescription(String description) { + @Override public void setDescription(String description) { this.description = description; } - @Override - public boolean isShowSuppressedViolations() { + @Override public boolean isShowSuppressedViolations() { return showSuppressedViolations; } - @Override - public void setShowSuppressedViolations(boolean showSuppressedViolations) { + @Override public void setShowSuppressedViolations(boolean showSuppressedViolations) { this.showSuppressedViolations = showSuppressedViolations; } - @Override - public void setFileNameRenderer(FileNameRenderer fileNameRenderer) { + @Override public void setFileNameRenderer(FileNameRenderer fileNameRenderer) { this.fileNameRenderer = Objects.requireNonNull(fileNameRenderer); } @@ -84,13 +76,11 @@ protected final String determineFileName(FileId fileId) { return fileNameRenderer.getDisplayName(fileId); } - @Override - public void setWriter(Writer writer) { + @Override public void setWriter(Writer writer) { this.writer = new PrintWriter(writer); } - @Override - public Writer getWriter() { + @Override public Writer getWriter() { return writer; } @@ -115,8 +105,7 @@ public void flush() { *

    This default implementation always uses the system default charset for the writer. * Overwrite in specific renderers to support other charsets. */ - @Override - public void setReportFile(String reportFilename) { + @Override public void setReportFile(String reportFilename) { this.setWriter(IOUtil.createWriter(reportFilename)); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java index 85e869eced6..1ae4a683cd8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CSVRenderer.java @@ -39,16 +39,15 @@ public class CSVRenderer extends AbstractIncrementingRenderer { public static final String NAME = "csv"; - @SuppressWarnings("unchecked") - private final ColumnDescriptor[] allColumns = new ColumnDescriptor[] { - newColDescriptor("problem", "Problem", (idx, rv, cr) -> Integer.toString(idx)), - newColDescriptor("package", "Package", (idx, rv, cr) -> rv.getAdditionalInfo().getOrDefault(RuleViolation.PACKAGE_NAME, "")), - newColDescriptor("file", "File", (idx, rv, cr) -> determineFileName(rv.getFileId())), - newColDescriptor("priority", "Priority", (idx, rv, cr) -> Integer.toString(rv.getRule().getPriority().getPriority())), - newColDescriptor("line", "Line", (idx, rv, cr) -> Integer.toString(rv.getBeginLine())), - newColDescriptor("desc", "Description", (idx, rv, cr) -> StringUtils.replaceChars(rv.getDescription(), '\"', '\'')), - newColDescriptor("ruleSet", "Rule set", (idx, rv, cr) -> rv.getRule().getRuleSetName()), - newColDescriptor("rule", "Rule", (idx, rv, cr) -> rv.getRule().getName()), + @SuppressWarnings("unchecked") private final ColumnDescriptor[] allColumns = new ColumnDescriptor[]{ + newColDescriptor("problem", "Problem", (idx, rv, cr) -> Integer.toString(idx)), + newColDescriptor("package", "Package", (idx, rv, cr) -> rv.getAdditionalInfo().getOrDefault(RuleViolation.PACKAGE_NAME, "")), + newColDescriptor("file", "File", (idx, rv, cr) -> determineFileName(rv.getFileId())), + newColDescriptor("priority", "Priority", (idx, rv, cr) -> Integer.toString(rv.getRule().getPriority().getPriority())), + newColDescriptor("line", "Line", (idx, rv, cr) -> Integer.toString(rv.getBeginLine())), + newColDescriptor("desc", "Description", (idx, rv, cr) -> StringUtils.replaceChars(rv.getDescription(), '\"', '\'')), + newColDescriptor("ruleSet", "Rule set", (idx, rv, cr) -> rv.getRule().getRuleSetName()), + newColDescriptor("rule", "Rule", (idx, rv, cr) -> rv.getRule().getName()), }; private static @NonNull ColumnDescriptor newColDescriptor(String id, String title, Accessor accessor) { @@ -112,18 +111,15 @@ private CSVWriter csvWriter() { return csvWriter; } - @Override - public void start() throws IOException { + @Override public void start() throws IOException { csvWriter().writeTitles(getWriter()); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "csv"; } - @Override - public void renderFileViolations(Iterator violations) throws IOException { + @Override public void renderFileViolations(Iterator violations) throws IOException { csvWriter().writeData(getWriter(), violations); } @@ -132,8 +128,7 @@ public void renderFileViolations(Iterator violations) throws IOEx * * @see PropertySource#dysfunctionReason() */ - @Override - public String dysfunctionReason() { + @Override public String dysfunctionReason() { return activeColumns().isEmpty() ? "No columns selected" : null; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java index 2e892d9385e..74d79e38f8b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/CodeClimateRenderer.java @@ -26,7 +26,7 @@ public class CodeClimateRenderer extends AbstractIncrementingRenderer { public static final String NAME = "codeclimate"; public static final String BODY_PLACEHOLDER = "REPLACE_THIS_WITH_MARKDOWN"; public static final int REMEDIATION_POINTS_DEFAULT = 50000; - public static final String[] CODECLIMATE_DEFAULT_CATEGORIES = new String[] {"Style"}; + public static final String[] CODECLIMATE_DEFAULT_CATEGORIES = new String[]{"Style"}; // Note: required by https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md protected static final String NULL_CHARACTER = "\u0000"; @@ -45,8 +45,7 @@ private static String getPmdPropertiesURL() { return BASE_URL + VERSION_PART + PAGE; } - @Override - public void renderFileViolations(Iterator violations) throws IOException { + @Override public void renderFileViolations(Iterator violations) throws IOException { Gson gson = new GsonBuilder().disableHtmlEscaping().create(); while (violations.hasNext()) { @@ -76,29 +75,28 @@ private CodeClimateIssue asIssue(RuleViolation rv) { issue.categories = getCategories(); switch (rule.getPriority()) { - case HIGH: - issue.severity = "blocker"; - break; - case MEDIUM_HIGH: - issue.severity = "critical"; - break; - case MEDIUM: - issue.severity = "major"; - break; - case MEDIUM_LOW: - issue.severity = "minor"; - break; - case LOW: - default: - issue.severity = "info"; - break; + case HIGH: + issue.severity = "blocker"; + break; + case MEDIUM_HIGH: + issue.severity = "critical"; + break; + case MEDIUM: + issue.severity = "major"; + break; + case MEDIUM_LOW: + issue.severity = "minor"; + break; + case LOW: + default: + issue.severity = "info"; + break; } return issue; } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "json"; } @@ -155,8 +153,7 @@ private String getBody() { continue; } - @SuppressWarnings("unchecked") - PropertyDescriptor typed = (PropertyDescriptor) property; + @SuppressWarnings("unchecked") PropertyDescriptor typed = (PropertyDescriptor) property; T value = rule.getProperty(typed); String propertyValue = typed.serializer().toString(value); propertyValue = propertyValue.replaceAll("\\R", "\\\\n"); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmacsRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmacsRenderer.java index 2f1a144f0a7..368e7c54fc9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmacsRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmacsRenderer.java @@ -22,13 +22,11 @@ public EmacsRenderer() { super(NAME, "GNU Emacs integration."); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "emacs"; } - @Override - public void renderFileViolations(Iterator violations) throws IOException { + @Override public void renderFileViolations(Iterator violations) throws IOException { StringBuilder buf = new StringBuilder(); while (violations.hasNext()) { RuleViolation rv = violations.next(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmptyRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmptyRenderer.java index 6161d866048..60dfe363bb8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmptyRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/EmptyRenderer.java @@ -19,28 +19,23 @@ public EmptyRenderer() { super(NAME, "Empty, nothing."); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return ""; } - @Override - public void start() throws IOException { + @Override public void start() throws IOException { // deliberately does nothing } - @Override - public void startFileAnalysis(TextFile dataSource) { + @Override public void startFileAnalysis(TextFile dataSource) { // deliberately does nothing } - @Override - public void renderFileReport(Report report) throws IOException { + @Override public void renderFileReport(Report report) throws IOException { // deliberately does nothing } - @Override - public void end() throws IOException { + @Override public void end() throws IOException { // deliberately does nothing } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java index 016cc31f403..1e1c10a92bc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/HTMLRenderer.java @@ -33,21 +33,21 @@ public class HTMLRenderer extends AbstractIncrementingRenderer { public static final String NAME = "html"; public static final PropertyDescriptor> LINE_PREFIX = - PropertyFactory.stringProperty("linePrefix") - .desc("Prefix for line number anchor in the source file.") - .toOptional("") - .defaultValue(Optional.empty()) - .build(); + PropertyFactory.stringProperty("linePrefix") + .desc("Prefix for line number anchor in the source file.") + .toOptional("") + .defaultValue(Optional.empty()) + .build(); public static final PropertyDescriptor LINK_PREFIX = - PropertyFactory.stringProperty("linkPrefix").desc("Path to HTML source.").defaultValue("").build(); + PropertyFactory.stringProperty("linkPrefix").desc("Path to HTML source.").defaultValue("").build(); public static final PropertyDescriptor HTML_EXTENSION = - PropertyFactory.booleanProperty("htmlExtension") - .desc("Replace file extension with .html for the links.") - // default value is false - to have the old (pre 6.23.0) behavior, this needs to be set to true. - .defaultValue(false) - .build(); + PropertyFactory.booleanProperty("htmlExtension") + .desc("Replace file extension with .html for the links.") + // default value is false - to have the old (pre 6.23.0) behavior, this needs to be set to true. + .defaultValue(false) + .build(); private String linkPrefix; private String linePrefix; @@ -63,8 +63,7 @@ public HTMLRenderer() { definePropertyDescriptor(HTML_EXTENSION); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "html"; } @@ -90,8 +89,7 @@ public void renderBody(PrintWriter writer, Report report) throws IOException { glomConfigurationErrors(writer, configErrors); } - @Override - public void start() throws IOException { + @Override public void start() throws IOException { linkPrefix = getProperty(LINK_PREFIX); linePrefix = getProperty(LINE_PREFIX).orElse(null); replaceHtmlExtension = getProperty(HTML_EXTENSION); @@ -103,13 +101,11 @@ public void start() throws IOException { writer.println("#FileLineProblem"); } - @Override - public void renderFileViolations(Iterator violations) throws IOException { + @Override public void renderFileViolations(Iterator violations) throws IOException { glomRuleViolations(writer, violations); } - @Override - public void end() throws IOException { + @Override public void end() throws IOException { writer.write(""); glomProcessingErrors(writer, errors); if (showSuppressedViolations) { @@ -135,9 +131,9 @@ private void glomRuleViolations(Writer writer, Iterator violation buf.append("> ").append(System.lineSeparator()); buf.append("").append(violationCount).append("").append(System.lineSeparator()); buf.append("") - .append(renderFileName(rv.getFileId(), rv.getBeginLine())) - .append("") - .append(System.lineSeparator()); + .append(renderFileName(rv.getFileId(), rv.getBeginLine())) + .append("") + .append(System.lineSeparator()); buf.append("").append(rv.getBeginLine()).append("").append(System.lineSeparator()); String d = StringEscapeUtils.escapeHtml4(rv.getDescription()); @@ -147,11 +143,11 @@ private void glomRuleViolations(Writer writer, Iterator violation d = "" + d + ""; } buf.append("") - .append(d) - .append("") - .append(System.lineSeparator()) - .append("") - .append(System.lineSeparator()); + .append(d) + .append("") + .append(System.lineSeparator()) + .append("") + .append(System.lineSeparator()); writer.write(buf.toString()); violationCount++; } @@ -274,6 +270,6 @@ private String maybeWrap(String filename, String line) { } return "" - + newFileName + ""; + + newFileName + ""; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/IDEAJRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/IDEAJRenderer.java index fcfa274fde1..c241654dfeb 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/IDEAJRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/IDEAJRenderer.java @@ -26,11 +26,11 @@ public class IDEAJRenderer extends AbstractIncrementingRenderer { public static final String NAME = "ideaj"; public static final PropertyDescriptor FILE_NAME = - PropertyFactory.stringProperty("fileName").desc("File name.").defaultValue("").build(); + PropertyFactory.stringProperty("fileName").desc("File name.").defaultValue("").build(); public static final PropertyDescriptor SOURCE_PATH = - PropertyFactory.stringProperty("sourcePath").desc("Source path.").defaultValue("").build(); + PropertyFactory.stringProperty("sourcePath").desc("Source path.").defaultValue("").build(); public static final PropertyDescriptor CLASS_AND_METHOD_NAME = - PropertyFactory.stringProperty("classAndMethodName").desc("Class and Method name, pass '.method' when processing a directory.").defaultValue("").build(); + PropertyFactory.stringProperty("classAndMethodName").desc("Class and Method name, pass '.method' when processing a directory.").defaultValue("").build(); private static final String FILE_SEPARATOR = System.getProperty("file.separator"); private static final String PATH_SEPARATOR = System.getProperty("path.separator"); @@ -42,13 +42,11 @@ public IDEAJRenderer() { definePropertyDescriptor(CLASS_AND_METHOD_NAME); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "txt"; } - @Override - public void renderFileViolations(Iterator violations) throws IOException { + @Override public void renderFileViolations(Iterator violations) throws IOException { classAndMethodName = getProperty(CLASS_AND_METHOD_NAME); fileName = getProperty(FILE_NAME); @@ -98,7 +96,7 @@ private static class SourcePath { private Set paths = new HashSet<>(); SourcePath(String sourcePathString) { - for (StringTokenizer st = new StringTokenizer(sourcePathString, PATH_SEPARATOR); st.hasMoreTokens();) { + for (StringTokenizer st = new StringTokenizer(sourcePathString, PATH_SEPARATOR); st.hasMoreTokens(); ) { paths.add(st.nextToken()); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/JsonRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/JsonRenderer.java index 388dca779f9..0604acf7245 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/JsonRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/JsonRenderer.java @@ -42,13 +42,11 @@ public JsonRenderer() { super(NAME, "JSON format."); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "json"; } - @Override - public void start() throws IOException { + @Override public void start() throws IOException { jsonWriter = new JsonWriter(writer); jsonWriter.setHtmlSafe(true); jsonWriter.setIndent(" "); @@ -60,8 +58,7 @@ public void start() throws IOException { jsonWriter.name("files").beginArray(); } - @Override - public void renderFileViolations(Iterator violations) throws IOException { + @Override public void renderFileViolations(Iterator violations) throws IOException { String filename = null; while (violations.hasNext()) { @@ -116,8 +113,7 @@ private String getSuppressionType(ViolationSuppressor suppressor) { return SUPPRESSION_TYPE_FORMAT_0.getOrDefault(suppressor.getId(), suppressor.getId()); } - @Override - public void end() throws IOException { + @Override public void end() throws IOException { jsonWriter.endArray(); // files jsonWriter.name("suppressedViolations").beginArray(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/Renderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/Renderer.java index d88f4305093..1a60964bc9e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/Renderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/Renderer.java @@ -53,8 +53,7 @@ public interface Renderer extends PropertySource { * * @return The name of the Renderer. */ - @Override - String getName(); + @Override String getName(); /** * Set the name of the Renderer. @@ -185,7 +184,6 @@ public interface Renderer extends PropertySource { void setReportFile(String reportFilename); - /** * Returns a new analysis listener, that handles violations by rendering * them in an implementation-defined way. @@ -206,30 +204,25 @@ default GlobalAnalysisListener newListener() throws IOException { final GlobalReportBuilderListener configErrorReport = new GlobalReportBuilderListener(); - @Override - public void onConfigError(ConfigurationError error) { + @Override public void onConfigError(ConfigurationError error) { configErrorReport.onConfigError(error); } - @Override - public ListenerInitializer initializer() { + @Override public ListenerInitializer initializer() { return new ListenerInitializer() { - @Override - public void setFileNameRenderer(FileNameRenderer fileNameRenderer) { + @Override public void setFileNameRenderer(FileNameRenderer fileNameRenderer) { Renderer.this.setFileNameRenderer(fileNameRenderer); } }; } - @Override - public FileAnalysisListener startFileAnalysis(TextFile file) { + @Override public FileAnalysisListener startFileAnalysis(TextFile file) { Renderer renderer = Renderer.this; renderer.startFileAnalysis(file); // this routine is thread-safe by contract return new CloseHookFileListener(new ReportBuilderListener()) { - @Override - protected void doClose(ReportBuilderListener reportBuilder, @Nullable Exception ignoredEx) throws Exception { + @Override protected void doClose(ReportBuilderListener reportBuilder, @Nullable Exception ignoredEx) throws Exception { reportBuilder.close(); synchronized (reportMergeLock) { // TODO renderFileReport should be thread-safe instead @@ -239,15 +232,13 @@ protected void doClose(ReportBuilderListener reportBuilder, @Nullable Exception } } - @Override - public String toString() { + @Override public String toString() { return "FileRendererListener[" + Renderer.this + "]"; } }; } - @Override - public void close() throws Exception { + @Override public void close() throws Exception { configErrorReport.close(); Renderer.this.renderFileReport(configErrorReport.getResult()); try (TimedOperation ignored = TimeTracker.startOperation(TimedOperationCategory.REPORTING)) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java index cccd6b1d7be..5165ff838af 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/RendererFactory.java @@ -51,7 +51,8 @@ public final class RendererFactory { REPORT_FORMAT_TO_RENDERER = Collections.unmodifiableMap(map); } - private RendererFactory() { } + private RendererFactory() { + } /** * Retrieves a collection of all supported renderer names. @@ -88,8 +89,7 @@ public static Renderer createRenderer(String reportFormat, Properties properties for (PropertyDescriptor prop : renderer.getPropertyDescriptors()) { String value = properties.getProperty(prop.name()); if (value != null) { - @SuppressWarnings("unchecked") - PropertyDescriptor prop2 = (PropertyDescriptor) prop; + @SuppressWarnings("unchecked") PropertyDescriptor prop2 = (PropertyDescriptor) prop; Object valueFrom = prop2.serializer().fromString(value); renderer.setProperty(prop2, valueFrom); } @@ -111,8 +111,7 @@ public static Renderer createRenderer(String reportFormat, Properties properties return renderer; } - @SuppressWarnings("unchecked") - private static Class getRendererClass(String reportFormat) { + @SuppressWarnings("unchecked") private static Class getRendererClass(String reportFormat) { AssertionUtil.requireParamNotNull("reportFormat", reportFormat); Class rendererClass = REPORT_FORMAT_TO_RENDERER.get(reportFormat); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java index 047b6e2ac39..bf6d7dc21f9 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SarifRenderer.java @@ -33,26 +33,22 @@ public SarifRenderer() { super(NAME, DEFAULT_DESCRIPTION); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return DEFAULT_FILE_EXTENSION; } - @Override - public void start() throws IOException { + @Override public void start() throws IOException { sarifLogBuilder = SarifLogBuilder.sarifLogBuilder(); } - @Override - public void renderFileViolations(Iterator violations) throws IOException { + @Override public void renderFileViolations(Iterator violations) throws IOException { while (violations.hasNext()) { final RuleViolation violation = violations.next(); sarifLogBuilder.add(violation); } } - @Override - public void end() throws IOException { + @Override public void end() throws IOException { addErrors(); writeLog(); } @@ -62,7 +58,7 @@ private void addErrors() { sarifLogBuilder.addRunTimeError(error); } - for (Report.ConfigurationError error: this.configErrors) { + for (Report.ConfigurationError error : this.configErrors) { sarifLogBuilder.addConfigurationError(error); } } @@ -74,8 +70,7 @@ private void writeLog() throws IOException { writer.println(); } - @Override - public void setReportFile(String reportFilename) { + @Override public void setReportFile(String reportFilename) { this.setWriter(IOUtil.createWriter(StandardCharsets.UTF_8, reportFilename)); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java index b552af92d0e..20e12a5feba 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/SummaryHTMLRenderer.java @@ -32,13 +32,11 @@ public SummaryHTMLRenderer() { definePropertyDescriptor(HTMLRenderer.HTML_EXTENSION); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "html"; } - @Override - public void outputReport(Report report) throws IOException { + @Override public void outputReport(Report report) throws IOException { writer.println("PMD"); renderSummary(report); writer.write("

    Detail

    "); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextColorRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextColorRenderer.java index 010a15170f2..79a69e07977 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextColorRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextColorRenderer.java @@ -70,13 +70,11 @@ public TextColorRenderer() { super(NAME, "Text format, with color support (requires ANSI console support, e.g. xterm, rxvt, etc.)."); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "txt"; } - @Override - public void outputReport(Report report) throws IOException { + @Override public void outputReport(Report report) throws IOException { StringBuilder buf = new StringBuilder(500); buf.append(System.lineSeparator()); String lastFile = null; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextPadRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextPadRenderer.java index 77ced0a1c4f..37e079d9b42 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextPadRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextPadRenderer.java @@ -42,13 +42,11 @@ public TextPadRenderer() { super(NAME, "TextPad integration."); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "txt"; } - @Override - public void renderFileViolations(Iterator violations) throws IOException { + @Override public void renderFileViolations(Iterator violations) throws IOException { StringBuilder buf = new StringBuilder(); while (violations.hasNext()) { RuleViolation rv = violations.next(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java index 4e727c125cc..cd7765a04c5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/TextRenderer.java @@ -25,13 +25,11 @@ public TextRenderer() { super(NAME, "Text format."); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "txt"; } - @Override - public void renderFileViolations(Iterator violations) throws IOException { + @Override public void renderFileViolations(Iterator violations) throws IOException { StringBuilder buf = new StringBuilder(); while (violations.hasNext()) { @@ -45,8 +43,7 @@ public void renderFileViolations(Iterator violations) throws IOEx } } - @Override - public void end() throws IOException { + @Override public void end() throws IOException { StringBuilder buf = new StringBuilder(500); for (Report.ProcessingError error : errors) { @@ -59,10 +56,10 @@ public void end() throws IOException { for (Report.SuppressedViolation excluded : suppressed) { buf.setLength(0); buf.append(excluded.getRuleViolation().getRule().getName()) - .append(" rule violation suppressed by ") - .append(excluded.getSuppressor().getId()) - .append(" in ") - .append(determineFileName(excluded.getRuleViolation().getFileId())); + .append(" rule violation suppressed by ") + .append(excluded.getSuppressor().getId()) + .append(" in ") + .append(determineFileName(excluded.getRuleViolation().getFileId())); writer.println(buf); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/VBHTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/VBHTMLRenderer.java index 2d751aedb45..24c1e277802 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/VBHTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/VBHTMLRenderer.java @@ -23,18 +23,15 @@ public VBHTMLRenderer() { super(NAME, "Vladimir Bossicard HTML format."); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "vb.html"; } - @Override - public void start() throws IOException { + @Override public void start() throws IOException { getWriter().write(header()); } - @Override - public void renderFileViolations(Iterator violations) throws IOException { + @Override public void renderFileViolations(Iterator violations) throws IOException { if (!violations.hasNext()) { return; } @@ -78,8 +75,7 @@ public void renderFileViolations(Iterator violations) throws IOEx } } - @Override - public void end() throws IOException { + @Override public void end() throws IOException { StringBuilder sb = new StringBuilder(); writer.write("
    "); @@ -128,16 +124,16 @@ public void end() throws IOException { private String header() { return "PMD" - + "" - + "
    "; + + "" + + "
    "; } private String footer() { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java index 3f600098386..108f8050aa8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XMLRenderer.java @@ -40,7 +40,7 @@ public class XMLRenderer extends AbstractIncrementingRenderer { public static final String NAME = "xml"; public static final PropertyDescriptor ENCODING = - PropertyFactory.stringProperty("encoding").desc("XML encoding format").defaultValue("UTF-8").build(); + PropertyFactory.stringProperty("encoding").desc("XML encoding format").defaultValue("UTF-8").build(); private static final String PMD_REPORT_NS_URI = "http://pmd.sourceforge.net/report/2.0.0"; private static final String PMD_REPORT_NS_LOCATION = "https://pmd.github.io/schema/report_2_0_0.xsd"; @@ -60,13 +60,11 @@ public XMLRenderer(String encoding) { setProperty(ENCODING, encoding); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "xml"; } - @Override - public void start() throws IOException { + @Override public void start() throws IOException { String encoding = getProperty(ENCODING); String unmarkedEncoding = toUnmarkedEncoding(encoding); lineSeparator = System.lineSeparator().getBytes(unmarkedEncoding); @@ -136,8 +134,7 @@ private void writeNewLine() throws XMLStreamException, IOException { stream.write(lineSeparator); } - @Override - public void renderFileViolations(Iterator violations) throws IOException { + @Override public void renderFileViolations(Iterator violations) throws IOException { String filename = null; try { @@ -186,8 +183,7 @@ public void renderFileViolations(Iterator violations) throws IOEx } } - @Override - public void end() throws IOException { + @Override public void end() throws IOException { try { // errors for (Report.ProcessingError pe : errors) { @@ -244,8 +240,7 @@ private void maybeAdd(String attr, String value) throws XMLStreamException { } } - @Override - public void setReportFile(String reportFilename) { + @Override public void setReportFile(String reportFilename) { String encoding = getProperty(ENCODING); try { @@ -261,8 +256,7 @@ public void setReportFile(String reportFilename) { } } - @Override - public void setWriter(final Writer writer) { + @Override public void setWriter(final Writer writer) { String encoding = getProperty(ENCODING); // for backwards compatibility, create a OutputStream that writes to the writer. this.stream = IOUtil.fromWriter(writer, encoding); @@ -286,8 +280,7 @@ private static class WrappedOutputStreamWriter extends OutputStreamWriter { this.xmlWriter = xmlWriter; } - @Override - public void flush() throws IOException { + @Override public void flush() throws IOException { try { xmlWriter.flush(); } catch (XMLStreamException e) { @@ -296,8 +289,7 @@ public void flush() throws IOException { super.flush(); } - @Override - public void close() throws IOException { + @Override public void close() throws IOException { try { xmlWriter.close(); } catch (XMLStreamException e) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XSLTRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XSLTRenderer.java index d505eb08eb3..3d441ce7e38 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XSLTRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/XSLTRenderer.java @@ -59,13 +59,11 @@ public XSLTRenderer() { definePropertyDescriptor(XSLT_FILENAME); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "xsl"; } - @Override - public void start() throws IOException { + @Override public void start() throws IOException { String xsltFilenameProperty = getProperty(XSLT_FILENAME); if (StringUtils.isNotBlank(xsltFilenameProperty)) { File file = new File(xsltFilenameProperty); @@ -117,8 +115,7 @@ private void prepareTransformer(InputStream xslt) { } } - @Override - public void end() throws IOException { + @Override public void end() throws IOException { // First we finish the XML report super.end(); // Now we transform it using XSLT diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/YAHTMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/YAHTMLRenderer.java index 03170d23ae4..e4d4c789e6b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/YAHTMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/YAHTMLRenderer.java @@ -29,10 +29,10 @@ public class YAHTMLRenderer extends AbstractAccumulatingRenderer { public static final String NAME = "yahtml"; public static final PropertyDescriptor OUTPUT_DIR = - PropertyFactory.stringProperty("outputDir") - .desc("Output directory.") - .defaultValue(".") - .build(); + PropertyFactory.stringProperty("outputDir") + .desc("Output directory.") + .defaultValue(".") + .build(); private SortedMap reportNodesByPackage = new TreeMap<>(); @@ -42,8 +42,7 @@ public YAHTMLRenderer() { definePropertyDescriptor(OUTPUT_DIR); } - @Override - public String defaultFileExtension() { + @Override public String defaultFileExtension() { return "html"; } @@ -88,8 +87,7 @@ private void addViolation(RuleViolation violation) { rootNode.incrementViolations(); } - @Override - public void outputReport(Report report) throws IOException { + @Override public void outputReport(Report report) throws IOException { String outputDir = getProperty(OUTPUT_DIR); for (RuleViolation ruleViolation : report.getViolations()) { @@ -195,11 +193,11 @@ private void renderClasses(String outputDir) throws IOException { private String renderViolationRow(String name, String value) { return "" - + name - + "" - + "" - + value - + ""; + + name + + "" + + "" + + value + + ""; } private static class ReportNode { @@ -249,13 +247,12 @@ public boolean hasViolations() { return !violations.isEmpty(); } - @Override - public String toString() { + @Override public String toString() { return "ReportNode[packageName=" + packageName - + ",className=" + className - + ",violationCount=" + violationCount - + ",violations=" + violations.size() - + "]"; + + ",className=" + className + + ",violationCount=" + violationCount + + ",violations=" + violations.size() + + "]"; } } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLog.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLog.java index 17c9d255cad..f45211ec4de 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLog.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLog.java @@ -23,8 +23,7 @@ * @see Static Analysis Results Interchange Format (SARIF) Version 2.1.0 */ public final class SarifLog { - @SerializedName("$schema") - private String schema; + @SerializedName("$schema") private String schema; private String version; private List runs; @@ -72,8 +71,7 @@ public SarifLog.Location build() { return new SarifLog.Location(this.id, this.physicalLocation); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Location.LocationBuilder(id=" + this.id + ", physicalLocation=" + this.physicalLocation + ")"; } } @@ -116,8 +114,7 @@ public SarifLog.Location setPhysicalLocation(final PhysicalLocation physicalLoca return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -125,13 +122,11 @@ public boolean equals(Object o) { return Objects.equals(id, location.id) && Objects.equals(physicalLocation, location.physicalLocation); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(id, physicalLocation); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Location(id=" + this.getId() + ", physicalLocation=" + this.getPhysicalLocation() + ")"; } } @@ -195,8 +190,7 @@ public SarifLog.ArtifactLocation build() { return new SarifLog.ArtifactLocation(this.uri, this.uriBaseId, this.index); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.ArtifactLocation.ArtifactLocationBuilder(uri=" + this.uri + ", uriBaseId=" + this.uriBaseId + ", index=" + this.index + ")"; } } @@ -258,8 +252,7 @@ public SarifLog.ArtifactLocation setIndex(final Integer index) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -267,13 +260,11 @@ public boolean equals(Object o) { return Objects.equals(uri, that.uri) && Objects.equals(uriBaseId, that.uriBaseId) && Objects.equals(index, that.index); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(uri, uriBaseId, index); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.ArtifactLocation(uri=" + this.getUri() + ", uriBaseId=" + this.getUriBaseId() + ", index=" + this.getIndex() + ")"; } } @@ -325,8 +316,7 @@ public SarifLog.PhysicalLocation build() { return new SarifLog.PhysicalLocation(this.artifactLocation, this.region); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.PhysicalLocation.PhysicalLocationBuilder(artifactLocation=" + this.artifactLocation + ", region=" + this.region + ")"; } } @@ -369,8 +359,7 @@ public SarifLog.PhysicalLocation setRegion(final Region region) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -378,13 +367,11 @@ public boolean equals(Object o) { return Objects.equals(artifactLocation, that.artifactLocation) && Objects.equals(region, that.region); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(artifactLocation, region); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.PhysicalLocation(artifactLocation=" + this.getArtifactLocation() + ", region=" + this.getRegion() + ")"; } } @@ -447,8 +434,7 @@ public SarifLog.PropertyBag build() { return new SarifLog.PropertyBag(this.ruleset, this.priority, this.tags); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.PropertyBag.PropertyBagBuilder(ruleset=" + this.ruleset + ", priority=" + this.priority + ", tags=" + this.tags + ")"; } } @@ -508,8 +494,7 @@ public SarifLog.PropertyBag setTags(final Set tags) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -517,13 +502,11 @@ public boolean equals(Object o) { return Objects.equals(ruleset, that.ruleset) && Objects.equals(priority, that.priority) && Objects.equals(tags, that.tags); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(ruleset, priority, tags); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.PropertyBag(ruleset=" + this.getRuleset() + ", priority=" + this.getPriority() + ", tags=" + this.getTags() + ")"; } } @@ -600,8 +583,7 @@ public SarifLog.Region build() { return new SarifLog.Region(this.startLine, this.startColumn, this.endLine, this.endColumn); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Region.RegionBuilder(startLine=" + this.startLine + ", startColumn=" + this.startColumn + ", endLine=" + this.endLine + ", endColumn=" + this.endColumn + ")"; } } @@ -678,8 +660,7 @@ public SarifLog.Region setEndColumn(final Integer endColumn) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -687,13 +668,11 @@ public boolean equals(Object o) { return Objects.equals(startLine, region.startLine) && Objects.equals(startColumn, region.startColumn) && Objects.equals(endLine, region.endLine) && Objects.equals(endColumn, region.endColumn); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(startLine, startColumn, endLine, endColumn); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Region(startLine=" + this.getStartLine() + ", startColumn=" + this.getStartColumn() + ", endLine=" + this.getEndLine() + ", endColumn=" + this.getEndColumn() + ")"; } } @@ -799,8 +778,7 @@ public SarifLog.Result build() { return new SarifLog.Result(this.ruleId, this.ruleIndex, this.message, this.level, this.locations, this.properties); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Result.ResultBuilder(ruleId=" + this.ruleId + ", ruleIndex=" + this.ruleIndex + ", message=" + this.message + ", level=" + this.level + ", locations=" + this.locations + ", properties=" + this.properties + ")"; } } @@ -918,8 +896,7 @@ public SarifLog.Result setProperties(final PropertyBag properties) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -927,13 +904,11 @@ public boolean equals(Object o) { return Objects.equals(ruleId, result.ruleId) && Objects.equals(ruleIndex, result.ruleIndex) && Objects.equals(message, result.message) && Objects.equals(level, result.level) && Objects.equals(locations, result.locations) && Objects.equals(properties, result.properties); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(ruleId, ruleIndex, message, level, locations, properties); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Result(ruleId=" + this.getRuleId() + ", ruleIndex=" + this.getRuleIndex() + ", message=" + this.getMessage() + ", level=" + this.getLevel() + ", locations=" + this.getLocations() + ", properties=" + this.getProperties() + ")"; } } @@ -997,8 +972,7 @@ public SarifLog.Message build() { return new SarifLog.Message(this.text, this.markdown, this.id); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Message.MessageBuilder(text=" + this.text + ", markdown=" + this.markdown + ", id=" + this.id + ")"; } } @@ -1058,8 +1032,7 @@ public SarifLog.Message setId(final String id) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -1067,13 +1040,11 @@ public boolean equals(Object o) { return Objects.equals(text, message.text) && Objects.equals(markdown, message.markdown) && Objects.equals(id, message.id); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(text, markdown, id); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Message(text=" + this.getText() + ", markdown=" + this.getMarkdown() + ", id=" + this.getId() + ")"; } } @@ -1168,20 +1139,19 @@ public SarifLog.Run.RunBuilder invocations(final List invocations) { public SarifLog.Run build() { List results; switch (this.results == null ? 0 : this.results.size()) { - case 0: - results = Collections.emptyList(); - break; - case 1: - results = Collections.singletonList(this.results.get(0)); - break; - default: - results = Collections.unmodifiableList(new ArrayList<>(this.results)); + case 0: + results = Collections.emptyList(); + break; + case 1: + results = Collections.singletonList(this.results.get(0)); + break; + default: + results = Collections.unmodifiableList(new ArrayList<>(this.results)); } return new SarifLog.Run(this.tool, results, this.invocations); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Run.RunBuilder(tool=" + this.tool + ", results=" + this.results + ", invocations=" + this.invocations + ")"; } } @@ -1249,8 +1219,7 @@ public SarifLog.Run setInvocations(final List invocations) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -1258,13 +1227,11 @@ public boolean equals(Object o) { return Objects.equals(tool, run.tool) && Objects.equals(results, run.results) && Objects.equals(invocations, run.invocations); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(tool, results, invocations); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Run(tool=" + this.getTool() + ", results=" + this.getResults() + ", invocations=" + this.getInvocations() + ")"; } } @@ -1302,8 +1269,7 @@ public SarifLog.Tool build() { return new SarifLog.Tool(this.driver); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Tool.ToolBuilder(driver=" + this.driver + ")"; } } @@ -1329,8 +1295,7 @@ public SarifLog.Tool setDriver(final Component driver) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -1338,13 +1303,11 @@ public boolean equals(Object o) { return Objects.equals(driver, tool.driver); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hashCode(driver); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Tool(driver=" + this.getDriver() + ")"; } } @@ -1420,8 +1383,7 @@ public SarifLog.Component build() { return new SarifLog.Component(this.name, this.version, this.informationUri, this.rules); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Component.ComponentBuilder(name=" + this.name + ", version=" + this.version + ", informationUri=" + this.informationUri + ", rules=" + this.rules + ")"; } } @@ -1502,8 +1464,7 @@ public SarifLog.Component setRules(final List rules) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -1511,13 +1472,11 @@ public boolean equals(Object o) { return Objects.equals(name, component.name) && Objects.equals(version, component.version) && Objects.equals(informationUri, component.informationUri) && Objects.equals(rules, component.rules); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(name, version, informationUri, rules); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Component(name=" + this.getName() + ", version=" + this.getVersion() + ", informationUri=" + this.getInformationUri() + ", rules=" + this.getRules() + ")"; } } @@ -1664,8 +1623,7 @@ public SarifLog.ReportingDescriptor build() { return new SarifLog.ReportingDescriptor(this.id, this.name, this.shortDescription, this.fullDescription, this.messageStrings, this.helpUri, this.help, this.properties, this.defaultConfiguration); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.ReportingDescriptor.ReportingDescriptorBuilder(id=" + this.id + ", name=" + this.name + ", shortDescription=" + this.shortDescription + ", fullDescription=" + this.fullDescription + ", messageStrings=" + this.messageStrings + ", helpUri=" + this.helpUri + ", help=" + this.help + ", properties=" + this.properties + ", defaultConfiguration=" + this.defaultConfiguration + ")"; } } @@ -1835,8 +1793,7 @@ public SarifLog.ReportingDescriptor setDefaultConfiguration(final ReportingConfi return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -1844,13 +1801,11 @@ public boolean equals(Object o) { return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(shortDescription, that.shortDescription) && Objects.equals(fullDescription, that.fullDescription) && Objects.equals(messageStrings, that.messageStrings) && Objects.equals(helpUri, that.helpUri) && Objects.equals(help, that.help) && Objects.equals(properties, that.properties) && Objects.equals(defaultConfiguration, that.defaultConfiguration); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(id, name, shortDescription, fullDescription, messageStrings, helpUri, help, properties, defaultConfiguration); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.ReportingDescriptor(id=" + this.getId() + ", name=" + this.getName() + ", shortDescription=" + this.getShortDescription() + ", fullDescription=" + this.getFullDescription() + ", messageStrings=" + this.getMessageStrings() + ", helpUri=" + this.getHelpUri() + ", help=" + this.getHelp() + ", properties=" + this.getProperties() + ", defaultConfiguration=" + this.getDefaultConfiguration() + ")"; } } @@ -1926,8 +1881,7 @@ public SarifLog.ReportingConfiguration build() { return new SarifLog.ReportingConfiguration(this.enabled, this.level, this.rank, this.parameters); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.ReportingConfiguration.ReportingConfigurationBuilder(enabled=" + this.enabled + ", level=" + this.level + ", rank=" + this.rank + ", parameters=" + this.parameters + ")"; } } @@ -2004,8 +1958,7 @@ public SarifLog.ReportingConfiguration setParameters(final PropertyBag parameter return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -2013,13 +1966,11 @@ public boolean equals(Object o) { return Objects.equals(enabled, that.enabled) && Objects.equals(level, that.level) && Objects.equals(rank, that.rank) && Objects.equals(parameters, that.parameters); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(enabled, level, rank, parameters); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.ReportingConfiguration(enabled=" + this.getEnabled() + ", level=" + this.getLevel() + ", rank=" + this.getRank() + ", parameters=" + this.getParameters() + ")"; } } @@ -2073,8 +2024,7 @@ public SarifLog.MultiformatMessage build() { return new SarifLog.MultiformatMessage(this.text, this.markdown); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.MultiformatMessage.MultiformatMessageBuilder(text=" + this.text + ", markdown=" + this.markdown + ")"; } } @@ -2117,8 +2067,7 @@ public SarifLog.MultiformatMessage setMarkdown(final String markdown) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -2126,13 +2075,11 @@ public boolean equals(Object o) { return Objects.equals(text, that.text) && Objects.equals(markdown, that.markdown); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(text, markdown); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.MultiformatMessage(text=" + this.getText() + ", markdown=" + this.getMarkdown() + ")"; } } @@ -2169,8 +2116,7 @@ public SarifLog.Exception build() { return new SarifLog.Exception(this.message); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Exception.ExceptionBuilder(message=" + this.message + ")"; } } @@ -2200,8 +2146,7 @@ public SarifLog.Exception setMessage(final String message) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -2209,13 +2154,11 @@ public boolean equals(Object o) { return Objects.equals(message, exception.message); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hashCode(message); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Exception(message=" + this.getMessage() + ")"; } } @@ -2252,8 +2195,7 @@ public SarifLog.AssociatedRule build() { return new SarifLog.AssociatedRule(this.id); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.AssociatedRule.AssociatedRuleBuilder(id=" + this.id + ")"; } } @@ -2283,8 +2225,7 @@ public SarifLog.AssociatedRule setId(final String id) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -2292,13 +2233,11 @@ public boolean equals(Object o) { return Objects.equals(id, that.id); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hashCode(id); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.AssociatedRule(id=" + this.getId() + ")"; } } @@ -2348,8 +2287,7 @@ public SarifLog.ToolConfigurationNotification build() { return new SarifLog.ToolConfigurationNotification(this.associatedRule, this.message); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.ToolConfigurationNotification.ToolConfigurationNotificationBuilder(associatedRule=" + this.associatedRule + ", message=" + this.message + ")"; } } @@ -2396,8 +2334,7 @@ public SarifLog.ToolConfigurationNotification setMessage(final Message message) return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -2405,13 +2342,11 @@ public boolean equals(Object o) { return Objects.equals(associatedRule, that.associatedRule) && Objects.equals(message, that.message); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(associatedRule, message); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.ToolConfigurationNotification(associatedRule=" + this.getAssociatedRule() + ", message=" + this.getMessage() + ")"; } } @@ -2474,8 +2409,7 @@ public SarifLog.ToolExecutionNotification build() { return new SarifLog.ToolExecutionNotification(this.locations, this.message, this.exception); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.ToolExecutionNotification.ToolExecutionNotificationBuilder(locations=" + this.locations + ", message=" + this.message + ", exception=" + this.exception + ")"; } } @@ -2539,8 +2473,7 @@ public SarifLog.ToolExecutionNotification setException(final Exception exception return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -2548,13 +2481,11 @@ public boolean equals(Object o) { return Objects.equals(locations, that.locations) && Objects.equals(message, that.message) && Objects.equals(exception, that.exception); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(locations, message, exception); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.ToolExecutionNotification(locations=" + this.getLocations() + ", message=" + this.getMessage() + ", exception=" + this.getException() + ")"; } } @@ -2611,8 +2542,7 @@ public SarifLog.Invocation build() { return new SarifLog.Invocation(this.executionSuccessful, this.toolConfigurationNotifications, this.toolExecutionNotifications); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog.Invocation.InvocationBuilder(executionSuccessful=" + this.executionSuccessful + ", toolConfigurationNotifications=" + this.toolConfigurationNotifications + ", toolExecutionNotifications=" + this.toolExecutionNotifications + ")"; } } @@ -2652,8 +2582,7 @@ public SarifLog.Invocation setToolExecutionNotifications(final List runs) { return this; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } @@ -2812,13 +2737,11 @@ public boolean equals(Object o) { return Objects.equals(schema, sarifLog.schema) && Objects.equals(version, sarifLog.version) && Objects.equals(runs, sarifLog.runs); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(schema, version, runs); } - @Override - public String toString() { + @Override public String toString() { return "SarifLog(schema=" + this.getSchema() + ", version=" + this.getVersion() + ", runs=" + this.getRuns() + ")"; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java index fcb825b12e0..0cbea3b898e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/internal/sarif/SarifLogBuilder.java @@ -154,11 +154,11 @@ private Location getRuleViolationLocation(RuleViolation rv) { .build(); Region region = Region.builder() - .startLine(rv.getBeginLine()) - .endLine(rv.getEndLine()) - .startColumn(rv.getBeginColumn()) - .endColumn(rv.getEndColumn()) - .build(); + .startLine(rv.getBeginLine()) + .endLine(rv.getEndLine()) + .startColumn(rv.getBeginColumn()) + .endColumn(rv.getEndColumn()) + .build(); PhysicalLocation physicalLocation = PhysicalLocation.builder() .artifactLocation(artifactLocation) @@ -166,20 +166,20 @@ private Location getRuleViolationLocation(RuleViolation rv) { .build(); return Location.builder() - .physicalLocation(physicalLocation) - .build(); + .physicalLocation(physicalLocation) + .build(); } private ReportingDescriptor getReportingDescriptor(RuleViolation rv) { return ReportingDescriptor.builder() - .id(rv.getRule().getName()) - .shortDescription(new MultiformatMessage(rv.getDescription())) - .fullDescription(new MultiformatMessage(rv.getRule().getDescription())) - .helpUri(rv.getRule().getExternalInfoUrl()) - .help(new MultiformatMessage(rv.getRule().getDescription())) - .properties(getRuleProperties(rv)) - .defaultConfiguration(getDefaultConfigForRuleViolation(rv)) - .build(); + .id(rv.getRule().getName()) + .shortDescription(new MultiformatMessage(rv.getDescription())) + .fullDescription(new MultiformatMessage(rv.getRule().getDescription())) + .helpUri(rv.getRule().getExternalInfoUrl()) + .help(new MultiformatMessage(rv.getRule().getDescription())) + .properties(getRuleProperties(rv)) + .defaultConfiguration(getDefaultConfigForRuleViolation(rv)) + .build(); } private ReportingConfiguration getDefaultConfigForRuleViolation(RuleViolation rv) { @@ -214,16 +214,16 @@ private Component getDriverComponent() { */ private String pmdPriorityToSarifSeverityLevel(RulePriority rulePriority) { switch (rulePriority) { - case HIGH: - case MEDIUM_HIGH: - return "error"; - case MEDIUM: - return "warning"; - case MEDIUM_LOW: - case LOW: - return "note"; - default: - return "none"; // should not occur + case HIGH: + case MEDIUM_HIGH: + return "error"; + case MEDIUM: + return "warning"; + case MEDIUM_LOW: + case LOW: + return "note"; + default: + return "none"; // should not occur } } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/AbstractAnnotationSuppressor.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/AbstractAnnotationSuppressor.java index 79bcbee3f13..6f35289fcd4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/AbstractAnnotationSuppressor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/AbstractAnnotationSuppressor.java @@ -42,21 +42,18 @@ protected AbstractAnnotationSuppressor(Class annotationClass) { this.annotationNodeType = annotationClass; } - @Override - public String getId() { + @Override public String getId() { return "@SuppressWarnings"; } - @Override - public Report.SuppressedViolation suppressOrNull(RuleViolation rv, @NonNull Node node) { + @Override public Report.SuppressedViolation suppressOrNull(RuleViolation rv, @NonNull Node node) { if (contextSuppresses(node, rv.getRule())) { return new SuppressedViolation(rv, this, null); } return null; } - @Override - public Set getUnusedSuppressors(RootNode tree) { + @Override public Set getUnusedSuppressors(RootNode tree) { return tree.descendants(annotationNodeType).crossFindBoundaries().toStream().map(this::getUnusedSuppressorNodes).flatMap(Set::stream).collect(Collectors.toSet()); } @@ -249,13 +246,11 @@ private static final class SuppressorNodeImpl implements UnusedSuppressorNode { this.message = message; } - @Override - public Reportable getLocation() { + @Override public Reportable getLocation() { return location; } - @Override - public String unusedReason() { + @Override public String unusedReason() { return message; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/CloseHookFileListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/CloseHookFileListener.java index 073bd0716d7..16864cd8f50 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/CloseHookFileListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/CloseHookFileListener.java @@ -22,23 +22,19 @@ public CloseHookFileListener(T delegate) { this.delegate = delegate; } - @Override - public void onRuleViolation(RuleViolation violation) { + @Override public void onRuleViolation(RuleViolation violation) { delegate.onRuleViolation(violation); } - @Override - public void onSuppressedRuleViolation(SuppressedViolation violation) { + @Override public void onSuppressedRuleViolation(SuppressedViolation violation) { delegate.onSuppressedRuleViolation(violation); } - @Override - public void onError(ProcessingError error) { + @Override public void onError(ProcessingError error) { delegate.onError(error); } - @Override - public final void close() throws Exception { + @Override public final void close() throws Exception { Exception e = null; try { delegate.close(); @@ -48,8 +44,7 @@ public final void close() throws Exception { doClose(delegate, e); } - @Override - public String toString() { + @Override public String toString() { return "CloseHookFileListener [delegate=" + delegate + "]"; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ConfigurableFileNameRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ConfigurableFileNameRenderer.java index 9ced5e7df5c..36ec54d46c5 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ConfigurableFileNameRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ConfigurableFileNameRenderer.java @@ -42,8 +42,7 @@ public void relativizeWith(Path path) { this.relativizeRootPaths.sort(Comparator.naturalOrder()); } - @Override - public String getDisplayName(@NonNull FileId fileId) { + @Override public String getDisplayName(@NonNull FileId fileId) { String localDisplayName = getLocalDisplayName(fileId); FileId parent = fileId.getParentFsPath(); if (parent != null) { @@ -81,8 +80,8 @@ private static String relativizePath(Path base, String other) { // with the empty string. int maxi = Math.min(base.getNameCount(), otherSegments.length - 1); while (prefixLength < maxi - // here we add 1 for the same reason vvvvvvvvvvvvvvvv - && base.getName(prefixLength).toString().equals(otherSegments[prefixLength + 1])) { + // here we add 1 for the same reason vvvvvvvvvvvvvvvv + && base.getName(prefixLength).toString().equals(otherSegments[prefixLength + 1])) { prefixLength++; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/DeterministicOutputListenerWrapper.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/DeterministicOutputListenerWrapper.java index e95906b2e53..d6460e35fe1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/DeterministicOutputListenerWrapper.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/DeterministicOutputListenerWrapper.java @@ -55,11 +55,9 @@ public DeterministicOutputListenerWrapper(GlobalAnalysisListener listener) { this.listener = Objects.requireNonNull(listener); } - @Override - public ListenerInitializer initializer() { + @Override public ListenerInitializer initializer() { return ListenerInitializer.tee(listOf(new ListenerInitializer() { - @Override - public void setFilesToAnalyze(List files) { + @Override public void setFilesToAnalyze(List files) { for (int i = 0; i < files.size(); i++) { filesToIdx.put(files.get(i), i); } @@ -67,14 +65,12 @@ public void setFilesToAnalyze(List files) { }, listener.initializer())); } - @Override - public FileAnalysisListener startFileAnalysis(TextFile file) { + @Override public FileAnalysisListener startFileAnalysis(TextFile file) { Integer fileIdx = filesToIdx.get(file.getFileId()); Objects.requireNonNull(fileIdx, "File " + file.getFileId() + " was not declared when starting the analysis"); return new CloseHookFileListener(new ReportBuilderListener()) { - @Override - protected void doClose(ReportBuilderListener delegate, @Nullable Exception ignored) throws Exception { + @Override protected void doClose(ReportBuilderListener delegate, @Nullable Exception ignored) throws Exception { Report result = delegate.getResult(); ReportWrapper wrapper = new ReportWrapper(result, file, fileIdx); synchronized (lock) { @@ -122,8 +118,7 @@ private void tryToFlushBuffer() throws Exception { } } - @Override - public void close() throws Exception { + @Override public void close() throws Exception { synchronized (lock) { tryToFlushBuffer(); if (!reportBuffer.isEmpty()) { @@ -134,8 +129,7 @@ public void close() throws Exception { listener.close(); } - @Override - public void onConfigError(ConfigurationError error) { + @Override public void onConfigError(ConfigurationError error) { listener.onConfigError(error); } @@ -154,8 +148,7 @@ private void outputReport(ReportWrapper wrapper) throws Exception { } } - @Override - public String toString() { + @Override public String toString() { return "DeterministicOutputListenerWrapper [listener=" + listener + ", bufferSize=" + reportBuffer.size() + "]"; } @@ -170,8 +163,7 @@ private static final class ReportWrapper implements Comparable { this.idx = idx; } - @Override - public int compareTo(ReportWrapper o) { + @Override public int compareTo(ReportWrapper o) { return Integer.compare(this.idx, o.idx); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java index 78a6368526e..f2bbe1c78c3 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/FileAnalysisListener.java @@ -58,8 +58,7 @@ default void onError(ProcessingError error) { * * @throws Exception If an exception occurs, e.g. IOException when writing to a renderer */ - @Override - default void close() throws Exception { + @Override default void close() throws Exception { // by default do nothing } @@ -83,8 +82,7 @@ static FileAnalysisListener noop() { * @throws IllegalArgumentException If the parameter is empty * @throws NullPointerException If the parameter or any of its elements is null */ - @SuppressWarnings("PMD.CloseResource") - static FileAnalysisListener tee(Collection listeners) { + @SuppressWarnings("PMD.CloseResource") static FileAnalysisListener tee(Collection listeners) { AssertionUtil.requireParamNotNull("Listeners", listeners); AssertionUtil.requireNotEmpty("Listeners", listeners); AssertionUtil.requireContainsNoNullValue("Listeners", listeners); @@ -100,37 +98,32 @@ static FileAnalysisListener tee(Collection liste class TeeListener implements FileAnalysisListener { - @Override - public void onRuleViolation(RuleViolation violation) { + @Override public void onRuleViolation(RuleViolation violation) { for (FileAnalysisListener it : list) { it.onRuleViolation(violation); } } - @Override - public void onSuppressedRuleViolation(SuppressedViolation violation) { + @Override public void onSuppressedRuleViolation(SuppressedViolation violation) { for (FileAnalysisListener it : list) { it.onSuppressedRuleViolation(violation); } } - @Override - public void onError(ProcessingError error) { + @Override public void onError(ProcessingError error) { for (FileAnalysisListener it : list) { it.onError(error); } } - @Override - public void close() throws Exception { + @Override public void close() throws Exception { Exception composed = IOUtil.closeAll(list); if (composed != null) { throw composed; } } - @Override - public String toString() { + @Override public String toString() { return "Tee" + list; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java index 740d56e9a8f..f20d8ab982f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/GlobalAnalysisListener.java @@ -50,7 +50,7 @@ public interface GlobalAnalysisListener extends AutoCloseable { default ListenerInitializer initializer() { return ListenerInitializer.noop(); } - + /** * Returns a file listener that will handle events occurring during * the analysis of the given file. The new listener may receive events @@ -81,8 +81,7 @@ default ListenerInitializer initializer() { * @throws Exception If an error occurs. For example, renderer listeners * may throw {@link IOException} */ - @Override - void close() throws Exception; + @Override void close() throws Exception; /** @@ -122,44 +121,39 @@ final class TeeListener implements GlobalAnalysisListener { TeeListener(List myList) { this.myList = myList; } - - @Override - public ListenerInitializer initializer() { + + @Override public ListenerInitializer initializer() { return ListenerInitializer.tee(CollectionUtil.map(myList, GlobalAnalysisListener::initializer)); } - @Override - public FileAnalysisListener startFileAnalysis(TextFile file) { + @Override public FileAnalysisListener startFileAnalysis(TextFile file) { return FileAnalysisListener.tee(CollectionUtil.map(myList, it -> it.startFileAnalysis(file))); } - @Override - public void close() throws Exception { + @Override public void close() throws Exception { Exception composed = IOUtil.closeAll(myList); if (composed != null) { throw composed; } } - @Override - public String toString() { + @Override public String toString() { return "TeeListener{" + myList + '}'; } - @Override - public void onConfigError(ConfigurationError error) { + @Override public void onConfigError(ConfigurationError error) { myList.forEach(l -> l.onConfigError(error)); } } - + // Flatten other tee listeners in the list // This prevents suppressed exceptions from being chained too deep if they occur in close() List myList = - listeners.stream() - .flatMap(l -> l instanceof TeeListener ? ((TeeListener) l).myList.stream() : Stream.of(l)) - .filter(l -> !(l instanceof NoopAnalysisListener)) - .collect(CollectionUtil.toUnmodifiableList()); - + listeners.stream() + .flatMap(l -> l instanceof TeeListener ? ((TeeListener) l).myList.stream() : Stream.of(l)) + .filter(l -> !(l instanceof NoopAnalysisListener)) + .collect(CollectionUtil.toUnmodifiableList()); + if (myList.isEmpty()) { return noop(); } else if (myList.size() == 1) { @@ -178,13 +172,11 @@ final class ViolationCounterListener extends BaseResultProducingCloseable count.incrementAndGet(); } } @@ -201,29 +193,24 @@ public FileAnalysisListener startFileAnalysis(TextFile file) { static GlobalAnalysisListener exceptionThrower() { class ExceptionThrowingListener implements GlobalAnalysisListener { - @Override - public FileAnalysisListener startFileAnalysis(TextFile file) { + @Override public FileAnalysisListener startFileAnalysis(TextFile file) { FileId filename = file.getFileId(); // capture the filename instead of the file return new FileAnalysisListener() { - @Override - public void onRuleViolation(RuleViolation violation) { + @Override public void onRuleViolation(RuleViolation violation) { // do nothing } - @Override - public void onError(ProcessingError error) throws FileAnalysisException { + @Override public void onError(ProcessingError error) throws FileAnalysisException { throw FileAnalysisException.wrap(filename, error.getError().getMessage(), error.getError()); } - @Override - public String toString() { + @Override public String toString() { return "ExceptionThrower"; } }; } - @Override - public void close() { + @Override public void close() { // nothing to do } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/InternalApiBridge.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/InternalApiBridge.java index be65d395216..9ad61b96fc4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/InternalApiBridge.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/InternalApiBridge.java @@ -24,7 +24,8 @@ */ @InternalApi public final class InternalApiBridge { - private InternalApiBridge() {} + private InternalApiBridge() { + } public static Rule getRule(RuleContext ruleContext) { return ruleContext.getRule(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ListenerInitializer.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ListenerInitializer.java index 326b1f000dc..ada60230a6f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ListenerInitializer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ListenerInitializer.java @@ -63,8 +63,7 @@ default void setFileNameRenderer(FileNameRenderer fileNameRenderer) { * * @throws Exception If an exception occurs, eg IOException when writing to a renderer */ - @Override - default void close() throws Exception { + @Override default void close() throws Exception { // by default do nothing } @@ -87,8 +86,7 @@ static ListenerInitializer noop() { * @throws IllegalArgumentException If the parameter is empty * @throws NullPointerException If the parameter or any of its elements is null */ - @SuppressWarnings("PMD.CloseResource") - static ListenerInitializer tee(Collection listeners) { + @SuppressWarnings("PMD.CloseResource") static ListenerInitializer tee(Collection listeners) { AssertionUtil.requireParamNotNull("Listeners", listeners); AssertionUtil.requireNotEmpty("Listeners", listeners); AssertionUtil.requireContainsNoNullValue("Listeners", listeners); @@ -104,37 +102,32 @@ static ListenerInitializer tee(Collection listene class TeeListener implements ListenerInitializer { - @Override - public void setNumberOfFilesToAnalyze(int totalFiles) { + @Override public void setNumberOfFilesToAnalyze(int totalFiles) { for (ListenerInitializer initializer : list) { initializer.setNumberOfFilesToAnalyze(totalFiles); } } - @Override - public void setFilesToAnalyze(List files) { + @Override public void setFilesToAnalyze(List files) { for (ListenerInitializer initializer : list) { initializer.setFilesToAnalyze(files); } } - @Override - public void setFileNameRenderer(FileNameRenderer fileNameRenderer) { + @Override public void setFileNameRenderer(FileNameRenderer fileNameRenderer) { for (ListenerInitializer initializer : list) { initializer.setFileNameRenderer(fileNameRenderer); } } - @Override - public void close() throws Exception { + @Override public void close() throws Exception { Exception composed = IOUtil.closeAll(list); if (composed != null) { throw composed; } } - @Override - public String toString() { + @Override public String toString() { return "Tee" + list; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopAnalysisListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopAnalysisListener.java index 64a29d5b168..7b2bb4814c8 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopAnalysisListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopAnalysisListener.java @@ -17,13 +17,11 @@ private NoopAnalysisListener() { } - @Override - public FileAnalysisListener startFileAnalysis(TextFile file) { + @Override public FileAnalysisListener startFileAnalysis(TextFile file) { return FileAnalysisListener.noop(); } - @Override - public void close() { + @Override public void close() { // do nothing } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopFileListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopFileListener.java index 223fb948f5d..3789669d792 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopFileListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopFileListener.java @@ -12,13 +12,11 @@ private NoopFileListener() { // singleton } - @Override - public void onRuleViolation(RuleViolation violation) { + @Override public void onRuleViolation(RuleViolation violation) { // do nothing } - @Override - public String toString() { + @Override public String toString() { return "Noop"; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopListenerInitializer.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopListenerInitializer.java index 525f7bad770..4e979d7f855 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopListenerInitializer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/NoopListenerInitializer.java @@ -12,8 +12,7 @@ private NoopListenerInitializer() { // singleton } - @Override - public String toString() { + @Override public String toString() { return "Noop"; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ParametricRuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ParametricRuleViolation.java index 5ca33eeadb0..f41716bb8b7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ParametricRuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ParametricRuleViolation.java @@ -38,28 +38,23 @@ class ParametricRuleViolation implements RuleViolation { } } - @Override - public Map getAdditionalInfo() { + @Override public Map getAdditionalInfo() { return additionalInfo; } - @Override - public Rule getRule() { + @Override public Rule getRule() { return rule; } - @Override - public String getDescription() { + @Override public String getDescription() { return description; } - @Override - public FileLocation getLocation() { + @Override public FileLocation getLocation() { return location; } - @Override - public String toString() { + @Override public String toString() { return getLocation().startPosToStringWithFile() + ':' + getRule() + ':' + getDescription(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Report.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Report.java index 10f0058e94e..88fd8343ed6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Report.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/Report.java @@ -278,28 +278,23 @@ public ReportBuilderListener() { this.report = report; } - @Override - protected Report getResultImpl() { + @Override protected Report getResultImpl() { return report; } - @Override - public void onRuleViolation(RuleViolation violation) { + @Override public void onRuleViolation(RuleViolation violation) { report.addRuleViolation(violation); } - @Override - public void onSuppressedRuleViolation(SuppressedViolation violation) { + @Override public void onSuppressedRuleViolation(SuppressedViolation violation) { report.addSuppressedViolation(violation); } - @Override - public void onError(ProcessingError error) { + @Override public void onError(ProcessingError error) { report.addError(error); } - @Override - public String toString() { + @Override public String toString() { return "ReportBuilderListener"; } } @@ -312,19 +307,16 @@ public static final class GlobalReportBuilderListener extends BaseResultProducin private final Report report = new Report(); - @Override - public FileAnalysisListener startFileAnalysis(TextFile file) { + @Override public FileAnalysisListener startFileAnalysis(TextFile file) { // note that the report is shared, but Report is now thread-safe return new ReportBuilderListener(this.report); } - @Override - public void onConfigError(ConfigurationError error) { + @Override public void onConfigError(ConfigurationError error) { report.addConfigError(error); } - @Override - public Report getResultImpl() { + @Override public Report getResultImpl() { return report; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ReportStats.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ReportStats.java index 9ac07837a3d..82660f8cd21 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ReportStats.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ReportStats.java @@ -37,8 +37,7 @@ public int getNumViolations() { return numViolations; } - @Override - public String toString() { + @Override public String toString() { return "ReportStats{numErrors=" + numErrors + ", numViolations=" + numViolations + '}'; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ReportStatsListener.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ReportStatsListener.java index 49d18837d3a..c2ae21e822d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ReportStatsListener.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ReportStatsListener.java @@ -20,26 +20,22 @@ public final class ReportStatsListener extends BaseResultProducingCloseable 0) { ReportStatsListener.this.numErrors.addAndGet(this.numErrors); } @@ -50,11 +46,10 @@ public void close() { }; } - @Override - protected ReportStats getResultImpl() { + @Override protected ReportStats getResultImpl() { return new ReportStats( - numErrors.get(), - numViolations.get() + numErrors.get(), + numViolations.get() ); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleContext.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleContext.java index a86feb993e1..df98affe86a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleContext.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleContext.java @@ -45,8 +45,8 @@ public final class RuleContext { private static final Object[] NO_ARGS = new Object[0]; static final List DEFAULT_SUPPRESSORS = listOf(ViolationSuppressor.NOPMD_COMMENT_SUPPRESSOR, - ViolationSuppressor.REGEX_SUPPRESSOR, - ViolationSuppressor.XPATH_SUPPRESSOR); + ViolationSuppressor.REGEX_SUPPRESSOR, + ViolationSuppressor.XPATH_SUPPRESSOR); private final FileAnalysisListener listener; private final Rule rule; @@ -138,7 +138,7 @@ public void addViolationWithPosition(Node node, int beginLine, int endLine, Stri FileLocation location; if (beginLine != -1 && endLine != -1) { location = FileLocation.range(node.getTextDocument().getFileId(), - TextRange2d.range2d(beginLine, 1, endLine, 1)); + TextRange2d.range2d(beginLine, 1, endLine, 1)); } else { location = node.getReportLocation(); } @@ -161,9 +161,8 @@ public void addViolationWithPosition(Node node, int beginLine, int endLine, Stri * replaced by a fluent API or something to report violations. Do not use * this outside of the PMD codebase. See [core] Add fluent API to report violations #5039. */ - @Experimental - public void addViolationWithPosition(Reportable reportable, AstInfo astInfo, FileLocation location, - String message, Object... formatArgs) { + @Experimental public void addViolationWithPosition(Reportable reportable, AstInfo astInfo, FileLocation location, + String message, Object... formatArgs) { Objects.requireNonNull(reportable, "Node was null"); Objects.requireNonNull(message, "Message was null"); Objects.requireNonNull(formatArgs, "Format arguments were null, use an empty array"); @@ -182,9 +181,8 @@ public void addViolationWithPosition(Reportable reportable, AstInfo astInfo, /** * @experimental Since 7.14.0. See [core] Add rule to report unnecessary suppression comments/annotations #5609 */ - @Experimental - public void addViolationNoSuppress(Reportable reportable, AstInfo astInfo, - String message, Object... formatArgs) { + @Experimental public void addViolationNoSuppress(Reportable reportable, AstInfo astInfo, + String message, Object... formatArgs) { Objects.requireNonNull(reportable, "Node was null"); Objects.requireNonNull(message, "Message was null"); Objects.requireNonNull(formatArgs, "Format arguments were null, use an empty array"); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java index 20da6f80f53..2e4fe52da42 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/RuleViolation.java @@ -28,13 +28,13 @@ public interface RuleViolation { * in an unspecified order. */ Comparator DEFAULT_COMPARATOR = - Comparator.comparing(RuleViolation::getFileId) - .thenComparingInt(RuleViolation::getBeginLine) - .thenComparingInt(RuleViolation::getBeginColumn) - .thenComparing(RuleViolation::getDescription, Comparator.nullsLast(Comparator.naturalOrder())) - .thenComparingInt(RuleViolation::getEndLine) - .thenComparingInt(RuleViolation::getEndColumn) - .thenComparing(rv -> rv.getRule().getName()); + Comparator.comparing(RuleViolation::getFileId) + .thenComparingInt(RuleViolation::getBeginLine) + .thenComparingInt(RuleViolation::getBeginColumn) + .thenComparing(RuleViolation::getDescription, Comparator.nullsLast(Comparator.naturalOrder())) + .thenComparingInt(RuleViolation::getEndLine) + .thenComparingInt(RuleViolation::getEndColumn) + .thenComparing(rv -> rv.getRule().getName()); /** diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationDecorator.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationDecorator.java index ead8232db38..e098f257bab 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationDecorator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationDecorator.java @@ -50,6 +50,7 @@ static ViolationDecorator chain(List list) { } static ViolationDecorator noop() { - return (node, map) -> { }; + return (node, map) -> { + }; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationSuppressor.java b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationSuppressor.java index 6f7f0a926f6..3bc5b472416 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationSuppressor.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/reporting/ViolationSuppressor.java @@ -41,13 +41,11 @@ public interface ViolationSuppressor { * Suppressor for the violationSuppressRegex property. */ ViolationSuppressor REGEX_SUPPRESSOR = new ViolationSuppressor() { - @Override - public String getId() { + @Override public String getId() { return "Regex"; } - @Override - public @Nullable SuppressedViolation suppressOrNull(RuleViolation rv, @NonNull Node node) { + @Override public @Nullable SuppressedViolation suppressOrNull(RuleViolation rv, @NonNull Node node) { Optional regex = rv.getRule().getProperty(Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR); // Regex if (regex.isPresent() && rv.getDescription() != null) { if (regex.get().matcher(rv.getDescription()).matches()) { @@ -62,13 +60,11 @@ public String getId() { * Suppressor for the violationSuppressXPath property. */ ViolationSuppressor XPATH_SUPPRESSOR = new ViolationSuppressor() { - @Override - public String getId() { + @Override public String getId() { return "XPath"; } - @Override - public @Nullable SuppressedViolation suppressOrNull(RuleViolation rv, @NonNull Node node) { + @Override public @Nullable SuppressedViolation suppressOrNull(RuleViolation rv, @NonNull Node node) { // todo this should not be implemented via a rule property // because the parsed xpath expression should be stored, not a random string // this needs to be checked to be a valid xpath expression in the ruleset, @@ -79,11 +75,11 @@ public String getId() { return null; } SaxonXPathRuleQuery rq = new SaxonXPathRuleQuery( - xpath.get(), - XPathVersion.DEFAULT, - rule.getPropertiesByPropertyDescriptor(), - node.getAstInfo().getLanguageProcessor().services().getXPathHandler(), - DeprecatedAttrLogger.createForSuppression(rv.getRule()) + xpath.get(), + XPathVersion.DEFAULT, + rule.getPropertiesByPropertyDescriptor(), + node.getAstInfo().getLanguageProcessor().services().getXPathHandler(), + DeprecatedAttrLogger.createForSuppression(rv.getRule()) ); if (!rq.evaluate(node).isEmpty()) { return new SuppressedViolation(rv, this, xpath.get()); @@ -101,15 +97,13 @@ public String getId() { */ ViolationSuppressor NOPMD_COMMENT_SUPPRESSOR = new ViolationSuppressor() { private final SimpleDataKey> usedSuppressionComments = - DataMap.simpleDataKey("pmd.core.comment.suppressor"); + DataMap.simpleDataKey("pmd.core.comment.suppressor"); - @Override - public String getId() { + @Override public String getId() { return "//NOPMD"; } - @Override - public @Nullable SuppressedViolation suppressOrNull(RuleViolation rv, @NonNull Node node) { + @Override public @Nullable SuppressedViolation suppressOrNull(RuleViolation rv, @NonNull Node node) { AstInfo astInfo = node.getAstInfo(); SuppressionCommentWrapper wrapper = astInfo.getSuppressionComment(rv.getBeginLine()); if (wrapper != null) { @@ -119,32 +113,27 @@ public String getId() { return null; } - @Override - public Set getUnusedSuppressors(RootNode tree) { + @Override public Set getUnusedSuppressors(RootNode tree) { Set usedSuppressors = tree.getAstInfo().getUserMap().getOrDefault(usedSuppressionComments, Collections.emptySet()); Set allSuppressors = new HashSet<>(tree.getAstInfo().getAllSuppressionComments()); allSuppressors.removeAll(usedSuppressors); return new AbstractSet() { - @Override - public @NonNull Iterator iterator() { + @Override public @NonNull Iterator iterator() { return IteratorUtil.map( - allSuppressors.iterator(), - comment -> new UnusedSuppressorNode() { - @Override - public Reportable getLocation() { - return comment.getLocation(); + allSuppressors.iterator(), + comment -> new UnusedSuppressorNode() { + @Override public Reportable getLocation() { + return comment.getLocation(); + } + + @Override public String unusedReason() { + return "Unnecessary PMD suppression comment"; + } } - - @Override - public String unusedReason() { - return "Unnecessary PMD suppression comment"; - } - } ); } - @Override - public int size() { + @Override public int size() { return allSuppressors.size(); } }; @@ -163,8 +152,7 @@ public int size() { * suppressed by this object. The node and the rule are provided * for context. Returns null if the violation is not suppressed. */ - @Nullable - SuppressedViolation suppressOrNull(RuleViolation rv, @NonNull Node node); + @Nullable SuppressedViolation suppressOrNull(RuleViolation rv, @NonNull Node node); /** @@ -192,8 +180,8 @@ default Set getUnusedSuppressors(RootNode tree) { * suppressor matches, then returns null. */ static @Nullable SuppressedViolation suppressOrNull(List suppressorList, - RuleViolation rv, - Node node) { + RuleViolation rv, + Node node) { for (ViolationSuppressor suppressor : suppressorList) { SuppressedViolation suppressed = suppressor.suppressOrNull(rv, node); if (suppressed != null) { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/AssertionUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/AssertionUtil.java index 7ab20afbd63..228148d5dde 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/AssertionUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/AssertionUtil.java @@ -117,7 +117,7 @@ public static void validateStringRange(CharSequence string, int startInclusive, */ public static void assertValidStringRange(CharSequence string, int startInclusive, int endExclusive) { assert isValidRange(startInclusive, endExclusive, 0, string.length()) - : invalidRangeMessage(startInclusive, endExclusive, 0, string.length()); + : invalidRangeMessage(startInclusive, endExclusive, 0, string.length()); } /** @@ -218,8 +218,7 @@ public static E mustBe(String name, Object value, S return exceptionMaker.apply(String.format("%s must be %s, got %s", name, condition, value)); } - @NonNull - public static T requireParamNotNull(String paramName, T obj) { + @NonNull public static T requireParamNotNull(String paramName, T obj) { if (obj == null) { throw new NullPointerException("Parameter " + paramName + " is null"); } @@ -234,7 +233,7 @@ public static T requireParamNotNull(String paramName, T obj) { public static @NonNull AssertionError shouldNotReachHere(String message, Throwable cause) { String prefix = "This should be unreachable"; message = StringUtils.isBlank(message) ? prefix - : prefix + ": " + message; + : prefix + ": " + message; return new AssertionError(message, cause); } @@ -248,7 +247,7 @@ public static T requireParamNotNull(String paramName, T obj) { public static @NonNull ContextedRuntimeException contexted(RuntimeException e) { return e instanceof ContextedRuntimeException ? (ContextedRuntimeException) e - : new ContextedRuntimeException(e); + : new ContextedRuntimeException(e); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/BaseResultProducingCloseable.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/BaseResultProducingCloseable.java index d28e7180df5..e0e9992f2e4 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/BaseResultProducingCloseable.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/BaseResultProducingCloseable.java @@ -40,8 +40,7 @@ public final T getResult() { * * @implNote Override {@link #closeImpl()} instead. */ - @Override - public final void close() { + @Override public final void close() { if (!closed) { closed = true; closeImpl(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java index de335c7a259..10d28e3239b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/CollectionUtil.java @@ -86,8 +86,7 @@ public static List concatView(List head, List t */ public static Map mapView(Map map, Function valueMapper) { return new AbstractMap() { - @Override - public U get(Object key) { + @Override public U get(Object key) { V v = map.get(key); if (v == null && !map.containsKey(key)) { return null; @@ -95,17 +94,14 @@ public U get(Object key) { return valueMapper.apply(v); } - @Override - public Set> entrySet() { + @Override public Set> entrySet() { return new AbstractSet>() { - @Override - public Iterator> iterator() { + @Override public Iterator> iterator() { return IteratorUtil.map(map.entrySet().iterator(), entry -> new AbstractMap.SimpleEntry<>(entry.getKey(), valueMapper.apply(entry.getValue()))); } - @Override - public int size() { + @Override public int size() { return map.size(); } }; @@ -122,8 +118,7 @@ public int size() { * * @return Union of both arguments */ - @SafeVarargs - public static Set union(Collection c1, Collection c2, Collection... rest) { + @SafeVarargs public static Set union(Collection c1, Collection c2, Collection... rest) { Set union = new LinkedHashSet<>(c1); union.addAll(c2); for (Collection ts : rest) { @@ -140,8 +135,7 @@ public static Set union(Collection c1, Collection Set intersect(Collection c1, Collection c2, Collection... rest) { + @SafeVarargs public static Set intersect(Collection c1, Collection c2, Collection... rest) { Set union = new LinkedHashSet<>(c1); union.retainAll(c2); for (Collection ts : rest) { @@ -160,8 +154,7 @@ public static Set intersect(Collection c1, Collection Set diff(Collection c1, Collection c2, Collection... rest) { + @SafeVarargs public static Set diff(Collection c1, Collection c2, Collection... rest) { Set union = new LinkedHashSet<>(c1); union.removeAll(c2); for (Collection ts : rest) { @@ -177,8 +170,7 @@ public static Set diff(Collection c1, Collection Set setOf(T first, T... rest) { + @SafeVarargs public static Set setOf(T first, T... rest) { return immutableSetOf(first, rest); } @@ -188,8 +180,7 @@ public static Set setOf(T first, T... rest) { * @param first First element * @param rest Following elements */ - @SafeVarargs - public static Set immutableSetOf(T first, T... rest) { + @SafeVarargs public static Set immutableSetOf(T first, T... rest) { if (rest.length == 0) { return Collections.singleton(first); } @@ -205,14 +196,12 @@ public static Set immutableSetOf(T first, T... rest) { * @param first First element * @param rest Following elements */ - @SafeVarargs - public static > Set immutableEnumSet(T first, T... rest) { + @SafeVarargs public static > Set immutableEnumSet(T first, T... rest) { return Collections.unmodifiableSet(EnumSet.of(first, rest)); } - @SafeVarargs - public static List listOf(T first, T... rest) { + @SafeVarargs public static List listOf(T first, T... rest) { if (rest.length == 0) { return ConsPStack.singleton(first); } @@ -301,9 +290,7 @@ public static List emptyList() { * Returns an unmodifiable set containing the set union of the collection, * and the new elements. */ - @SafeVarargs - @SuppressWarnings("unchecked") - public static Set setUnion(Collection set, V first, V... newElements) { + @SafeVarargs @SuppressWarnings("unchecked") public static Set setUnion(Collection set, V first, V... newElements) { if (set instanceof PSet) { return ((PSet) set).plus(first).plusAll(asList(newElements)); } @@ -472,8 +459,8 @@ private static List map(Iterator from, int sizeHint, Func * and accumulates it into the collector. */ public static C map(Collector collector, - Iterable from, - Function f) { + Iterable from, + Function f) { if (from == null) { return map(collector, emptyIterator(), f); } @@ -486,8 +473,8 @@ public static C map(Collector collector, */ // one more type param and we can write tupac public static C map(Collector collector, - Iterator from, - Function f) { + Iterator from, + Function f) { A a = collector.supplier().get(); BiConsumer accumulator = collector.accumulator(); from.forEachRemaining(t -> accumulator.accept(a, f.apply(t))); @@ -553,13 +540,13 @@ class Holder { } return Collector.of( - Holder::new, - (h, t) -> h.set = h.set.plus(t), - (left, right) -> { - left.set = left.set.plusAll(right.set); - return left; - }, - a -> a.set + Holder::new, + (h, t) -> h.set = h.set.plus(t), + (left, right) -> { + left.set = left.set.plusAll(right.set); + return left; + }, + a -> a.set ); } @@ -578,13 +565,13 @@ public static List drop(List list, int n) { AssertionUtil.requireNonNegative("n", n); return list.size() <= n ? emptyList() - : list.subList(n, list.size()); + : list.subList(n, list.size()); } public static List take(List list, int n) { AssertionUtil.requireNonNegative("n", n); return list.size() <= n ? list - : list.subList(0, n); + : list.subList(0, n); } @@ -661,9 +648,9 @@ public static Set defensiveUnmodifiableCopyToSet(Collection * on a preexisting {@link StringBuilder}. The result value is that StringBuilder. */ public static StringBuilder joinOn(StringBuilder sb, - Iterable iterable, - BiConsumer appendItem, - String delimiter) { + Iterable iterable, + BiConsumer appendItem, + String delimiter) { boolean first = true; for (T t : iterable) { if (first) { @@ -678,10 +665,10 @@ public static StringBuilder joinOn(StringBuilder sb, public static @NonNull StringBuilder joinCharsIntoStringBuilder(List lines, String delimiter) { return joinOn( - new StringBuilder(), - lines, - (buf, line) -> line.appendChars(buf), - delimiter + new StringBuilder(), + lines, + (buf, line) -> line.appendChars(buf), + delimiter ); } @@ -714,6 +701,6 @@ public static PSet union(PSet as, PSet bs) { return (List) list; } return list == null || list.isEmpty() ? emptyList() - : Collections.unmodifiableList(list); + : Collections.unmodifiableList(list); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ConsList.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ConsList.java index 66fdfcfe73f..f81e09d481d 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ConsList.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ConsList.java @@ -22,8 +22,7 @@ final class ConsList extends AbstractList { this.size = head.size() + tail.size(); } - @Override - public T get(int index) { + @Override public T get(int index) { Validate.validIndex(this, index); if (index < head.size()) { return head.get(index); @@ -31,13 +30,11 @@ public T get(int index) { return tail.get(index - head.size()); } - @Override - public Iterator iterator() { + @Override public Iterator iterator() { return IteratorUtil.concat(head.iterator(), tail.iterator()); } - @Override - public int size() { + @Override public int size() { return size; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedAssertionError.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedAssertionError.java index a6cb0615eb9..35e5612bc73 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedAssertionError.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedAssertionError.java @@ -25,21 +25,18 @@ private ContextedAssertionError(AssertionError e) { public static ContextedAssertionError wrap(AssertionError e) { return e instanceof ContextedAssertionError ? (ContextedAssertionError) e - : new ContextedAssertionError(e); + : new ContextedAssertionError(e); } - @Override - public String getMessage() { + @Override public String getMessage() { return getFormattedExceptionMessage(super.getMessage()); } - @Override - public DefaultExceptionContext getExceptionContext() { + @Override public DefaultExceptionContext getExceptionContext() { return exceptionContext; } - @Override - public ContextedAssertionError getThrowable() { + @Override public ContextedAssertionError getThrowable() { return this; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedStackOverflowError.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedStackOverflowError.java index 854f3a6b8e3..41769668c33 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedStackOverflowError.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ContextedStackOverflowError.java @@ -25,21 +25,18 @@ private ContextedStackOverflowError(StackOverflowError e) { public static ContextedStackOverflowError wrap(StackOverflowError e) { return e instanceof ContextedStackOverflowError ? (ContextedStackOverflowError) e - : new ContextedStackOverflowError(e); + : new ContextedStackOverflowError(e); } - @Override - public String getMessage() { + @Override public String getMessage() { return getFormattedExceptionMessage(super.getMessage()); } - @Override - public DefaultExceptionContext getExceptionContext() { + @Override public DefaultExceptionContext getExceptionContext() { return exceptionContext; } - @Override - public ContextedStackOverflowError getThrowable() { + @Override public ContextedStackOverflowError getThrowable() { return this; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/DataMap.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/DataMap.java index 86294162887..48db4b1568b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/DataMap.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/DataMap.java @@ -38,8 +38,7 @@ private DataMap() { * * @return Previous value associated with the key (nullable) */ - @SuppressWarnings("unchecked") - public @Nullable T set(DataKey key, T data) { + @SuppressWarnings("unchecked") public @Nullable T set(DataKey key, T data) { return (T) getMap().put(key, data); } @@ -51,13 +50,11 @@ private DataMap() { * * @return Value associated with the key (nullable) */ - @SuppressWarnings("unchecked") - public @Nullable T get(DataKey key) { + @SuppressWarnings("unchecked") public @Nullable T get(DataKey key) { return map == null ? null : (T) map.get(key); } - @SuppressWarnings("unchecked") - public T getOrDefault(DataKey key, T defaultValue) { + @SuppressWarnings("unchecked") public T getOrDefault(DataKey key, T defaultValue) { return map == null ? defaultValue : (T) map.getOrDefault(key, defaultValue); } @@ -70,8 +67,7 @@ public T getOrDefault(DataKey key, T defaultValue) * * @return Value associated with the key (as nullable as the */ - @SuppressWarnings("unchecked") - public T computeIfAbsent(DataKey key, Supplier supplier) { + @SuppressWarnings("unchecked") public T computeIfAbsent(DataKey key, Supplier supplier) { return (T) getMap().computeIfAbsent(key, k -> supplier.get()); } @@ -85,16 +81,14 @@ public T computeIfAbsent(DataKey key, Supplier * * @return Value returned by the parameter function */ - @SuppressWarnings("unchecked") - public T compute(DataKey key, Function function) { + @SuppressWarnings("unchecked") public T compute(DataKey key, Function function) { return (T) getMap().compute(key, (k, v) -> function.apply((T) v)); } /** * @see Map#merge(Object, Object, BiFunction) */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - public T merge(DataKey key, T value, BiFunction function) { + @SuppressWarnings({"unchecked", "rawtypes"}) public T merge(DataKey key, T value, BiFunction function) { return (T) getMap().merge(key, value, (BiFunction) function); } @@ -150,8 +144,7 @@ public static class SimpleDataKey implements DataKey, T> { this.name = name; } - @Override - public String toString() { + @Override public String toString() { return name; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/GraphUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/GraphUtil.java index 087e15d33fe..26d7e8c41f6 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/GraphUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/GraphUtil.java @@ -33,10 +33,10 @@ private GraphUtil() { * @param Type of vertex, must be usable as map key (equals/hash) */ public static String toDot( - Collection vertices, - Function> successorFun, - Function colorFun, - Function labelFun + Collection vertices, + Function> successorFun, + Function colorFun, + Function labelFun ) { // generates a DOT representation of the lattice // Visualize eg at http://webgraphviz.com/ @@ -49,11 +49,11 @@ public static String toDot( String id = "n" + i++; ids.put(node, id); sb.append(id) - .append(" [ shape=box, color=") - .append(colorFun.apply(node).toDot()) - .append(", label=\"") - .append(escapeDotString(labelFun.apply(node))) - .append("\" ];\n"); + .append(" [ shape=box, color=") + .append(colorFun.apply(node).toDot()) + .append(", label=\"") + .append(escapeDotString(labelFun.apply(node))) + .append("\" ];\n"); } List edges = new ArrayList<>(); @@ -74,10 +74,9 @@ public static String toDot( } - @NonNull - private static String escapeDotString(String string) { + @NonNull private static String escapeDotString(String string) { return string.replaceAll("\\R", "\\\n") - .replaceAll("\"", "\\\""); + .replaceAll("\"", "\\\""); } public enum DotColor { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/IteratorUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/IteratorUtil.java index 362bf94a4f6..52ba7c22b62 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/IteratorUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/IteratorUtil.java @@ -44,8 +44,7 @@ private IteratorUtil() { public static Iterator takeWhile(Iterator iter, Predicate predicate) { return new AbstractIterator() { - @Override - protected void computeNext() { + @Override protected void computeNext() { if (iter.hasNext()) { T next = iter.next(); if (predicate.test(next)) { @@ -68,8 +67,7 @@ public static Iterator flatMap(Iterator iter, Function() { private Iterator current = null; - @Override - protected void computeNext() { + @Override protected void computeNext() { if (current != null && current.hasNext()) { setNext(current.next()); } else { @@ -97,8 +95,7 @@ public static Iterator flatMapWithSelf(Iterator iter, Functi return new AbstractIterator() { private Iterator current = null; - @Override - protected void computeNext() { + @Override protected void computeNext() { if (current != null && current.hasNext()) { setNext(current.next()); } else { @@ -122,8 +119,7 @@ protected void computeNext() { public static Iterator<@NonNull R> mapNotNull(Iterator it, Function<@NonNull ? super T, @Nullable ? extends R> mapper) { return new AbstractIterator() { - @Override - protected void computeNext() { + @Override protected void computeNext() { while (it.hasNext()) { T next = it.next(); if (next != null) { @@ -141,8 +137,7 @@ protected void computeNext() { public static Iterator filter(Iterator it, Predicate filter) { return new AbstractIterator() { - @Override - protected void computeNext() { + @Override protected void computeNext() { while (it.hasNext()) { T next = it.next(); if (filter.test(next)) { @@ -164,13 +159,11 @@ public static Iterator peek(Iterator iter, Consumer Iterator map(Iterator iter, Function mapper) { return new Iterator() { - @Override - public boolean hasNext() { + @Override public boolean hasNext() { return iter.hasNext(); } - @Override - public R next() { + @Override public R next() { return mapper.apply(iter.next()); } }; @@ -183,8 +176,7 @@ public static Iterable mapIterator(Iterable iter, Functio return () -> mapper.apply(iter.iterator()); } - @SafeVarargs - public static Iterator iterate(T... elements) { + @SafeVarargs public static Iterator iterate(T... elements) { return Arrays.asList(elements).iterator(); } @@ -196,13 +188,11 @@ public static Iterator concat(Iterator as, Iterator() { - @Override - public boolean hasNext() { + @Override public boolean hasNext() { return as.hasNext() || bs.hasNext(); } - @Override - public T next() { + @Override public T next() { return as.hasNext() ? as.next() : bs.next(); } }; @@ -246,8 +236,7 @@ public static List toList(Iterator it) { return new AbstractIterator() { T next = it.next(); - @Override - protected void computeNext() { + @Override protected void computeNext() { if (it.hasNext()) { setNext(next); next = it.next(); @@ -271,8 +260,7 @@ protected void computeNext() { return new AbstractIterator() { private int idx = 0; - @Override - protected void computeNext() { + @Override protected void computeNext() { if (it.hasNext()) { setNext((T) ringBuffer[idx]); // yield element X from the buffer ringBuffer[idx] = it.next(); // overwrite with the element X+n @@ -290,8 +278,7 @@ protected void computeNext() { * Coerce an iterator with a wildcard. This is safe because the Iterator * interface is covariant (not {@link ListIterator} though). */ - @SuppressWarnings("unchecked") - public static Iterator coerceWildcard(final Iterator it) { + @SuppressWarnings("unchecked") public static Iterator coerceWildcard(final Iterator it) { return (Iterator) it; } @@ -349,8 +336,7 @@ public static Iterator take(Iterator iterator, final int n) return new AbstractIterator() { private int yielded = 0; - @Override - protected void computeNext() { + @Override protected void computeNext() { if (yielded >= n || !iterator.hasNext()) { done(); } else { @@ -371,8 +357,7 @@ public static Iterator drop(Iterator source, final int n) { return new AbstractIterator() { private int yielded = 0; - @Override - protected void computeNext() { + @Override protected void computeNext() { while (yielded++ < n && source.hasNext()) { source.next(); } @@ -399,8 +384,7 @@ protected void computeNext() { return new AbstractIterator() { T next = seed; - @Override - protected void computeNext() { + @Override protected void computeNext() { if (next == null) { done(); return; @@ -453,13 +437,11 @@ public static Iterator singletonIterator(T value) { class SingletonIterator implements Iterator { private boolean done; - @Override - public boolean hasNext() { + @Override public boolean hasNext() { return !done; } - @Override - public T next() { + @Override public T next() { if (done) { throw new NoSuchElementException(); } @@ -467,8 +449,7 @@ public T next() { return value; } - @Override - public void forEachRemaining(Consumer action) { + @Override public void forEachRemaining(Consumer action) { action.accept(value); } } @@ -483,20 +464,17 @@ public static Iterable asReversed(final List lst) { ListIterator li = lst.listIterator(lst.size()); - @Override - public boolean hasNext() { + @Override public boolean hasNext() { return li.hasPrevious(); } - @Override - public T next() { + @Override public T next() { return li.previous(); } - @Override - public void remove() { + @Override public void remove() { li.remove(); } }; @@ -523,25 +501,23 @@ public abstract static class AbstractIterator implements Iterator { private T next = null; - @Override - public boolean hasNext() { + @Override public boolean hasNext() { switch (state) { - case DONE: - return false; - case READY: - return true; - default: - state = null; - computeNext(); - if (state == null) { - throw new IllegalStateException("Should have called done or setNext"); - } - return state == State.READY; + case DONE: + return false; + case READY: + return true; + default: + state = null; + computeNext(); + if (state == null) { + throw new IllegalStateException("Should have called done or setNext"); + } + return state == State.READY; } } - @Override - public T next() { + @Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } @@ -577,8 +553,7 @@ enum State { * @throws UnsupportedOperationException always, as the {@code remove} * operation is not supported by this iterator */ - @Override - public final void remove() { + @Override public final void remove() { throw new UnsupportedOperationException("remove"); } @@ -589,8 +564,7 @@ public abstract static class AbstractPausingIterator extends AbstractIterator private int numYielded = 0; private T currentValue; - @Override - public T next() { + @Override public T next() { T next = super.next(); currentValue = next; prepareViewOn(next); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/OptionalBool.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/OptionalBool.java index c820ce0c6fe..480bdb4a468 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/OptionalBool.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/OptionalBool.java @@ -18,12 +18,12 @@ public enum OptionalBool { */ public OptionalBool complement() { switch (this) { - case YES: - return NO; - case NO: - return YES; - default: - return this; + case YES: + return NO; + case NO: + return YES; + default: + return this; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java index 60ec003e578..2b35ee8198e 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/StringUtil.java @@ -303,8 +303,8 @@ public static List linesWithTrimIndent(Chars source) { public static void trimIndentInPlace(List lines) { int trimDepth = maxCommonLeadingWhitespaceForAll(lines); lines.replaceAll(chars -> chars.length() >= trimDepth - ? chars.subSequence(trimDepth).trimEnd() - : chars.trimEnd()); + ? chars.subSequence(trimDepth).trimEnd() + : chars.trimEnd()); } /** @@ -343,7 +343,7 @@ private static int countLeadingWhitespace(CharSequence s) { * @return true if the Strings are the same, false otherwise. */ public static boolean isSame(String s1, String s2, boolean trim, boolean ignoreCase, - boolean standardizeWhitespace) { + boolean standardizeWhitespace) { if (s1 == null && s2 == null) { return true; } else if (s1 == null || s2 == null) { @@ -403,8 +403,8 @@ public static String asString(Object[] items, String separator) { */ public static String removeSurrounding(String string, char delimiter) { if (string.length() >= 2 - && string.charAt(0) == delimiter - && string.charAt(string.length() - 1) == delimiter) { + && string.charAt(0) == delimiter + && string.charAt(string.length() - 1) == delimiter) { return string.substring(1, string.length() - 1); } return string; @@ -446,40 +446,40 @@ public static String escapeJava(String str) { for (int i = 0; i < str.length(); i++) { final char ch = str.charAt(i); switch (ch) { - case 0: - break; - case '\b': - retval.append("\\b"); - break; - case '\t': - retval.append("\\t"); - break; - case '\n': - retval.append("\\n"); - break; - case '\f': - retval.append("\\f"); - break; - case '\r': - retval.append("\\r"); - break; - case '\"': - retval.append("\\\""); - break; - case '\'': - retval.append("\\'"); - break; - case '\\': - retval.append("\\\\"); - break; - default: - if (ch < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u").append(s.substring(s.length() - 4)); - } else { - retval.append(ch); - } - break; + case 0: + break; + case '\b': + retval.append("\\b"); + break; + case '\t': + retval.append("\\t"); + break; + case '\n': + retval.append("\\n"); + break; + case '\f': + retval.append("\\f"); + break; + case '\r': + retval.append("\\r"); + break; + case '\"': + retval.append("\\\""); + break; + case '\'': + retval.append("\\'"); + break; + case '\\': + retval.append("\\\\"); + break; + default: + if (ch < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u").append(s.substring(s.length() - 4)); + } else { + retval.append(ch); + } + break; } } return retval.toString(); @@ -503,25 +503,21 @@ public static String nullToEmpty(final String value) { public enum CaseConvention { /** SCREAMING_SNAKE_CASE. */ SCREAMING_SNAKE_CASE { - @Override - List toWords(String name) { + @Override List toWords(String name) { return CollectionUtil.map(name.split("_"), s -> s.toLowerCase(Locale.ROOT)); } - @Override - String joinWords(List words) { + @Override String joinWords(List words) { return words.stream().map(s -> s.toUpperCase(Locale.ROOT)).collect(Collectors.joining("_")); } }, /** camelCase. */ CAMEL_CASE { - @Override - List toWords(String name) { + @Override List toWords(String name) { return PASCAL_CASE.toWords(name); } - @Override - String joinWords(List words) { + @Override String joinWords(List words) { if (words.isEmpty()) { return ""; } @@ -530,25 +526,21 @@ String joinWords(List words) { }, /** PascalCase. */ PASCAL_CASE { - @Override - List toWords(String name) { + @Override List toWords(String name) { return CollectionUtil.map(name.split("(? s.toLowerCase(Locale.ROOT)); } - @Override - String joinWords(List words) { + @Override String joinWords(List words) { return words.stream().map(StringUtils::capitalize).collect(Collectors.joining()); } }, /** space separated. */ SPACE_SEPARATED { - @Override - List toWords(String name) { + @Override List toWords(String name) { return CollectionUtil.map(name.split("\\s++"), s -> s.toLowerCase(Locale.ROOT)); } - @Override - String joinWords(List words) { + @Override String joinWords(List words) { return String.join(" ", words); } }; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBType.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBType.java index c0bf035948c..9d0208e28ad 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBType.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBType.java @@ -254,8 +254,7 @@ public static Properties getResourceBundleAsProperties(ResourceBundle resourceBu return properties; } - @Override - public int hashCode() { + @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((characterSet == null) ? 0 : characterSet.hashCode()); @@ -268,8 +267,7 @@ public int hashCode() { return result; } - @Override - public boolean equals(Object obj) { + @Override public boolean equals(Object obj) { if (this == obj) { return true; } @@ -405,8 +403,7 @@ public void setProperties(Properties properties) { } - @Override - public String toString() { + @Override public String toString() { return DBType.class.getCanonicalName() + "@" + propertiesSource; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBURI.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBURI.java index 1a5b2ac8564..4bd554dcdfc 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBURI.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/DBURI.java @@ -509,8 +509,7 @@ private void setFields() throws URISyntaxException, IOException { } - @Override - public String toString() { + @Override public String toString() { return uri.toASCIIString(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/ResourceResolver.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/ResourceResolver.java index 233157831bc..0d405ec772b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/ResourceResolver.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/ResourceResolver.java @@ -10,8 +10,7 @@ import javax.xml.transform.stream.StreamSource; public class ResourceResolver implements URIResolver { - @Override - public Source resolve(String href, String base) throws TransformerException { + @Override public Source resolve(String href, String base) throws TransformerException { if (null == href || href.length() == 0) { return null; // will make Oracle XSLT processor explode, // even though it's correct diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/SourceObject.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/SourceObject.java index 1e2112c3157..6eba466de70 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/database/SourceObject.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/database/SourceObject.java @@ -56,8 +56,7 @@ public class SourceObject { this.revision = revision; } - @Override - public String toString() { + @Override public String toString() { return String.format("schema=\"%s\",type=\"%s\",name=\"%s\",revision=\"%s\"", this.getSchema(), this.getType(), this.getName(), this.getRevision()); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/designerbindings/DesignerBindings.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/designerbindings/DesignerBindings.java index 03a58ab3bff..ef4410afe44 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/designerbindings/DesignerBindings.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/designerbindings/DesignerBindings.java @@ -134,18 +134,15 @@ class DefaultDesignerBindings implements DesignerBindings { private static final DefaultDesignerBindings INSTANCE = new DefaultDesignerBindings(); - @Override - public RelatedNodesSelector getRelatedNodesSelector() { + @Override public RelatedNodesSelector getRelatedNodesSelector() { return null; } - @Override - public Collection getAdditionalInfo(Node node) { + @Override public Collection getAdditionalInfo(Node node) { return Collections.emptyList(); } - @Override - public Attribute getMainAttribute(Node node) { + @Override public Attribute getMainAttribute(Node node) { String image = node.getImage(); if (image != null) { return new Attribute(node, "Image", image); @@ -153,13 +150,11 @@ public Attribute getMainAttribute(Node node) { return null; } - @Override - public boolean isExpandedByDefaultInTree(Node node) { + @Override public boolean isExpandedByDefaultInTree(Node node) { return true; } - @Override - public TreeIconId getIcon(Node node) { + @Override public TreeIconId getIcon(Node node) { return null; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/internal/xml/SchemaConstant.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/internal/xml/SchemaConstant.java index 399d4f3d2d7..6097d55d6d1 100755 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/internal/xml/SchemaConstant.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/internal/xml/SchemaConstant.java @@ -79,12 +79,12 @@ public boolean hasAttribute(Element element) { public List getChildrenIn(Element elt) { return XmlUtil.getElementChildrenNamed(elt, name) - .collect(Collectors.toList()); + .collect(Collectors.toList()); } public List getElementChildrenNamedReportOthers(Element elt, PmdXmlReporter err) { return XmlUtil.getElementChildrenNamedReportOthers(elt, setOf(this), err) - .collect(Collectors.toList()); + .collect(Collectors.toList()); } public @NonNull Element getSingleChildIn(Element elt, PmdXmlReporter err) { @@ -109,8 +109,7 @@ public String xmlName() { } - @Override - public String toString() { + @Override public String toString() { return xmlName(); } @@ -119,8 +118,7 @@ public boolean matchesElt(Node node) { return node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals(name); } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } @@ -131,8 +129,7 @@ public boolean equals(Object o) { return Objects.equals(name, that.name); } - @Override - public int hashCode() { + @Override public int hashCode() { return Objects.hash(name); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/internal/xml/XmlUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/internal/xml/XmlUtil.java index 695f203e6d6..c6f1923871f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/internal/xml/XmlUtil.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/internal/xml/XmlUtil.java @@ -32,8 +32,8 @@ private XmlUtil() { public static Stream getElementChildren(Element parent) { return DomUtils.asList(parent.getChildNodes()).stream() - .filter(it -> it.getNodeType() == Node.ELEMENT_NODE) - .map(Element.class::cast); + .filter(it -> it.getNodeType() == Node.ELEMENT_NODE) + .map(Element.class::cast); } public static List getElementChildrenList(Element parent) { @@ -46,14 +46,14 @@ public static Stream getElementChildrenNamed(Element parent, Set getElementChildrenNamedReportOthers(Element parent, Set names, PmdXmlReporter err) { return getElementChildren(parent) - .map(it -> { - if (matchesName(it, names)) { - return it; - } else { - err.at(it).warn(IGNORED__UNEXPECTED_ELEMENT_IN, it.getTagName(), formatPossibleNames(names)); - return null; - } - }).filter(Objects::nonNull); + .map(it -> { + if (matchesName(it, names)) { + return it; + } else { + err.at(it).warn(IGNORED__UNEXPECTED_ELEMENT_IN, it.getTagName(), formatPossibleNames(names)); + return null; + } + }).filter(Objects::nonNull); } public static boolean matchesName(Element elt, Set names) { @@ -61,13 +61,13 @@ public static boolean matchesName(Element elt, Set names) { } public static void reportIgnoredUnexpectedElt(Element parent, - Element unexpectedChild, - Set names, - PmdXmlReporter err) { + Element unexpectedChild, + Set names, + PmdXmlReporter err) { err.at(unexpectedChild).warn(IGNORED__UNEXPECTED_ELEMENT, - unexpectedChild.getTagName(), - parent.getTagName(), - formatPossibleNames(names)); + unexpectedChild.getTagName(), + parent.getTagName(), + formatPossibleNames(names)); } public static Stream getElementChildrenNamed(Element parent, String name) { @@ -113,9 +113,9 @@ public static Set toConstants(Set names) { return StringUtil.inSingleQuotes(names.iterator().next().xmlName()); } else { return "one of " + names.stream() - .map(SchemaConstant::xmlName) - .map(StringUtil::inSingleQuotes) - .collect(Collectors.joining(", ")); + .map(SchemaConstant::xmlName) + .map(StringUtil::inSingleQuotes) + .collect(Collectors.joining(", ")); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/ErrorsAsWarningsReporter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/ErrorsAsWarningsReporter.java index 9befa9e29f6..8fa9a43dc44 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/ErrorsAsWarningsReporter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/ErrorsAsWarningsReporter.java @@ -21,16 +21,14 @@ public ErrorsAsWarningsReporter(PmdReporter backend) { this.backend = backend; } - @Override - protected boolean isLoggableImpl(Level level) { + @Override protected boolean isLoggableImpl(Level level) { if (level == Level.ERROR) { level = Level.WARN; } return super.isLoggableImpl(level); } - @Override - protected void logImpl(Level level, String message) { + @Override protected void logImpl(Level level, String message) { if (level == Level.ERROR) { level = Level.WARN; } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/MessageReporterBase.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/MessageReporterBase.java index 617b1502379..793ba685d12 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/MessageReporterBase.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/MessageReporterBase.java @@ -33,19 +33,17 @@ public final void setLevel(@Nullable Level minLevel) { this.minLevel = minLevel; } - @Override - public final boolean isLoggable(Level level) { + @Override public final boolean isLoggable(Level level) { return minLevel != null - && minLevel.compareTo(level) >= 0 - && isLoggableImpl(level); + && minLevel.compareTo(level) >= 0 + && isLoggableImpl(level); } protected boolean isLoggableImpl(Level level) { return true; } - @Override - public void logEx(Level level, @Nullable String message, Object[] formatArgs, @Nullable Throwable error) { + @Override public void logEx(Level level, @Nullable String message, Object[] formatArgs, @Nullable Throwable error) { if (isLoggable(level)) { if (error == null) { Objects.requireNonNull(message, "cannot call this method with null message and error"); @@ -81,8 +79,7 @@ public void logEx(Level level, @Nullable String message, Object[] formatArgs, @N return errorMessage; } - @Override - public final void log(Level level, String message, Object... formatArgs) { + @Override public final void log(Level level, String message, Object... formatArgs) { if (level == Level.ERROR) { this.numErrors++; } @@ -97,8 +94,7 @@ public final void log(Level level, String message, Object... formatArgs) { protected abstract void logImpl(Level level, String message); - @Override - public int numErrors() { + @Override public int numErrors() { return numErrors; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/QuietReporter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/QuietReporter.java index b60bba7b463..c5b4acb48ee 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/QuietReporter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/QuietReporter.java @@ -18,13 +18,11 @@ public class QuietReporter extends MessageReporterBase implements PmdReporter { // note: not singleton because PmdLogger accumulates error count. // note: not final because used as mock in tests. - @Override - protected boolean isLoggableImpl(Level level) { + @Override protected boolean isLoggableImpl(Level level) { return false; } - @Override - protected void logImpl(Level level, String message) { + @Override protected void logImpl(Level level, String message) { // noop } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/SimpleMessageReporter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/SimpleMessageReporter.java index fd6189dbe67..0a674136a38 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/SimpleMessageReporter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/log/internal/SimpleMessageReporter.java @@ -22,44 +22,42 @@ public SimpleMessageReporter(Logger backend) { this.backend = backend; } - @Override - protected boolean isLoggableImpl(Level level) { + @Override protected boolean isLoggableImpl(Level level) { switch (level) { - case ERROR: - return backend.isErrorEnabled(); - case WARN: - return backend.isWarnEnabled(); - case INFO: - return backend.isInfoEnabled(); - case DEBUG: - return backend.isDebugEnabled(); - case TRACE: - return backend.isTraceEnabled(); - default: - return false; + case ERROR: + return backend.isErrorEnabled(); + case WARN: + return backend.isWarnEnabled(); + case INFO: + return backend.isInfoEnabled(); + case DEBUG: + return backend.isDebugEnabled(); + case TRACE: + return backend.isTraceEnabled(); + default: + return false; } } - @Override - protected void logImpl(Level level, String message) { + @Override protected void logImpl(Level level, String message) { switch (level) { - case ERROR: - backend.error(message); - break; - case WARN: - backend.warn(message); - break; - case INFO: - backend.info(message); - break; - case DEBUG: - backend.debug(message); - break; - case TRACE: - backend.trace(message); - break; - default: - throw new AssertionError("Invalid log level: " + level); + case ERROR: + backend.error(message); + break; + case WARN: + backend.warn(message); + break; + case INFO: + backend.info(message); + break; + case DEBUG: + backend.debug(message); + break; + case TRACE: + backend.trace(message); + break; + default: + throw new AssertionError("Invalid log level: " + level); } } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/Io.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/Io.java index 2ff20bac747..f542ff0fce2 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/Io.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/Io.java @@ -23,7 +23,7 @@ final class Io { this.stderr = stderr; this.stdin = stdin; } - + public static Io system() { return new Io(System.out, System.err, System.in); } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TextTreeRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TextTreeRenderer.java index 18c1fa19651..98f9ca43384 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TextTreeRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TextTreeRenderer.java @@ -50,28 +50,25 @@ public class TextTreeRenderer implements TreeRenderer { static final TreeRendererDescriptor DESCRIPTOR = new TreeRendererDescriptor() { private final PropertyDescriptor onlyAscii = - PropertyFactory.booleanProperty("onlyAsciiChars") - .defaultValue(false) - .desc("Use only ASCII characters in the structure") - .build(); + PropertyFactory.booleanProperty("onlyAsciiChars") + .defaultValue(false) + .desc("Use only ASCII characters in the structure") + .build(); private final PropertyDescriptor maxLevel = - PropertyFactory.intProperty("maxLevel") - .defaultValue(-1) - .desc("Max level on which to recurse. Negative means unbounded") - .build(); + PropertyFactory.intProperty("maxLevel") + .defaultValue(-1) + .desc("Max level on which to recurse. Negative means unbounded") + .build(); - @Override - public PropertySource newPropertyBundle() { + @Override public PropertySource newPropertyBundle() { PropertySource bundle = new AbstractPropertySource() { - @Override - protected String getPropertySourceType() { + @Override protected String getPropertySourceType() { return "tree renderer"; } - @Override - public String getName() { + @Override public String getName() { return "text"; } }; @@ -82,18 +79,15 @@ public String getName() { return bundle; } - @Override - public String id() { + @Override public String id() { return "text"; } - @Override - public String description() { + @Override public String description() { return "Text renderer"; } - @Override - public TreeRenderer produceRenderer(PropertySource properties) { + @Override public TreeRenderer produceRenderer(PropertySource properties) { return new TextTreeRenderer(properties.getProperty(onlyAscii), properties.getProperty(maxLevel)); } }; @@ -117,8 +111,7 @@ public TextTreeRenderer(boolean onlyAscii, int maxLevel) { this.maxLevel = maxLevel; } - @Override - public void renderSubtree(Node node, Appendable out) throws IOException { + @Override public void renderSubtree(Node node, Appendable out) throws IOException { printInnerNode(node, out, 0, "", true); } @@ -142,10 +135,10 @@ protected void appendNodeInfoLn(Appendable out, Node node) throws IOException { private void printInnerNode(Node node, - Appendable out, - int level, - String prefix, - boolean isTail) throws IOException { + Appendable out, + int level, + String prefix, + boolean isTail) throws IOException { appendIndent(out, prefix, isTail); appendNodeInfoLn(out, node); @@ -179,16 +172,16 @@ protected void appendBoundaryForNodeLn(Node node, Appendable out, String indentS private static final class Strings { private static final Strings ASCII = new Strings( - "+- ", - "+- ", - "| ", - " " + "+- ", + "+- ", + "| ", + " " ); private static final Strings UNICODE = new Strings( - "└─ ", - "├─ ", - "│ ", - " " + "└─ ", + "├─ ", + "│ ", + " " ); private final String tailFork; diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExportConfiguration.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExportConfiguration.java index d36f79aa9c0..debf2ce4d5a 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExportConfiguration.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExportConfiguration.java @@ -47,7 +47,7 @@ public Language getLanguage() { public Properties getProperties() { return properties; } - + public Path getFile() { return file; } @@ -59,15 +59,15 @@ public Properties getLanguageProperties() { public boolean isReadStdin() { return readStdin; } - + public void setFormat(String format) { this.format = format; } - + public void setLanguage(Language language) { this.language = language; } - + public void setProperties(Properties properties) { this.properties = properties; } @@ -79,7 +79,7 @@ public void setLanguageProperties(Properties properties) { public void setFile(Path file) { this.file = file; } - + public void setReadStdin(boolean readStdin) { this.readStdin = readStdin; } @@ -92,18 +92,15 @@ public void setMessageReporter(PmdReporter messageReporter) { this.messageReporter = messageReporter; } - @Override - public List getRelativizeRoots() { + @Override public List getRelativizeRoots() { throw new UnsupportedOperationException(); } - @Override - public void addRelativizeRoot(Path path) { + @Override public void addRelativizeRoot(Path path) { throw new UnsupportedOperationException(); } - @Override - public void addRelativizeRoots(List paths) { + @Override public void addRelativizeRoots(List paths) { throw new UnsupportedOperationException(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExporter.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExporter.java index 60a7f7a52f1..1d104fc3aaa 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExporter.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeExporter.java @@ -33,16 +33,16 @@ public class TreeExporter { private final TreeExportConfiguration configuration; private final Io io; - + public TreeExporter(final TreeExportConfiguration configuration) { this(configuration, Io.system()); } - + TreeExporter(final TreeExportConfiguration configuration, final Io io) { this.configuration = configuration; this.io = io; } - + public void export() throws IOException { TreeRendererDescriptor descriptor = TreeRenderers.findById(configuration.getFormat()); if (descriptor == null) { @@ -54,20 +54,18 @@ public void export() throws IOException { LanguageRegistry lang = LanguageRegistry.PMD.getDependenciesOf(configuration.getLanguage()); try (LanguageProcessorRegistry lpRegistry = LanguageProcessorRegistry.create(lang, - Collections.singletonMap(configuration.getLanguage(), langProperties), - configuration.getMessageReporter())) { + Collections.singletonMap(configuration.getLanguage(), langProperties), + configuration.getMessageReporter())) { run(lpRegistry, descriptor.produceRenderer(bundle)); } } - + private void run(LanguageProcessorRegistry langRegistry, final TreeRenderer renderer) throws IOException { LanguageVersion langVersion = configuration.getLanguage().getDefaultVersion(); - @SuppressWarnings("PMD.CloseResource") - LanguageProcessor processor = langRegistry.getProcessor(configuration.getLanguage()); + @SuppressWarnings("PMD.CloseResource") LanguageProcessor processor = langRegistry.getProcessor(configuration.getLanguage()); Parser parser = processor.services().getParser(); - @SuppressWarnings("PMD.CloseResource") - TextFile textFile; + @SuppressWarnings("PMD.CloseResource") TextFile textFile; if (configuration.isReadStdin()) { io.stderr.println("Reading from stdin..."); textFile = TextFile.forReader(readFromSystemIn(), FileId.STDIN, langVersion); @@ -103,11 +101,11 @@ private T parseProperties(T bundle, Properties proper } return bundle; } - + private void setProperty(PropertyDescriptor descriptor, PropertySource bundle, String value) { bundle.setProperty(descriptor, descriptor.serializer().fromString(value)); } - + private AbortedException bail(String message) { io.stderr.println(message); io.stderr.println("Use --help for usage information"); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRendererDescriptorImpl.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRendererDescriptorImpl.java index 0ebe81504c6..92af99385e7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRendererDescriptorImpl.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRendererDescriptorImpl.java @@ -23,8 +23,7 @@ protected TreeRendererDescriptorImpl(String id, String description) { } - @Override - public PropertySource newPropertyBundle() { + @Override public PropertySource newPropertyBundle() { return new PropertyBundle(id, availableDescriptors()); } @@ -33,22 +32,19 @@ protected Set> availableDescriptors() { return Collections.emptySet(); } - @Override - public String id() { + @Override public String id() { return id; } - @Override - public String description() { + @Override public String description() { return description; } - @Override - public String toString() { + @Override public String toString() { return "TreeDescriptorImpl{" - + "id='" + id + '\'' - + ", description='" + description + '\'' - + '}'; + + "id='" + id + '\'' + + ", description='" + description + '\'' + + '}'; } private static class PropertyBundle extends AbstractPropertySource { @@ -57,20 +53,18 @@ private static class PropertyBundle extends AbstractPropertySource { private final String name; PropertyBundle(String name, - Set> available) { + Set> available) { this.name = name; for (PropertyDescriptor p : available) { definePropertyDescriptor(p); } } - @Override - public String getName() { + @Override public String getName() { return name; } - @Override - protected String getPropertySourceType() { + @Override protected String getPropertySourceType() { return "tree renderer"; } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRenderers.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRenderers.java index 2b6dc0399c4..ea86793aeb1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRenderers.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/TreeRenderers.java @@ -34,67 +34,64 @@ public final class TreeRenderers { // descriptors are test only static final PropertyDescriptor XML_RENDER_PROLOG = - PropertyFactory.booleanProperty("renderProlog") - .desc("True to output a prolog") - .defaultValue(true) - .build(); + PropertyFactory.booleanProperty("renderProlog") + .desc("True to output a prolog") + .defaultValue(true) + .build(); static final PropertyDescriptor XML_USE_SINGLE_QUOTES = - PropertyFactory.booleanProperty("singleQuoteAttributes") - .desc("Use single quotes to delimit attribute values") - .defaultValue(true) - .build(); + PropertyFactory.booleanProperty("singleQuoteAttributes") + .desc("Use single quotes to delimit attribute values") + .defaultValue(true) + .build(); static final PropertyDescriptor XML_LINE_SEPARATOR = - PropertyFactory.stringProperty("lineSeparator") - .desc("Line separator to use. The default is platform-specific. " - + "The values 'CR', 'CRLF', 'LF', '\\r', '\\r\\n' and '\\n' can be used " - + "to represent a carriage return, line feed and their combination more easily.") - .defaultValue(System.lineSeparator()) - .build(); + PropertyFactory.stringProperty("lineSeparator") + .desc("Line separator to use. The default is platform-specific. " + + "The values 'CR', 'CRLF', 'LF', '\\r', '\\r\\n' and '\\n' can be used " + + "to represent a carriage return, line feed and their combination more easily.") + .defaultValue(System.lineSeparator()) + .build(); static final PropertyDescriptor XML_RENDER_COMMON_ATTRIBUTES = - PropertyFactory.booleanProperty("renderCommonAttributes") - .desc("True to render attributes like BeginLine, EndLine, etc.") - .defaultValue(false) - .build(); + PropertyFactory.booleanProperty("renderCommonAttributes") + .desc("True to render attributes like BeginLine, EndLine, etc.") + .defaultValue(false) + .build(); static final TreeRendererDescriptor XML = - new TreeRendererDescriptorImpl("xml", "XML format with the same structure as the one used in XPath") { + new TreeRendererDescriptorImpl("xml", "XML format with the same structure as the one used in XPath") { - private final Set> myDescriptors - = Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.>asList( - XML_USE_SINGLE_QUOTES, XML_LINE_SEPARATOR, XML_RENDER_PROLOG, XML_RENDER_COMMON_ATTRIBUTES - ))); + private final Set> myDescriptors + = Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.>asList( + XML_USE_SINGLE_QUOTES, XML_LINE_SEPARATOR, XML_RENDER_PROLOG, XML_RENDER_COMMON_ATTRIBUTES + ))); - @Override - protected Set> availableDescriptors() { - return myDescriptors; - } + @Override protected Set> availableDescriptors() { + return myDescriptors; + } - @Override - public TreeRenderer produceRenderer(final PropertySource properties) { + @Override public TreeRenderer produceRenderer(final PropertySource properties) { - XmlRenderingConfig config = - new XmlRenderingConfig() { + XmlRenderingConfig config = + new XmlRenderingConfig() { - private final List excluded = Arrays.asList("BeginLine", "BeginColumn", "EndLine", "EndColumn", "SingleLine", "FindBoundary"); + private final List excluded = Arrays.asList("BeginLine", "BeginColumn", "EndLine", "EndColumn", "SingleLine", "FindBoundary"); - @Override - protected boolean takeAttribute(Node node, Attribute attribute) { - return properties.getProperty(XML_RENDER_COMMON_ATTRIBUTES) - || !excluded.contains(attribute.getName()); - } - } - .singleQuoteAttributes(properties.getProperty(XML_USE_SINGLE_QUOTES)) - .renderProlog(properties.getProperty(XML_RENDER_PROLOG)) - .lineSeparator(properties.getProperty(XML_LINE_SEPARATOR)); + @Override protected boolean takeAttribute(Node node, Attribute attribute) { + return properties.getProperty(XML_RENDER_COMMON_ATTRIBUTES) + || !excluded.contains(attribute.getName()); + } + } + .singleQuoteAttributes(properties.getProperty(XML_USE_SINGLE_QUOTES)) + .renderProlog(properties.getProperty(XML_RENDER_PROLOG)) + .lineSeparator(properties.getProperty(XML_LINE_SEPARATOR)); - return new XmlTreeRenderer(config); - } - }; + return new XmlTreeRenderer(config); + } + }; private static final Map REGISTRY = new ConcurrentHashMap<>(); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/XmlTreeRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/XmlTreeRenderer.java index 9d1e1eacd2a..ba1e23c0241 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/XmlTreeRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/treeexport/XmlTreeRenderer.java @@ -73,8 +73,7 @@ public XmlTreeRenderer() { * @throws IllegalArgumentException If some node has attributes or * a name that is not a valid XML name */ - @Override - public void renderSubtree(Node node, Appendable out) throws IOException { + @Override public void renderSubtree(Node node, Appendable out) throws IOException { if (strategy.renderProlog) { renderProlog(out); } @@ -84,8 +83,8 @@ public void renderSubtree(Node node, Appendable out) throws IOException { private void renderProlog(Appendable out) throws IOException { out.append("").append(strategy.lineSeparator); + .append(" encoding=").append(attrDelim).append("UTF-8").append(attrDelim) + .append(" ?>").append(strategy.lineSeparator); } private void renderSubtree(int depth, Node node, Appendable out) throws IOException { @@ -125,11 +124,11 @@ private void appendAttribute(Appendable out, String name, String value) throws I checkValidName(name); out.append(' ') - .append(name) - .append('=') - .append(attrDelim) - .append(escapeXmlAttribute(value, strategy.singleQuoteAttributes)) - .append(attrDelim); + .append(name) + .append('=') + .append(attrDelim) + .append(escapeXmlAttribute(value, strategy.singleQuoteAttributes)) + .append(attrDelim); } private void checkValidName(String name) { @@ -147,14 +146,14 @@ private Appendable indent(int depth, Appendable out) throws IOException { private static String escapeXmlText(String xml) { return xml.replaceAll("<", "<") - .replaceAll("&", "&"); + .replaceAll("&", "&"); } private static String escapeXmlAttribute(String xml, boolean isSingleQuoted) { return isSingleQuoted ? escapeXmlText(xml).replaceAll("'", "'") - : escapeXmlText(xml).replaceAll("\"", """); + : escapeXmlText(xml).replaceAll("\"", """); } private static boolean isValidXmlName(String xml) { @@ -233,17 +232,17 @@ public XmlRenderingConfig lineSeparator(String lineSeparator) { private static String interpretLineSep(String lineSeparator) { switch (lineSeparator) { - case "CR": - case "\\r": - return "\r"; - case "CRLF": - case "\\r\\n": - return "\r\n"; - case "LF": - case "\\n": - return "\n"; - default: - return lineSeparator; + case "CR": + case "\\r": + return "\r"; + case "CRLF": + case "\\r\\n": + return "\r\n"; + case "LF": + case "\\n": + return "\n"; + default: + return lineSeparator; } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java index 868f2e657a0..2f8426cb06e 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/AbstractRuleTest.java @@ -55,8 +55,7 @@ private static class MyRule extends AbstractRule { setProperty(FOO_PROPERTY, "value"); } - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { } } @@ -71,16 +70,13 @@ private static class MyOtherRule extends AbstractRule { setProperty(FOO_PROPERTY, "value"); } - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { } } - @RegisterExtension - private final DummyParsingHelper helper = new DummyParsingHelper(); + @RegisterExtension private final DummyParsingHelper helper = new DummyParsingHelper(); - @Test - void testCreateRV() { + @Test void testCreateRV() { MyRule r = new MyRule(); r.setRuleSetName("foo"); DummyRootNode s = helper.parse("abc()", FileId.fromPathLikeString("abc")); @@ -94,8 +90,7 @@ void testCreateRV() { }, r).addViolation(s); } - @Test - void testCreateRV2() { + @Test void testCreateRV2() { MyRule r = new MyRule(); DummyRootNode s = helper.parse("abc()", FileId.fromPathLikeString("filename")); @@ -107,11 +102,9 @@ void testCreateRV2() { }, r).addViolationWithMessage(s, "specificdescription"); } - @Test - void testRuleWithVariableInMessage() { + @Test void testRuleWithVariableInMessage() { MyRule r = new MyRule() { - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { ctx.addViolation(target); } }; @@ -124,8 +117,7 @@ public void apply(Node target, RuleContext ctx) { assertEquals("Message foo ${className} ${methodName} ${variableName} 10 ${noSuchProperty}", rv.getDescription()); } - @Test - void testRuleSuppress() { + @Test void testRuleSuppress() { DummyRootNode n = helper.parse("abc()", FileId.UNKNOWN); n = n.withNoPmdComments(new SuppressionCommentImpl<>(n, "ohio")); @@ -137,57 +129,49 @@ void testRuleSuppress() { verify(listener, times(1)).onSuppressedRuleViolation(any()); } - @Test - void testEquals1() { + @Test void testEquals1() { MyRule r = new MyRule(); assertFalse(r.equals(null), "A rule is never equals to null!"); } - @Test - void testEquals2() { + @Test void testEquals2() { MyRule r = new MyRule(); assertEquals(r, r, "A rule must be equals to itself"); } - @Test - void testEquals3() { + @Test void testEquals3() { MyRule r1 = new MyRule(); MyRule r2 = new MyRule(); assertEquals(r1, r2, "Two instances of the same rule are equal"); assertEquals(r1.hashCode(), r2.hashCode(), "Hashcode for two instances of the same rule must be equal"); } - @Test - void testEquals4() { + @Test void testEquals4() { MyRule myRule = new MyRule(); assertFalse(myRule.equals("MyRule"), "A rule cannot be equal to an object of another class"); } - @Test - void testEquals5() { + @Test void testEquals5() { MyRule myRule = new MyRule(); MyOtherRule myOtherRule = new MyOtherRule(); assertFalse(myRule.equals(myOtherRule), "Two rules from different classes cannot be equal"); } - @Test - void testEquals6() { + @Test void testEquals6() { MyRule r1 = new MyRule(); MyRule r2 = new MyRule(); r2.setName("MyRule2"); assertFalse(r1.equals(r2), "Rules with different names cannot be equal"); } - @Test - void testEquals7() { + @Test void testEquals7() { MyRule r1 = new MyRule(); MyRule r2 = new MyRule(); r2.setPriority(RulePriority.HIGH); assertFalse(r1.equals(r2), "Rules with different priority levels cannot be equal"); } - @Test - void testEquals8() { + @Test void testEquals8() { MyRule r1 = new MyRule(); r1.setProperty(MyRule.XPATH_PROPERTY, "something"); MyRule r2 = new MyRule(); @@ -195,16 +179,14 @@ void testEquals8() { assertFalse(r1.equals(r2), "Rules with different properties values cannot be equal"); } - @Test - void testEquals9() { + @Test void testEquals9() { MyRule r1 = new MyRule(); MyRule r2 = new MyRule(); r2.setProperty(MyRule.XPATH_PROPERTY, "something else"); assertFalse(r1.equals(r2), "Rules with different properties cannot be equal"); } - @Test - void testEquals10() { + @Test void testEquals10() { MyRule r1 = new MyRule(); MyRule r2 = new MyRule(); r2.setMessage("another message"); @@ -212,8 +194,7 @@ void testEquals10() { assertEquals(r1.hashCode(), r2.hashCode(), "Rules that are equal must have the an equal hashcode"); } - @Test - void twoRulesUsingPatternPropertiesShouldBeEqual() { + @Test void twoRulesUsingPatternPropertiesShouldBeEqual() { class MockRuleWithPatternProperty extends net.sourceforge.pmd.lang.rule.MockRule { MockRuleWithPatternProperty(String defaultValue) { super(); @@ -243,8 +224,7 @@ class MockRuleWithPatternProperty extends net.sourceforge.pmd.lang.rule.MockRule assertEquals(new MockRuleWithPatternProperty("jkl"), rule2); } - @Test - void testDeepCopyRule() { + @Test void testDeepCopyRule() { MyRule r1 = new MyRule(); MyRule r2 = (MyRule) r1.deepCopy(); assertEquals(r1.getDescription(), r2.getDescription()); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/DummyParsingHelper.java b/pmd-core/src/test/java/net/sourceforge/pmd/DummyParsingHelper.java index aa0da9ba920..3eee16f196c 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/DummyParsingHelper.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/DummyParsingHelper.java @@ -45,23 +45,21 @@ public DummyRootNode parse(String code, String filename) { public DummyRootNode parse(String code, FileId filename) { LanguageVersion version = DummyLanguageModule.getInstance().getDefaultVersion(); ParserTask task = new ParserTask( - TextDocument.readOnlyString(code, filename, version), - SemanticErrorReporter.noop(), - LanguageProcessorRegistry.singleton(dummyProcessor)); + TextDocument.readOnlyString(code, filename, version), + SemanticErrorReporter.noop(), + LanguageProcessorRegistry.singleton(dummyProcessor)); return (DummyRootNode) dummyProcessor.services().getParser().parse(task); } - @Override - public void afterEach(ExtensionContext context) throws Exception { + @Override public void afterEach(ExtensionContext context) throws Exception { dummyProcessor.close(); } - @Override - public void beforeEach(ExtensionContext context) throws Exception { + @Override public void beforeEach(ExtensionContext context) throws Exception { LanguageProcessorRegistry registry = LanguageProcessorRegistry.create( - LanguageRegistry.PMD, - Collections.emptyMap(), - PmdReporter.quiet() + LanguageRegistry.PMD, + Collections.emptyMap(), + PmdReporter.quiet() ); dummyProcessor = registry.getProcessor(DummyLanguageModule.getInstance()); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/FileSelectorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/FileSelectorTest.java index bb3b5ecf626..5ae6c860554 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/FileSelectorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/FileSelectorTest.java @@ -24,8 +24,7 @@ class FileSelectorTest { /** * Test wanted selection of a source file. */ - @Test - void testWantedFile() { + @Test void testWantedFile() { LanguageFilenameFilter fileSelector = new LanguageFilenameFilter(DummyLanguageModule.getInstance()); File javaFile = new File("/path/to/myFile.dummy"); @@ -37,8 +36,7 @@ void testWantedFile() { /** * Test unwanted selection of a non source file. */ - @Test - void testUnwantedFile() { + @Test void testUnwantedFile() { LanguageFilenameFilter fileSelector = new LanguageFilenameFilter(DummyLanguageModule.getInstance()); File javaFile = new File("/path/to/myFile.notdummy"); @@ -50,8 +48,7 @@ void testUnwantedFile() { /** * Test unwanted selection of a java file. */ - @Test - void testUnwantedJavaFile() { + @Test void testUnwantedJavaFile() { LanguageFilenameFilter fileSelector = new LanguageFilenameFilter(DummyLanguageModule.getInstance()); File javaFile = new File("/path/to/MyClass.java"); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java b/pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java index 3b3141baadb..cdb6b357717 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/FooRule.java @@ -25,23 +25,19 @@ public FooRule() { setLanguage(DummyLanguageModule.getInstance()); } - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forXPathNames(setOf("dummyNode", "dummyRootNode")); } - @Override - public String getMessage() { + @Override public String getMessage() { return "blah"; } - @Override - public String getRuleSetName() { + @Override public String getRuleSetName() { return "RuleSet"; } - @Override - public void apply(Node node, RuleContext ctx) { + @Override public void apply(Node node, RuleContext ctx) { for (int i = 0; i < node.getNumChildren(); i++) { apply(node.getChild(i), ctx); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/InternalApiBridgeForTestsOnly.java b/pmd-core/src/test/java/net/sourceforge/pmd/InternalApiBridgeForTestsOnly.java index f12d571d01a..3c27430474d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/InternalApiBridgeForTestsOnly.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/InternalApiBridgeForTestsOnly.java @@ -20,7 +20,8 @@ */ @InternalApi public final class InternalApiBridgeForTestsOnly { - private InternalApiBridgeForTestsOnly() {} + private InternalApiBridgeForTestsOnly() { + } public static void setAnalysisCache(PMDConfiguration pmdConfiguration, AnalysisCache cache) { pmdConfiguration.setAnalysisCache(cache); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java index 4a471ce2dc2..9f93c65c9be 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdAnalysisTest.java @@ -43,8 +43,7 @@ */ class PmdAnalysisTest { - @Test - void testPmdAnalysisWithEmptyConfig() { + @Test void testPmdAnalysisWithEmptyConfig() { PMDConfiguration config = new PMDConfiguration(); try (PmdAnalysis pmd = PmdAnalysis.create(config)) { assertThat(pmd.files().getCollectedFiles(), empty()); @@ -53,8 +52,7 @@ void testPmdAnalysisWithEmptyConfig() { } } - @Test - void testRendererInteractions() throws IOException { + @Test void testRendererInteractions() throws IOException { PMDConfiguration config = new PMDConfiguration(); config.addInputPath(Paths.get("sample-source/dummy")); Renderer renderer = spy(Renderer.class); @@ -70,8 +68,7 @@ void testRendererInteractions() throws IOException { verify(renderer, times(1)).flush(); } - @Test - void testRulesetLoading() { + @Test void testRulesetLoading() { PMDConfiguration config = new PMDConfiguration(); config.addRuleSet("rulesets/dummy/basic.xml"); try (PmdAnalysis pmd = PmdAnalysis.create(config)) { @@ -79,8 +76,7 @@ void testRulesetLoading() { } } - @Test - void testRulesetWhenSomeoneHasAnError() { + @Test void testRulesetWhenSomeoneHasAnError() { PMDConfiguration config = new PMDConfiguration(); config.addRuleSet("rulesets/dummy/basic.xml"); config.addRuleSet("rulesets/xxxe/notaruleset.xml"); @@ -90,8 +86,7 @@ void testRulesetWhenSomeoneHasAnError() { } } - @Test - void testParseException() { + @Test void testParseException() { PMDConfiguration config = new PMDConfiguration(); config.setThreads(1); config.setForceLanguageVersion(DummyLanguageModule.getInstance().getVersionWhereParserThrows()); @@ -105,8 +100,7 @@ void testParseException() { } } - @Test - void testRuleFailureDuringInitialization() { + @Test void testRuleFailureDuringInitialization() { PMDConfiguration config = new PMDConfiguration(); config.setThreads(1); PmdReporter mockReporter = spy(PmdReporter.quiet()); @@ -114,8 +108,7 @@ void testRuleFailureDuringInitialization() { try (PmdAnalysis pmd = PmdAnalysis.create(config)) { pmd.addRuleSet(RuleSet.forSingleRule(new MockRule() { - @Override - public void initialize(LanguageProcessor languageProcessor) { + @Override public void initialize(LanguageProcessor languageProcessor) { throw new IllegalStateException(); } })); @@ -132,8 +125,7 @@ public void initialize(LanguageProcessor languageProcessor) { } } - @Test - void testFileWithSpecificLanguage() { + @Test void testFileWithSpecificLanguage() { final Language language = Dummy2LanguageModule.getInstance(); PMDConfiguration config = new PMDConfiguration(); config.setIgnoreIncrementalAnalysis(true); @@ -151,8 +143,7 @@ void testFileWithSpecificLanguage() { } } - @Test - void testTextFileWithSpecificLanguage() { + @Test void testTextFileWithSpecificLanguage() { final Language language = Dummy2LanguageModule.getInstance(); PMDConfiguration config = new PMDConfiguration(); config.setIgnoreIncrementalAnalysis(true); @@ -176,8 +167,7 @@ private static class TestRule extends AbstractRule { setMessage("dummy 2 test rule"); } - @Override - public void apply(Node node, RuleContext ctx) { + @Override public void apply(Node node, RuleContext ctx) { ctx.addViolation(node); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java index 0424ee010b1..8beb80ec06b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/PmdConfigurationTest.java @@ -39,24 +39,21 @@ class PmdConfigurationTest { - @Test - void testSuppressMarker() { + @Test void testSuppressMarker() { PMDConfiguration configuration = new PMDConfiguration(); assertEquals(PMDConfiguration.DEFAULT_SUPPRESS_MARKER, configuration.getSuppressMarker(), "Default suppress marker"); configuration.setSuppressMarker("CUSTOM_MARKER"); assertEquals("CUSTOM_MARKER", configuration.getSuppressMarker(), "Changed suppress marker"); } - @Test - void testThreads() { + @Test void testThreads() { PMDConfiguration configuration = new PMDConfiguration(); assertEquals(Runtime.getRuntime().availableProcessors(), configuration.getThreads(), "Default threads"); configuration.setThreads(0); assertEquals(0, configuration.getThreads(), "Changed threads"); } - @Test - void testClassLoader() { + @Test void testClassLoader() { PMDConfiguration configuration = new PMDConfiguration(); assertEquals(PMDConfiguration.class.getClassLoader(), configuration.getClassLoader(), "Default ClassLoader"); configuration.prependAuxClasspath("some.jar"); @@ -72,8 +69,7 @@ void testClassLoader() { "Revert to default ClassLoader"); } - @Test - void auxClasspathWithRelativeFileEmpty() { + @Test void auxClasspathWithRelativeFileEmpty() { String relativeFilePath = "src/test/resources/net/sourceforge/pmd/auxclasspath-empty.cp"; PMDConfiguration configuration = new PMDConfiguration(); configuration.prependAuxClasspath("file:" + relativeFilePath); @@ -81,8 +77,7 @@ void auxClasspathWithRelativeFileEmpty() { assertEquals(0, urls.length); } - @Test - void auxClasspathWithRelativeFileEmpty2() { + @Test void auxClasspathWithRelativeFileEmpty2() { String relativeFilePath = "./src/test/resources/net/sourceforge/pmd/auxclasspath-empty.cp"; PMDConfiguration configuration = new PMDConfiguration(); configuration.prependAuxClasspath("file:" + relativeFilePath); @@ -90,8 +85,7 @@ void auxClasspathWithRelativeFileEmpty2() { assertEquals(0, urls.length); } - @Test - void auxClasspathWithRelativeFile() throws URISyntaxException { + @Test void auxClasspathWithRelativeFile() throws URISyntaxException { final String FILE_SCHEME = "file"; String currentWorkingDirectory = new File("").getAbsoluteFile().toURI().getPath(); @@ -103,21 +97,20 @@ void auxClasspathWithRelativeFile() throws URISyntaxException { for (int i = 0; i < urls.length; i++) { uris[i] = urls[i].toURI(); } - URI[] expectedUris = new URI[] { - new URI(FILE_SCHEME, null, currentWorkingDirectory + "lib1.jar", null), - new URI(FILE_SCHEME, null, currentWorkingDirectory + "other/directory/lib2.jar", null), - new URI(FILE_SCHEME, null, new File("/home/jondoe/libs/lib3.jar").getAbsoluteFile().toURI().getPath(), null), - new URI(FILE_SCHEME, null, currentWorkingDirectory + "classes", null), - new URI(FILE_SCHEME, null, currentWorkingDirectory + "classes2", null), - new URI(FILE_SCHEME, null, new File("/home/jondoe/classes").getAbsoluteFile().toURI().getPath(), null), - new URI(FILE_SCHEME, null, currentWorkingDirectory, null), - new URI(FILE_SCHEME, null, currentWorkingDirectory + "relative source dir/bar", null), + URI[] expectedUris = new URI[]{ + new URI(FILE_SCHEME, null, currentWorkingDirectory + "lib1.jar", null), + new URI(FILE_SCHEME, null, currentWorkingDirectory + "other/directory/lib2.jar", null), + new URI(FILE_SCHEME, null, new File("/home/jondoe/libs/lib3.jar").getAbsoluteFile().toURI().getPath(), null), + new URI(FILE_SCHEME, null, currentWorkingDirectory + "classes", null), + new URI(FILE_SCHEME, null, currentWorkingDirectory + "classes2", null), + new URI(FILE_SCHEME, null, new File("/home/jondoe/classes").getAbsoluteFile().toURI().getPath(), null), + new URI(FILE_SCHEME, null, currentWorkingDirectory, null), + new URI(FILE_SCHEME, null, currentWorkingDirectory + "relative source dir/bar", null), }; assertArrayEquals(expectedUris, uris); } - @Test - void testRuleSets() { + @Test void testRuleSets() { PMDConfiguration configuration = new PMDConfiguration(); assertThat(configuration.getRuleSetPaths(), empty()); configuration.setRuleSets(listOf("/rulesets/basic.xml")); @@ -131,32 +124,28 @@ void testRuleSets() { assertEquals(listOf("foo.xml"), configuration.getRuleSetPaths()); } - @Test - void testMinimumPriority() { + @Test void testMinimumPriority() { PMDConfiguration configuration = new PMDConfiguration(); assertEquals(RulePriority.LOW, configuration.getMinimumPriority(), "Default minimum priority"); configuration.setMinimumPriority(RulePriority.HIGH); assertEquals(RulePriority.HIGH, configuration.getMinimumPriority(), "Changed minimum priority"); } - @Test - void testSourceEncoding() { + @Test void testSourceEncoding() { PMDConfiguration configuration = new PMDConfiguration(); assertEquals(System.getProperty("file.encoding"), configuration.getSourceEncoding().name(), "Default source encoding"); configuration.setSourceEncoding(StandardCharsets.UTF_16LE); assertEquals(StandardCharsets.UTF_16LE, configuration.getSourceEncoding(), "Changed source encoding"); } - @Test - void testReportFormat() { + @Test void testReportFormat() { PMDConfiguration configuration = new PMDConfiguration(); assertEquals(null, configuration.getReportFormat(), "Default report format"); configuration.setReportFormat("csv"); assertEquals("csv", configuration.getReportFormat(), "Changed report format"); } - @Test - void testCreateRenderer() { + @Test void testCreateRenderer() { PMDConfiguration configuration = new PMDConfiguration(); configuration.setReportFormat("csv"); Renderer renderer = configuration.createRenderer(); @@ -169,16 +158,14 @@ void testCreateRenderer() { assertEquals(true, renderer.isShowSuppressedViolations(), "Changed renderer show suppressed violations"); } - @Test - void testShowSuppressedViolations() { + @Test void testShowSuppressedViolations() { PMDConfiguration configuration = new PMDConfiguration(); assertEquals(false, configuration.isShowSuppressedViolations(), "Default show suppressed violations"); configuration.setShowSuppressedViolations(true); assertEquals(true, configuration.isShowSuppressedViolations(), "Changed show suppressed violations"); } - @Test - void testReportProperties() { + @Test void testReportProperties() { PMDConfiguration configuration = new PMDConfiguration(); assertEquals(0, configuration.getReportProperties().size(), "Default report properties size"); configuration.getReportProperties().put("key", "value"); @@ -188,8 +175,7 @@ void testReportProperties() { assertEquals(0, configuration.getReportProperties().size(), "Replaced report properties size"); } - @Test - void testAnalysisCache(@TempDir Path folder) throws IOException { + @Test void testAnalysisCache(@TempDir Path folder) throws IOException { final PMDConfiguration configuration = new PMDConfiguration(); assertNotNull(configuration.getAnalysisCache(), "Default cache is null"); assertTrue(configuration.getAnalysisCache() instanceof NoopAnalysisCache, "Default cache is not a noop"); @@ -203,8 +189,7 @@ void testAnalysisCache(@TempDir Path folder) throws IOException { assertSame(analysisCache, configuration.getAnalysisCache(), "Configured cache not stored"); } - @Test - void testAnalysisCacheLocation() { + @Test void testAnalysisCacheLocation() { final PMDConfiguration configuration = new PMDConfiguration(); configuration.setAnalysisCacheLocation(null); @@ -218,8 +203,7 @@ void testAnalysisCacheLocation() { } - @Test - void testIgnoreIncrementalAnalysis(@TempDir Path folder) throws IOException { + @Test void testIgnoreIncrementalAnalysis(@TempDir Path folder) throws IOException { final PMDConfiguration configuration = new PMDConfiguration(); // set dummy cache location @@ -234,13 +218,12 @@ void testIgnoreIncrementalAnalysis(@TempDir Path folder) throws IOException { assertTrue(configuration.getAnalysisCache() instanceof NoopAnalysisCache, "Ignoring incremental analysis should turn the cache into a noop"); } - @Test - void testCpdOnlyLanguage() { + @Test void testCpdOnlyLanguage() { final PMDConfiguration configuration = new PMDConfiguration(LanguageRegistry.CPD); assertThrows(UnsupportedOperationException.class, - () -> configuration.setOnlyRecognizeLanguage(CpdOnlyDummyLanguage.getInstance())); + () -> configuration.setOnlyRecognizeLanguage(CpdOnlyDummyLanguage.getInstance())); assertThrows(UnsupportedOperationException.class, - () -> configuration.setDefaultLanguageVersion(CpdOnlyDummyLanguage.getInstance().getDefaultVersion())); + () -> configuration.setDefaultLanguageVersion(CpdOnlyDummyLanguage.getInstance().getDefaultVersion())); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetSchemaTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetSchemaTest.java index 48e0ded0972..0b0728f9105 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetSchemaTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleSetSchemaTest.java @@ -36,14 +36,12 @@ class RuleSetSchemaTest { private ErrorHandler errorHandler; - @BeforeEach - void setUp() { + @BeforeEach void setUp() { Locale.setDefault(Locale.ROOT); errorHandler = mock(ErrorHandler.class); } - @Test - void verifyVersion2() throws Exception { + @Test void verifyVersion2() throws Exception { String ruleset = generateRuleSet("2.0.0"); Document doc = parseWithVersion2(ruleset); assertNotNull(doc); @@ -53,8 +51,7 @@ void verifyVersion2() throws Exception { assertEquals("Custom ruleset", ((Attr) doc.getElementsByTagName("ruleset").item(0).getAttributes().getNamedItem("name")).getValue()); } - @Test - void validateOnly() throws Exception { + @Test void validateOnly() throws Exception { Validator validator = PMDRuleSetEntityResolver.getSchemaVersion2().newValidator(); validator.setErrorHandler(errorHandler); validator.validate(new StreamSource(new ByteArrayInputStream(generateRuleSet("2.0.0").getBytes(StandardCharsets.UTF_8)))); @@ -75,38 +72,37 @@ private Document parseWithVersion2(String ruleset) throws SAXException, ParserCo private String generateRuleSet(String version) { String versionUnderscore = version.replaceAll("\\.", "_"); return "\n" - + "\n" - + " \n" - + " This ruleset checks my code for bad stuff\n" - + " \n" - + " \n" - + " \n" - + " Just for test\n" - + " \n" - + " 3\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + "\n"; + + "\n" + + " \n" + + " This ruleset checks my code for bad stuff\n" + + " \n" + + " \n" + + " \n" + + " Just for test\n" + + " \n" + + " 3\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n"; } public static class PMDRuleSetEntityResolver implements EntityResolver { private static URL schema2 = PMDRuleSetEntityResolver.class.getResource("/ruleset_2_0_0.xsd"); private static SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - @Override - public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { + @Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { if ("https://pmd.sourceforge.io/ruleset_2_0_0.xsd".equals(systemId)) { return new InputSource(schema2.toExternalForm()); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/RuleWithProperties.java b/pmd-core/src/test/java/net/sourceforge/pmd/RuleWithProperties.java index 37defeccc35..646b6a128db 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/RuleWithProperties.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/RuleWithProperties.java @@ -17,16 +17,16 @@ public class RuleWithProperties extends FooRule { public static final PropertyDescriptor STRING_PROPERTY_DESCRIPTOR = - PropertyFactory.stringProperty("stringProperty") - .desc("simple string property") - .defaultValue("") - .build(); + PropertyFactory.stringProperty("stringProperty") + .desc("simple string property") + .defaultValue("") + .build(); public static final PropertyDescriptor> MULTI_STRING_PROPERTY_DESCRIPTOR = - PropertyFactory.stringListProperty("multiString") - .desc("multi string property") - .defaultValues("default1", "default2") - .build(); + PropertyFactory.stringListProperty("multiString") + .desc("multi string property") + .defaultValues("default1", "default2") + .build(); public RuleWithProperties() { definePropertyDescriptor(STRING_PROPERTY_DESCRIPTOR); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/AbstractClasspathEntryFingerprinterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/AbstractClasspathEntryFingerprinterTest.java index 4ba84186383..adf02bfadbd 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/AbstractClasspathEntryFingerprinterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/AbstractClasspathEntryFingerprinterTest.java @@ -26,14 +26,12 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) abstract class AbstractClasspathEntryFingerprinterTest { - @TempDir - Path tempDir; + @TempDir Path tempDir; protected ClasspathEntryFingerprinter fingerprinter = newFingerPrinter(); protected Checksum checksum = new Adler32(); - @BeforeEach - void setUp() { + @BeforeEach void setUp() { checksum.reset(); } @@ -45,25 +43,19 @@ void setUp() { protected abstract File createValidNonEmptyFile() throws IOException; - @Test - void appliesToNullIsSafe() { + @Test void appliesToNullIsSafe() { fingerprinter.appliesTo(null); } - @ParameterizedTest - @MethodSource("getValidFileExtensions") - void appliesToValidFile(final String extension) { + @ParameterizedTest @MethodSource("getValidFileExtensions") void appliesToValidFile(final String extension) { assertTrue(fingerprinter.appliesTo(extension)); } - @ParameterizedTest - @MethodSource("getInvalidFileExtensions") - void doesNotApplyToInvalidFile(final String extension) { + @ParameterizedTest @MethodSource("getInvalidFileExtensions") void doesNotApplyToInvalidFile(final String extension) { assertFalse(fingerprinter.appliesTo(extension)); } - @Test - void fingerprintNonExistingFile() throws MalformedURLException, IOException { + @Test void fingerprintNonExistingFile() throws MalformedURLException, IOException { final long prevValue = checksum.getValue(); fingerprinter.fingerprint(new File("non-existing").toURI().toURL(), checksum); @@ -71,8 +63,7 @@ void fingerprintNonExistingFile() throws MalformedURLException, IOException { assertEquals(prevValue, checksum.getValue()); } - @Test - void fingerprintExistingValidFile() throws IOException { + @Test void fingerprintExistingValidFile() throws IOException { final long prevValue = checksum.getValue(); final File file = createValidNonEmptyFile(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/FileAnalysisCacheTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/FileAnalysisCacheTest.java index 253abd19dd4..082ece9466b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/FileAnalysisCacheTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/FileAnalysisCacheTest.java @@ -53,8 +53,7 @@ class FileAnalysisCacheTest { - @TempDir - private Path tempFolder; + @TempDir private Path tempFolder; private File unexistingCacheFile; private File newCacheFile; @@ -66,8 +65,7 @@ class FileAnalysisCacheTest { private final LanguageVersion dummyVersion = PmdCoreTestUtils.dummyVersion(); - @BeforeEach - public void setUp() throws IOException { + @BeforeEach public void setUp() throws IOException { unexistingCacheFile = tempFolder.resolve("non-existing-file.cache").toFile(); newCacheFile = tempFolder.resolve("pmd-analysis.cache").toFile(); emptyCacheFile = Files.createTempFile(tempFolder, null, null).toFile(); @@ -77,49 +75,42 @@ public void setUp() throws IOException { this.sourceFile = TextDocument.create(sourceFileBackend); } - @Test - void testLoadFromNonExistingFile() throws IOException { + @Test void testLoadFromNonExistingFile() throws IOException { final FileAnalysisCache cache = new FileAnalysisCache(unexistingCacheFile); assertNotNull(cache, "Cache creation from non existing file failed."); } - @Test - void testLoadFromEmptyFile() throws IOException { + @Test void testLoadFromEmptyFile() throws IOException { final FileAnalysisCache cache = new FileAnalysisCache(emptyCacheFile); assertNotNull(cache, "Cache creation from empty file failed."); } - @Test - void testLoadFromDirectoryShouldntThrow() throws IOException { + @Test void testLoadFromDirectoryShouldntThrow() throws IOException { new FileAnalysisCache(tempFolder.toFile()); } - @Test - void testLoadFromUnreadableFileShouldntThrow() throws IOException { + @Test void testLoadFromUnreadableFileShouldntThrow() throws IOException { emptyCacheFile.setReadable(false); new FileAnalysisCache(emptyCacheFile); } - @Test - void testStoreCreatesFile() throws Exception { + @Test void testStoreCreatesFile() throws Exception { final FileAnalysisCache cache = new FileAnalysisCache(unexistingCacheFile); cache.persist(); assertTrue(unexistingCacheFile.exists(), "Cache file doesn't exist after store"); } - @Test - void testStoreOnUnwritableFileShouldntThrow() throws IOException { + @Test void testStoreOnUnwritableFileShouldntThrow() throws IOException { emptyCacheFile.setWritable(false); final FileAnalysisCache cache = new FileAnalysisCache(emptyCacheFile); cache.persist(); } - @Test - void testStorePersistsFilesWithViolations() throws IOException { + @Test void testStorePersistsFilesWithViolations() throws IOException { final FileAnalysisCache cache = new FileAnalysisCache(newCacheFile); cache.checkValidity(mock(RuleSets.class), mock(ClassLoader.class), setOf(sourceFileBackend)); final FileAnalysisListener cacheListener = cache.startFileAnalysis(sourceFile); - + cache.isUpToDate(sourceFile); final RuleViolation rv = mock(RuleViolation.class); @@ -147,8 +138,7 @@ void testStorePersistsFilesWithViolations() throws IOException { assertEquals(textLocation.getEndColumn(), cachedViolation.getEndColumn()); } - @Test - void testStorePersistsFilesWithViolationsAndProcessingErrors() throws IOException { + @Test void testStorePersistsFilesWithViolationsAndProcessingErrors() throws IOException { final FileAnalysisCache cache = new FileAnalysisCache(newCacheFile); cache.checkValidity(mock(RuleSets.class), mock(ClassLoader.class), setOf(sourceFileBackend)); final FileAnalysisListener cacheListener = cache.startFileAnalysis(sourceFile); @@ -177,8 +167,7 @@ void testStorePersistsFilesWithViolationsAndProcessingErrors() throws IOExceptio assertTrue(cachedViolations.isEmpty(), "There should be no cached rule violations"); } - @Test - void testDisplayNameIsRespected() throws Exception { + @Test void testDisplayNameIsRespected() throws Exception { // This checks that the display name of the file is respected even if // the file is assigned a different display name across runs. The path // id is saved into the cache file, and the cache implementation updates the @@ -216,7 +205,7 @@ private void reloadWithOneViolation(TextFile mockFile) throws IOException { reloadedCache.checkValidity(mock(RuleSets.class), mock(ClassLoader.class), setOf(mockFile)); try (TextDocument doc1 = TextDocument.create(mockFile)) { assertTrue(reloadedCache.isUpToDate(doc1), - "Cache believes unmodified file with violations is not up to date"); + "Cache believes unmodified file with violations is not up to date"); List cachedViolations = reloadedCache.getCachedViolations(doc1); assertEquals(1, cachedViolations.size(), "Cached rule violations count mismatch"); final RuleViolation cachedViolation = cachedViolations.get(0); @@ -225,8 +214,7 @@ private void reloadWithOneViolation(TextFile mockFile) throws IOException { } - @Test - void testCacheValidityWithNoChanges() throws IOException { + @Test void testCacheValidityWithNoChanges() throws IOException { final RuleSets rs = mock(RuleSets.class); final ClassLoader cl = mock(ClassLoader.class); @@ -238,16 +226,15 @@ void testCacheValidityWithNoChanges() throws IOException { "Cache believes unmodified file is not up to date without ruleset / classpath changes"); } - @Test - void testCacheValidityWithIrrelevantChanges() throws IOException { + @Test void testCacheValidityWithIrrelevantChanges() throws IOException { final RuleSets rs = mock(RuleSets.class); final URLClassLoader cl = mock(URLClassLoader.class); - when(cl.getURLs()).thenReturn(new URL[] {}); + when(cl.getURLs()).thenReturn(new URL[]{}); setupCacheWithFiles(newCacheFile, rs, cl); final File classpathFile = Files.createTempFile(tempFolder, null, "foo.xml").toFile(); - when(cl.getURLs()).thenReturn(new URL[] { classpathFile.toURI().toURL(), }); + when(cl.getURLs()).thenReturn(new URL[]{classpathFile.toURI().toURL(), }); final FileAnalysisCache reloadedCache = new FileAnalysisCache(newCacheFile); reloadedCache.checkValidity(rs, cl, setOf(sourceFileBackend)); @@ -255,8 +242,7 @@ void testCacheValidityWithIrrelevantChanges() throws IOException { "Cache believes unmodified file is not up to date without ruleset / classpath changes"); } - @Test - void testRulesetChangeInvalidatesCache() throws IOException { + @Test void testRulesetChangeInvalidatesCache() throws IOException { final RuleSets rs = mock(RuleSets.class); final ClassLoader cl = mock(ClassLoader.class); @@ -269,47 +255,44 @@ void testRulesetChangeInvalidatesCache() throws IOException { "Cache believes unmodified file is up to date after ruleset changed"); } - @Test - void testAuxClasspathNonExistingAuxclasspathEntriesIgnored() throws MalformedURLException, IOException { + @Test void testAuxClasspathNonExistingAuxclasspathEntriesIgnored() throws MalformedURLException, IOException { final RuleSets rs = mock(RuleSets.class); final URLClassLoader cl = mock(URLClassLoader.class); - when(cl.getURLs()).thenReturn(new URL[] { tempFolder.resolve("non-existing-dir").toFile().toURI().toURL(), }); + when(cl.getURLs()).thenReturn(new URL[]{tempFolder.resolve("non-existing-dir").toFile().toURI().toURL(), }); setupCacheWithFiles(newCacheFile, rs, cl); final FileAnalysisCache analysisCache = new FileAnalysisCache(newCacheFile); - when(cl.getURLs()).thenReturn(new URL[] {}); + when(cl.getURLs()).thenReturn(new URL[]{}); analysisCache.checkValidity(rs, cl, setOf(sourceFileBackend)); assertTrue(analysisCache.isUpToDate(sourceFile), "Cache believes unmodified file is not up to date after non-existing auxclasspath entry removed"); } - @Test - void testAuxClasspathChangeWithoutDFAorTypeResolutionDoesNotInvalidatesCache() throws MalformedURLException, IOException { + @Test void testAuxClasspathChangeWithoutDFAorTypeResolutionDoesNotInvalidatesCache() throws MalformedURLException, IOException { final RuleSets rs = mock(RuleSets.class); final URLClassLoader cl = mock(URLClassLoader.class); - when(cl.getURLs()).thenReturn(new URL[] { }); + when(cl.getURLs()).thenReturn(new URL[]{}); setupCacheWithFiles(newCacheFile, rs, cl); final FileAnalysisCache reloadedCache = new FileAnalysisCache(newCacheFile); - when(cl.getURLs()).thenReturn(new URL[] { Files.createTempFile(tempFolder, null, null).toFile().toURI().toURL(), }); + when(cl.getURLs()).thenReturn(new URL[]{Files.createTempFile(tempFolder, null, null).toFile().toURI().toURL(), }); reloadedCache.checkValidity(rs, cl, setOf(sourceFileBackend)); assertTrue(reloadedCache.isUpToDate(sourceFile), "Cache believes unmodified file is not up to date after auxclasspath changed when no rule cares"); } - @Test - void testAuxClasspathChangeInvalidatesCache() throws MalformedURLException, IOException { + @Test void testAuxClasspathChangeInvalidatesCache() throws MalformedURLException, IOException { final RuleSets rs = mock(RuleSets.class); final URLClassLoader cl = mock(URLClassLoader.class); - when(cl.getURLs()).thenReturn(new URL[] { }); + when(cl.getURLs()).thenReturn(new URL[]{}); setupCacheWithFiles(newCacheFile, rs, cl); final FileAnalysisCache reloadedCache = new FileAnalysisCache(newCacheFile); final File classpathFile = Files.createTempFile(tempFolder, null, "foo.class").toFile(); - when(cl.getURLs()).thenReturn(new URL[] { classpathFile.toURI().toURL(), }); + when(cl.getURLs()).thenReturn(new URL[]{classpathFile.toURI().toURL(), }); // Make sure the auxclasspath file is not empty Files.write(classpathFile.toPath(), "some text".getBytes()); @@ -322,13 +305,12 @@ void testAuxClasspathChangeInvalidatesCache() throws MalformedURLException, IOEx "Cache believes unmodified file is up to date after auxclasspath changed"); } - @Test - void testAuxClasspathJarContentsChangeInvalidatesCache() throws MalformedURLException, IOException { + @Test void testAuxClasspathJarContentsChangeInvalidatesCache() throws MalformedURLException, IOException { final RuleSets rs = mock(RuleSets.class); final URLClassLoader cl = mock(URLClassLoader.class); final File classpathFile = Files.createTempFile(tempFolder, null, "foo.class").toFile(); - when(cl.getURLs()).thenReturn(new URL[] { classpathFile.toURI().toURL(), }); + when(cl.getURLs()).thenReturn(new URL[]{classpathFile.toURI().toURL(), }); final Rule r = mock(Rule.class); when(r.getLanguage()).thenReturn(mock(Language.class)); @@ -345,8 +327,7 @@ void testAuxClasspathJarContentsChangeInvalidatesCache() throws MalformedURLExce "Cache believes cache is up to date when a auxclasspath file changed"); } - @Test - void testClasspathNonExistingEntryIsIgnored() throws Exception { + @Test void testClasspathNonExistingEntryIsIgnored() throws Exception { restoreSystemProperties(() -> { final RuleSets rs = mock(RuleSets.class); final ClassLoader cl = mock(ClassLoader.class); @@ -363,8 +344,7 @@ void testClasspathNonExistingEntryIsIgnored() throws Exception { }); } - @Test - void testClasspathChangeInvalidatesCache() throws Exception { + @Test void testClasspathChangeInvalidatesCache() throws Exception { restoreSystemProperties(() -> { final RuleSets rs = mock(RuleSets.class); final ClassLoader cl = mock(ClassLoader.class); @@ -384,8 +364,7 @@ void testClasspathChangeInvalidatesCache() throws Exception { }); } - @Test - void testClasspathContentsChangeInvalidatesCache() throws Exception { + @Test void testClasspathContentsChangeInvalidatesCache() throws Exception { restoreSystemProperties(() -> { final RuleSets rs = mock(RuleSets.class); final ClassLoader cl = mock(ClassLoader.class); @@ -408,8 +387,7 @@ void testClasspathContentsChangeInvalidatesCache() throws Exception { }); } - @Test - void testWildcardClasspath() throws Exception { + @Test void testWildcardClasspath() throws Exception { restoreSystemProperties(() -> { final RuleSets rs = mock(RuleSets.class); final ClassLoader cl = mock(ClassLoader.class); @@ -427,8 +405,7 @@ void testWildcardClasspath() throws Exception { }); } - @Test - void testWildcardClasspathContentsChangeInvalidatesCache() throws Exception { + @Test void testWildcardClasspathContentsChangeInvalidatesCache() throws Exception { restoreSystemProperties(() -> { final RuleSets rs = mock(RuleSets.class); final ClassLoader cl = mock(ClassLoader.class); @@ -452,15 +429,13 @@ void testWildcardClasspathContentsChangeInvalidatesCache() throws Exception { }); } - @Test - void testUnknownFileIsNotUpToDate() throws IOException { + @Test void testUnknownFileIsNotUpToDate() throws IOException { final FileAnalysisCache cache = new FileAnalysisCache(newCacheFile); assertFalse(cache.isUpToDate(sourceFile), "Cache believes an unknown file is up to date"); } - @Test - void testFileIsUpToDate() throws IOException { + @Test void testFileIsUpToDate() throws IOException { setupCacheWithFiles(newCacheFile, mock(RuleSets.class), mock(ClassLoader.class)); final FileAnalysisCache cache = new FileAnalysisCache(newCacheFile); @@ -469,8 +444,7 @@ void testFileIsUpToDate() throws IOException { "Cache believes a known, unchanged file is not up to date"); } - @Test - void testFileIsNotUpToDateWhenEdited() throws IOException { + @Test void testFileIsNotUpToDateWhenEdited() throws IOException { setupCacheWithFiles(newCacheFile, mock(RuleSets.class), mock(ClassLoader.class)); // Edit the file @@ -485,8 +459,8 @@ void testFileIsNotUpToDateWhenEdited() throws IOException { } private void setupCacheWithFiles(final File cacheFile, - final RuleSets ruleSets, - final ClassLoader classLoader) throws IOException { + final RuleSets ruleSets, + final ClassLoader classLoader) throws IOException { // Setup a cache file with an entry for an empty Source.java with no violations final FileAnalysisCache cache = new FileAnalysisCache(cacheFile); cache.checkValidity(ruleSets, classLoader, setOf(sourceFileBackend)); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinterTest.java index 31a5910e4c1..1f1f9c67f7a 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/RawFileFingerprinterTest.java @@ -12,23 +12,19 @@ class RawFileFingerprinterTest extends AbstractClasspathEntryFingerprinterTest { - @Override - protected ClasspathEntryFingerprinter newFingerPrinter() { + @Override protected ClasspathEntryFingerprinter newFingerPrinter() { return new RawFileFingerprinter(); } - @Override - protected String[] getValidFileExtensions() { - return new String[] { "class" }; + @Override protected String[] getValidFileExtensions() { + return new String[]{"class"}; } - @Override - protected String[] getInvalidFileExtensions() { - return new String[] { "xml" }; + @Override protected String[] getInvalidFileExtensions() { + return new String[]{"xml"}; } - @Override - protected File createValidNonEmptyFile() throws IOException { + @Override protected File createValidNonEmptyFile() throws IOException { Path file = tempDir.resolve("Foo.class"); Files.write(file, "some content".getBytes(StandardCharsets.UTF_8)); return file.toFile(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/ZipFileFingerprinterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/ZipFileFingerprinterTest.java index f9a829b17dc..114150809f5 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/ZipFileFingerprinterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cache/internal/ZipFileFingerprinterTest.java @@ -22,8 +22,7 @@ class ZipFileFingerprinterTest extends AbstractClasspathEntryFingerprinterTest { - @Test - void zipEntryMetadataDoesNotAffectFingerprint() throws IOException { + @Test void zipEntryMetadataDoesNotAffectFingerprint() throws IOException { final File file = createValidNonEmptyFile(); final long baselineFingerprint = getBaseLineFingerprint(file); final long originalFileSize = file.length(); @@ -40,50 +39,44 @@ void zipEntryMetadataDoesNotAffectFingerprint() throws IOException { assertEquals(baselineFingerprint, updateFingerprint(file)); assertNotEquals(originalFileSize, file.length()); } - - @Test - void zipEntryOrderDoesNotAffectFingerprint() throws IOException { + + @Test void zipEntryOrderDoesNotAffectFingerprint() throws IOException { final File zipFile = tempDir.resolve("foo.jar").toFile(); final ZipEntry fooEntry = new ZipEntry("lib/Foo.class"); final ZipEntry barEntry = new ZipEntry("lib/Bar.class"); overwriteZipFileContents(zipFile, fooEntry, barEntry); final long baselineFingerprint = getBaseLineFingerprint(zipFile); - + // swap order overwriteZipFileContents(zipFile, barEntry, fooEntry); assertEquals(baselineFingerprint, updateFingerprint(zipFile)); } - - @Test - void nonClassZipEntryDoesNotAffectFingerprint() throws IOException { + + @Test void nonClassZipEntryDoesNotAffectFingerprint() throws IOException { final File zipFile = tempDir.resolve("foo.jar").toFile(); final ZipEntry fooEntry = new ZipEntry("lib/Foo.class"); final ZipEntry barEntry = new ZipEntry("bar.properties"); overwriteZipFileContents(zipFile, fooEntry); final long baselineFingerprint = getBaseLineFingerprint(zipFile); - + // add a properties file to the jar overwriteZipFileContents(zipFile, fooEntry, barEntry); assertEquals(baselineFingerprint, updateFingerprint(zipFile)); } - @Override - protected ClasspathEntryFingerprinter newFingerPrinter() { + @Override protected ClasspathEntryFingerprinter newFingerPrinter() { return new ZipFileFingerprinter(); } - @Override - protected String[] getValidFileExtensions() { - return new String[] { "zip", "jar" }; + @Override protected String[] getValidFileExtensions() { + return new String[]{"zip", "jar"}; } - @Override - protected String[] getInvalidFileExtensions() { - return new String[] { "xml" }; + @Override protected String[] getInvalidFileExtensions() { + return new String[]{"xml"}; } - @Override - protected File createValidNonEmptyFile() throws IOException { + @Override protected File createValidNonEmptyFile() throws IOException { final File zipFile = tempDir.resolve("foo.jar").toFile(); overwriteZipFileContents(zipFile, new ZipEntry("lib/Foo.class")); return zipFile; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/AnyCpdLexerTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/AnyCpdLexerTest.java index d2ec5f54327..825e3676d0f 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/AnyCpdLexerTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/AnyCpdLexerTest.java @@ -19,20 +19,17 @@ class AnyCpdLexerTest { - @Test - void testMultiLineMacros() throws IOException { + @Test void testMultiLineMacros() throws IOException { AnyCpdLexer tokenizer = new AnyCpdLexer("//"); compareResult(tokenizer, TEST1, EXPECTED); } - @Test - void testStringEscape() throws IOException { + @Test void testStringEscape() throws IOException { AnyCpdLexer tokenizer = new AnyCpdLexer("//"); compareResult(tokenizer, "a = \"oo\\n\"", listOf("a", "=", "\"oo\\n\"", "EOF")); } - @Test - void testMultilineString() throws IOException { + @Test void testMultilineString() throws IOException { AnyCpdLexer tokenizer = new AnyCpdLexer("//"); Tokens tokens = compareResult(tokenizer, "a = \"oo\n\";", listOf("a", "=", "\"oo\n\"", ";", "EOF")); TokenEntry string = tokens.getTokens().get(2); @@ -51,8 +48,7 @@ void testMultilineString() throws IOException { /** * Tests that [core][cpd] AnyTokenizer doesn't count columns correctly #2760 is actually fixed. */ - @Test - void testTokenPosition() throws IOException { + @Test void testTokenPosition() throws IOException { AnyCpdLexer tokenizer = new AnyCpdLexer(); TextDocument code = TextDocument.readOnlyString("a;\nbbbb\n;", FileId.UNKNOWN, DummyLanguageModule.getInstance().getDefaultVersion()); Tokens tokens = new Tokens(); @@ -79,25 +75,25 @@ private Tokens compareResult(AnyCpdLexer tokenizer, String source, List } private static final List EXPECTED = listOf( - "using", "System", ";", - "namespace", "HelloNameSpace", "{", - "public", "class", "HelloWorld", "{", // note: comment is excluded - "static", "void", "Main", "(", "string", "[", "]", "args", ")", "{", - "Console", ".", "WriteLine", "(", "\"Hello World!\"", ")", ";", - "}", "}", "}", "EOF" + "using", "System", ";", + "namespace", "HelloNameSpace", "{", + "public", "class", "HelloWorld", "{", // note: comment is excluded + "static", "void", "Main", "(", "string", "[", "]", "args", ")", "{", + "Console", ".", "WriteLine", "(", "\"Hello World!\"", ")", ";", + "}", "}", "}", "EOF" ); private static final String TEST1 = - "using System;\n" - + "namespace HelloNameSpace {\n" - + "\n" - + " public class HelloWorld { // A comment\n" - + " static void Main(string[] args) {\n" - + "\n" - + " Console.WriteLine(\"Hello World!\");\n" - + " }\n" - + " }\n" - + "\n" - + "}\n"; + "using System;\n" + + "namespace HelloNameSpace {\n" + + "\n" + + " public class HelloWorld { // A comment\n" + + " static void Main(string[] args) {\n" + + "\n" + + " Console.WriteLine(\"Hello World!\");\n" + + " }\n" + + " }\n" + + "\n" + + "}\n"; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDConfigurationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDConfigurationTest.java index acb2dc8cfe4..23936ae9a41 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDConfigurationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDConfigurationTest.java @@ -22,8 +22,7 @@ class CPDConfigurationTest { - @Test - void testRenderers() { + @Test void testRenderers() { Map> renderersToTest = new HashMap<>(); renderersToTest.put("csv", CSVRenderer.class); renderersToTest.put("xml", XMLRenderer.class); @@ -38,8 +37,7 @@ void testRenderers() { } } - @Test - void testRendererEncoding() { + @Test void testRendererEncoding() { CPDConfiguration conf = new CPDConfiguration(); conf.setRendererName("xml"); conf.setSourceEncoding(StandardCharsets.UTF_16); @@ -50,8 +48,7 @@ void testRendererEncoding() { assertEquals(StandardCharsets.UTF_16.name(), ((XMLRenderer) renderer).getEncoding()); } - @Test - void testRendererEncoding2() { + @Test void testRendererEncoding2() { CPDConfiguration conf = new CPDConfiguration(); // here the order of these statements are reversed conf.setSourceEncoding(StandardCharsets.UTF_16); @@ -64,15 +61,14 @@ void testRendererEncoding2() { } - @Test - void testCpdNotSupported() { + @Test void testCpdNotSupported() { DummyLanguageNoCapabilities lang = DummyLanguageNoCapabilities.getInstance(); final CPDConfiguration configuration = new CPDConfiguration(LanguageRegistry.singleton(lang)); assertThrows(UnsupportedOperationException.class, - () -> configuration.setOnlyRecognizeLanguage(lang)); + () -> configuration.setOnlyRecognizeLanguage(lang)); assertThrows(UnsupportedOperationException.class, - () -> configuration.setDefaultLanguageVersion(lang.getDefaultVersion())); + () -> configuration.setDefaultLanguageVersion(lang.getDefaultVersion())); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDFilelistTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDFilelistTest.java index 355d169b89a..397f1261e57 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDFilelistTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDFilelistTest.java @@ -20,13 +20,11 @@ class CPDFilelistTest { - @Test - void testFilelist() throws IOException { + @Test void testFilelist() throws IOException { testFileList("src/test/resources/net/sourceforge/pmd/cpd/cli/filelist.txt"); } - @Test - void testFilelistMultipleLines() throws IOException { + @Test void testFilelistMultipleLines() throws IOException { testFileList("src/test/resources/net/sourceforge/pmd/cpd/cli/filelist2.txt"); } @@ -42,8 +40,8 @@ private static void testFileList(String first) throws IOException { assertEquals(2, paths.size()); List simpleNames = CollectionUtil.map(paths, FileId::getFileName); assertEquals( - listOf("anotherfile.dummy", "somefile.dummy"), - simpleNames + listOf("anotherfile.dummy", "somefile.dummy"), + simpleNames ); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDReportTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDReportTest.java index 083ce1db74c..3f2a0d7deba 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDReportTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDReportTest.java @@ -15,8 +15,7 @@ class CPDReportTest { - @Test - void testFilterMatches() { + @Test void testFilterMatches() { CpdReportBuilder reportBuilder = new CpdReportBuilder(); FileId file1 = FileId.fromPathLikeString("file1.java"); FileId file2 = FileId.fromPathLikeString("file2.java"); @@ -32,15 +31,15 @@ void testFilterMatches() { assertEquals(3, original.getMatches().size()); CPDReport filtered = original.filterMatches( - // only keep file1.java - match -> CollectionUtil.any(match, mark -> mark.getLocation().getFileId().equals(file1)) + // only keep file1.java + match -> CollectionUtil.any(match, mark -> mark.getLocation().getFileId().equals(file1)) ); assertEquals(2, filtered.getMatches().size()); for (Match match : filtered.getMatches()) { boolean containsFile1 = - match.getMarkSet().stream().map(Mark::getFileId) - .anyMatch(file1::equals); + match.getMarkSet().stream().map(Mark::getFileId) + .anyMatch(file1::equals); assertTrue(containsFile1); } @@ -50,7 +49,7 @@ void testFilterMatches() { private Match createMatch(CpdReportBuilder builder, FileId file1, FileId file2, int line) { return new Match(5, - builder.tokens.addToken("firstToken", file1, line, 1, line, 1), - builder.tokens.addToken("secondToken", file2, line, 2, line, 2)); + builder.tokens.addToken("firstToken", file1, line, 1, line, 1), + builder.tokens.addToken("secondToken", file2, line, 2, line, 2)); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CSVRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CSVRendererTest.java index 8ee85e12e02..6580fb4b8f3 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CSVRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CSVRendererTest.java @@ -16,8 +16,7 @@ class CSVRendererTest { - @Test - void testLineCountPerFile() throws IOException { + @Test void testLineCountPerFile() throws IOException { CPDReportRenderer renderer = new CSVRenderer(true); CpdReportBuilder builder = new CpdReportBuilder(); Mark mark1 = builder.createMark("public", CpdTestUtils.FOO_FILE_ID, 48, 10); @@ -28,14 +27,13 @@ void testLineCountPerFile() throws IOException { renderer.render(builder.build(), sw); String report = sw.toString(); String expectedReport = "tokens,occurrences" + System.lineSeparator() - + "75,2,48,10," + CpdTestUtils.FOO_FILE_ID.getAbsolutePath() + ",73,20," - + CpdTestUtils.BAR_FILE_ID.getAbsolutePath() + System.lineSeparator(); + + "75,2,48,10," + CpdTestUtils.FOO_FILE_ID.getAbsolutePath() + ",73,20," + + CpdTestUtils.BAR_FILE_ID.getAbsolutePath() + System.lineSeparator(); assertEquals(expectedReport, report); } - @Test - void testFilenameEscapes() throws IOException { + @Test void testFilenameEscapes() throws IOException { CPDReportRenderer renderer = new CSVRenderer(); CpdReportBuilder builder = new CpdReportBuilder(); FileId foo = FileId.fromPathLikeString("/var,with,commas/Foo.java"); @@ -48,8 +46,8 @@ void testFilenameEscapes() throws IOException { renderer.render(builder.build(), sw); String report = sw.toString(); String expectedReport = "lines,tokens,occurrences" + System.lineSeparator() - + "10,75,2,48,\"" + foo.getAbsolutePath() + "\",73,\"" + bar.getAbsolutePath() + "\"" - + System.lineSeparator(); + + "10,75,2,48,\"" + foo.getAbsolutePath() + "\",73,\"" + bar.getAbsolutePath() + "\"" + + System.lineSeparator(); assertEquals(expectedReport, report); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdAnalysisTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdAnalysisTest.java index f390e7c760a..2fbff440234 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdAnalysisTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdAnalysisTest.java @@ -51,13 +51,11 @@ class CpdAnalysisTest { private static final String BASE_TEST_RESOURCE_PATH = "src/test/resources/net/sourceforge/pmd/cpd/files/"; private static final String TARGET_TEST_RESOURCE_PATH = "target/classes/net/sourceforge/pmd/cpd/files/"; - @TempDir - private Path tempDir; + @TempDir private Path tempDir; private CPDConfiguration config = new CPDConfiguration(); - @BeforeEach - void setup() { + @BeforeEach void setup() { config.setOnlyRecognizeLanguage(DummyLanguageModule.getInstance()); config.setMinimumTileSize(10); } @@ -72,12 +70,12 @@ void setup() { private void prepareSymLinks() throws Exception { Runtime runtime = Runtime.getRuntime(); if (!new File(TARGET_TEST_RESOURCE_PATH, "symlink-for-real-file.txt").exists()) { - runtime.exec(new String[] { "ln", "-s", BASE_TEST_RESOURCE_PATH + "real-file.txt", - TARGET_TEST_RESOURCE_PATH + "symlink-for-real-file.txt", }).waitFor(); + runtime.exec(new String[]{"ln", "-s", BASE_TEST_RESOURCE_PATH + "real-file.txt", + TARGET_TEST_RESOURCE_PATH + "symlink-for-real-file.txt", }).waitFor(); } if (!new File(BASE_TEST_RESOURCE_PATH, "this-is-a-broken-sym-link-for-test").exists()) { - runtime.exec(new String[] { "ln", "-s", "broken-sym-link", - TARGET_TEST_RESOURCE_PATH + "this-is-a-broken-sym-link-for-test", }).waitFor(); + runtime.exec(new String[]{"ln", "-s", "broken-sym-link", + TARGET_TEST_RESOURCE_PATH + "this-is-a-broken-sym-link-for-test", }).waitFor(); } } @@ -88,8 +86,7 @@ private void prepareSymLinks() throws Exception { * @throws Exception * any error */ - @Test - @EnabledOnOs(OS.LINUX) // Symlinks are not well supported under Windows + @Test @EnabledOnOs(OS.LINUX) // Symlinks are not well supported under Windows void testFileSectionWithBrokenSymlinks() throws Exception { prepareSymLinks(); @@ -110,8 +107,7 @@ void testFileSectionWithBrokenSymlinks() throws Exception { * @throws Exception * any error */ - @Test - @EnabledOnOs(OS.LINUX) // Symlinks are not well supported under Windows + @Test @EnabledOnOs(OS.LINUX) // Symlinks are not well supported under Windows void testFileAddedAsSymlinkAndReal() throws Exception { prepareSymLinks(); @@ -129,8 +125,7 @@ void testFileAddedAsSymlinkAndReal() throws Exception { /** * A file should be not be added via a sym link. */ - @Test - @EnabledOnOs(OS.LINUX) // Symlinks are not well supported under Windows + @Test @EnabledOnOs(OS.LINUX) // Symlinks are not well supported under Windows void testNoFileAddedAsSymlink() throws Exception { prepareSymLinks(); @@ -151,8 +146,7 @@ void testNoFileAddedAsSymlink() throws Exception { * @throws Exception * any error */ - @Test - void testFileAddedWithRelativePath() throws Exception { + @Test void testFileAddedWithRelativePath() throws Exception { FileCountAssertListener listener = new FileCountAssertListener(1); try (CpdAnalysis cpd = CpdAnalysis.create(config)) { cpd.setCpdListener(listener); @@ -168,8 +162,7 @@ void testFileAddedWithRelativePath() throws Exception { * See also https://github.com/pmd/pmd/issues/1196 * @throws Exception */ - @Test - void testFileOrderRelevance() throws Exception { + @Test void testFileOrderRelevance() throws Exception { Path dup1 = Paths.get("./" + BASE_TEST_RESOURCE_PATH, "dup1.txt"); Path dup2 = Paths.get("./" + BASE_TEST_RESOURCE_PATH, "dup2.txt"); @@ -202,8 +195,7 @@ void testFileOrderRelevance() throws Exception { } } - @Test - void testNoSkipLexicalErrors() throws IOException { + @Test void testNoSkipLexicalErrors() throws IOException { PmdReporter reporter = mock(PmdReporter.class); config.setReporter(reporter); @@ -219,8 +211,7 @@ void testNoSkipLexicalErrors() throws IOException { verifyNoMoreInteractions(reporter); } - @Test - void reportShouldContainProcessingErrors() throws IOException { + @Test void reportShouldContainProcessingErrors() throws IOException { AtomicReference report = new AtomicReference<>(); PmdReporter reporter = mock(PmdReporter.class); config.setReporter(reporter); @@ -248,16 +239,14 @@ void reportShouldContainProcessingErrors() throws IOException { verifyNoMoreInteractions(reporter); } - @Test - void reportToNonExistentFile(@TempDir Path tmpDir) throws IOException { + @Test void reportToNonExistentFile(@TempDir Path tmpDir) throws IOException { Path reportFile = tmpDir.resolve("cpd.txt"); assertFalse(Files.exists(reportFile), "Report file " + reportFile + " should not exist"); testReportFile(reportFile); } - @Test - void reportToExistingFileShouldOverwrite(@TempDir Path tmpDir) throws IOException { + @Test void reportToExistingFileShouldOverwrite(@TempDir Path tmpDir) throws IOException { Path reportFile = tmpDir.resolve("cpd.txt"); assertFalse(Files.exists(reportFile), "Report file " + reportFile + " should not exist"); final String sentinel = "EMPTY_FILE"; @@ -293,8 +282,7 @@ private String testReportFile(Path reportFile) throws IOException { } - @Test - void testSkipLexicalErrors() throws IOException { + @Test void testSkipLexicalErrors() throws IOException { PmdReporter reporter = mock(PmdReporter.class); config.setReporter(reporter); @@ -308,8 +296,7 @@ void testSkipLexicalErrors() throws IOException { verifyNoMoreInteractions(reporter); } - @Test - void duplicatedFilesShouldBeSkipped() throws IOException { + @Test void duplicatedFilesShouldBeSkipped() throws IOException { String filename = "file1.dummy"; Path aFile1 = Files.createDirectory(tempDir.resolve("a")).resolve(filename).toAbsolutePath(); Path bFile1 = Files.createDirectory(tempDir.resolve("b")).resolve(filename).toAbsolutePath(); @@ -343,16 +330,14 @@ private static class FileCountAssertListener implements CPDListener { this.files = 0; } - @Override - public void addedFile(int fileCount) { + @Override public void addedFile(int fileCount) { files++; if (files > expectedFilesCount) { fail("File was added!"); } } - @Override - public void phaseUpdate(int phase) { + @Override public void phaseUpdate(int phase) { // not needed for this test } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdTestUtils.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdTestUtils.java index 1a41f616660..f17514fda04 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdTestUtils.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdTestUtils.java @@ -34,16 +34,16 @@ static CPDReport makeReport(List matches, Map numTokensP Set textFiles = new HashSet<>(); for (Match match : matches) { match.iterator().forEachRemaining( - mark -> textFiles.add( - TextFile.forCharSeq(DUMMY_FILE_CONTENT, - mark.getLocation().getFileId(), - DummyLanguageModule.getInstance().getDefaultVersion()))); + mark -> textFiles.add( + TextFile.forCharSeq(DUMMY_FILE_CONTENT, + mark.getLocation().getFileId(), + DummyLanguageModule.getInstance().getDefaultVersion()))); } return new CPDReport( - new SourceManager(new ArrayList<>(textFiles)), - matches, - numTokensPerFile, - processingErrors + new SourceManager(new ArrayList<>(textFiles)), + matches, + numTokensPerFile, + processingErrors ); } @@ -73,10 +73,10 @@ CPDReport build() { Set textFiles = new HashSet<>(); fileContents.forEach((fname, contents) -> textFiles.add(TextFile.forCharSeq(contents, fname, DummyLanguageModule.getInstance().getDefaultVersion()))); return new CPDReport( - new SourceManager(new ArrayList<>(textFiles)), - matches, - numTokensPerFile, - Collections.emptyList() + new SourceManager(new ArrayList<>(textFiles)), + matches, + numTokensPerFile, + Collections.emptyList() ); } @@ -95,10 +95,10 @@ CpdReportBuilder addMatch(Match match) { Mark createMark(String image, FileId fileId, int beginLine, int lineCount, int beginColumn, int endColumn) { fileContents.putIfAbsent(fileId, DUMMY_FILE_CONTENT); final TokenEntry beginToken = tokens.addToken(image, fileId, beginLine, beginColumn, beginLine, - beginColumn + image.length()); + beginColumn + image.length()); final TokenEntry endToken = tokens.addToken(image, fileId, - beginLine + lineCount - 1, beginColumn, - beginLine + lineCount - 1, endColumn); + beginLine + lineCount - 1, beginColumn, + beginLine + lineCount - 1, endColumn); final Mark result = new Mark(beginToken); result.setEndToken(endToken); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdXsltTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdXsltTest.java index b4ae82b687b..c1cef8654f8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdXsltTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CpdXsltTest.java @@ -35,15 +35,13 @@ class CpdXsltTest { */ - @Test - void cpdhtml() throws Exception { + @Test void cpdhtml() throws Exception { String result = runXslt("cpdhtml.xslt"); String expected = IOUtil.readToString(CpdXsltTest.class.getResourceAsStream("ExpectedCpdHtmlReport.html"), StandardCharsets.UTF_8); assertEquals(expected, result); } - @Test - void cpdhtmlv2() throws Exception { + @Test void cpdhtmlv2() throws Exception { String result = runXslt("cpdhtml-v2.xslt"); String expected = IOUtil.readToString(CpdXsltTest.class.getResourceAsStream("ExpectedCpdHtmlReport-v2.html"), StandardCharsets.UTF_8); assertEquals(expected, result); @@ -72,18 +70,15 @@ private String runXslt(String stylesheet) throws Exception { private static class XSLTErrorListener implements ErrorListener { final List errors = new ArrayList<>(); - @Override - public void warning(TransformerException exception) throws TransformerException { + @Override public void warning(TransformerException exception) throws TransformerException { errors.add(exception); } - @Override - public void fatalError(TransformerException exception) throws TransformerException { + @Override public void fatalError(TransformerException exception) throws TransformerException { errors.add(exception); } - @Override - public void error(TransformerException exception) throws TransformerException { + @Override public void error(TransformerException exception) throws TransformerException { errors.add(exception); } @@ -91,8 +86,7 @@ public boolean hasNoErrors() { return errors.isEmpty(); } - @Override - public String toString() { + @Override public String toString() { return errors.toString(); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MarkTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MarkTest.java index 09e84e1ad87..dad05ba3bfb 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MarkTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MarkTest.java @@ -13,8 +13,7 @@ class MarkTest { - @Test - void testSimple() { + @Test void testSimple() { final FileId filename = CpdTestUtils.FOO_FILE_ID; Tokens tokens = new Tokens(); TokenEntry token = tokens.addToken("public", filename, 1, 2, 3, 4); @@ -30,8 +29,7 @@ void testSimple() { assertEquals(4, loc.getEndColumn()); } - @Test - void testColumns() { + @Test void testColumns() { final FileId filename = CpdTestUtils.FOO_FILE_ID; Tokens tokens = new Tokens(); final int beginLine = 1; @@ -39,9 +37,9 @@ void testColumns() { final int endColumn = 2; final int lineCount = 10; TokenEntry token = tokens.addToken("public", filename, beginLine, beginColumn, beginLine, - beginColumn + "public".length()); + beginColumn + "public".length()); TokenEntry endToken = tokens.addToken("}", filename, - beginLine + lineCount, 1, beginLine + lineCount - 1, endColumn); + beginLine + lineCount, 1, beginLine + lineCount - 1, endColumn); final Mark mark = new Mark(token); mark.setEndToken(endToken); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MatchAlgorithmTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MatchAlgorithmTest.java index 5e2afca9b20..40ac8fefa60 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MatchAlgorithmTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MatchAlgorithmTest.java @@ -48,8 +48,7 @@ private static String getMultipleRepetitionsCode() { + "];"; } - @Test - void testSimple() throws IOException { + @Test void testSimple() throws IOException { DummyLanguageModule dummy = DummyLanguageModule.getInstance(); CpdLexer cpdLexer = dummy.createCpdLexer(dummy.newPropertyBundle()); FileId fileName = FileId.fromPathLikeString("Foo.dummy"); @@ -79,8 +78,7 @@ void testSimple() throws IOException { assertEquals(LINE_4 + "\n", sourceManager.getSlice(mark2).toString()); } - @Test - void testMultipleMatches() throws IOException { + @Test void testMultipleMatches() throws IOException { DummyLanguageModule dummy = DummyLanguageModule.getInstance(); CpdLexer cpdLexer = dummy.createCpdLexer(dummy.newPropertyBundle()); FileId fileName = FileId.fromPathLikeString("Foo.dummy"); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MatchTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MatchTest.java index 1d6ba62c0fe..5b400406326 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MatchTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/MatchTest.java @@ -20,8 +20,7 @@ class MatchTest { - @Test - void testSimple() { + @Test void testSimple() { String codeFragment1 = "1234567890"; FileId fileName = CpdTestUtils.FOO_FILE_ID; TextFile tf = TextFile.forCharSeq(codeFragment1, fileName, DummyLanguageModule.getInstance().getDefaultVersion()); @@ -52,16 +51,15 @@ void testSimple() { assertEquals(Chars.wrap("1234567890"), sourceManager.getSlice(mark2)); } - @Test - void testCompareTo() { + @Test void testCompareTo() { Tokens tokens = new Tokens(); FileId fileName = CpdTestUtils.FOO_FILE_ID; Match m1 = new Match(1, - tokens.addToken("public", fileName, 1, 2, 3, 4), - tokens.addToken("class", fileName, 1, 2, 3, 4)); + tokens.addToken("public", fileName, 1, 2, 3, 4), + tokens.addToken("class", fileName, 1, 2, 3, 4)); Match m2 = new Match(2, tokens.addToken("Foo", fileName, 1, 2, 3, 4), - tokens.addToken("{", fileName, 1, 2, 3, 4)); + tokens.addToken("{", fileName, 1, 2, 3, 4)); assertTrue(m2.compareTo(m1) < 0); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/TokenEntryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/TokenEntryTest.java index 247fe7eb9b3..e5b158680cb 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/TokenEntryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/TokenEntryTest.java @@ -10,8 +10,7 @@ class TokenEntryTest { - @Test - void testSimple() { + @Test void testSimple() { Tokens tokens = new Tokens(); TokenEntry mark = tokens.addToken("public", CpdTestUtils.FOO_FILE_ID, 1, 2, 3, 4); assertEquals(1, mark.getBeginLine()); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLOldRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLOldRendererTest.java index 3c0c74b3407..bdb6d985365 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLOldRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLOldRendererTest.java @@ -24,8 +24,7 @@ class XMLOldRendererTest { private static final String ENCODING = (String) System.getProperties().get("file.encoding"); - @Test - void testWithNoDuplication() throws IOException, ParserConfigurationException, SAXException { + @Test void testWithNoDuplication() throws IOException, ParserConfigurationException, SAXException { CPDReportRenderer renderer = new XMLOldRenderer(); StringWriter sw = new StringWriter(); renderer.render(CpdTestUtils.makeReport(Collections.emptyList()), sw); @@ -43,8 +42,7 @@ void testWithNoDuplication() throws IOException, ParserConfigurationException, S assertEquals(0, doc.getElementsByTagName("duplication").getLength()); } - @Test - void testWithOneDuplication() throws Exception { + @Test void testWithOneDuplication() throws Exception { CPDReportRenderer renderer = new XMLOldRenderer(); CpdTestUtils.CpdReportBuilder builder = new CpdTestUtils.CpdReportBuilder(); int lineCount = 6; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLRendererTest.java index 05b511d0c0b..0ac509110e7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/XMLRendererTest.java @@ -50,8 +50,7 @@ class XMLRendererTest { private static final String FORM_FEED = "\u000C"; // this character is invalid in XML 1.0 documents private static final String FORM_FEED_ENTITY = " "; // this is also not allowed in XML 1.0 documents - @Test - void testWithNoDuplication() throws IOException, ParserConfigurationException, SAXException { + @Test void testWithNoDuplication() throws IOException, ParserConfigurationException, SAXException { CPDReportRenderer renderer = new XMLRenderer(); StringWriter sw = new StringWriter(); renderer.render(CpdTestUtils.makeReport(Collections.emptyList()), sw); @@ -70,15 +69,14 @@ void testWithNoDuplication() throws IOException, ParserConfigurationException, S "namespace is missing or wrong"); Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() - .parse(new ByteArrayInputStream(report.getBytes(ENCODING))); + .parse(new ByteArrayInputStream(report.getBytes(ENCODING))); NodeList nodes = doc.getChildNodes(); Node n = nodes.item(0); assertEquals("pmd-cpd", n.getNodeName()); assertEquals(0, doc.getElementsByTagName("duplication").getLength()); } - @Test - void testWithOneDuplication() throws Exception { + @Test void testWithOneDuplication() throws Exception { CPDReportRenderer renderer = new XMLRenderer(); CpdReportBuilder builder = new CpdReportBuilder(); int lineCount = 6; @@ -93,7 +91,7 @@ void testWithOneDuplication() throws Exception { assertReportIsValidSchema(report); Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() - .parse(new ByteArrayInputStream(report.getBytes(ENCODING))); + .parse(new ByteArrayInputStream(report.getBytes(ENCODING))); NodeList dupes = doc.getElementsByTagName("duplication"); assertEquals(1, dupes.getLength()); Node file = dupes.item(0).getFirstChild(); @@ -121,8 +119,7 @@ void testWithOneDuplication() throws Exception { assertEquals(CpdTestUtils.generateDummyContent(lineCount), doc.getElementsByTagName("codefragment").item(0).getTextContent()); } - @Test - void testRenderWithMultipleMatch() throws Exception { + @Test void testRenderWithMultipleMatch() throws Exception { CPDReportRenderer renderer = new XMLRenderer(); CpdReportBuilder builder = new CpdReportBuilder(); int lineCount1 = 6; @@ -143,13 +140,12 @@ void testRenderWithMultipleMatch() throws Exception { assertReportIsValidSchema(report); Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() - .parse(new ByteArrayInputStream(report.getBytes(ENCODING))); + .parse(new ByteArrayInputStream(report.getBytes(ENCODING))); assertEquals(2, doc.getElementsByTagName("duplication").getLength()); assertEquals(4, doc.getElementsByTagName("file").getLength()); } - @Test - void testWithOneDuplicationWithColumns() throws Exception { + @Test void testWithOneDuplicationWithColumns() throws Exception { CPDReportRenderer renderer = new XMLRenderer(); int lineCount = 2; CpdReportBuilder builder = new CpdReportBuilder(); @@ -164,7 +160,7 @@ void testWithOneDuplicationWithColumns() throws Exception { assertReportIsValidSchema(report); Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() - .parse(new ByteArrayInputStream(report.getBytes(ENCODING))); + .parse(new ByteArrayInputStream(report.getBytes(ENCODING))); NodeList dupes = doc.getElementsByTagName("duplication"); assertEquals(1, dupes.getLength()); Node file = dupes.item(0).getFirstChild(); @@ -192,8 +188,7 @@ void testWithOneDuplicationWithColumns() throws Exception { assertEquals(CpdTestUtils.generateDummyContent(2), doc.getElementsByTagName("codefragment").item(0).getTextContent()); } - @Test - void testRendererEncodedPath() throws Exception { + @Test void testRendererEncodedPath() throws Exception { CPDReportRenderer renderer = new XMLRenderer(); CpdReportBuilder builder = new CpdReportBuilder(); final String escapeChar = "&"; @@ -208,8 +203,7 @@ void testRendererEncodedPath() throws Exception { assertThat(report, containsString(escapeChar)); } - @Test - void testFilesWithNumberOfTokens() throws IOException, ParserConfigurationException, SAXException { + @Test void testFilesWithNumberOfTokens() throws IOException, ParserConfigurationException, SAXException { final CPDReportRenderer renderer = new XMLRenderer(); CpdReportBuilder builder = new CpdReportBuilder(); final FileId filename = CpdTestUtils.FOO_FILE_ID; @@ -226,7 +220,7 @@ void testFilesWithNumberOfTokens() throws IOException, ParserConfigurationExcept final String xmlOutput = writer.toString(); assertReportIsValidSchema(xmlOutput); final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() - .parse(new ByteArrayInputStream(xmlOutput.getBytes(ENCODING))); + .parse(new ByteArrayInputStream(xmlOutput.getBytes(ENCODING))); final NodeList files = doc.getElementsByTagName("file"); final Node file = files.item(0); final NamedNodeMap attributes = file.getAttributes(); @@ -234,8 +228,7 @@ void testFilesWithNumberOfTokens() throws IOException, ParserConfigurationExcept assertEquals("888", attributes.getNamedItem("totalNumberOfTokens").getNodeValue()); } - @Test - void testGetDuplicationStartEnd() throws IOException, ParserConfigurationException, SAXException { + @Test void testGetDuplicationStartEnd() throws IOException, ParserConfigurationException, SAXException { final CPDReportRenderer renderer = new XMLRenderer(); CpdReportBuilder builder = new CpdReportBuilder(); final FileId filename = CpdTestUtils.FOO_FILE_ID; @@ -252,7 +245,7 @@ void testGetDuplicationStartEnd() throws IOException, ParserConfigurationExcepti final String xmlOutput = writer.toString(); assertReportIsValidSchema(xmlOutput); final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() - .parse(new ByteArrayInputStream(xmlOutput.getBytes(ENCODING))); + .parse(new ByteArrayInputStream(xmlOutput.getBytes(ENCODING))); final NodeList files = doc.getElementsByTagName("file"); final Node dup_1 = files.item(1); final NamedNodeMap attrs_1 = dup_1.getAttributes(); @@ -265,10 +258,9 @@ void testGetDuplicationStartEnd() throws IOException, ParserConfigurationExcepti assertEquals("3", attrs_2.getNamedItem("endtoken").getNodeValue()); } - @Test - void testRendererXMLEscaping() throws Exception { + @Test void testRendererXMLEscaping() throws Exception { String codefragment = "code fragment" + FORM_FEED - + "\nline2\nline3\nno & escaping necessary in CDATA\nx=\"]]>\";"; + + "\nline2\nline3\nno & escaping necessary in CDATA\nx=\"]]>\";"; CPDReportRenderer renderer = new XMLRenderer(); CpdReportBuilder builder = new CpdReportBuilder(); @@ -291,8 +283,7 @@ void testRendererXMLEscaping() throws Exception { assertThat(report, not(containsString("x=\"]]>\";"))); // must be escaped } - @Test - void reportContainsProcessingError() throws Exception { + @Test void reportContainsProcessingError() throws Exception { FileId fileId = FileId.fromPathLikeString("file1.txt"); Report.ProcessingError processingError = new Report.ProcessingError( new LexException(2, 1, fileId, "test exception", new RuntimeException("cause exception")), @@ -325,8 +316,7 @@ void reportContainsProcessingError() throws Exception { * * @see [core] xml output doesn't escape CDATA inside its own CDATA */ - @Test - void cdataSectionInError() throws Exception { + @Test void cdataSectionInError() throws Exception { FileId fileId = FileId.fromPathLikeString("file1.txt"); Report.ProcessingError processingError = new Report.ProcessingError( new LexException(2, 1, fileId, "test exception", new RuntimeException("Invalid source: ' ...'")), @@ -352,13 +342,11 @@ private static void assertReportIsValidSchema(String report) throws SAXException SAXParser saxParser = saxParserFactory.newSAXParser(); saxParser.parse(new InputSource(new StringReader(report)), new DefaultHandler() { - @Override - public void error(SAXParseException e) throws SAXException { + @Override public void error(SAXParseException e) throws SAXException { throw e; } - @Override - public void warning(SAXParseException e) throws SAXException { + @Override public void warning(SAXParseException e) throws SAXException { throw e; } }); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/impl/BaseTokenFilterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/impl/BaseTokenFilterTest.java index e295ba9e984..1a07df27412 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/impl/BaseTokenFilterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/impl/BaseTokenFilterTest.java @@ -34,43 +34,35 @@ static class StringToken implements GenericToken { this.text = text; } - @Override - public StringToken getNext() { + @Override public StringToken getNext() { return null; } - @Override - public StringToken getPreviousComment() { + @Override public StringToken getPreviousComment() { return null; } - @Override - public TextRegion getRegion() { + @Override public TextRegion getRegion() { return TextRegion.fromBothOffsets(0, text.length()); } - @Override - public boolean isEof() { + @Override public boolean isEof() { return text == null; } - @Override - public String getImageCs() { + @Override public String getImageCs() { return text; } - @Override - public FileLocation getReportLocation() { + @Override public FileLocation getReportLocation() { return FileLocation.range(FileId.UNKNOWN, TextRange2d.range2d(1, 1, 1, 1)); } - @Override - public int compareTo(StringToken o) { + @Override public int compareTo(StringToken o) { return text.compareTo(o.text); } - @Override - public int getKind() { + @Override public int getKind() { return 0; } } @@ -79,8 +71,7 @@ static class StringTokenManager implements TokenManager { Iterator iterator = Collections.unmodifiableList(Arrays.asList("a", "b", "c")).iterator(); - @Override - public StringToken getNextToken() { + @Override public StringToken getNextToken() { if (iterator.hasNext()) { return new StringToken(iterator.next()); } else { @@ -98,13 +89,11 @@ static class DummyTokenFilter> extends BaseTokenFilter super(tokenManager); } - @Override - protected boolean shouldStopProcessing(final T currentToken) { + @Override protected boolean shouldStopProcessing(final T currentToken) { return currentToken == null; } - @Override - protected void analyzeTokens(final T currentToken, final Iterable remainingTokens) { + @Override protected void analyzeTokens(final T currentToken, final Iterable remainingTokens) { this.remainingTokens = remainingTokens; } @@ -113,8 +102,7 @@ public Iterable getRemainingTokens() { } } - @Test - void testRemainingTokensFunctionality1() { + @Test void testRemainingTokensFunctionality1() { final TokenManager tokenManager = new StringTokenManager(); final DummyTokenFilter tokenFilter = new DummyTokenFilter<>(tokenManager); final StringToken firstToken = tokenFilter.getNextToken(); @@ -139,8 +127,7 @@ void testRemainingTokensFunctionality1() { assertEquals("c", secondValSecondIt.getImage()); } - @Test - void testRemainingTokensFunctionality2() { + @Test void testRemainingTokensFunctionality2() { final TokenManager tokenManager = new StringTokenManager(); final DummyTokenFilter tokenFilter = new DummyTokenFilter<>(tokenManager); final StringToken firstToken = tokenFilter.getNextToken(); @@ -165,8 +152,7 @@ void testRemainingTokensFunctionality2() { assertEquals("c", secondValSecondIt.getImage()); } - @Test - void testRemainingTokensFunctionality3() { + @Test void testRemainingTokensFunctionality3() { final TokenManager tokenManager = new StringTokenManager(); final DummyTokenFilter tokenFilter = new DummyTokenFilter<>(tokenManager); final StringToken firstToken = tokenFilter.getNextToken(); @@ -181,8 +167,7 @@ void testRemainingTokensFunctionality3() { assertThrows(NoSuchElementException.class, () -> it1.next()); } - @Test - void testRemainingTokensFunctionality4() { + @Test void testRemainingTokensFunctionality4() { final TokenManager tokenManager = new StringTokenManager(); final DummyTokenFilter tokenFilter = new DummyTokenFilter<>(tokenManager); final StringToken firstToken = tokenFilter.getNextToken(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/internal/util/ClasspathClassLoaderTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/internal/util/ClasspathClassLoaderTest.java index 1bbd34cd945..2bae2228865 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/internal/util/ClasspathClassLoaderTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/internal/util/ClasspathClassLoaderTest.java @@ -36,11 +36,9 @@ import org.junit.jupiter.params.provider.ValueSource; class ClasspathClassLoaderTest { - @TempDir - private Path tempDir; + @TempDir private Path tempDir; - @Test - void loadEmptyClasspathWithParent() throws IOException { + @Test void loadEmptyClasspathWithParent() throws IOException { try (ClasspathClassLoader loader = new ClasspathClassLoader("", ClasspathClassLoader.class.getClassLoader())) { try (InputStream resource = loader.getResourceAsStream("java/lang/Object.class")) { assertNotNull(resource); @@ -58,8 +56,7 @@ void loadEmptyClasspathWithParent() throws IOException { * behavior of {@link java.lang.ClassLoader#getResource(java.lang.String)}, which will * search the class loader built into the VM (BootLoader). */ - @Test - void loadEmptyClasspathNoParent() throws IOException { + @Test void loadEmptyClasspathNoParent() throws IOException { try (ClasspathClassLoader loader = new ClasspathClassLoader("", null)) { try (InputStream resource = loader.getResourceAsStream("java/lang/Object.class")) { assertNotNull(resource); @@ -85,8 +82,7 @@ private Path prepareCustomJar() throws IOException { return jarPath; } - @Test - void loadFromJar() throws IOException { + @Test void loadFromJar() throws IOException { Path jarPath = prepareCustomJar(); String classpath = jarPath.toString(); @@ -102,8 +98,7 @@ void loadFromJar() throws IOException { /** * @see [java] Parsing failed in ParseLock#doParse() java.io.IOException: Stream closed #4899 */ - @Test - void loadMultithreadedFromJar() throws IOException, InterruptedException { + @Test void loadMultithreadedFromJar() throws IOException, InterruptedException { Path jarPath = prepareCustomJar(); String classpath = jarPath.toString(); @@ -121,8 +116,7 @@ class ThreadRunnable extends Thread { this.number = number; } - @Override - public void run() { + @Override public void run() { try (ClasspathClassLoader loader = new ClasspathClassLoader(classpath, null)) { // Make sure, the threads get the resource stream one after another, so that the // underlying Jar File is definitively cached (if caching is enabled). @@ -185,9 +179,7 @@ public void run() { * This test only runs, if you have a folder ${HOME}/openjdk{javaVersion}. *

    */ - @ParameterizedTest - @ValueSource(ints = {11, 17, 21}) - void loadFromJava(int javaVersion) throws IOException { + @ParameterizedTest @ValueSource(ints = {11, 17, 21}) void loadFromJava(int javaVersion) throws IOException { Path javaHome = Paths.get(System.getProperty("user.home"), "openjdk" + javaVersion); assumeTrue(Files.isDirectory(javaHome), "Couldn't find java" + javaVersion + " installation at " + javaHome); @@ -235,8 +227,7 @@ private static byte[] readBytes(InputStream stream) throws IOException { return data.toByteArray(); } - @Test - void findModuleInfoFromJar() throws IOException { + @Test void findModuleInfoFromJar() throws IOException { try (ClasspathClassLoader loader = new ClasspathClassLoader("", ClasspathClassLoader.class.getClassLoader())) { // search for module org.junit.platform.suite.api, which should be on the test-classpath in pmd-core... // inside a jar diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/CpdOnlyDummyLanguage.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/CpdOnlyDummyLanguage.java index 85f57d383fe..c896e5f640d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/CpdOnlyDummyLanguage.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/CpdOnlyDummyLanguage.java @@ -20,15 +20,14 @@ public class CpdOnlyDummyLanguage extends CpdOnlyLanguageModuleBase { public CpdOnlyDummyLanguage() { super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("dummy", "txt") - .addDefaultVersion("1.7", "7")); + .addDefaultVersion("1.7", "7")); } public static CpdOnlyDummyLanguage getInstance() { return (CpdOnlyDummyLanguage) Objects.requireNonNull(LanguageRegistry.CPD.getLanguageByFullName(NAME)); } - @Override - public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { + @Override public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { return new AnyCpdLexer(); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/Dummy2LanguageModule.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/Dummy2LanguageModule.java index 6b20bc93b2f..ad4c67b4978 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/Dummy2LanguageModule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/Dummy2LanguageModule.java @@ -19,7 +19,7 @@ public class Dummy2LanguageModule extends SimpleLanguageModuleBase { public Dummy2LanguageModule() { super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("dummy2") - .addDefaultVersion("1.0"), new Handler()); + .addDefaultVersion("1.0"), new Handler()); } public static Dummy2LanguageModule getInstance() { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageDialectModule.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageDialectModule.java index 380ec1356f9..b41f908d220 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageDialectModule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageDialectModule.java @@ -27,7 +27,7 @@ public class DummyLanguageDialectModule extends SimpleDialectLanguageModuleBase public static final Metric DUMMY_DIALECT_METRIC = Metric.of((node, options) -> null, (node) -> node, - "Constant NULL metric", "null"); + "Constant NULL metric", "null"); public static final PropertyDescriptor DUMMY_DIALECT_PROP = PropertyFactory.booleanProperty("dummyDialectProperty") @@ -45,8 +45,7 @@ public static DummyLanguageDialectModule getInstance() { return (DummyLanguageDialectModule) Objects.requireNonNull(LanguageRegistry.PMD.getLanguageByFullName(NAME)); } - @Override - protected @NonNull LanguagePropertyBundle newDialectPropertyBundle() { + @Override protected @NonNull LanguagePropertyBundle newDialectPropertyBundle() { LanguagePropertyBundle bundle = super.newDialectPropertyBundle(); bundle.definePropertyDescriptor(DUMMY_DIALECT_PROP); return bundle; @@ -54,32 +53,26 @@ public static DummyLanguageDialectModule getInstance() { public static class Handler extends BasePmdDialectLanguageVersionHandler { - @Override - public XPathHandler getXPathHandler() { + @Override public XPathHandler getXPathHandler() { return XPathHandler.getHandlerForFunctionDefs(dummyDialectFunction()); } - @Override - public LanguageMetricsProvider getLanguageMetricsProvider() { + @Override public LanguageMetricsProvider getLanguageMetricsProvider() { return () -> CollectionUtil.setOf(DUMMY_DIALECT_METRIC); } } - @NonNull - public static XPathFunctionDefinition dummyDialectFunction() { + @NonNull public static XPathFunctionDefinition dummyDialectFunction() { return new XPathFunctionDefinition("dummyDialectFn", DummyLanguageDialectModule.getInstance()) { - @Override - public Type[] getArgumentTypes() { - return new Type[] {Type.SINGLE_STRING}; + @Override public Type[] getArgumentTypes() { + return new Type[]{Type.SINGLE_STRING}; } - @Override - public Type getResultType() { + @Override public Type getResultType() { return Type.SINGLE_BOOLEAN; } - @Override - public FunctionCall makeCallExpression() { + @Override public FunctionCall makeCallExpression() { return (contextNode, arguments) -> StringUtils.equals(arguments[0].toString(), contextNode.getImage()); } }; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageModule.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageModule.java index f040da86b59..8b8c0842ffa 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageModule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageModule.java @@ -48,32 +48,30 @@ public class DummyLanguageModule extends SimpleLanguageModuleBase implements Cpd public DummyLanguageModule() { super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("dummy", "txt") - .addVersion("1.0") - .addVersion("1.1") - .addVersion("1.2") - .addVersion("1.3") - .addVersion("1.4") - .addVersion("1.5", "5") - .addVersion("1.6", "6") - .addDefaultVersion("1.7", "7") - .addVersion(PARSER_THROWS) - .addVersion("1.8", "8"), new Handler()); + .addVersion("1.0") + .addVersion("1.1") + .addVersion("1.2") + .addVersion("1.3") + .addVersion("1.4") + .addVersion("1.5", "5") + .addVersion("1.6", "6") + .addDefaultVersion("1.7", "7") + .addVersion(PARSER_THROWS) + .addVersion("1.8", "8"), new Handler()); } public static DummyLanguageModule getInstance() { return (DummyLanguageModule) Objects.requireNonNull(LanguageRegistry.PMD.getLanguageByFullName(NAME)); } - @Override - public LanguagePropertyBundle newPropertyBundle() { + @Override public LanguagePropertyBundle newPropertyBundle() { LanguagePropertyBundle bundle = super.newPropertyBundle(); bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS); bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS); return bundle; } - @Override - public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { + @Override public CpdLexer createCpdLexer(LanguagePropertyBundle bundle) { CpdLexer base = new AnyCpdLexer(); return (doc, tokens) -> { Chars text = doc.getText(); @@ -101,8 +99,7 @@ public LanguageVersion getVersionWhereParserThrows() { public static class Handler extends AbstractPmdLanguageVersionHandler { - @Override - public Parser getParser() { + @Override public Parser getParser() { return task -> { if (PARSER_THROWS.equals(task.getLanguageVersion().getVersion())) { throw new ParseException("ohio"); @@ -111,21 +108,18 @@ public Parser getParser() { }; } - @Override - public ViolationDecorator getViolationDecorator() { + @Override public ViolationDecorator getViolationDecorator() { return (node, data) -> data.put(RuleViolation.PACKAGE_NAME, "foo"); } - @Override - public XPathHandler getXPathHandler() { + @Override public XPathHandler getXPathHandler() { return XPathHandler.getHandlerForFunctionDefs(imageIsFunction()); } - @Override - public LanguageMetricsProvider getLanguageMetricsProvider() { + @Override public LanguageMetricsProvider getLanguageMetricsProvider() { return () -> CollectionUtil.setOf( Metric.of((node, options) -> 1, (node) -> node, - "Constant value metric", "const1")); + "Constant value metric", "const1")); } } @@ -196,21 +190,17 @@ public static DummyRootNode readLispNode(ParserTask task) { return root; } - @NonNull - public static XPathFunctionDefinition imageIsFunction() { + @NonNull public static XPathFunctionDefinition imageIsFunction() { return new XPathFunctionDefinition("imageIs", DummyLanguageModule.getInstance()) { - @Override - public Type[] getArgumentTypes() { - return new Type[] {Type.SINGLE_STRING}; + @Override public Type[] getArgumentTypes() { + return new Type[]{Type.SINGLE_STRING}; } - @Override - public Type getResultType() { + @Override public Type getResultType() { return Type.SINGLE_BOOLEAN; } - @Override - public FunctionCall makeCallExpression() { + @Override public FunctionCall makeCallExpression() { return (contextNode, arguments) -> StringUtils.equals(arguments[0].toString(), contextNode.getImage()); } }; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageNoCapabilities.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageNoCapabilities.java index 2d2b347faad..f84b1c76892 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageNoCapabilities.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/DummyLanguageNoCapabilities.java @@ -16,7 +16,7 @@ public class DummyLanguageNoCapabilities extends LanguageModuleBase { public DummyLanguageNoCapabilities() { super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("dummyxxx", "txt") - .addDefaultVersion("1.7", "7")); + .addDefaultVersion("1.7", "7")); } public static DummyLanguageNoCapabilities getInstance() { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageModuleBaseTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageModuleBaseTest.java index 677ba748fa1..d1682714e53 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageModuleBaseTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageModuleBaseTest.java @@ -21,8 +21,7 @@ class LanguageModuleBaseTest { - @Test - void testInvalidId() { + @Test void testInvalidId() { assertInvalidId(""); assertInvalidId("two words"); assertInvalidId("CapitalLetters"); @@ -41,34 +40,29 @@ void testInvalidId() { "Empty versions should not be allowed."); } - @Test - void testVersions() { + @Test void testVersions() { LanguageModuleBase lang = makeLanguage(LanguageMetadata.withId("dumdum").name("Name").extensions("o").addDefaultVersion("abc")); assertThat(lang.getDefaultVersion(), equalTo(lang.getVersion("abc"))); } - @Test - void testMissingVersions() { + @Test void testMissingVersions() { Exception e = assertThrows(IllegalStateException.class, () -> makeLanguage(LanguageMetadata.withId("dumdum").name("Name").extensions("o")), "Languages without versions should not be allowed."); assertEquals("No versions for 'dumdum'", e.getMessage()); } - @Test - void testNoExtensions() { + @Test void testNoExtensions() { Exception ex = assertThrows(IllegalStateException.class, () -> makeLanguage(LanguageMetadata.withId("dumdum").name("Name").addVersion("abc"))); assertThat(ex.getMessage(), containsString("extension")); } - @Test - void testShortNameDefault() { + @Test void testShortNameDefault() { LanguageMetadata meta = LanguageMetadata.withId("java").name("Java"); assertEquals("Java", meta.getShortName()); } - @Test - void testInvalidDependency() { + @Test void testInvalidDependency() { LanguageMetadata meta = LanguageMetadata.withId("java").name("Java"); assertThrows(IllegalArgumentException.class, () -> meta.dependsOnLanguage("not an id")); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageProcessorRegistryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageProcessorRegistryTest.java index cb4824a27b0..a02322d45df 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageProcessorRegistryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageProcessorRegistryTest.java @@ -16,8 +16,7 @@ import net.sourceforge.pmd.util.log.PmdReporter; class LanguageProcessorRegistryTest { - @Test - void loadEnvironmentVariables() throws Exception { + @Test void loadEnvironmentVariables() throws Exception { Map env = new HashMap<>(); env.put("PMD_DUMMY_ROOT_DIRECTORY", "theValue"); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageRegistryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageRegistryTest.java index 4d4109ffa5e..e29d19da951 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageRegistryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageRegistryTest.java @@ -15,8 +15,7 @@ class LanguageRegistryTest { private final LanguageRegistry languageRegistry = LanguageRegistry.PMD; - @Test - void getDefaultVersionLanguageTest() { + @Test void getDefaultVersionLanguageTest() { Language dummy = languageRegistry.getLanguageById("dummy"); LanguageVersion dummy12 = dummy.getVersion("1.2"); assertNotNull(dummy12); @@ -27,8 +26,7 @@ void getDefaultVersionLanguageTest() { assertNotSame(dummy12, dummyDefault); } - @Test - void getLanguageVersionByAliasTest() { + @Test void getLanguageVersionByAliasTest() { Language dummy = languageRegistry.getLanguageById("dummy"); LanguageVersion dummy17 = dummy.getVersion("1.7"); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageVersionDiscovererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageVersionDiscovererTest.java index db639a1dbf5..299b988f2ff 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageVersionDiscovererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/LanguageVersionDiscovererTest.java @@ -17,8 +17,7 @@ class LanguageVersionDiscovererTest { - @Test - void testFileLanguageIsUnknown() { + @Test void testFileLanguageIsUnknown() { DummyLanguageModule lang = DummyLanguageModule.getInstance(); LanguageRegistry lr = LanguageRegistry.singleton(lang); LanguageVersionDiscoverer lvDicoverer = new LanguageVersionDiscoverer(lr); @@ -27,8 +26,7 @@ void testFileLanguageIsUnknown() { assertNull(versionForFile); } - @Test - void testFileLanguageIsDetected() { + @Test void testFileLanguageIsDetected() { DummyLanguageModule lang = DummyLanguageModule.getInstance(); LanguageRegistry lr = LanguageRegistry.singleton(lang); LanguageVersionDiscoverer lvDicoverer = new LanguageVersionDiscoverer(lr); @@ -39,8 +37,7 @@ void testFileLanguageIsDetected() { assertEquals(lang.getDefaultVersion().getVersion(), versionForFile.getVersion()); } - @Test - void testDialectTakesPrecedence() { + @Test void testDialectTakesPrecedence() { DummyLanguageModule lang = DummyLanguageModule.getInstance(); DummyLanguageDialectModule dialect = DummyLanguageDialectModule.getInstance(); Set langSet = new HashSet<>(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/BoundaryTraversalTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/BoundaryTraversalTest.java index e99324f2fdf..53cb3015dac 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/BoundaryTraversalTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/BoundaryTraversalTest.java @@ -29,13 +29,11 @@ private DummyNode addChild(final DummyNode parent, final DummyNode child) { return parent; } - @BeforeEach - void setUpSampleNodeTree() { + @BeforeEach void setUpSampleNodeTree() { rootNode = newDummyNode(false); } - @Test - void testBoundaryIsHonored() { + @Test void testBoundaryIsHonored() { addChild(rootNode, addChild(newDummyNode(true), newDummyNode(false))); List descendantsOfType = rootNode.descendants(DummyNode.class).toList(); @@ -43,8 +41,7 @@ void testBoundaryIsHonored() { assertTrue(descendantsOfType.get(0).isFindBoundary()); } - @Test - void testSearchFromBoundary() { + @Test void testSearchFromBoundary() { addChild(rootNode, addChild(newDummyNode(true), newDummyNode(false))); List descendantsOfType = rootNode.descendants(DummyNode.class).first().descendants(DummyNode.class).toList(); @@ -52,8 +49,7 @@ void testSearchFromBoundary() { assertFalse(descendantsOfType.get(0).isFindBoundary()); } - @Test - void testSearchFromBoundaryFromNonOptimisedStream() { + @Test void testSearchFromBoundaryFromNonOptimisedStream() { addChild(rootNode, addChild(newDummyNode(true), newDummyNode(false))); List descendantsOfType = rootNode.descendants(DummyNode.class).take(1).descendants(DummyNode.class).toList(); @@ -61,8 +57,7 @@ void testSearchFromBoundaryFromNonOptimisedStream() { assertFalse(descendantsOfType.get(0).isFindBoundary()); } - @Test - void testSearchIgnoringBoundary() { + @Test void testSearchIgnoringBoundary() { addChild(rootNode, addChild(newDummyNode(true), newDummyNode(false))); List descendantsOfType = rootNode.descendants(DummyNode.class).crossFindBoundaries().toList(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/DummyNode.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/DummyNode.java index 627b9395a22..39c20a996c8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/DummyNode.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/DummyNode.java @@ -55,13 +55,11 @@ public DummyNode(boolean findBoundary, String xpathName) { } } - @Override - public void addChild(DummyNode child, int index) { + @Override public void addChild(DummyNode child, int index) { super.addChild(child, index); } - @Override - public void setParent(DummyNode node) { + @Override public void setParent(DummyNode node) { super.setParent(node); } @@ -72,8 +70,7 @@ public void publicSetChildren(DummyNode... children) { } } - @Override - public TextRegion getTextRegion() { + @Override public TextRegion getTextRegion() { return region; } @@ -92,23 +89,19 @@ public void setImage(String image) { } } - @Override - public String getImage() { + @Override public String getImage() { return image; } - @Override - public String toString() { + @Override public String toString() { return getXPathNodeName() + "[@Image=" + getImage() + "]"; } - @Override - public String getXPathNodeName() { + @Override public String getXPathNodeName() { return xpathName; } - @Override - public boolean isFindBoundary() { + @Override public boolean isFindBoundary() { return findBoundary; } @@ -121,8 +114,7 @@ public void clearXPathAttributes() { attributes.clear(); } - @Override - public Iterator getXPathAttributesIterator() { + @Override public Iterator getXPathAttributesIterator() { return attributes.iterator(); } @@ -135,21 +127,21 @@ public static class DummyRootNode extends DummyNode implements RootNode, Generic // FIXME remove this private static final LanguageProcessor STATIC_PROCESSOR = - DummyLanguageModule.getInstance().createProcessor(DummyLanguageModule.getInstance().newPropertyBundle()); + DummyLanguageModule.getInstance().createProcessor(DummyLanguageModule.getInstance().newPropertyBundle()); private AstInfo astInfo; public DummyRootNode() { TextDocument document = TextDocument.readOnlyString( - "dummy text", - FileId.UNKNOWN, - DummyLanguageModule.getInstance().getDefaultVersion() + "dummy text", + FileId.UNKNOWN, + DummyLanguageModule.getInstance().getDefaultVersion() ); astInfo = new AstInfo<>( - new ParserTask( - document, - SemanticErrorReporter.noop(), - LanguageProcessorRegistry.singleton(STATIC_PROCESSOR)), - this); + new ParserTask( + document, + SemanticErrorReporter.noop(), + LanguageProcessorRegistry.singleton(STATIC_PROCESSOR)), + this); } public DummyRootNode withTaskInfo(ParserTask task) { @@ -162,13 +154,11 @@ public DummyRootNode withNoPmdComments(SuppressionCommentWrapper... suppressMap) return this; } - @Override - public AstInfo getAstInfo() { + @Override public AstInfo getAstInfo() { return Objects.requireNonNull(astInfo, "no ast info"); } - @Override - public String getXPathNodeName() { + @Override public String getXPathNodeName() { return "dummyRootNode"; } } @@ -181,25 +171,21 @@ public DummyNodeTypeB() { } public static class DummyTextNode extends DummyNode implements TextNode { - @Override - public String getText() { + @Override public String getText() { return getImage(); } - @Override - public String getXPathNodeName() { + @Override public String getXPathNodeName() { return TextNode.super.getXPathNodeName(); } } public static class DummyCommentNode extends DummyNode implements CommentNode { - @Override - public String getData() { + @Override public String getData() { return getImage(); } - @Override - public String getXPathNodeName() { + @Override public String getXPathNodeName() { return CommentNode.super.getXPathNodeName(); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/DummyNodeWithDeprecatedAttribute.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/DummyNodeWithDeprecatedAttribute.java index 9a84d9997c9..50d5d6f0aca 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/DummyNodeWithDeprecatedAttribute.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/DummyNodeWithDeprecatedAttribute.java @@ -17,20 +17,17 @@ public class DummyNodeWithDeprecatedAttribute extends DummyNode { // this is the deprecated attribute - @Deprecated - public int getSize() { + @Deprecated public int getSize() { return 2; } // this is a attribute that is deprecated for xpath, because it will be removed. // it should still be available via Java. - @DeprecatedAttribute(replaceWith = "@Image") - public String getName() { + @DeprecatedAttribute(replaceWith = "@Image") public String getName() { return "foo"; } - @Override - public Iterator getXPathAttributesIterator() { + @Override public Iterator getXPathAttributesIterator() { return new AttributeAxisIterator(this); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/LexExceptionTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/LexExceptionTest.java index 33bbcc972fe..9e4f4355593 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/LexExceptionTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/LexExceptionTest.java @@ -9,28 +9,24 @@ import org.junit.jupiter.api.Test; class LexExceptionTest { - @Test - void invalidLocation() { + @Test void invalidLocation() { LexException error = new LexException(2, 0, null, "test", null); // this shouldn't throw a IllegalArgumentException assertEquals("line 2, column 1", error.location().startPosToString()); } - @Test - void invalidLocationJavaCC() { + @Test void invalidLocationJavaCC() { LexException error = new LexException(false, "DEFAULT", 2, 0, "}", '\n'); // this shouldn't throw a IllegalArgumentException assertEquals("line 2, column 1", error.location().startPosToString()); } - @Test - void validLocation() { + @Test void validLocation() { LexException error = new LexException(1, 1, null, "test", null); assertEquals("line 1, column 1", error.location().startPosToString()); } - @Test - void validLocationJavaCC() { + @Test void validLocationJavaCC() { LexException error = new LexException(false, "DEFAULT", 1, 1, "}", '\n'); assertEquals("line 1, column 1", error.location().startPosToString()); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporterTest.java index 7769164d373..f80faba2614 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/SemanticErrorReporterTest.java @@ -33,18 +33,15 @@ class SemanticErrorReporterTest { PmdReporter mockReporter; Logger mockLogger; - @RegisterExtension - private final DummyParsingHelper helper = new DummyParsingHelper(); + @RegisterExtension private final DummyParsingHelper helper = new DummyParsingHelper(); - @BeforeEach - void setup() { + @BeforeEach void setup() { mockReporter = mock(PmdReporter.class); when(mockReporter.isLoggable(Level.ERROR)).thenReturn(true); mockLogger = spy(NOPLogger.class); } - @Test - void testErrorLogging() { + @Test void testErrorLogging() { SemanticErrorReporter reporter = SemanticErrorReporter.reportToLogger(mockReporter); RootNode node = parseMockNode(); @@ -59,8 +56,7 @@ void testErrorLogging() { assertNotNull(reporter.getFirstError()); } - @Test - void testEscaping() { + @Test void testEscaping() { SemanticErrorReporter reporter = SemanticErrorReporter.reportToLogger(mockReporter); RootNode node = parseMockNode(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/AbstractNodeTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/AbstractNodeTest.java index 430f6b3dc8c..533b9a04fc9 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/AbstractNodeTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/AbstractNodeTest.java @@ -55,7 +55,7 @@ static Object[] childrenAndGrandChildrenIndexes() { int i = 0; for (final int childIndex : childrenIndexes) { for (final int grandChildIndex : grandChildrenIndexes) { - indexes[i++] = new Integer[] { childIndex, grandChildIndex }; + indexes[i++] = new Integer[]{childIndex, grandChildIndex}; } } return indexes; @@ -63,21 +63,20 @@ static Object[] childrenAndGrandChildrenIndexes() { private DummyRootNode rootNode; - @BeforeEach - void setUpSampleNodeTree() { + @BeforeEach void setUpSampleNodeTree() { rootNode = tree( - () -> { - DummyRootNode root = root(); - - for (int i = 0; i < NUM_CHILDREN; i++) { - final DummyNode child = node(); - for (int j = 0; j < NUM_GRAND_CHILDREN; j++) { - child.addChild(node(), j); + () -> { + DummyRootNode root = root(); + + for (int i = 0; i < NUM_CHILDREN; i++) { + final DummyNode child = node(); + for (int j = 0; j < NUM_GRAND_CHILDREN; j++) { + child.addChild(node(), j); + } + root.addChild(child, i); } - root.addChild(child, i); + return root; } - return root; - } ); } @@ -85,9 +84,7 @@ void setUpSampleNodeTree() { /** * Explicitly tests the {@code remove} method, and implicitly the {@code removeChildAtIndex} method */ - @ParameterizedTest - @MethodSource("childrenIndexes") - void testRemoveChildOfRootNode(final int childIndex) { + @ParameterizedTest @MethodSource("childrenIndexes") void testRemoveChildOfRootNode(final int childIndex) { final DummyNode child = rootNode.getChild(childIndex); final List grandChildren = child.children().toList(); @@ -104,8 +101,7 @@ void testRemoveChildOfRootNode(final int childIndex) { } } - @Test - void testPrevNextSiblings() { + @Test void testPrevNextSiblings() { DummyRootNode root = tree(() -> root(node(), node())); assertNull(root.getNextSibling()); @@ -124,8 +120,7 @@ void testPrevNextSiblings() { * Explicitly tests the {@code remove} method, and implicitly the {@code removeChildAtIndex} method. * This is a border case as the root node does not have any parent. */ - @Test - void testRemoveRootNode() { + @Test void testRemoveRootNode() { // Check that the root node has the expected properties final List children = rootNode.children().toList(); @@ -145,9 +140,7 @@ void testRemoveRootNode() { * Explicitly tests the {@code remove} method, and implicitly the {@code removeChildAtIndex} method. * These are border cases as grandchildren nodes do not have any child. */ - @ParameterizedTest - @MethodSource("childrenAndGrandChildrenIndexes") - void testRemoveGrandChildNode(final int childIndex, final int grandChildIndex) { + @ParameterizedTest @MethodSource("childrenAndGrandChildrenIndexes") void testRemoveGrandChildNode(final int childIndex, final int grandChildIndex) { final DummyNode child = rootNode.getChild(childIndex); final DummyNode grandChild = child.getChild(grandChildIndex); @@ -163,9 +156,7 @@ void testRemoveGrandChildNode(final int childIndex, final int grandChildIndex) { /** * Explicitly tests the {@code removeChildAtIndex} method. */ - @ParameterizedTest - @MethodSource("childrenIndexes") - void testRemoveRootNodeChildAtIndex(final int childIndex) { + @ParameterizedTest @MethodSource("childrenIndexes") void testRemoveRootNodeChildAtIndex(final int childIndex) { final List originalChildren = rootNode.children().toList(); // Do the actual removal @@ -190,8 +181,7 @@ void testRemoveRootNodeChildAtIndex(final int childIndex) { * Explicitly tests the {@code removeChildAtIndex} method. * Test that invalid indexes cases are handled without exception. */ - @Test - void testRemoveChildAtIndexWithInvalidIndex() { + @Test void testRemoveChildAtIndexWithInvalidIndex() { try { rootNode.removeChildAtIndex(-1); rootNode.removeChildAtIndex(rootNode.getNumChildren()); @@ -204,9 +194,7 @@ void testRemoveChildAtIndexWithInvalidIndex() { * Explicitly tests the {@code removeChildAtIndex} method. * This is a border case as the method invocation should do nothing. */ - @ParameterizedTest - @MethodSource("grandChildrenIndexes") - void testRemoveChildAtIndexOnNodeWithNoChildren(final int grandChildIndex) { + @ParameterizedTest @MethodSource("grandChildrenIndexes") void testRemoveChildAtIndexOnNodeWithNoChildren(final int grandChildIndex) { // grandChild does not have any child final DummyNode grandChild = rootNode.getChild(grandChildIndex).getChild(grandChildIndex); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/CharStreamTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/CharStreamTest.java index ff730aec425..b989842dd20 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/CharStreamTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/CharStreamTest.java @@ -22,8 +22,7 @@ class CharStreamTest { private LanguageVersion dummyVersion = DummyLanguageModule.getInstance().getDefaultVersion(); - @Test - void testReadZeroChars() throws IOException { + @Test void testReadZeroChars() throws IOException { CharStream stream = simpleCharStream(""); @@ -33,8 +32,7 @@ void testReadZeroChars() throws IOException { assertEquals(stream.getEndOffset(), 0); } - @Test - void testMultipleEofReads() throws IOException { + @Test void testMultipleEofReads() throws IOException { CharStream stream = simpleCharStream(""); @@ -44,8 +42,7 @@ void testMultipleEofReads() throws IOException { } - @Test - void testReadStuff() throws IOException { + @Test void testReadStuff() throws IOException { CharStream stream = simpleCharStream("abcd"); @@ -57,8 +54,7 @@ void testReadStuff() throws IOException { assertThrows(EOFException.class, stream::readChar); } - @Test - void testReadBacktrack() throws IOException { + @Test void testReadBacktrack() throws IOException { CharStream stream = simpleCharStream("abcd"); @@ -77,8 +73,7 @@ void testReadBacktrack() throws IOException { assertThrows(EOFException.class, stream::readChar); } - @Test - void testReadBacktrackWithEscapes() throws IOException { + @Test void testReadBacktrackWithEscapes() throws IOException { CharStream stream = javaCharStream("__\\u00a0_\\u00a0_"); @@ -105,8 +100,7 @@ void testReadBacktrackWithEscapes() throws IOException { assertThrows(EOFException.class, stream::readChar); } - @Test - void testBacktrackTooMuch() throws IOException { + @Test void testBacktrackTooMuch() throws IOException { CharStream stream = simpleCharStream("abcd"); @@ -120,8 +114,7 @@ void testBacktrackTooMuch() throws IOException { assertThrows(IllegalArgumentException.class, () -> stream.backup(1)); } - @Test - void testBacktrackTooMuch2() throws IOException { + @Test void testBacktrackTooMuch2() throws IOException { CharStream stream = simpleCharStream("abcd"); @@ -140,13 +133,12 @@ CharStream simpleCharStream(String abcd) { CharStream javaCharStream(String abcd) { return CharStream.create( - TextDocument.readOnlyString(abcd, dummyVersion), - new TokenDocumentBehavior(Collections.emptyList()) { - @Override - public TextDocument translate(TextDocument text) throws MalformedSourceException { - return new JavaEscapeTranslator(text).translateDocument(); - } - }); + TextDocument.readOnlyString(abcd, dummyVersion), + new TokenDocumentBehavior(Collections.emptyList()) { + @Override public TextDocument translate(TextDocument text) throws MalformedSourceException { + return new JavaEscapeTranslator(text).translateDocument(); + } + }); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaEscapeReaderTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaEscapeReaderTest.java index a1e8c8faec1..8394f284801 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaEscapeReaderTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/impl/javacc/JavaEscapeReaderTest.java @@ -23,8 +23,7 @@ TextDocument readString(String input) { } - @Test - void testSimpleRead() throws IOException { + @Test void testSimpleRead() throws IOException { String input = "abcdede"; try (TextDocument r = readString(input)) { @@ -32,8 +31,7 @@ void testSimpleRead() throws IOException { } } - @Test - void testNotAnEscape1Read() throws IOException { + @Test void testNotAnEscape1Read() throws IOException { String input = "abc\\dede"; try (TextDocument r = readString(input)) { @@ -41,8 +39,7 @@ void testNotAnEscape1Read() throws IOException { } } - @Test - void testNotAnEscape1Read2() throws IOException { + @Test void testNotAnEscape1Read2() throws IOException { String input = "abc\\\\\\dede"; try (TextDocument r = readString(input)) { @@ -50,8 +47,7 @@ void testNotAnEscape1Read2() throws IOException { } } - @Test - void testAnEscapeStopAtEnd() throws IOException { + @Test void testAnEscapeStopAtEnd() throws IOException { String input = "abc\\\\\\u00a0dede"; try (TextDocument r = readString(input)) { @@ -59,8 +55,7 @@ void testAnEscapeStopAtEnd() throws IOException { } } - @Test - void testSeveralEscapes() throws IOException { + @Test void testSeveralEscapes() throws IOException { String input = "abc\\\\\\u00a0d\\uu00a0ede"; try (TextDocument r = readString(input)) { @@ -68,8 +63,7 @@ void testSeveralEscapes() throws IOException { } } - @Test - void testAnEscapeInsideBlock() throws IOException { + @Test void testAnEscapeInsideBlock() throws IOException { String input = "abc\\\\\\u00a0dede\\u00a0"; try (TextDocument r = readString(input)) { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeFindingUtilTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeFindingUtilTest.java index 4bdf1d8a0f6..9b093b87518 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeFindingUtilTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeFindingUtilTest.java @@ -25,8 +25,7 @@ class NodeFindingUtilTest { - @Test - void testFindNode() { + @Test void testFindNode() { DummyNode.DummyRootNode root = parseLispish("(a(b)x(c))"); assertFinds("a", 1, root); @@ -57,9 +56,9 @@ static DummyNode.DummyRootNode parseLispish(String source) { DummyLanguageModule lang = DummyLanguageModule.getInstance(); try (LanguageProcessor processor = lang.createProcessor(lang.newPropertyBundle())) { Parser.ParserTask task = new Parser.ParserTask( - TextDocument.readOnlyString(source, lang.getDefaultVersion()), - SemanticErrorReporter.noop(), - LanguageProcessorRegistry.singleton(processor) + TextDocument.readOnlyString(source, lang.getDefaultVersion()), + SemanticErrorReporter.noop(), + LanguageProcessorRegistry.singleton(processor) ); RootNode root = processor.services().getParser().parse(task); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamBlanketTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamBlanketTest.java index 83be8001b3c..e76a8d8567e 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamBlanketTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamBlanketTest.java @@ -37,39 +37,37 @@ class NodeStreamBlanketTest { private static final List ASTS = Arrays.asList( - tree( - () -> - root( - - node( - node(), - nodeB( - node( - nodeB() + tree( + () -> + root( + + node( + node(), + nodeB( + node( + nodeB() + ) + ), + node(), + nodeB() + ), + node() ) - ), - node(), - nodeB() - ), - node() - ) - ), - tree( - () -> - root( - node(), - node(), - nodeB( - node() - ), - node() - ) - ) + ), + tree( + () -> + root( + node(), + node(), + nodeB( + node() + ), + node() + ) + ) ); - @ParameterizedTest - @MethodSource("allNodeStreamVariants") - void testToListConsistency(NodeStream stream) { + @ParameterizedTest @MethodSource("allNodeStreamVariants") void testToListConsistency(NodeStream stream) { List toList = stream.toList(); List collected = stream.collect(Collectors.toList()); List fromStream = stream.toStream().collect(Collectors.toList()); @@ -80,124 +78,100 @@ void testToListConsistency(NodeStream stream) { assertEquals(toList, cached); } - @ParameterizedTest - @MethodSource("allNodeStreamVariants") - void testToListSize(NodeStream stream) { + @ParameterizedTest @MethodSource("allNodeStreamVariants") void testToListSize(NodeStream stream) { List toList = stream.toList(); assertEquals(toList.size(), stream.count()); } - @ParameterizedTest - @MethodSource("nodeStreamVariantsNonEmpty") - void testLast(NodeStream stream) { + @ParameterizedTest @MethodSource("nodeStreamVariantsNonEmpty") void testLast(NodeStream stream) { assertImplication( - stream, - prop("nonEmpty", NodeStream::nonEmpty), - prop("last() == toList().last()", it -> it.last() == it.toList().get(it.count() - 1)) + stream, + prop("nonEmpty", NodeStream::nonEmpty), + prop("last() == toList().last()", it -> it.last() == it.toList().get(it.count() - 1)) ); } - @ParameterizedTest - @MethodSource("nodeStreamVariantsNonEmpty") - void testFirst(NodeStream stream) { + @ParameterizedTest @MethodSource("nodeStreamVariantsNonEmpty") void testFirst(NodeStream stream) { assertImplication( - stream, - prop("nonEmpty", NodeStream::nonEmpty), - prop("first() == toList().get(0)", it -> it.first() == it.toList().get(0)) + stream, + prop("nonEmpty", NodeStream::nonEmpty), + prop("first() == toList().get(0)", it -> it.first() == it.toList().get(0)) ); } - @ParameterizedTest - @MethodSource("nodeStreamVariantsNonEmpty") - void testDrop(NodeStream stream) { + @ParameterizedTest @MethodSource("nodeStreamVariantsNonEmpty") void testDrop(NodeStream stream) { assertImplication( - stream, - prop("nonEmpty", NodeStream::nonEmpty), - prop("drop(0) == this", it -> it.drop(0) == it), - prop("drop(1).count() == count() - 1", it -> it.drop(1).count() == it.count() - 1), - prop("drop(1).toList() == toList().tail()", it -> it.drop(1).toList().equals(tail(it.toList()))) + stream, + prop("nonEmpty", NodeStream::nonEmpty), + prop("drop(0) == this", it -> it.drop(0) == it), + prop("drop(1).count() == count() - 1", it -> it.drop(1).count() == it.count() - 1), + prop("drop(1).toList() == toList().tail()", it -> it.drop(1).toList().equals(tail(it.toList()))) ); } - @ParameterizedTest - @MethodSource("nodeStreamVariantsNonEmpty") - void testDropLast(NodeStream stream) { + @ParameterizedTest @MethodSource("nodeStreamVariantsNonEmpty") void testDropLast(NodeStream stream) { assertImplication( - stream, - prop("nonEmpty", NodeStream::nonEmpty), - prop("dropLast(0) == this", it -> it.dropLast(0) == it), - prop("dropLast(1).count() == count() - 1", it -> it.dropLast(1).count() == it.count() - 1), - prop("dropLast(1).toList() == toList().init()", it -> it.dropLast(1).toList().equals(init(it.toList()))) + stream, + prop("nonEmpty", NodeStream::nonEmpty), + prop("dropLast(0) == this", it -> it.dropLast(0) == it), + prop("dropLast(1).count() == count() - 1", it -> it.dropLast(1).count() == it.count() - 1), + prop("dropLast(1).toList() == toList().init()", it -> it.dropLast(1).toList().equals(init(it.toList()))) ); } - @ParameterizedTest - @MethodSource("nodeStreamVariantsMoreThanOne") - void testDropMoreThan1(NodeStream stream) { + @ParameterizedTest @MethodSource("nodeStreamVariantsMoreThanOne") void testDropMoreThan1(NodeStream stream) { assertImplication( - stream, - prop("count() > 1", it -> it.count() > 1), - prop("drop(2).toList() == toList().tail().tail()", it -> it.drop(2).toList().equals(tail(tail(it.toList())))), - prop("drop(1).drop(1) == drop(2)", it -> it.drop(1).drop(1).toList().equals(it.drop(2).toList())) + stream, + prop("count() > 1", it -> it.count() > 1), + prop("drop(2).toList() == toList().tail().tail()", it -> it.drop(2).toList().equals(tail(tail(it.toList())))), + prop("drop(1).drop(1) == drop(2)", it -> it.drop(1).drop(1).toList().equals(it.drop(2).toList())) ); } - @ParameterizedTest - @MethodSource("nodeStreamVariantsNonEmpty") - void testTake(NodeStream stream) { + @ParameterizedTest @MethodSource("nodeStreamVariantsNonEmpty") void testTake(NodeStream stream) { assertImplication( - stream, - prop("nonEmpty", NodeStream::nonEmpty), - prop("it.take(0).count() == 0", it -> it.take(0).count() == 0), - prop("it.take(1).count() == 1", it -> it.take(1).count() == 1), - prop("it.take(it.count()).count() == it.count()", it -> it.take(it.count()).count() == it.count()) + stream, + prop("nonEmpty", NodeStream::nonEmpty), + prop("it.take(0).count() == 0", it -> it.take(0).count() == 0), + prop("it.take(1).count() == 1", it -> it.take(1).count() == 1), + prop("it.take(it.count()).count() == it.count()", it -> it.take(it.count()).count() == it.count()) ); } - @ParameterizedTest - @MethodSource("allNodeStreamVariants") - void testGet(NodeStream stream) { + @ParameterizedTest @MethodSource("allNodeStreamVariants") void testGet(NodeStream stream) { for (int i = 0; i < 100; i++) { assertSame(stream.get(i), stream.drop(i).first(), "stream.get(i) == stream.drop(i).first()"); } } - @ParameterizedTest - @MethodSource("allNodeStreamVariants") - void testGetNegative(NodeStream stream) { + @ParameterizedTest @MethodSource("allNodeStreamVariants") void testGetNegative(NodeStream stream) { assertThrows(IllegalArgumentException.class, () -> stream.get(-1)); } - @ParameterizedTest - @MethodSource("allNodeStreamVariants") - void testDropNegative(NodeStream stream) { + @ParameterizedTest @MethodSource("allNodeStreamVariants") void testDropNegative(NodeStream stream) { assertThrows(IllegalArgumentException.class, () -> stream.drop(-1)); } - @ParameterizedTest - @MethodSource("allNodeStreamVariants") - void testTakeNegative(NodeStream stream) { + @ParameterizedTest @MethodSource("allNodeStreamVariants") void testTakeNegative(NodeStream stream) { assertThrows(IllegalArgumentException.class, () -> stream.take(-1)); } - @ParameterizedTest - @MethodSource("allNodeStreamVariants") - void testEmpty(NodeStream stream) { + @ParameterizedTest @MethodSource("allNodeStreamVariants") void testEmpty(NodeStream stream) { assertEquivalence( - stream, - prop("isEmpty", NodeStream::isEmpty), - prop("!nonEmpty", it -> !it.nonEmpty()), - prop("last() == null", it -> it.last() == null), - prop("first() == null", it -> it.first() == null), - prop("first(_ -> true) == null", it -> it.first(i -> true) == null), - prop("first(Node.class) == null", it -> it.first(Node.class) == null), - prop("count() == 0", it -> it.count() == 0), - prop("any(_) == false", it -> !it.any(i -> true)), - prop("all(_) == true", it -> it.all(i -> false)), - prop("none(_) == true", it -> it.none(i -> true)) + stream, + prop("isEmpty", NodeStream::isEmpty), + prop("!nonEmpty", it -> !it.nonEmpty()), + prop("last() == null", it -> it.last() == null), + prop("first() == null", it -> it.first() == null), + prop("first(_ -> true) == null", it -> it.first(i -> true) == null), + prop("first(Node.class) == null", it -> it.first(Node.class) == null), + prop("count() == 0", it -> it.count() == 0), + prop("any(_) == false", it -> !it.any(i -> true)), + prop("all(_) == true", it -> it.all(i -> false)), + prop("none(_) == true", it -> it.none(i -> true)) ); } @@ -212,70 +186,68 @@ static Collection> nodeStreamVariantsMoreThanOne() { static Collection> allNodeStreamVariants() { return ASTS.stream().flatMap( - root -> Stream.of( - root.asStream(), - root.children().first().asStream(), - // keep this, so that transformation are tested on empty node streams as well - NodeStream.empty() - ) + root -> Stream.of( + root.asStream(), + root.children().first().asStream(), + // keep this, so that transformation are tested on empty node streams as well + NodeStream.empty() + ) ).flatMap( - // add some transformations on each of them - stream -> Stream.of( - stream, - stream.drop(1), - stream.take(2), - stream.filter(n -> !n.getImage().isEmpty()), - stream.firstChild(DummyNodeTypeB.class), - stream.children(DummyNodeTypeB.class), - stream.descendants(DummyNodeTypeB.class), - stream.ancestors(DummyNodeTypeB.class), - stream.descendants(), - stream.ancestors(), - stream.ancestorsOrSelf(), - stream.followingSiblings(), - stream.precedingSiblings(), - stream.descendantsOrSelf(), - stream.children(), - stream.children().filter(c -> "0".equals(c.getImage())), - stream.children(DummyNode.class) - ) + // add some transformations on each of them + stream -> Stream.of( + stream, + stream.drop(1), + stream.take(2), + stream.filter(n -> !n.getImage().isEmpty()), + stream.firstChild(DummyNodeTypeB.class), + stream.children(DummyNodeTypeB.class), + stream.descendants(DummyNodeTypeB.class), + stream.ancestors(DummyNodeTypeB.class), + stream.descendants(), + stream.ancestors(), + stream.ancestorsOrSelf(), + stream.followingSiblings(), + stream.precedingSiblings(), + stream.descendantsOrSelf(), + stream.children(), + stream.children().filter(c -> "0".equals(c.getImage())), + stream.children(DummyNode.class) + ) ).flatMap( - // add some transformations on each of them - stream -> Stream.of( - stream, - stream.filterIs(DummyNode.class), - stream.take(1), - stream.drop(1), - stream.filter(n -> !n.getImage().isEmpty()), - stream.cached() - ) + // add some transformations on each of them + stream -> Stream.of( + stream, + stream.filterIs(DummyNode.class), + stream.take(1), + stream.drop(1), + stream.filter(n -> !n.getImage().isEmpty()), + stream.cached() + ) ).collect(Collectors.toCollection(ArrayList::new)); } - @SafeVarargs - private static void assertEquivalence(T input, Prop... properties) { + @SafeVarargs private static void assertEquivalence(T input, Prop... properties) { for (Prop prop1 : properties) { for (Prop prop2 : properties) { boolean p1 = prop1.test(input); assertEquals( - p1, prop2.test(input), - "Expected (" + prop1.description + ") === (" + prop2.description - + "), but the LHS was " + p1 + " and the RHS was " + !p1 + p1, prop2.test(input), + "Expected (" + prop1.description + ") === (" + prop2.description + + "), but the LHS was " + p1 + " and the RHS was " + !p1 ); } } } - @SafeVarargs - private static void assertImplication(T input, Prop precond, Prop... properties) { + @SafeVarargs private static void assertImplication(T input, Prop precond, Prop... properties) { assumeTrue(precond.test(input)); for (Prop prop : properties) { assertTrue( - prop.test(input), - "Expected (" + precond.description + ") to entail (" + prop.description - + "), but the latter was false" + prop.test(input), + "Expected (" + precond.description + ") to entail (" + prop.description + + "), but the latter was false" ); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamTest.java index 8ad655b2210..c6e5be8f588 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/internal/NodeStreamTest.java @@ -40,39 +40,38 @@ class NodeStreamTest { private final DummyNode tree1 = tree( - () -> - root(// "" - nodeB(// 0 - node(), // 00 - nodeB(// 01 - node(), // 010 - node(// 011 - node() // 0110 - ), - node(), // 012 - node() // 013 - ) - ), - node() // 1 - ) + () -> + root(// "" + nodeB(// 0 + node(), // 00 + nodeB(// 01 + node(), // 010 + node(// 011 + node() // 0110 + ), + node(), // 012 + node() // 013 + ) + ), + node() // 1 + ) ); private final DummyNode tree2 = tree( - () -> - root( - node(), - node(), - node( - node() - ), - node() - ) + () -> + root( + node(), + node(), + node( + node() + ), + node() + ) ); - @Test - void testStreamConstructionIsNullSafe() { + @Test void testStreamConstructionIsNullSafe() { assertTrue(NodeStream.of((Node) null).isEmpty()); assertThat(NodeStream.of(null, null, tree1).count(), equalTo(1)); assertThat(NodeStream.fromIterable(Arrays.asList(tree1, null, null)).count(), equalTo(1)); @@ -80,27 +79,23 @@ void testStreamConstructionIsNullSafe() { } - @Test - void testMapIsNullSafe() { + @Test void testMapIsNullSafe() { assertTrue(tree1.descendantsOrSelf().map(n -> null).isEmpty()); } - @Test - void testFlatMapIsNullSafe() { + @Test void testFlatMapIsNullSafe() { assertTrue(tree1.descendantsOrSelf().flatMap(n -> null).isEmpty()); } - @Test - void testChildrenStream() { + @Test void testChildrenStream() { assertThat(pathsOf(tree1.children()), contains("0", "1")); assertThat(pathsOf(tree1.asStream().children()), contains("0", "1")); } - @Test - void testChildrenEagerEvaluation() { + @Test void testChildrenEagerEvaluation() { NodeStream children = tree1.children(); assertThat(children, is(instanceOf(AxisStream.ChildrenStream.class))); NodeStream children1 = children.children(); @@ -109,28 +104,24 @@ void testChildrenEagerEvaluation() { } - @Test - void testDescendantStream() { + @Test void testDescendantStream() { assertThat(pathsOf(tree1.descendants()), contains("0", "00", "01", "010", "011", "0110", "012", "013", "1")); assertThat(pathsOf(tree1.asStream().descendants()), contains("0", "00", "01", "010", "011", "0110", "012", "013", "1")); } - @Test - void testSingletonStream() { + @Test void testSingletonStream() { assertThat(pathsOf(tree1.asStream()), contains("")); assertThat(pathsOf(NodeStream.of(tree1)), contains("")); } - @Test - void testDescendantOrSelfStream() { + @Test void testDescendantOrSelfStream() { assertThat(pathsOf(tree1.descendantsOrSelf()), contains("", "0", "00", "01", "010", "011", "0110", "012", "013", "1")); assertThat(pathsOf(NodeStream.of(tree1).descendantsOrSelf()), contains("", "0", "00", "01", "010", "011", "0110", "012", "013", "1")); assertThat(pathsOf(followPath(tree1, "0110").descendantsOrSelf()), contains("0110")); // with a leaf node } - @Test - void testAncestors() { + @Test void testAncestors() { // 010 Node node = tree1.children().children().children().first(); assertEquals("010", node.getImage()); @@ -143,8 +134,7 @@ void testAncestors() { assertNull(node.ancestors().get(3)); } - @Test - void testAncestorsFiltered() { + @Test void testAncestorsFiltered() { // 0110 Node node = tree1.children().children().children().children().first(); assertEquals("0110", node.getImage()); @@ -153,8 +143,7 @@ void testAncestorsFiltered() { } - @Test - void testAncestorsFilteredDrop() { + @Test void testAncestorsFilteredDrop() { // 0110 Node node = tree1.children().children().children().children().first(); assertEquals("0110", node.getImage()); @@ -164,56 +153,48 @@ void testAncestorsFilteredDrop() { } - @Test - void testFollowingSiblings() { + @Test void testFollowingSiblings() { assertThat(pathsOf(followPath(tree2, "2").asStream().followingSiblings()), contains("3")); assertThat(pathsOf(followPath(tree2, "0").asStream().followingSiblings()), contains("1", "2", "3")); assertTrue(pathsOf(followPath(tree2, "3").asStream().followingSiblings()).isEmpty()); } - @Test - void testPrecedingSiblings() { + @Test void testPrecedingSiblings() { assertThat(pathsOf(followPath(tree2, "2").asStream().precedingSiblings()), contains("0", "1")); assertThat(pathsOf(followPath(tree2, "3").asStream().precedingSiblings()), contains("0", "1", "2")); assertTrue(pathsOf(followPath(tree2, "0").asStream().precedingSiblings()).isEmpty()); } - @Test - void testRootSiblings() { + @Test void testRootSiblings() { assertTrue(tree2.asStream().precedingSiblings().isEmpty()); assertTrue(tree2.asStream().followingSiblings().isEmpty()); } - @Test - void testAncestorStream() { + @Test void testAncestorStream() { assertThat(pathsOf(followPath(tree1, "01").ancestors()), contains("0", "")); assertThat(pathsOf(followPath(tree1, "01").asStream().ancestors()), contains("0", "")); } - @Test - void testParentStream() { + @Test void testParentStream() { assertThat(pathsOf(followPath(tree1, "01").asStream().parents()), contains("0")); } - @Test - void testAncestorStreamUnion() { + @Test void testAncestorStreamUnion() { assertThat(pathsOf(NodeStream.union(followPath(tree1, "01").ancestors(), - tree2.children().ancestors())), contains("0", "", "", "", "", "")); + tree2.children().ancestors())), contains("0", "", "", "", "", "")); } - @Test - void testDistinct() { + @Test void testDistinct() { assertThat(pathsOf(NodeStream.union(followPath(tree1, "01").ancestors(), - tree2.children().ancestors()).distinct()), contains("0", "", "")); // roots of both trees + tree2.children().ancestors()).distinct()), contains("0", "", "")); // roots of both trees } - @Test - void testGet() { + @Test void testGet() { // ("0", "00", "01", "010", "011", "0110", "012", "013", "1") DescendantNodeStream stream = tree1.descendants(); @@ -225,8 +206,7 @@ void testGet() { assertNull(stream.get(9)); } - @Test - void testNodeStreamsCanBeIteratedSeveralTimes() { + @Test void testNodeStreamsCanBeIteratedSeveralTimes() { DescendantNodeStream stream = tree1.descendants(); assertThat(stream.count(), equalTo(9)); @@ -234,12 +214,11 @@ void testNodeStreamsCanBeIteratedSeveralTimes() { assertThat(pathsOf(stream), contains("0", "00", "01", "010", "011", "0110", "012", "013", "1")); assertThat(pathsOf(stream.filter(n -> n.getNumChildren() == 0)), - contains("00", "010", "0110", "012", "013", "1")); + contains("00", "010", "0110", "012", "013", "1")); } - @Test - void testNodeStreamPipelineIsLazy() { + @Test void testNodeStreamPipelineIsLazy() { MutableInt numEvals = new MutableInt(); @@ -252,17 +231,16 @@ void testNodeStreamPipelineIsLazy() { } - @Test - void testForkJoinUpstreamPipelineIsExecutedAtMostOnce() { + @Test void testForkJoinUpstreamPipelineIsExecutedAtMostOnce() { MutableInt numEvals = new MutableInt(); NodeStream stream = - NodeStream - .forkJoin( - hook(numEvals::increment, tree1.descendants()), - n -> NodeStream.of(n).filter(m -> m.hasImageEqualTo("0")), - n -> NodeStream.of(n).filter(m -> m.hasImageEqualTo("1")) - ); + NodeStream + .forkJoin( + hook(numEvals::increment, tree1.descendants()), + n -> NodeStream.of(n).filter(m -> m.hasImageEqualTo("0")), + n -> NodeStream.of(n).filter(m -> m.hasImageEqualTo("1")) + ); // assertThat(numEvals.getValue(), equalTo(0)); // not evaluated yet @@ -276,20 +254,19 @@ void testForkJoinUpstreamPipelineIsExecutedAtMostOnce() { } - @Test - void testCachedStreamUpstreamPipelineIsExecutedAtMostOnce() { + @Test void testCachedStreamUpstreamPipelineIsExecutedAtMostOnce() { MutableInt upstreamEvals = new MutableInt(); MutableInt downstreamEvals = new MutableInt(); NodeStream stream = - tree1.descendants() - .filter(n -> n.getImage().matches("0.*")) - .take(4) - .peek(n -> upstreamEvals.increment()) - .cached() - .filter(n -> true) - .peek(n -> downstreamEvals.increment()); + tree1.descendants() + .filter(n -> n.getImage().matches("0.*")) + .take(4) + .peek(n -> upstreamEvals.increment()) + .cached() + .filter(n -> true) + .peek(n -> downstreamEvals.increment()); // assertThat(upstreamEvals.getValue(), equalTo(0)); // not evaluated yet @@ -305,14 +282,13 @@ void testCachedStreamUpstreamPipelineIsExecutedAtMostOnce() { } - @Test - void testUnionIsLazy() { + @Test void testUnionIsLazy() { MutableInt tree1Evals = new MutableInt(); MutableInt tree2Evals = new MutableInt(); NodeStream unionStream = NodeStream.union(tree1.descendantsOrSelf().peek(n -> tree1Evals.increment()), - tree2.descendantsOrSelf().peek(n -> tree2Evals.increment())); + tree2.descendantsOrSelf().peek(n -> tree2Evals.increment())); assertThat(tree1Evals.getValue(), equalTo(0)); // not evaluated yet assertThat(tree2Evals.getValue(), equalTo(0)); // not evaluated yet @@ -324,8 +300,7 @@ void testUnionIsLazy() { } - @Test - void testSomeOperationsAreLazy() { + @Test void testSomeOperationsAreLazy() { MutableInt tree1Evals = new MutableInt(); @@ -366,8 +341,7 @@ void testSomeOperationsAreLazy() { } - @Test - void testFollowingSiblingsNonEmpty() { + @Test void testFollowingSiblingsNonEmpty() { DummyNode node = followPath(tree1, "012"); NodeStream nodes = node.asStream().followingSiblings(); @@ -376,8 +350,7 @@ void testFollowingSiblingsNonEmpty() { assertEquals("013", nodes.first().getImage()); } - @Test - void testPrecedingSiblingsNonEmpty() { + @Test void testPrecedingSiblingsNonEmpty() { DummyNode node = followPath(tree1, "011"); NodeStream nodes = node.asStream().precedingSiblings(); @@ -386,8 +359,7 @@ void testPrecedingSiblingsNonEmpty() { assertEquals("010", nodes.first().getImage()); } - @Test - void testPrecedingSiblingsDrop() { + @Test void testPrecedingSiblingsDrop() { DummyNode node = followPath(tree1, "012"); NodeStream nodes = node.asStream().precedingSiblings().drop(1); @@ -395,8 +367,7 @@ void testPrecedingSiblingsDrop() { assertThat(pathsOf(nodes), contains("011")); } - @Test - void testFollowingSiblingsDrop() { + @Test void testFollowingSiblingsDrop() { DummyNode node = followPath(tree1, "011"); NodeStream nodes = node.asStream().followingSiblings().drop(1); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java index cebb76f7483..926b97ea6d9 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/CharsTest.java @@ -32,20 +32,17 @@ */ class CharsTest { - @Test - void wrapStringRoundTrip() { + @Test void wrapStringRoundTrip() { String s = "ooo"; assertSame(s, Chars.wrap(s).toString()); } - @Test - void wrapCharsRoundTrip() { + @Test void wrapCharsRoundTrip() { Chars s = Chars.wrap("ooo"); assertSame(s, Chars.wrap(s)); } - @Test - void appendChars() { + @Test void appendChars() { StringBuilder sb = new StringBuilder(); Chars bc = Chars.wrap("abcd").slice(1, 2); assertEquals("bc", bc.toString()); @@ -54,8 +51,7 @@ void appendChars() { assertEquals("bc", sb.toString()); } - @Test - void appendCharsWithOffsets() { + @Test void appendCharsWithOffsets() { StringBuilder sb = new StringBuilder(); Chars bc = Chars.wrap("abcd").slice(1, 2); assertEquals("bc", bc.toString()); @@ -64,16 +60,14 @@ void appendCharsWithOffsets() { assertEquals("b", sb.toString()); } - @Test - void toStringBuilder() { + @Test void toStringBuilder() { Chars bc = Chars.wrap("abcd").slice(1, 2); assertEquals("bc", bc.toString()); assertEquals("bc", bc.toStringBuilder().toString()); } - @Test - void write() throws IOException { + @Test void write() throws IOException { StringWriter writer = new StringWriter(); Chars bc = Chars.wrap("abcd").slice(1, 2); assertEquals("bc", bc.toString()); @@ -85,13 +79,12 @@ void write() throws IOException { assertEquals("bc", writer.toString()); } - @Test - void getChars() { + @Test void getChars() { char[] arr = new char[4]; Chars bc = Chars.wrap("abcd").slice(1, 2); bc.getChars(0, arr, 1, 2); - assertArrayEquals(arr, new char[] { 0, 'b', 'c', 0 }); + assertArrayEquals(arr, new char[]{0, 'b', 'c', 0}); assertThrows(IndexOutOfBoundsException.class, () -> bc.getChars(2, arr, 0, 1)); assertThrows(IndexOutOfBoundsException.class, () -> bc.getChars(-1, arr, 0, 1)); @@ -100,8 +93,7 @@ void getChars() { assertThrows(NullPointerException.class, () -> bc.getChars(0, null, 0, 0)); } - @Test - void indexOf() { + @Test void indexOf() { Chars bc = Chars.wrap("aaaaabcdb").slice(5, 2); // -- assertEquals(0, bc.indexOf('b', 0)); @@ -115,8 +107,7 @@ void indexOf() { } - @Test - void indexOfWithEndOffset() { + @Test void indexOfWithEndOffset() { Chars bc = Chars.wrap("aaaaabcdb").slice(5, 2); // -- assertEquals(-1, bc.indexOf('b', 0, 0)); @@ -135,8 +126,7 @@ void indexOfWithEndOffset() { } - @Test - void indexOfWithEndOffsetFullStr() { + @Test void indexOfWithEndOffsetFullStr() { Chars bc = Chars.wrap("aaaaabc").slice(5, 2); // -- assertEquals(-1, bc.indexOf('b', 0, 0)); @@ -157,8 +147,7 @@ void indexOfWithEndOffsetFullStr() { } - @Test - void indexOfString() { + @Test void indexOfString() { Chars bc = Chars.wrap("aaaaabcdb").slice(5, 2); // -- assertEquals(0, bc.indexOf("b", 0)); @@ -182,8 +171,7 @@ void indexOfString() { assertEquals(2, bc.indexOf("bx", 0)); } - @Test - void lastIndexOf() { + @Test void lastIndexOf() { Chars bc = Chars.wrap("aaaaabcdb").slice(5, 2); // -- assertEquals(0, bc.lastIndexOf('b', 0)); @@ -199,8 +187,7 @@ void lastIndexOf() { assertEquals(-1, bc.lastIndexOf('a', 1)); } - @Test - void startsWith() { + @Test void startsWith() { Chars bc = Chars.wrap("abcdb").slice(1, 2); assertTrue(bc.startsWith("bc")); @@ -225,8 +212,7 @@ void startsWith() { } - @Test - void removeSuffix() { + @Test void removeSuffix() { Chars bc = Chars.wrap("abcdb").slice(1, 2); // -- @@ -241,8 +227,7 @@ void removeSuffix() { assertEquals("aaa", bc.removeSuffix("aaaa").toString()); } - @Test - void removePrefix() { + @Test void removePrefix() { Chars bc = Chars.wrap("abcdb").slice(1, 2); // -- @@ -259,8 +244,7 @@ void removePrefix() { assertEquals("aaa", bc.removePrefix("aaaa").toString()); } - @Test - void trimNoop() { + @Test void trimNoop() { Chars bc = Chars.wrap("abcdb").slice(1, 2); assertEquals("bc", bc.toString()); assertEquals("bc", bc.trimStart().toString()); @@ -268,8 +252,7 @@ void trimNoop() { assertEquals("bc", bc.trim().toString()); } - @Test - void trimStartAndEnd() { + @Test void trimStartAndEnd() { Chars bc = Chars.wrap("a bc db").slice(1, 6); // ------ assertEquals(" bc ", bc.toString()); @@ -278,8 +261,7 @@ void trimStartAndEnd() { assertEquals("bc", bc.trim().toString()); } - @Test - void charAt() { + @Test void charAt() { Chars bc = Chars.wrap("a bc db").slice(1, 6); // ------ @@ -291,8 +273,7 @@ void charAt() { assertThrows(IndexOutOfBoundsException.class, () -> bc.charAt(7)); } - @Test - void linesTest() { + @Test void linesTest() { Chars bc = Chars.wrap("a \n \r\nbc db").slice(1, 9); // ------------ @@ -300,29 +281,25 @@ void linesTest() { assertEquals(listOf(" ", " ", "bc "), lines); } - @Test - void linesTest2() { + @Test void linesTest2() { Chars bc = Chars.wrap("aa\n"); List lines = CollectionUtil.map(bc.lines(), Chars::toString); assertEquals(listOf("aa"), lines); } - @Test - void linesStreamTest() { + @Test void linesStreamTest() { Chars bc = Chars.wrap("aa\nb\rded\r\nlff"); List lines = bc.lineStream().map(Chars::toString).collect(Collectors.toList()); assertEquals(listOf("aa", "b", "ded", "lff"), lines); } - @Test - void linesTest3WithCr() { + @Test void linesTest3WithCr() { Chars bc = Chars.wrap("aa\rb"); List lines = CollectionUtil.map(bc.lines(), Chars::toString); assertEquals(listOf("aa", "b"), lines); } - @Test - void testEqualsHashCode() { + @Test void testEqualsHashCode() { Chars chars = Chars.wrap("a_a_b_c_s").slice(2, 5); @@ -338,8 +315,7 @@ void testEqualsHashCode() { } - @Test - void testContentEquals() { + @Test void testContentEquals() { Chars chars = Chars.wrap("a_a_b_c_s").slice(2, 5); @@ -354,8 +330,7 @@ void testContentEquals() { assertTrue(chars.contentEquals(Chars.wrap("A_B_C"), true)); } - @Test - void testSplits() { + @Test void testSplits() { Chars chars = Chars.wrap("a_a_b_c_s").slice(2, 5); assertEquals("a_b_c", chars.toString()); @@ -387,8 +362,7 @@ private void testSplits(Chars chars, String regex) { assertEquals(expected, splitList, "Split should behave like String#split"); } - @Test - void testSlice() { + @Test void testSlice() { // slice is offset + length Chars chars = Chars.wrap("a_a_b_c_s").slice(2, 5); // ----- @@ -397,8 +371,7 @@ void testSlice() { assertThrows(IndexOutOfBoundsException.class, () -> chars.slice(0, 6)); } - @Test - void testSubsequence() { + @Test void testSubsequence() { // subsequence is start + end Chars chars = Chars.wrap("a_a_b_c_s").slice(2, 5); // ----- @@ -407,8 +380,7 @@ void testSubsequence() { assertThrows(IndexOutOfBoundsException.class, () -> chars.slice(0, 6)); } - @Test - void testSubstring() { + @Test void testSubstring() { // substring is start + end Chars chars = Chars.wrap("a_a_b_c_s").slice(2, 5); // ----- @@ -418,10 +390,9 @@ void testSubstring() { } - @Test - void testTrimBlankLines() { + @Test void testTrimBlankLines() { assertTrimBlankLinesEquals(" \n \n abc \n \n de \n \n ", - " abc \n \n de "); + " abc \n \n de "); assertTrimBlankLinesEquals("", ""); } @@ -431,8 +402,7 @@ private void assertTrimBlankLinesEquals(String input, String expected) { } - @Test - void testReaderSingleChars() throws IOException { + @Test void testReaderSingleChars() throws IOException { Chars bc = Chars.wrap("a \n \r\nbc db").slice(1, 9); // ------------ @@ -450,8 +420,7 @@ void testReaderSingleChars() throws IOException { } } - @Test - void testReaderBuffer() throws IOException { + @Test void testReaderBuffer() throws IOException { Chars bc = Chars.wrap("a \n \r\nbc db").slice(1, 9); // ------------ @@ -468,8 +437,7 @@ void testReaderBuffer() throws IOException { } } - @Test - void testReaderSlicedBuffer() throws IOException { + @Test void testReaderSlicedBuffer() throws IOException { Chars bc = Chars.wrap("a \n \r\nbc db").slice(1, 9); // ------------ @@ -487,8 +455,7 @@ void testReaderSlicedBuffer() throws IOException { } } - @Test - void testReadClosed() throws IOException { + @Test void testReadClosed() throws IOException { Chars bc = Chars.wrap("a \n \r\nbc db").slice(1, 9); // ------------ @@ -497,8 +464,7 @@ void testReadClosed() throws IOException { assertThrows(IOException.class, reader::read); } - @Test - void testReaderMark() throws IOException { + @Test void testReaderMark() throws IOException { Chars bc = Chars.wrap("abcdefghijklmnop").slice(1, 9); // ------------ @@ -527,8 +493,7 @@ void testReaderMark() throws IOException { } } - @Test - void testReaderMissingMark() throws IOException { + @Test void testReaderMissingMark() throws IOException { Chars bc = Chars.wrap("abcdefghijklmnop").slice(1, 9); // ------------ @@ -540,8 +505,7 @@ void testReaderMissingMark() throws IOException { } } - @Test - void testReaderSkip() throws IOException { + @Test void testReaderSkip() throws IOException { Chars bc = Chars.wrap("abcdefghijklmnop").slice(1, 9); // ------------ @@ -564,8 +528,7 @@ void testReaderSkip() throws IOException { } } - @Test - void testReaderInvalidParams() throws IOException { + @Test void testReaderInvalidParams() throws IOException { Chars bc = Chars.wrap("abcdefghijklmnop").slice(1, 9); // ------------ char[] cbuf = new char[4]; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileCollectorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileCollectorTest.java index a276b5147cb..812cafbe6f9 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileCollectorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileCollectorTest.java @@ -40,11 +40,9 @@ class FileCollectorTest { private static final Path RESOURCES = Paths.get("src/test/resources/net/sourceforge/pmd/lang/document/filecollectortest/"); - @TempDir - private Path tempFolder; + @TempDir private Path tempFolder; - @Test - void testAddFile() throws IOException { + @Test void testAddFile() throws IOException { Path foo = newFile(tempFolder, "foo.dummy"); Path bar = newFile(tempFolder, "bar.unknown"); @@ -56,8 +54,7 @@ void testAddFile() throws IOException { assertCollected(collector, listOf(FileId.fromPath(foo))); } - @Test - void testAddFileForceLanguage() throws IOException { + @Test void testAddFileForceLanguage() throws IOException { Path bar = newFile(tempFolder, "bar.unknown"); Language dummy = DummyLanguageModule.getInstance(); @@ -69,16 +66,14 @@ void testAddFileForceLanguage() throws IOException { assertNoErrors(collector); } - @Test - void testAddFileNotExists() { + @Test void testAddFileNotExists() { FileCollector collector = newCollector(); assertFalse(collector.addFile(tempFolder.resolve("does_not_exist.dummy"))); assertEquals(1, collector.getReporter().numErrors()); } - @Test - void testAddFileNotAFile() throws IOException { + @Test void testAddFileNotAFile() throws IOException { Path dir = tempFolder.resolve("src"); Files.createDirectories(dir); @@ -87,8 +82,7 @@ void testAddFileNotAFile() throws IOException { assertEquals(1, collector.getReporter().numErrors()); } - @Test - void testAddDirectory() throws IOException { + @Test void testAddDirectory() throws IOException { Path root = tempFolder; Path foo = newFile(root, "src/foo.dummy"); newFile(root, "src/bar.unknown"); @@ -101,8 +95,7 @@ void testAddDirectory() throws IOException { assertCollected(collector, listOf(FileId.fromPath(foo), FileId.fromPath(bar))); } - @Test - void testGetApplicableFiles() { + @Test void testGetApplicableFiles() { FileCollector collector = newCollector(); collectFileList(collector, RESOURCES.resolve("filelist.txt")); @@ -113,8 +106,7 @@ void testGetApplicableFiles() { assertThat(applicableFiles.get(1).getFileId().getFileName(), equalTo("somefile.dummy")); } - @Test - void testGetApplicableFilesMultipleLines() { + @Test void testGetApplicableFilesMultipleLines() { FileCollector collector = newCollector(); collectFileList(collector, RESOURCES.resolve("filelist2.txt")); @@ -126,8 +118,7 @@ void testGetApplicableFilesMultipleLines() { assertFilenameIs(applicableFiles.get(1), "somefile.dummy"); } - @Test - void testGetApplicableFilesWithIgnores() { + @Test void testGetApplicableFilesWithIgnores() { FileCollector collector = newCollector(); PMDConfiguration configuration = new PMDConfiguration(); @@ -141,8 +132,7 @@ void testGetApplicableFilesWithIgnores() { assertFilenameIs(applicableFiles.get(1), "somefile4.dummy"); } - @Test - void testRelativizeWith() { + @Test void testRelativizeWith() { PMDConfiguration conf = new PMDConfiguration(); conf.setInputFilePath(RESOURCES.resolve("filelist2.txt")); conf.addRelativizeRoot(Paths.get("src/test/resources")); @@ -154,8 +144,7 @@ void testRelativizeWith() { } } - @Test - void testRelativizeWithOtherDir() { + @Test void testRelativizeWithOtherDir() { PMDConfiguration conf = new PMDConfiguration(); conf.setInputFilePath(RESOURCES.resolve("filelist4.txt")); conf.addRelativizeRoot(RESOURCES.resolve("src")); @@ -168,8 +157,7 @@ void testRelativizeWithOtherDir() { } } - @Test - void testRelativizeWithSeveralDirs() { + @Test void testRelativizeWithSeveralDirs() { PMDConfiguration conf = new PMDConfiguration(); conf.setInputFilePath(RESOURCES.resolve("filelist4.txt")); conf.addRelativizeRoot(RESOURCES.resolve("src")); @@ -183,8 +171,7 @@ void testRelativizeWithSeveralDirs() { } } - @Test - void testUseAbsolutePaths() { + @Test void testUseAbsolutePaths() { PMDConfiguration conf = new PMDConfiguration(); conf.setInputFilePath(RESOURCES.resolve("filelist4.txt")); conf.addRelativizeRoot(RESOURCES.toAbsolutePath().getRoot()); @@ -198,8 +185,7 @@ void testUseAbsolutePaths() { } - @Test - void testGetApplicableFilesWithDirAndIgnores() { + @Test void testGetApplicableFilesWithDirAndIgnores() { PMDConfiguration configuration = new PMDConfiguration(); configuration.addInputPath(RESOURCES.resolve("src")); configuration.setIgnoreFilePath(RESOURCES.resolve("ignorelist.txt")); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileCollectorZipTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileCollectorZipTest.java index 634e2859a11..13a78b009cb 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileCollectorZipTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileCollectorZipTest.java @@ -27,8 +27,7 @@ class FileCollectorZipTest { private static final String ZIP_PATH = "src/test/resources/net/sourceforge/pmd/lang/document/filecollectorziptest/zipWithSources.zip"; private final Path zipPath = Paths.get(ZIP_PATH); - @Test - void testZipFile() { + @Test void testZipFile() { PMDConfiguration conf = new PMDConfiguration(); conf.addInputPath(zipPath); // no relativizeRoot paths configured -> we use the relative path @@ -42,8 +41,7 @@ void testZipFile() { } } - @Test - void testZipFileIds() throws IOException { + @Test void testZipFileIds() throws IOException { PMDConfiguration conf = new PMDConfiguration(); // no relativizeRoot paths configured -> we use the relative path try (PmdAnalysis pmd = PmdAnalysis.create(conf)) { @@ -51,14 +49,13 @@ void testZipFileIds() throws IOException { List files = pmd.files().getCollectedFiles(); assertThat(files, hasSize(3)); assertThat(files.get(0).getFileId().getUriString(), - equalTo("jar:" + zipPath.toUri() + "!/otherSrc/somefile.dummy")); + equalTo("jar:" + zipPath.toUri() + "!/otherSrc/somefile.dummy")); } } - @Test - void testZipFileRelativizeWith() { + @Test void testZipFileRelativizeWith() { PMDConfiguration conf = new PMDConfiguration(); conf.addInputPath(zipPath); conf.addRelativizeRoot(Paths.get("src/test/resources")); @@ -72,8 +69,7 @@ void testZipFileRelativizeWith() { } } - @Test - void testZipFileRelativizeWithRoot() { + @Test void testZipFileRelativizeWithRoot() { PMDConfiguration conf = new PMDConfiguration(); conf.addInputPath(zipPath); // this configures "/" as the relativizeRoot -> result are absolute paths diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileIdTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileIdTest.java index 58f0cb7bd91..bc13fda35e4 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileIdTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileIdTest.java @@ -20,8 +20,7 @@ class FileIdTest { // note we can't hardcode the expected paths because they look different on win and nix - @Test - void testFromPath() { + @Test void testFromPath() { Path path = Paths.get("/a"); Path absPath = path.toAbsolutePath(); FileId fileId = FileId.fromPath(path); @@ -29,16 +28,14 @@ void testFromPath() { } - @Test - void testFromUri() { + @Test void testFromUri() { Path absPath = Paths.get("/a/b.c"); String uriStr = absPath.toUri().toString(); FileId fileId = FileId.fromURI(uriStr); checkId(fileId, absPath.toAbsolutePath().toString(), "b.c", uriStr, absPath.toAbsolutePath().toString()); } - @Test - void testFromAsChild() { + @Test void testFromAsChild() { FileId parent = FileId.fromPathLikeString("bla"); FileId child = FileId.fromPathLikeString("bla"); FileId fileId = FileId.asChildOf(child, parent); @@ -48,8 +45,7 @@ void testFromAsChild() { assertSame(fileId, FileId.asChildOf(fileId, parent)); } - @Test - void testFromUriForJar() { + @Test void testFromUriForJar() { Path zipPath = Paths.get("/a/b.zip"); String uriStr = "jar:" + zipPath.toUri() + "!/x/c.d"; FileId fileId = FileId.fromURI(uriStr); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileLocationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileLocationTest.java index c0d23846238..cb0d07e1981 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileLocationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FileLocationTest.java @@ -17,8 +17,7 @@ class FileLocationTest { public static final FileId FNAME = FileId.fromPathLikeString("fname"); - @Test - void testSimple() { + @Test void testSimple() { FileLocation loc = FileLocation.range(FNAME, TextRange2d.range2d(1, 1, 1, 2)); assertEquals(FNAME, loc.getFileId()); assertEquals(1, loc.getStartLine()); @@ -27,24 +26,22 @@ void testSimple() { assertEquals(2, loc.getEndColumn()); } - @Test - void testToRange() { + @Test void testToRange() { TextRange2d range2d = TextRange2d.range2d(1, 1, 1, 2); FileLocation loc = FileLocation.range(FNAME, range2d); assertEquals(range2d, loc.toRange2d()); } - @Test - void testToString() { + @Test void testToString() { FileLocation loc = FileLocation.range(FNAME, TextRange2d.range2d(1, 1, 1, 2)); assertEquals( - "line 1, column 1", - loc.startPosToString() + "line 1, column 1", + loc.startPosToString() ); assertEquals( - "fname:1:1", - loc.startPosToStringWithFile() + "fname:1:1", + loc.startPosToStringWithFile() ); assertThat(loc.toString(), containsString("!debug only!")); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FragmentedTextDocumentTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FragmentedTextDocumentTest.java index bb123982c88..a73787ac8a5 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FragmentedTextDocumentTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/FragmentedTextDocumentTest.java @@ -18,8 +18,7 @@ class FragmentedTextDocumentTest { LanguageVersion dummyVersion = DummyLanguageModule.getInstance().getDefaultVersion(); - @Test - void testSimple() throws IOException { + @Test void testSimple() throws IOException { try (TextDocument base = TextDocument.readOnlyString("abc", dummyVersion)) { FragmentedDocBuilder builder = new FragmentedDocBuilder(base); @@ -41,8 +40,7 @@ void testSimple() throws IOException { } - @Test - void testToLocationWithCaret() throws IOException { + @Test void testToLocationWithCaret() throws IOException { try (TextDocument base = TextDocument.readOnlyString("abc", dummyVersion)) { FragmentedDocBuilder builder = new FragmentedDocBuilder(base); @@ -57,8 +55,7 @@ void testToLocationWithCaret() throws IOException { } } - @Test - void testToLocationWithCaretBetweenEscapes() throws IOException { + @Test void testToLocationWithCaretBetweenEscapes() throws IOException { try (TextDocument base = TextDocument.readOnlyString("aBBCCd", dummyVersion)) { FragmentedDocBuilder builder = new FragmentedDocBuilder(base); @@ -74,8 +71,7 @@ void testToLocationWithCaretBetweenEscapes() throws IOException { } } - @Test - void offsetAtLineColumn() throws IOException { + @Test void offsetAtLineColumn() throws IOException { try (TextDocument base = TextDocument.readOnlyString("ABC\n123\n", dummyVersion)) { FragmentedDocBuilder builder = new FragmentedDocBuilder(base); builder.recordDelta(3, 3, Chars.wrap("X")); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/NioTextFileTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/NioTextFileTest.java index f2b4c4264bf..7a8adc4f384 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/NioTextFileTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/NioTextFileTest.java @@ -21,11 +21,9 @@ class NioTextFileTest { - @TempDir - private Path tempDir; + @TempDir private Path tempDir; - @Test - void zipFileDisplayName() throws Exception { + @Test void zipFileDisplayName() throws Exception { Path zipArchive = tempDir.resolve("sources.zip"); try (ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(zipArchive.toFile()))) { ZipEntry zipEntry = new ZipEntry("path/inside/someSource.dummy"); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SourceCodePositionerTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SourceCodePositionerTest.java index 7a48aced91d..3617c2f0cc4 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SourceCodePositionerTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/SourceCodePositionerTest.java @@ -14,8 +14,7 @@ */ class SourceCodePositionerTest { - @Test - void testLineNumberFromOffset() { + @Test void testLineNumberFromOffset() { final String source = "abcd\ndefghi\n\rjklmn\ropq"; SourceCodePositioner positioner = SourceCodePositioner.create(source); @@ -47,8 +46,7 @@ void testLineNumberFromOffset() { assertEquals(-1, positioner.columnFromOffset(3, offset)); } - @Test - void testOffsetFromLineColumn() { + @Test void testOffsetFromLineColumn() { final String source = "abcd\ndefghi\r\njklmn\nopq"; SourceCodePositioner positioner = SourceCodePositioner.create(source); @@ -70,8 +68,7 @@ void testOffsetFromLineColumn() { } - @Test - void testWrongOffsets() { + @Test void testWrongOffsets() { final String source = "abcd\ndefghi\r\njklmn\nopq"; SourceCodePositioner positioner = SourceCodePositioner.create(source); @@ -88,8 +85,7 @@ void testWrongOffsets() { } - @Test - void testEmptyDocument() { + @Test void testEmptyDocument() { SourceCodePositioner positioner = SourceCodePositioner.create(""); @@ -104,8 +100,7 @@ void testEmptyDocument() { } - @Test - void testDocumentStartingWithNl() { + @Test void testDocumentStartingWithNl() { SourceCodePositioner positioner = SourceCodePositioner.create("\n"); @@ -120,37 +115,34 @@ void testDocumentStartingWithNl() { } - @Test - void lineToOffsetMappingWithLineFeedShouldSucceed() { + @Test void lineToOffsetMappingWithLineFeedShouldSucceed() { final String code = "public static int main(String[] args) {\n" - + "int var;\n" - + "}"; + + "int var;\n" + + "}"; SourceCodePositioner positioner = SourceCodePositioner.create(code); - assertArrayEquals(new int[] { 0, 40, 49, 50 }, positioner.getLineOffsets()); + assertArrayEquals(new int[]{0, 40, 49, 50}, positioner.getLineOffsets()); } - @Test - void lineToOffsetMappingWithCarriageReturnFeedLineFeedShouldSucceed() { + @Test void lineToOffsetMappingWithCarriageReturnFeedLineFeedShouldSucceed() { final String code = "public static int main(String[] args) {\r\n" - + "int var;\r\n" - + "}"; + + "int var;\r\n" + + "}"; SourceCodePositioner positioner = SourceCodePositioner.create(code); - assertArrayEquals(new int[] { 0, 41, 51, 52 }, positioner.getLineOffsets()); + assertArrayEquals(new int[]{0, 41, 51, 52}, positioner.getLineOffsets()); } - @Test - void lineToOffsetMappingWithMixedLineSeparatorsShouldSucceed() { + @Test void lineToOffsetMappingWithMixedLineSeparatorsShouldSucceed() { final String code = "public static int main(String[] args) {\r\n" - + "int var;\n" - + "}"; + + "int var;\n" + + "}"; SourceCodePositioner positioner = SourceCodePositioner.create(code); - assertArrayEquals(new int[] { 0, 41, 50, 51 }, positioner.getLineOffsets()); + assertArrayEquals(new int[]{0, 41, 50, 51}, positioner.getLineOffsets()); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java index 1e4aa3ded14..16b817d9a99 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextDocumentTest.java @@ -21,8 +21,7 @@ class TextDocumentTest { - @Test - void testSingleLineRegion() { + @Test void testSingleLineRegion() { TextDocument doc = TextDocument.readOnlyString("bonjour\ntristesse", dummyVersion()); TextRegion region = TextRegion.fromOffsetLength(0, "bonjour".length()); @@ -40,8 +39,7 @@ void testSingleLineRegion() { assertEquals("bonjour".length(), withLines.getEndColumn() - withLines.getStartColumn()); } - @Test - void testRegionAtEol() { + @Test void testRegionAtEol() { TextDocument doc = TextDocument.readOnlyString("bonjour\ntristesse", dummyVersion()); TextRegion region = TextRegion.fromOffsetLength(0, "bonjour\n".length()); @@ -55,8 +53,7 @@ void testRegionAtEol() { assertEquals("bonjour\n".length(), withLines.getEndColumn() - withLines.getStartColumn()); } - @Test - void testEmptyRegionAtEol() { + @Test void testEmptyRegionAtEol() { TextDocument doc = TextDocument.readOnlyString("bonjour\ntristesse", dummyVersion()); // ^ The caret position right after the \n // We consider it's part of the next line @@ -72,8 +69,7 @@ void testEmptyRegionAtEol() { assertEquals(1, withLines.getEndColumn()); } - @Test - void testRegionForEol() { + @Test void testRegionForEol() { TextDocument doc = TextDocument.readOnlyString("bonjour\ntristesse", dummyVersion()); // [ [ The region containing the \n // We consider it ends on the same line, not the next one @@ -90,8 +86,7 @@ void testRegionForEol() { assertEquals(1 + "bonjour\n".length(), withLines.getEndColumn()); } - @Test - void testRegionAtEndOfFile() { + @Test void testRegionAtEndOfFile() { TextDocument doc = TextDocument.readOnlyString("flemme", dummyVersion()); TextRegion region = TextRegion.fromOffsetLength(0, doc.getLength()); @@ -105,8 +100,7 @@ void testRegionAtEndOfFile() { assertEquals(1 + doc.getLength(), withLines.getEndColumn()); } - @Test - void testMultiLineRegion() { + @Test void testMultiLineRegion() { TextDocument doc = TextDocument.readOnlyString("bonjour\noha\ntristesse", dummyVersion()); TextRegion region = TextRegion.fromOffsetLength("bonjou".length(), "r\noha\ntri".length()); @@ -124,8 +118,7 @@ void testMultiLineRegion() { } - @Test - void testLineColumnFromOffset() { + @Test void testLineColumnFromOffset() { TextDocument doc = TextDocument.readOnlyString("ab\ncd\n", dummyVersion()); assertPos2dEqualsAt(doc, 0, "a", pos2d(1, 1), true); @@ -147,8 +140,7 @@ private void assertPos2dEqualsAt(TextDocument doc, int offset, String c, TextPos assertEquals(pos, doc.lineColumnAtOffset(offset, inclusive)); } - @Test - void testEmptyRegion() { + @Test void testEmptyRegion() { TextDocument doc = TextDocument.readOnlyString("bonjour\noha\ntristesse", dummyVersion()); TextRegion region = TextRegion.fromOffsetLength("bonjour".length(), 0); @@ -166,8 +158,7 @@ void testEmptyRegion() { } - @Test - void testLineRange() { + @Test void testLineRange() { TextDocument doc = TextDocument.readOnlyString("bonjour\noha\ntristesse", dummyVersion()); assertEquals(Chars.wrap("bonjour\n"), doc.sliceTranslatedText(doc.createLineRange(1, 1))); @@ -179,39 +170,33 @@ void testLineRange() { assertThrows(IndexOutOfBoundsException.class, () -> doc.createLineRange(0, 2)); } - @ParameterizedTest - @MethodSource("documentProvider") - void testEntireRegion(TextDocument doc) { + @ParameterizedTest @MethodSource("documentProvider") void testEntireRegion(TextDocument doc) { assertEquals(TextRegion.fromOffsetLength(0, doc.getLength()), doc.getEntireRegion(), "getEntireRegion should return something based on length"); } - @ParameterizedTest - @MethodSource("documentProvider") - void testReader(TextDocument doc) throws IOException { + @ParameterizedTest @MethodSource("documentProvider") void testReader(TextDocument doc) throws IOException { assertEquals(doc.getText().toString(), - IOUtil.readToString(doc.newReader()), - "NewReader should read the text"); + IOUtil.readToString(doc.newReader()), + "NewReader should read the text"); } - @Test - void testRegionOutOfBounds() { + @Test void testRegionOutOfBounds() { TextDocument doc = TextDocument.readOnlyString("bonjour\noha\ntristesse", dummyVersion()); assertThrows(AssertionError.class, () -> TextRegion.isValidRegion(0, 40, doc)); } - @SuppressWarnings("resource") - static Object[] documentProvider() { + @SuppressWarnings("resource") static Object[] documentProvider() { LanguageVersion dummyVersion = DummyLanguageModule.getInstance().getDefaultVersion(); - return new TextDocument[] { - TextDocument.readOnlyString("bonjour\noha\ntristesse", dummyVersion), - TextDocument.readOnlyString("bonjour\n", dummyVersion), - TextDocument.readOnlyString("\n", dummyVersion), - TextDocument.readOnlyString("", dummyVersion), + return new TextDocument[]{ + TextDocument.readOnlyString("bonjour\noha\ntristesse", dummyVersion), + TextDocument.readOnlyString("bonjour\n", dummyVersion), + TextDocument.readOnlyString("\n", dummyVersion), + TextDocument.readOnlyString("", dummyVersion), }; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFileContentTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFileContentTest.java index 6773dbfd649..71172fe5777 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFileContentTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFileContentTest.java @@ -25,33 +25,26 @@ class TextFileContentTest { // we use this dummy value private static final String LINESEP_SENTINEL = ":fallback:"; - @ParameterizedTest - @EnumSource - void testMixedDelimiters(TextContentOrigin origin) throws IOException { + @ParameterizedTest @EnumSource void testMixedDelimiters(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("a\r\nb\n\rc"); assertEquals(Chars.wrap("a\nb\n\nc"), content.getNormalizedText()); assertEquals(LINESEP_SENTINEL, content.getLineTerminator()); } - @ParameterizedTest - @EnumSource - void testFormFeedIsNotNewline(TextContentOrigin origin) throws IOException { + @ParameterizedTest @EnumSource void testFormFeedIsNotNewline(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("a\f\nb\nc"); assertEquals(Chars.wrap("a\f\nb\nc"), content.getNormalizedText()); assertEquals("\n", content.getLineTerminator()); } - @Test - void testNormTextPreservation() { + @Test void testNormTextPreservation() { Chars input = Chars.wrap("a\nb\nc"); TextFileContent content = TextFileContent.fromCharSeq(input); assertSame(input, content.getNormalizedText()); assertEquals("\n", content.getLineTerminator()); } - @ParameterizedTest - @EnumSource - void testBomElimination(TextContentOrigin origin) throws IOException { + @ParameterizedTest @EnumSource void testBomElimination(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("\ufeffabc"); Chars normalizedText = content.getNormalizedText(); assertEquals(Chars.wrap("abc"), normalizedText); @@ -62,24 +55,19 @@ void testBomElimination(TextContentOrigin origin) throws IOException { assertSame(normalizedText.toString(), normalizedText.toString()); } - @ParameterizedTest - @EnumSource - void testNoExplicitLineMarkers(TextContentOrigin origin) throws IOException { + @ParameterizedTest @EnumSource void testNoExplicitLineMarkers(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("a"); assertEquals(Chars.wrap("a"), content.getNormalizedText()); assertEquals(LINESEP_SENTINEL, content.getLineTerminator()); } - @ParameterizedTest - @EnumSource - void testEmptyFile(TextContentOrigin origin) throws IOException { + @ParameterizedTest @EnumSource void testEmptyFile(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize(""); assertEquals(Chars.wrap(""), content.getNormalizedText()); assertEquals(LINESEP_SENTINEL, content.getLineTerminator()); } - @Test - void testCrlfSplitOnBuffer() throws IOException { + @Test void testCrlfSplitOnBuffer() throws IOException { StringReader reader = new StringReader("a\r\nb"); // now the buffer is of size 2, so we read first [a\r] then [\nb] // but there is a single line @@ -88,8 +76,7 @@ void testCrlfSplitOnBuffer() throws IOException { assertEquals("\r\n", content.getLineTerminator()); } - @Test - void testCrSplitOnBufferFp() throws IOException { + @Test void testCrSplitOnBufferFp() throws IOException { StringReader reader = new StringReader("a\rb\n"); // the buffer is of size 2, so we read first [a\r] then [b\n] // the \r is a line terminator on its own @@ -98,32 +85,25 @@ void testCrSplitOnBufferFp() throws IOException { assertEquals(LINESEP_SENTINEL, content.getLineTerminator()); } - @ParameterizedTest - @EnumSource - void testCrCr(TextContentOrigin origin) throws IOException { + @ParameterizedTest @EnumSource void testCrCr(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("a\r\rb"); assertEquals(Chars.wrap("a\n\nb"), content.getNormalizedText()); assertEquals("\r", content.getLineTerminator()); } - @ParameterizedTest - @EnumSource - void testCrIsEol(TextContentOrigin origin) throws IOException { + @ParameterizedTest @EnumSource void testCrIsEol(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("a\rb\rdede"); assertEquals(Chars.wrap("a\nb\ndede"), content.getNormalizedText()); assertEquals("\r", content.getLineTerminator()); } - @ParameterizedTest - @EnumSource - void testLfAtStartOfFile(TextContentOrigin origin) throws IOException { + @ParameterizedTest @EnumSource void testLfAtStartOfFile(TextContentOrigin origin) throws IOException { TextFileContent content = origin.normalize("\nohio"); assertEquals(Chars.wrap("\nohio"), content.getNormalizedText()); assertEquals("\n", content.getLineTerminator()); } - @Test - void testCrCrSplitBuffer() throws IOException { + @Test void testCrCrSplitBuffer() throws IOException { StringReader reader = new StringReader("a\r\r"); // the buffer is of size 2, so we read first [a\r] then [\ro] // the \r is not a line terminator though @@ -134,8 +114,7 @@ void testCrCrSplitBuffer() throws IOException { enum TextContentOrigin { INPUT_STREAM { - @Override - TextFileContent normalize(String text) throws IOException { + @Override TextFileContent normalize(String text) throws IOException { Charset charset = StandardCharsets.UTF_8; byte[] input = text.getBytes(charset); TextFileContent content; @@ -146,14 +125,12 @@ TextFileContent normalize(String text) throws IOException { } }, READER { - @Override - TextFileContent normalize(String input) throws IOException { + @Override TextFileContent normalize(String input) throws IOException { return TextFileContent.normalizingRead(new StringReader(input), 4096, LINESEP_SENTINEL); } }, STRING { - @Override - TextFileContent normalize(String input) throws IOException { + @Override TextFileContent normalize(String input) throws IOException { return TextFileContent.normalizeCharSeq(input, LINESEP_SENTINEL); } }; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFilesTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFilesTest.java index 607b2c60bdc..4b74c05431d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFilesTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextFilesTest.java @@ -25,11 +25,9 @@ class TextFilesTest { - @TempDir - Path tempDir; + @TempDir Path tempDir; - @Test - void testNioFile() throws IOException { + @Test void testNioFile() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content"); try (TextFile tf = TextFile.forPath(file, StandardCharsets.UTF_8, dummyVersion())) { assertEquals(file.toAbsolutePath().toUri().toString(), tf.getFileId().getUriString()); @@ -40,8 +38,7 @@ void testNioFile() throws IOException { } } - @Test - void testEquals() throws IOException { + @Test void testEquals() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content").toAbsolutePath(); try (TextFile tf = TextFile.forPath(file, StandardCharsets.UTF_8, dummyVersion())) { try (TextFile tfPrime = TextFile.forPath(file, StandardCharsets.UTF_8, dummyVersion())) { @@ -65,8 +62,7 @@ void testEquals() throws IOException { } } - @Test - void testNioFileWrite() throws IOException { + @Test void testNioFileWrite() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content"); try (TextFile tf = TextFile.forPath(file, StandardCharsets.UTF_8, dummyVersion())) { assertEquals(Chars.wrap("some content"), tf.readContents().getNormalizedText()); @@ -74,7 +70,7 @@ void testNioFileWrite() throws IOException { // write with CRLF tf.writeContents( - TextFileContent.fromCharSeq("new content\r\n") + TextFileContent.fromCharSeq("new content\r\n") ); TextFileContent read = tf.readContents(); @@ -84,28 +80,26 @@ void testNioFileWrite() throws IOException { assertEquals("\r\n", read.getLineTerminator()); tf.writeContents( - TextFileContent.fromCharSeq("new content\n") + TextFileContent.fromCharSeq("new content\n") ); assertEquals(Chars.wrap("new content\n"), tf.readContents().getNormalizedText()); } } - @Test - void testNioFileExplicitReadOnly() throws IOException { + @Test void testNioFileExplicitReadOnly() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content"); try (TextFile tf = TextFile.builderForPath(file, StandardCharsets.UTF_8, dummyVersion()) - .asReadOnly().build()) { + .asReadOnly().build()) { assertTrue(tf.isReadOnly(), "readonly"); assertThrows(ReadOnlyFileException.class, () -> tf.writeContents( - TextFileContent.fromCharSeq("new content") + TextFileContent.fromCharSeq("new content") )); } } - @Test - void testNioFileCanBeReadMultipleTimes() throws IOException { + @Test void testNioFileCanBeReadMultipleTimes() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content"); try (TextFile tf = TextFile.forPath(file, StandardCharsets.UTF_8, dummyVersion())) { assertEquals(Chars.wrap("some content"), tf.readContents().getNormalizedText()); @@ -113,27 +107,24 @@ void testNioFileCanBeReadMultipleTimes() throws IOException { } } - @Test - void testNioFileBuilder() throws IOException { + @Test void testNioFileBuilder() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some content"); try (TextFile tf = TextFile.builderForPath(file, StandardCharsets.UTF_8, dummyVersion()) - .build()) { + .build()) { assertEquals(file.toAbsolutePath().toUri().toString(), tf.getFileId().getUriString()); assertEquals(dummyVersion(), tf.getLanguageVersion()); assertEquals(Chars.wrap("some content"), tf.readContents().getNormalizedText()); } } - @Test - void testNioFileEscape() throws IOException { + @Test void testNioFileEscape() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some\r\ncontent"); try (TextFile tf = TextFile.forPath(file, StandardCharsets.UTF_8, dummyVersion())) { assertEquals(Chars.wrap("some\ncontent"), tf.readContents().getNormalizedText()); } } - @Test - void testReaderFile() throws IOException { + @Test void testReaderFile() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some\r\ncontent"); try (TextFile tf = TextFile.forReader(Files.newBufferedReader(file, StandardCharsets.UTF_8), FileId.UNKNOWN, dummyVersion())) { assertEquals(FileId.UNKNOWN, tf.getFileId()); @@ -142,31 +133,28 @@ void testReaderFile() throws IOException { } } - @Test - void testReaderFileIsReadOnly() throws IOException { + @Test void testReaderFileIsReadOnly() throws IOException { Path file = makeTmpFile(StandardCharsets.UTF_8, "some\r\ncontent"); try (TextFile tf = TextFile.forReader(Files.newBufferedReader(file, StandardCharsets.UTF_8), FileId.UNKNOWN, dummyVersion())) { assertTrue(tf.isReadOnly(), "readonly"); assertThrows(ReadOnlyFileException.class, () -> tf.writeContents( - TextFileContent.fromCharSeq("new content") + TextFileContent.fromCharSeq("new content") )); } } - @Test - void testStringFileEscape() throws IOException { + @Test void testStringFileEscape() throws IOException { try (TextFile tf = TextFile.forCharSeq("cont\r\nents", FileId.UNKNOWN, dummyVersion())) { assertEquals(FileId.UNKNOWN, tf.getFileId()); assertEquals(dummyVersion(), tf.getLanguageVersion()); assertEquals(Chars.wrap("cont\nents"), tf.readContents().getNormalizedText()); assertThrows(ReadOnlyFileException.class, () -> tf.writeContents( - TextFileContent.fromCharSeq("new content") + TextFileContent.fromCharSeq("new content") )); } } - @Test - void testStringFileCanBeReadMultipleTimes() throws IOException { + @Test void testStringFileCanBeReadMultipleTimes() throws IOException { try (TextFile tf = TextFile.forCharSeq("contents", FileId.UNKNOWN, dummyVersion())) { assertEquals(Chars.wrap("contents"), tf.readContents().getNormalizedText()); assertEquals(Chars.wrap("contents"), tf.readContents().getNormalizedText()); @@ -174,12 +162,11 @@ void testStringFileCanBeReadMultipleTimes() throws IOException { } } - @Test - void testStringFileIsReadonly() throws IOException { + @Test void testStringFileIsReadonly() throws IOException { try (TextFile tf = TextFile.forCharSeq("contents", FileId.UNKNOWN, dummyVersion())) { assertTrue(tf.isReadOnly(), "readonly"); assertThrows(ReadOnlyFileException.class, () -> tf.writeContents( - TextFileContent.fromCharSeq("new content") + TextFileContent.fromCharSeq("new content") )); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextPos2dTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextPos2dTest.java index fec89d5b21e..61b1b74aa4b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextPos2dTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextPos2dTest.java @@ -16,26 +16,24 @@ */ class TextPos2dTest { - @Test - void testToString() { + @Test void testToString() { TextPos2d pos = TextPos2d.pos2d(1, 2); assertEquals( - "line 1, column 2", - pos.toDisplayStringInEnglish() + "line 1, column 2", + pos.toDisplayStringInEnglish() ); assertEquals( - "1:2", - pos.toDisplayStringWithColon() + "1:2", + pos.toDisplayStringWithColon() ); assertEquals( - "(line=1, column=2)", - pos.toTupleString() + "(line=1, column=2)", + pos.toTupleString() ); assertThat(pos.toString(), containsString("!debug only!")); } - @Test - void testEquals() { + @Test void testEquals() { TextPos2d pos = TextPos2d.pos2d(1, 1); TextPos2d pos2 = TextPos2d.pos2d(1, 2); assertNotEquals(pos, pos2); @@ -43,8 +41,7 @@ void testEquals() { assertEquals(pos2, pos2); } - @Test - void testCompareTo() { + @Test void testCompareTo() { TextPos2d pos = TextPos2d.pos2d(1, 1); TextPos2d pos2 = TextPos2d.pos2d(1, 2); TextPos2d pos3 = TextPos2d.pos2d(2, 1); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRange2dTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRange2dTest.java index 4f9df557c23..fa17a758f77 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRange2dTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRange2dTest.java @@ -16,15 +16,13 @@ */ class TextRange2dTest { - @Test - void testCtors() { + @Test void testCtors() { TextRange2d pos = TextRange2d.range2d(1, 2, 3, 4); TextRange2d pos2 = TextRange2d.range2d(TextPos2d.pos2d(1, 2), TextPos2d.pos2d(3, 4)); assertEquals(pos, pos2); } - @Test - void testEquals() { + @Test void testEquals() { TextRange2d pos = TextRange2d.range2d(1, 1, 1, 1); TextRange2d pos2 = TextRange2d.range2d(1, 1, 1, 2); assertNotEquals(pos, pos2); @@ -32,8 +30,7 @@ void testEquals() { assertEquals(pos2, pos2); } - @Test - void testCompareTo() { + @Test void testCompareTo() { TextRange2d pos = TextRange2d.range2d(1, 1, 1, 1); TextRange2d pos2 = TextRange2d.range2d(1, 1, 1, 2); @@ -42,12 +39,11 @@ void testCompareTo() { assertEquals(0, pos.compareTo(pos)); } - @Test - void testToString() { + @Test void testToString() { TextRange2d range = TextRange2d.range2d(1, 2, 3, 4); assertEquals( - "1:2-3:4", - range.toDisplayStringWithColon() + "1:2-3:4", + range.toDisplayStringWithColon() ); assertThat(range.toString(), containsString("!debug only!")); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRegionTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRegionTest.java index 3f989a94358..dbae59c4d7d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRegionTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/document/TextRegionTest.java @@ -15,22 +15,19 @@ class TextRegionTest { - @Test - void testIsEmpty() { + @Test void testIsEmpty() { TextRegion r = TextRegion.fromOffsetLength(0, 0); assertTrue(r.isEmpty()); } - @Test - void testEmptyContains() { + @Test void testEmptyContains() { TextRegion r1 = TextRegion.fromOffsetLength(0, 0); assertFalse(r1.contains(0)); } - @Test - void testContains() { + @Test void testContains() { TextRegion r1 = TextRegion.fromOffsetLength(1, 2); assertFalse(r1.contains(0)); @@ -39,8 +36,7 @@ void testContains() { assertFalse(r1.contains(3)); } - @Test - void testIntersectZeroLen() { + @Test void testIntersectZeroLen() { // r1: [[----- // r2: [ -----[ TextRegion r1 = TextRegion.fromOffsetLength(0, 0); @@ -51,8 +47,7 @@ void testIntersectZeroLen() { assertEquals(r1, inter); } - @Test - void testIntersectZeroLen2() { + @Test void testIntersectZeroLen2() { // r1: -----[[ // r2: [-----[ TextRegion r1 = TextRegion.fromOffsetLength(5, 0); @@ -63,8 +58,7 @@ void testIntersectZeroLen2() { assertEquals(r1, inter); } - @Test - void testIntersectZeroLen3() { + @Test void testIntersectZeroLen3() { // r1: -- -[---[ // r2: --[-[--- TextRegion r1 = TextRegion.fromOffsetLength(3, 3); @@ -77,8 +71,7 @@ void testIntersectZeroLen3() { } - @Test - void testIntersectZeroLen4() { + @Test void testIntersectZeroLen4() { TextRegion r1 = TextRegion.fromOffsetLength(0, 0); TextRegion inter = doIntersect(r1, r1); @@ -86,8 +79,7 @@ void testIntersectZeroLen4() { assertEquals(r1, inter); } - @Test - void testNonEmptyIntersect() { + @Test void testNonEmptyIntersect() { // r1: ---[-- --[ // r2: [--- --[-- // i: ---[--[-- @@ -99,8 +91,7 @@ void testNonEmptyIntersect() { assertRegionEquals(inter, 3, 2); } - @Test - void testIntersectContained() { + @Test void testIntersectContained() { // r1: --[- - ---[ // r2: -- -[-[--- // i: -- -[-[--- @@ -112,8 +103,7 @@ void testIntersectContained() { assertRegionEquals(inter, 3, 1); } - @Test - void testIntersectDisjoint() { + @Test void testIntersectDisjoint() { // r1: -- -[---[ // r2: --[-[--- TextRegion r1 = TextRegion.fromOffsetLength(4, 3); @@ -122,8 +112,7 @@ void testIntersectDisjoint() { noIntersect(r1, r2); } - @Test - void testOverlapContained() { + @Test void testOverlapContained() { // r1: --[- - ---[ // r2: -- -[-[--- // i: -- -[-[--- @@ -133,8 +122,7 @@ void testOverlapContained() { assertOverlap(r1, r2); } - @Test - void testOverlapDisjoint() { + @Test void testOverlapDisjoint() { // r1: -- -[---[ // r2: --[-[--- TextRegion r1 = TextRegion.fromOffsetLength(4, 3); @@ -144,8 +132,7 @@ void testOverlapDisjoint() { } - @Test - void testOverlapBoundary() { + @Test void testOverlapBoundary() { // r1: -- -[---[ // r2: --[-[--- TextRegion r1 = TextRegion.fromOffsetLength(3, 3); @@ -154,8 +141,7 @@ void testOverlapBoundary() { assertNoOverlap(r1, r2); } - @Test - void testCompare() { + @Test void testCompare() { // r1: --[-[--- // r2: -- -[---[ TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -164,8 +150,7 @@ void testCompare() { assertIsBefore(r1, r2); } - @Test - void testCompareSameOffset() { + @Test void testCompareSameOffset() { // r1: [-[-- // r2: [- --[ TextRegion r1 = TextRegion.fromOffsetLength(0, 1); @@ -175,8 +160,7 @@ void testCompareSameOffset() { } - @Test - void testUnion() { + @Test void testUnion() { // r1: --[-[--- // r2: -- -[---[ TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -187,8 +171,7 @@ void testUnion() { assertRegionEquals(union, 2, 4); } - @Test - void testUnionDisjoint() { + @Test void testUnionDisjoint() { // r1: --[-[- --- // r2: -- ---[---[ TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -199,8 +182,7 @@ void testUnionDisjoint() { assertRegionEquals(union, 2, 6); } - @Test - void testGrowLeft() { + @Test void testGrowLeft() { // r1: --[-[- // r2: [-- -[- TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -210,8 +192,7 @@ void testGrowLeft() { assertRegionEquals(r2, 0, 3); } - @Test - void testGrowLeftNegative() { + @Test void testGrowLeftNegative() { // r1: --[- [- // r2: -- -[[- TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -221,16 +202,14 @@ void testGrowLeftNegative() { assertRegionEquals(r2, 3, 0); } - @Test - void testGrowLeftOutOfBounds() { + @Test void testGrowLeftOutOfBounds() { // r1: --[-[- TextRegion r1 = TextRegion.fromOffsetLength(2, 1); assertThrows(AssertionError.class, () -> r1.growLeft(4)); } - @Test - void testGrowRight() { + @Test void testGrowRight() { // r1: --[-[- // r2: --[- -[ TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -240,8 +219,7 @@ void testGrowRight() { assertRegionEquals(r2, 2, 2); } - @Test - void testGrowRightNegative() { + @Test void testGrowRightNegative() { // r1: --[ -[- // r2: --[[- - TextRegion r1 = TextRegion.fromOffsetLength(2, 1); @@ -251,8 +229,7 @@ void testGrowRightNegative() { assertRegionEquals(r2, 2, 0); } - @Test - void testGrowRightOutOfBounds() { + @Test void testGrowRightOutOfBounds() { // r1: --[-[- TextRegion r1 = TextRegion.fromOffsetLength(2, 1); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessorTest.java index d1bd1c09ca0..c7bad724752 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/AbstractPMDProcessorTest.java @@ -41,8 +41,7 @@ abstract class AbstractPMDProcessorTest { protected abstract Class getExpectedImplementation(); - @Test - void shouldUseCorrectProcessorImpl() { + @Test void shouldUseCorrectProcessorImpl() { try (AbstractPMDProcessor processor = AbstractPMDProcessor.newFileProcessor(createTask(getThreads()))) { assertSame(getExpectedImplementation(), processor.getClass()); } @@ -52,8 +51,7 @@ private LanguageProcessor.AnalysisTask createTask(int threads) { return InternalApiBridge.createAnalysisTask(null, null, null, threads, null, Mockito.mock(PmdReporter.class), null); } - @Test - void exceptionsShouldBeLogged() { + @Test void exceptionsShouldBeLogged() { try (PmdAnalysis pmd = createPmdAnalysis()) { pmd.addRuleSet(RuleSet.forSingleRule(new RuleThatThrowsException())); pmd.performAnalysis(); @@ -99,8 +97,7 @@ protected static class RuleThatThrowsException extends AbstractRule { setLanguage(DummyLanguageModule.getInstance().getDefaultVersion().getLanguage()); } - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { throw new RuntimeException("test exception"); } } @@ -110,8 +107,7 @@ protected static class RuleThatThrowsError extends AbstractRule { setLanguage(DummyLanguageModule.getInstance().getDefaultVersion().getLanguage()); } - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { throw new Error("test error"); } } @@ -122,25 +118,21 @@ protected static class SimpleReportListener implements GlobalAnalysisListener { public AtomicInteger files = new AtomicInteger(0); public AtomicInteger errors = new AtomicInteger(0); - @Override - public FileAnalysisListener startFileAnalysis(TextFile file) { + @Override public FileAnalysisListener startFileAnalysis(TextFile file) { files.incrementAndGet(); return new FileAnalysisListener() { - @Override - public void onRuleViolation(RuleViolation violation) { + @Override public void onRuleViolation(RuleViolation violation) { violations.incrementAndGet(); } - @Override - public void onError(Report.ProcessingError error) { + @Override public void onError(Report.ProcessingError error) { errors.incrementAndGet(); } }; } - @Override - public void close() throws Exception { + @Override public void close() throws Exception { } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java index f02f3f23b30..eaf97e31b93 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MonoThreadProcessorTest.java @@ -16,18 +16,15 @@ class MonoThreadProcessorTest extends AbstractPMDProcessorTest { - @Override - protected int getThreads() { + @Override protected int getThreads() { return 0; } - @Override - protected Class getExpectedImplementation() { + @Override protected Class getExpectedImplementation() { return MonoThreadProcessor.class; } - @Test - void errorsShouldBeThrown() { + @Test void errorsShouldBeThrown() { try (PmdAnalysis pmd = createPmdAnalysis()) { pmd.addRuleSet(RuleSet.forSingleRule(new RuleThatThrowsError())); Error exception = assertThrows(Error.class, pmd::performAnalysis); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java index 1fc72e45c99..c2786dfdbb7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/MultiThreadProcessorTest.java @@ -21,13 +21,11 @@ class MultiThreadProcessorTest extends AbstractPMDProcessorTest { - @Override - protected int getThreads() { + @Override protected int getThreads() { return 2; } - @Override - protected Class getExpectedImplementation() { + @Override protected Class getExpectedImplementation() { return MultiThreadProcessor.class; } @@ -37,8 +35,7 @@ private PmdAnalysis createPmdAnalysis(final String ruleset) { return pmd; } - @Test - void errorsShouldBeThrown() { + @Test void errorsShouldBeThrown() { // in multithreading mode, the errors are detected when closing PmdAnalysis Error error = assertThrows(Error.class, () -> { try (PmdAnalysis pmd = createPmdAnalysis()) { @@ -79,8 +76,7 @@ void errorsShouldBeThrown() { // assertFalse("More configuration errors found than expected", configErrors.hasNext()); // } - @Test - void testRulesThreadSafety() throws Exception { + @Test void testRulesThreadSafety() throws Exception { try (PmdAnalysis pmd = createPmdAnalysis("rulesets/MultiThreadProcessorTest/basic.xml")) { pmd.performAnalysis(); } @@ -96,10 +92,10 @@ void testRulesThreadSafety() throws Exception { public static class NotThreadSafeRule extends AbstractRule { public static AtomicInteger count = new AtomicInteger(0); private boolean hasViolation; // this variable will be overridden + // between the threads - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { count.incrementAndGet(); if (target.getTextDocument().getFileId().getOriginalPath().contains("violation")) { @@ -129,13 +125,11 @@ public static class DysfunctionalRule extends AbstractRule { public static final String DYSFUNCTIONAL_RULE_REASON = "dysfunctional rule is dysfunctional"; - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { // noop } - @Override - public String dysfunctionReason() { + @Override public String dysfunctionReason() { return DYSFUNCTIONAL_RULE_REASON; } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/PmdRunnableTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/PmdRunnableTest.java index 7ca1db22f55..8011de9e017 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/PmdRunnableTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/PmdRunnableTest.java @@ -57,8 +57,7 @@ class PmdRunnableTest { private Rule rule; - @BeforeEach - void prepare() { + @BeforeEach void prepare() { // reset data rule = spy(new RuleThatThrows()); configuration = new PMDConfiguration(LanguageRegistry.singleton(ThrowingLanguageModule.INSTANCE)); @@ -80,8 +79,7 @@ private Report process(LanguageVersion lv) { } } - @Test - void inErrorRecoveryModeErrorsShouldBeLoggedByParser() throws Exception { + @Test void inErrorRecoveryModeErrorsShouldBeLoggedByParser() throws Exception { SystemLambda.restoreSystemProperties(() -> { System.setProperty(SystemProps.PMD_ERROR_RECOVERY, ""); @@ -91,8 +89,7 @@ void inErrorRecoveryModeErrorsShouldBeLoggedByParser() throws Exception { }); } - @Test - void inErrorRecoveryModeErrorsShouldBeLoggedByRule() throws Exception { + @Test void inErrorRecoveryModeErrorsShouldBeLoggedByRule() throws Exception { SystemLambda.restoreSystemProperties(() -> { System.setProperty(SystemProps.PMD_ERROR_RECOVERY, ""); @@ -105,16 +102,14 @@ void inErrorRecoveryModeErrorsShouldBeLoggedByRule() throws Exception { } - @Test - void withoutErrorRecoveryModeProcessingShouldBeAbortedByParser() throws Exception { + @Test void withoutErrorRecoveryModeProcessingShouldBeAbortedByParser() throws Exception { SystemLambda.restoreSystemProperties(() -> { System.clearProperty(SystemProps.PMD_ERROR_RECOVERY); assertThrows(AssertionError.class, () -> process(versionWithParserThatThrowsAssertionError())); }); } - @Test - void withoutErrorRecoveryModeProcessingShouldBeAbortedByRule() throws Exception { + @Test void withoutErrorRecoveryModeProcessingShouldBeAbortedByRule() throws Exception { SystemLambda.restoreSystemProperties(() -> { System.clearProperty(SystemProps.PMD_ERROR_RECOVERY); assertThrows(AssertionError.class, () -> process(ThrowingLanguageModule.INSTANCE.getDefaultVersion())); @@ -122,19 +117,17 @@ void withoutErrorRecoveryModeProcessingShouldBeAbortedByRule() throws Exception } - @Test - void semanticErrorShouldAbortTheRun() { + @Test void semanticErrorShouldAbortTheRun() { Report report = process(versionWithParserThatReportsSemanticError()); verify(reporter, times(1)) - .log(eq(Level.ERROR), eq("at test.dummy:1:1: " + TEST_MESSAGE_SEMANTIC_ERROR)); + .log(eq(Level.ERROR), eq("at test.dummy:1:1: " + TEST_MESSAGE_SEMANTIC_ERROR)); verify(rule, never()).apply(Mockito.any(), Mockito.any()); assertEquals(1, report.getProcessingErrors().size()); } - @Test - void semanticErrorThrownShouldAbortTheRun() { + @Test void semanticErrorThrownShouldAbortTheRun() { Report report = process(getVersionWithParserThatThrowsSemanticError()); verify(reporter, times(1)).log(eq(Level.ERROR), contains(TEST_MESSAGE_SEMANTIC_ERROR)); @@ -161,29 +154,29 @@ private static class ThrowingLanguageModule extends SimpleLanguageModuleBase { ThrowingLanguageModule() { super(LanguageMetadata.withId("foo").name("Foo").extensions("foo") - .addVersion(THROWS_ASSERTION_ERROR) - .addVersion(THROWS_SEMANTIC_ERROR) - .addVersion(PARSER_REPORTS_SEMANTIC_ERROR) - .addDefaultVersion("defalt"), - ThrowingLanguageModule::makeParser); + .addVersion(THROWS_ASSERTION_ERROR) + .addVersion(THROWS_SEMANTIC_ERROR) + .addVersion(PARSER_REPORTS_SEMANTIC_ERROR) + .addDefaultVersion("defalt"), + ThrowingLanguageModule::makeParser); } private static Parser makeParser() { return task -> { switch (task.getLanguageVersion().getVersion()) { - case THROWS_ASSERTION_ERROR: - throw new AssertionError("test error while parsing"); - case PARSER_REPORTS_SEMANTIC_ERROR: { - RootNode root = DummyLanguageModule.readLispNode(task); - task.getReporter().error(root, TEST_MESSAGE_SEMANTIC_ERROR); - return root; - } - case THROWS_SEMANTIC_ERROR: { - RootNode root = DummyLanguageModule.readLispNode(task); - throw task.getReporter().error(root, TEST_MESSAGE_SEMANTIC_ERROR); - } - default: - return DummyLanguageModule.readLispNode(task); + case THROWS_ASSERTION_ERROR: + throw new AssertionError("test error while parsing"); + case PARSER_REPORTS_SEMANTIC_ERROR: { + RootNode root = DummyLanguageModule.readLispNode(task); + task.getReporter().error(root, TEST_MESSAGE_SEMANTIC_ERROR); + return root; + } + case THROWS_SEMANTIC_ERROR: { + RootNode root = DummyLanguageModule.readLispNode(task); + throw task.getReporter().error(root, TEST_MESSAGE_SEMANTIC_ERROR); + } + default: + return DummyLanguageModule.readLispNode(task); } }; } @@ -195,8 +188,7 @@ private static class RuleThatThrows extends AbstractRule { setLanguage(ThrowingLanguageModule.INSTANCE); } - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { throw new AssertionError("test"); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/SimpleDialectLanguageModuleBaseTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/SimpleDialectLanguageModuleBaseTest.java index 4106fbe67e3..6e8bbe4a439 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/SimpleDialectLanguageModuleBaseTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/impl/SimpleDialectLanguageModuleBaseTest.java @@ -21,13 +21,12 @@ class SimpleDialectLanguageModuleBaseTest { - @Test - void baseLanguageXPathFunctionAvailable() throws Exception { + @Test void baseLanguageXPathFunctionAvailable() throws Exception { DummyLanguageModule lang = DummyLanguageModule.getInstance(); DummyLanguageDialectModule dialect = DummyLanguageDialectModule.getInstance(); try (LanguageProcessor baseProcessor = lang.createProcessor(lang.newPropertyBundle()); - LanguageProcessor dialectProcessor = dialect.createProcessor(dialect.newPropertyBundle())) { + LanguageProcessor dialectProcessor = dialect.createProcessor(dialect.newPropertyBundle())) { Set dialectFunctions = dialectProcessor.services().getXPathHandler().getRegisteredExtensionFunctions(); for (XPathFunctionDefinition fn : baseProcessor.services().getXPathHandler().getRegisteredExtensionFunctions()) { @@ -37,8 +36,7 @@ void baseLanguageXPathFunctionAvailable() throws Exception { } } - @Test - void dialectSpecificXPathFunctionAvailable() throws Exception { + @Test void dialectSpecificXPathFunctionAvailable() throws Exception { DummyLanguageDialectModule dialect = DummyLanguageDialectModule.getInstance(); try (LanguageProcessor dialectProcessor = dialect.createProcessor(dialect.newPropertyBundle())) { @@ -50,8 +48,7 @@ void dialectSpecificXPathFunctionAvailable() throws Exception { } } - @Test - void baseLanguagePropertiesAreAvailable() { + @Test void baseLanguagePropertiesAreAvailable() { DummyLanguageModule lang = DummyLanguageModule.getInstance(); DummyLanguageDialectModule dialect = DummyLanguageDialectModule.getInstance(); @@ -64,8 +61,7 @@ void baseLanguagePropertiesAreAvailable() { } } - @Test - void dialectSpecificPropertiesAreAvailable() { + @Test void dialectSpecificPropertiesAreAvailable() { DummyLanguageDialectModule dialect = DummyLanguageDialectModule.getInstance(); LanguagePropertyBundle dialectPropertyBundle = dialect.newPropertyBundle(); @@ -73,13 +69,12 @@ void dialectSpecificPropertiesAreAvailable() { "The property " + DummyLanguageDialectModule.DUMMY_DIALECT_PROP.name() + " is not available in the dialect."); } - @Test - void baseLanguageMetricsAreAvailable() throws Exception { + @Test void baseLanguageMetricsAreAvailable() throws Exception { DummyLanguageModule lang = DummyLanguageModule.getInstance(); DummyLanguageDialectModule dialect = DummyLanguageDialectModule.getInstance(); try (LanguageProcessor baseProcessor = lang.createProcessor(lang.newPropertyBundle()); - LanguageProcessor dialectProcessor = dialect.createProcessor(dialect.newPropertyBundle())) { + LanguageProcessor dialectProcessor = dialect.createProcessor(dialect.newPropertyBundle())) { for (Metric metric : baseProcessor.services().getLanguageMetricsProvider().getMetrics()) { assertNotNull(dialectProcessor.services().getLanguageMetricsProvider().getMetricWithName(metric.displayName()), "The metric " + metric.displayName() + " is not available in the dialect."); @@ -87,8 +82,7 @@ void baseLanguageMetricsAreAvailable() throws Exception { } } - @Test - void dialectSpecificMetricsAreAvailable() throws Exception { + @Test void dialectSpecificMetricsAreAvailable() throws Exception { DummyLanguageDialectModule dialect = DummyLanguageDialectModule.getInstance(); try (LanguageProcessor dialectProcessor = dialect.createProcessor(dialect.newPropertyBundle())) { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/metrics/ParameterizedMetricKeyTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/metrics/ParameterizedMetricKeyTest.java index ebe27c5ce81..b5a95e904aa 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/metrics/ParameterizedMetricKeyTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/metrics/ParameterizedMetricKeyTest.java @@ -21,8 +21,7 @@ class ParameterizedMetricKeyTest { private static final MetricOptions DUMMY_VERSION_2 = MetricOptions.ofOptions(Options.DUMMY2); private static final Metric DUMMY_METRIC = Metric.of((n, opts) -> 0., t -> t, "dummy"); - @Test - void testIdentity() { + @Test void testIdentity() { ParameterizedMetricKey key1 = ParameterizedMetricKey.getInstance(DUMMY_METRIC, DUMMY_VERSION_1); ParameterizedMetricKey key2 = ParameterizedMetricKey.getInstance(DUMMY_METRIC, DUMMY_VERSION_1); @@ -31,8 +30,7 @@ void testIdentity() { } - @Test - void testVersioning() { + @Test void testVersioning() { ParameterizedMetricKey key1 = ParameterizedMetricKey.getInstance(DUMMY_METRIC, DUMMY_VERSION_1); ParameterizedMetricKey key2 = ParameterizedMetricKey.getInstance(DUMMY_METRIC, DUMMY_VERSION_2); @@ -41,8 +39,7 @@ void testVersioning() { } - @Test - void testToString() { + @Test void testToString() { ParameterizedMetricKey key1 = ParameterizedMetricKey.getInstance(DUMMY_METRIC, DUMMY_VERSION_1); assertTrue(key1.toString().contains(key1.metric.displayName())); @@ -50,8 +47,7 @@ void testToString() { } - @Test - void testAdHocMetricKey() { + @Test void testAdHocMetricKey() { ParameterizedMetricKey key1 = ParameterizedMetricKey.getInstance(DUMMY_METRIC, DUMMY_VERSION_1); ParameterizedMetricKey key2 = ParameterizedMetricKey.getInstance(DUMMY_METRIC, DUMMY_VERSION_1); @@ -70,8 +66,7 @@ private enum Options implements MetricOption { DUMMY2; - @Override - public String valueName() { + @Override public String valueName() { return null; } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java index 550604494d8..a2d7dadb199 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRule.java @@ -22,9 +22,9 @@ public class MockRule extends MockRuleWithNoProperties { public static final PropertyDescriptor PROP = - PropertyFactory.intProperty("testIntProperty") - .desc("testIntProperty") - .require(inRange(1, 100)).defaultValue(1).build(); + PropertyFactory.intProperty("testIntProperty") + .desc("testIntProperty") + .require(inRange(1, 100)).defaultValue(1).build(); public MockRule() { super(); @@ -42,8 +42,7 @@ public MockRule(String name, String description, String message, String ruleSetN this(name, description, message, ruleSetName, RulePriority.MEDIUM); } - @Override - public void apply(Node node, RuleContext ctx) { + @Override public void apply(Node node, RuleContext ctx) { // the mock rule does nothing. Usually you would start here to analyze the AST. } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java index 8286a169859..948c179d1c8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/MockRuleWithNoProperties.java @@ -33,8 +33,7 @@ public MockRuleWithNoProperties(String name, String description, String message, setRuleSetName(ruleSetName); } - @Override - public void apply(Node node, RuleContext ctx) { + @Override public void apply(Node node, RuleContext ctx) { // the mock rule does nothing. Usually you would start here to analyze the AST. } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleReferenceTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleReferenceTest.java index 3114a6e4a32..a9b0355bd93 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleReferenceTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleReferenceTest.java @@ -23,15 +23,13 @@ class RuleReferenceTest { - @Test - void testRuleSetReference() { + @Test void testRuleSetReference() { RuleSetReference ruleSetReference = new RuleSetReference("somename"); RuleReference ruleReference = new RuleReference(null, ruleSetReference); assertEquals(ruleSetReference, ruleReference.getRuleSetReference(), "Not same rule set reference"); } - @Test - void testOverride() { + @Test void testOverride() { final PropertyDescriptor PROPERTY1_DESCRIPTOR = PropertyFactory.stringProperty("property1").desc("Test property").defaultValue("").build(); MockRule rule = new MockRule(); rule.definePropertyDescriptor(PROPERTY1_DESCRIPTOR); @@ -63,8 +61,7 @@ void testOverride() { validateOverriddenValues(PROPERTY1_DESCRIPTOR, PROPERTY2_DESCRIPTOR, ruleReference); } - @Test - void testOverridingDefaultValueOfProperty() { + @Test void testOverridingDefaultValueOfProperty() { final PropertyDescriptor PROPERTY1_DESCRIPTOR = PropertyFactory.stringProperty("property1").desc("Test property").defaultValue("the-default").build(); MockRule rule = new MockRule(); rule.definePropertyDescriptor(PROPERTY1_DESCRIPTOR); @@ -89,8 +86,7 @@ void testOverridingDefaultValueOfProperty() { assertTrue(overriddenPropertyDescriptors.contains(PROPERTY1_DESCRIPTOR)); } - @Test - void testLanguageOverrideDisallowed() { + @Test void testLanguageOverrideDisallowed() { MockRule rule = new MockRule(); Language dummyLang = dummyLanguage(); rule.setLanguage(dummyLang); @@ -105,8 +101,7 @@ void testLanguageOverrideDisallowed() { assertEquals(rule.getMinimumLanguageVersion(), ruleReference.getMinimumLanguageVersion()); } - @Test - void testDeepCopyOverride() { + @Test void testDeepCopyOverride() { final PropertyDescriptor PROPERTY1_DESCRIPTOR = PropertyFactory.stringProperty("property1").desc("Test property").defaultValue("").build(); MockRule rule = new MockRule(); rule.definePropertyDescriptor(PROPERTY1_DESCRIPTOR); @@ -142,17 +137,17 @@ void testDeepCopyOverride() { private void validateOverriddenValues(final PropertyDescriptor propertyDescriptor1, final PropertyDescriptor propertyDescriptor2, RuleReference ruleReference) { assertEquals(dummyLanguage(), ruleReference.getLanguage(), - "Override failed"); + "Override failed"); assertEquals(dummyLanguage().getVersion("1.3"), ruleReference.getMinimumLanguageVersion(), - "Override failed"); + "Override failed"); assertEquals(dummyLanguage().getVersion("1.3"), ruleReference.getOverriddenMinimumLanguageVersion(), - "Override failed"); + "Override failed"); assertEquals(dummyLanguage().getVersion("1.7"), ruleReference.getMaximumLanguageVersion(), - "Override failed"); + "Override failed"); assertEquals(dummyLanguage().getVersion("1.7"), ruleReference.getOverriddenMaximumLanguageVersion(), - "Override failed"); + "Override failed"); assertEquals(false, ruleReference.getRule().isDeprecated(), "Override failed"); assertEquals(true, ruleReference.isDeprecated(), "Override failed"); @@ -194,8 +189,7 @@ private void validateOverriddenValues(final PropertyDescriptor propertyD assertEquals(RulePriority.MEDIUM_HIGH, ruleReference.getOverriddenPriority(), "Override failed"); } - @Test - void testNotOverride() { + @Test void testNotOverride() { final PropertyDescriptor PROPERTY1_DESCRIPTOR = PropertyFactory.stringProperty("property1").desc("Test property").defaultValue("").build(); MockRule rule = new MockRule(); rule.definePropertyDescriptor(PROPERTY1_DESCRIPTOR); @@ -212,9 +206,9 @@ void testNotOverride() { RuleReference ruleReference = new RuleReference(rule, null); ruleReference - .setMinimumLanguageVersion(dummyLanguage().getVersion("1.3")); + .setMinimumLanguageVersion(dummyLanguage().getVersion("1.3")); ruleReference - .setMaximumLanguageVersion(dummyLanguage().getVersion("1.7")); + .setMaximumLanguageVersion(dummyLanguage().getVersion("1.7")); ruleReference.setDeprecated(false); ruleReference.setName("name1"); ruleReference.setProperty(PROPERTY1_DESCRIPTOR, "value1"); @@ -226,11 +220,11 @@ void testNotOverride() { assertEquals(dummyLanguage().getVersion("1.3"), ruleReference.getMinimumLanguageVersion(), - "Override failed"); + "Override failed"); assertNull(ruleReference.getOverriddenMinimumLanguageVersion(), "Override failed"); assertEquals(dummyLanguage().getVersion("1.7"), ruleReference.getMaximumLanguageVersion(), - "Override failed"); + "Override failed"); assertNull(ruleReference.getOverriddenMaximumLanguageVersion(), "Override failed"); assertEquals(false, ruleReference.isDeprecated(), "Override failed"); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java index 277624acc75..e9b411ec396 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryDuplicatedRuleLoggingTest.java @@ -18,8 +18,7 @@ class RuleSetFactoryDuplicatedRuleLoggingTest extends RulesetFactoryTestBase { private static final String DIR = "net/sourceforge/pmd/rulesets/duplicatedRuleLoggingTest"; - @Test - void duplicatedRuleReferenceShouldWarn() throws Exception { + @Test void duplicatedRuleReferenceShouldWarn() throws Exception { String log = SystemLambda.tapSystemErr(() -> { RuleSet ruleset = loadRuleSetInDir(DIR, "duplicatedRuleReference.xml"); @@ -29,12 +28,11 @@ void duplicatedRuleReferenceShouldWarn() throws Exception { assertEquals(RulePriority.MEDIUM, mockRule.getPriority()); }); assertThat(log, containsString( - "The rule DummyBasicMockRule is referenced multiple times in ruleset 'Custom Rules'. " - + "Only the last rule configuration is used")); + "The rule DummyBasicMockRule is referenced multiple times in ruleset 'Custom Rules'. " + + "Only the last rule configuration is used")); } - @Test - void duplicatedRuleReferenceWithOverrideShouldNotWarn() throws Exception { + @Test void duplicatedRuleReferenceWithOverrideShouldNotWarn() throws Exception { String log = SystemLambda.tapSystemErr(() -> { RuleSet ruleset = loadRuleSetInDir(DIR, "duplicatedRuleReferenceWithOverride.xml"); @@ -47,8 +45,7 @@ void duplicatedRuleReferenceWithOverrideShouldNotWarn() throws Exception { assertTrue(log.isEmpty()); } - @Test - void duplicatedRuleReferenceWithOverrideBeforeShouldNotWarn() throws Exception { + @Test void duplicatedRuleReferenceWithOverrideBeforeShouldNotWarn() throws Exception { String log = SystemLambda.tapSystemErr(() -> { RuleSet ruleset = loadRuleSetInDir(DIR, "duplicatedRuleReferenceWithOverrideBefore.xml"); assertEquals(2, ruleset.getRules().size()); @@ -60,8 +57,7 @@ void duplicatedRuleReferenceWithOverrideBeforeShouldNotWarn() throws Exception { assertTrue(log.isEmpty()); } - @Test - void multipleDuplicates() throws Exception { + @Test void multipleDuplicates() throws Exception { String log = SystemLambda.tapSystemErr(() -> { RuleSet ruleset = loadRuleSetInDir(DIR, "multipleDuplicates.xml"); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryMessagesTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryMessagesTest.java index b876dbcb549..4117e9aceea 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryMessagesTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryMessagesTest.java @@ -23,47 +23,44 @@ class RuleSetFactoryMessagesTest extends RulesetFactoryTestBase { - @Test - void testFullMessage() throws Exception { + @Test void testFullMessage() throws Exception { String log = SystemLambda.tapSystemErr(() -> assertCannotParse( - rulesetXml( - dummyRule( - priority("not a priority") + rulesetXml( + dummyRule( + priority("not a priority") + ) ) - ) )); assertThat(log, containsString( - "Error at dummyRuleset.xml:9:1\n" - + " 7| \n" - + " 8| \n" - + " 9| not a priority\n" - + " ^^^^^^^^^ Not a valid priority: 'not a priority', expected a number in [1,5]" + "Error at dummyRuleset.xml:9:1\n" + + " 7| \n" + + " 8| \n" + + " 9| not a priority\n" + + " ^^^^^^^^^ Not a valid priority: 'not a priority', expected a number in [1,5]" )); } - @Test - void testPropertyConstraintFailure() throws Exception { + @Test void testPropertyConstraintFailure() throws Exception { String log = SystemLambda.tapSystemErr(() -> assertCannotParse( - rulesetXml( - dummyRule( - attrs -> attrs.put(SchemaConstants.CLASS, MockRule.class.getName()), - properties( - propertyWithValueAttr(MockRule.PROP.name(), "-4") - ) + rulesetXml( + dummyRule( + attrs -> attrs.put(SchemaConstants.CLASS, MockRule.class.getName()), + properties( + propertyWithValueAttr(MockRule.PROP.name(), "-4") + ) + ) ) - ) )); assertThat(log, containsString( - " 10| \n" - + " ^^^^^ Value should be between 1 and 100" + " 10| \n" + + " ^^^^^ Value should be between 1 and 100" )); } - @Test - void testPropertyValueAsAttributeAndTag() throws Exception { + @Test void testPropertyValueAsAttributeAndTag() throws Exception { String log = SystemLambda.tapSystemErr(() -> assertEquals(1, loadFirstRule( rulesetXml( dummyRule( @@ -79,13 +76,12 @@ void testPropertyValueAsAttributeAndTag() throws Exception { assertThat(log, containsString( " 10| \n" - + " ^^^^^ Both a 'value' attribute and a child element are present, the attribute will be ignored\n" + + " ^^^^^ Both a 'value' attribute and a child element are present, the attribute will be ignored\n" )); } - @Test - void testStringMultiPropertyDelimiterDeprecated() throws Exception { + @Test void testStringMultiPropertyDelimiterDeprecated() throws Exception { String log = SystemLambda.tapSystemErr(() -> { Rule r = loadFirstRule( rulesetXml( @@ -108,22 +104,21 @@ void testStringMultiPropertyDelimiterDeprecated() throws Exception { assertThat(log, containsString( " 11| \n" - + " ^^^^^^^^^ Delimiter attribute is not supported anymore, values are always comma-separated.\n" + + " ^^^^^^^^^ Delimiter attribute is not supported anymore, values are always comma-separated.\n" )); } /** * @see [core] Referenced Rulesets do not emit details on validation errors #4978 */ - @Test - void validationMessagesFromReferencedRulesets(@TempDir Path tempDir) throws Exception { + @Test void validationMessagesFromReferencedRulesets(@TempDir Path tempDir) throws Exception { Path childRuleset = tempDir.resolve("invalid-ruleset.xml").toAbsolutePath(); Files.write(childRuleset, - rulesetXml( - dummyRule( - priority("not a priority") - ) - ).getBytes(StandardCharsets.UTF_8)); + rulesetXml( + dummyRule( + priority("not a priority") + ) + ).getBytes(StandardCharsets.UTF_8)); String log = SystemLambda.tapSystemErr(() -> { RuleSetLoadException exception = assertCannotParse( diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryTest.java index 7fe83afa0ab..b3be69d8e9a 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetFactoryTest.java @@ -35,8 +35,7 @@ class RuleSetFactoryTest extends RulesetFactoryTestBase { private static final String TEST_RULESET_1 = "net/sourceforge/pmd/lang/rule/TestRuleset1.xml"; private static final String REFERENCE_RULESET = "net/sourceforge/pmd/lang/rule/reference-ruleset.xml"; - @Test - void testRuleSetFileName() { + @Test void testRuleSetFileName() { RuleSet rs = new RuleSetLoader().loadFromString("dummyRuleset.xml", EMPTY_RULESET); assertEquals("dummyRuleset.xml", rs.getFileName()); @@ -44,14 +43,12 @@ void testRuleSetFileName() { assertEquals(rs.getFileName(), TEST_RULESET_1, "wrong RuleSet file name"); } - @Test - void testRefs() { + @Test void testRefs() { RuleSet rs = new RuleSetLoader().loadFromResource(TEST_RULESET_1); assertNotNull(rs.getRuleByName("TestRuleRef")); } - @Test - void testExtendedReferences() throws Exception { + @Test void testExtendedReferences() throws Exception { InputStream in = new ResourceLoader().loadClassPathResourceAsStream(REFERENCE_RULESET); assertNotNull(in, "Test ruleset not found - can't continue with test!"); in.close(); @@ -101,20 +98,17 @@ void testExtendedReferences() throws Exception { assertEquals(2, ruleset4Rule2.getPriority().getPriority()); } - @Test - void testRuleSetNotFound() { + @Test void testRuleSetNotFound() { assertThrows(RuleSetLoadException.class, () -> new RuleSetLoader().loadFromResource("fooooo")); } - @Test - void testCreateEmptyRuleSet() { + @Test void testCreateEmptyRuleSet() { RuleSet rs = loadRuleSet(EMPTY_RULESET); assertEquals("Custom ruleset", rs.getName()); assertEquals(0, rs.size()); } - @Test - void testSingleRule() { + @Test void testSingleRule() { RuleSet rs = loadRuleSet(SINGLE_RULE); assertEquals(1, rs.size()); Rule r = rs.getRules().iterator().next(); @@ -123,8 +117,7 @@ void testSingleRule() { assertEquals("avoid the mock rule", r.getMessage()); } - @Test - void testSingleRuleEmptyRef() throws Exception { + @Test void testSingleRuleEmptyRef() throws Exception { String log = SystemLambda.tapSystemErr(() -> { RuleSet rs = loadRuleSet(SINGLE_RULE_EMPTY_REF); assertEquals(1, rs.size()); @@ -137,11 +130,10 @@ void testSingleRuleEmptyRef() throws Exception { assertThat(log, containsString("Empty ref attribute")); } - @Test - void testMultipleRules() { + @Test void testMultipleRules() { RuleSet rs = loadRuleSet(rulesetXml( - dummyRule(attrs -> attrs.put(NAME, "MockRuleName1")), - dummyRule(attrs -> attrs.put(NAME, "MockRuleName2")) + dummyRule(attrs -> attrs.put(NAME, "MockRuleName1")), + dummyRule(attrs -> attrs.put(NAME, "MockRuleName2")) )); assertEquals(2, rs.size()); Set expected = new HashSet<>(); @@ -152,19 +144,17 @@ void testMultipleRules() { } } - @Test - void testSingleRuleWithPriority() { + @Test void testSingleRuleWithPriority() { Rule rule = loadFirstRule(rulesetXml( - rule( - dummyRuleDefAttrs(), - priority("3") - ) + rule( + dummyRuleDefAttrs(), + priority("3") + ) )); assertEquals(RulePriority.MEDIUM, rule.getPriority()); } - @Test - void testProps() { + @Test void testProps() { Rule r = loadFirstRule(PROPERTIES); assertEquals("bar", r.getProperty(r.getPropertyDescriptor("fooString"))); assertEquals(3, r.getProperty(r.getPropertyDescriptor("fooInt"))); @@ -174,17 +164,16 @@ void testProps() { assertNotSame(r.getDescription().indexOf("testdesc2"), -1); } - @Test - void testStringMultiPropertyDefaultDelimiter() { + @Test void testStringMultiPropertyDefaultDelimiter() { Rule r = loadFirstRule( - rulesetXml( - dummyRule( - priority("3"), - properties( - "" - ) - ) - )); + rulesetXml( + dummyRule( + priority("3"), + properties( + "" + ) + ) + )); Object propValue = r.getProperty(r.getPropertyDescriptor("packageRegEx")); assertEquals(listOf("com.aptsssss", "com.abc"), propValue); @@ -197,8 +186,7 @@ void testStringMultiPropertyDefaultDelimiter() { * * @see [java] TestClassWithoutTestCases - can not set test pattern to empty #4279 */ - @Test - void testEmptyStringProperty() { + @Test void testEmptyStringProperty() { Rule r = loadFirstRule("\n" + "\n " + " ruleset desc\n " @@ -213,12 +201,11 @@ void testEmptyStringProperty() { assertEquals("", value); } - @Test - void testRuleSetWithDeprecatedRule() { + @Test void testRuleSetWithDeprecatedRule() { RuleSet rs = loadRuleSet("\n" + "\n" - + " ruleset desc\n" - + " " - + ""); + + " ruleset desc\n" + + " " + + ""); assertEquals(1, rs.getRules().size()); Rule rule = rs.getRuleByName("DummyBasicMockRule"); assertNotNull(rule); @@ -234,16 +221,15 @@ void testRuleSetWithDeprecatedRule() { * This is because the deprecated reference points to a rule in the same ruleset. * */ - @Test - void testRuleSetWithDeprecatedButRenamedRule() throws Exception { + @Test void testRuleSetWithDeprecatedButRenamedRule() throws Exception { SystemLambda.tapSystemErr(() -> { RuleSet rs = loadRuleSetWithDeprecationWarnings( - "\n" + "\n" - + " ruleset desc\n" - + " " - + " " - + " d\n" + " 2\n" + " " - + ""); + "\n" + "\n" + + " ruleset desc\n" + + " " + + " " + + " d\n" + " 2\n" + " " + + ""); assertEquals(1, rs.getRules().size()); Rule rule = rs.getRuleByName("NewName"); assertNotNull(rule); @@ -262,18 +248,17 @@ void testRuleSetWithDeprecatedButRenamedRule() throws Exception { * include the deprecated rule reference, so that we can create a nice documentation. * */ - @Test - void testRuleSetWithDeprecatedRenamedRuleForDoc() { + @Test void testRuleSetWithDeprecatedRenamedRuleForDoc() { RuleSetLoader loader = new RuleSetLoader().includeDeprecatedRuleReferences(true); RuleSet rs = loader.loadFromString("ruleset.xml", - "\n" + "\n" - + " ruleset desc\n" - + " " - + " " - + " d\n" - + " 2\n" - + " " - + ""); + "\n" + "\n" + + " ruleset desc\n" + + " " + + " " + + " d\n" + + " 2\n" + + " " + + ""); assertEquals(2, rs.getRules().size()); assertNotNull(rs.getRuleByName("NewName")); assertNotNull(rs.getRuleByName("OldName")); @@ -283,21 +268,20 @@ void testRuleSetWithDeprecatedRenamedRuleForDoc() { * This is an example of a custom user ruleset, that references a rule, that has been renamed. * The user should get a deprecation warning. */ - @Test - void testRuleSetReferencesADeprecatedRenamedRule() throws Exception { + @Test void testRuleSetReferencesADeprecatedRenamedRule() throws Exception { SystemLambda.tapSystemErr(() -> { RuleSet rs = loadRuleSetWithDeprecationWarnings( - "\n" + "\n" - + " ruleset desc\n" - + " " + ""); + "\n" + "\n" + + " ruleset desc\n" + + " " + ""); assertEquals(1, rs.getRules().size()); Rule rule = rs.getRuleByName("OldNameOfDummyBasicMockRule"); assertNotNull(rule); }); verifyFoundAWarningWithMessage( - containing("Use Rule name rulesets/dummy/basic.xml/DummyBasicMockRule " - + "instead of the deprecated Rule name rulesets/dummy/basic.xml/OldNameOfDummyBasicMockRule") + containing("Use Rule name rulesets/dummy/basic.xml/DummyBasicMockRule " + + "instead of the deprecated Rule name rulesets/dummy/basic.xml/OldNameOfDummyBasicMockRule") ); } @@ -315,13 +299,12 @@ void testRuleSetReferencesADeprecatedRenamedRule() throws Exception { * In the end, we should get all non-deprecated rules of the referenced ruleset. * */ - @Test - void testRuleSetReferencesRulesetWithADeprecatedRenamedRule() throws Exception { + @Test void testRuleSetReferencesRulesetWithADeprecatedRenamedRule() throws Exception { SystemLambda.tapSystemErr(() -> { RuleSet rs = loadRuleSetWithDeprecationWarnings( - "\n" + "\n" - + " ruleset desc\n" - + " " + ""); + "\n" + "\n" + + " ruleset desc\n" + + " " + ""); assertEquals(2, rs.getRules().size()); assertNotNull(rs.getRuleByName("DummyBasicMockRule")); assertNotNull(rs.getRuleByName("SampleXPathRule")); @@ -345,8 +328,7 @@ void testRuleSetReferencesRulesetWithADeprecatedRenamedRule() throws Exception { * In the end, we should get all non-deprecated rules of the referenced ruleset. * */ - @Test - void testRuleSetReferencesRulesetWithAExcludedDeprecatedRule() throws Exception { + @Test void testRuleSetReferencesRulesetWithAExcludedDeprecatedRule() throws Exception { String log = SystemLambda.tapSystemErr(() -> { RuleSet rs = loadRuleSetWithDeprecationWarnings( "\n" + "\n" @@ -372,25 +354,24 @@ void testRuleSetReferencesRulesetWithAExcludedDeprecatedRule() throws Exception * Since the rule to be excluded doesn't exist, there should be a warning about that. * */ - @Test - void testRuleSetReferencesRulesetWithAExcludedNonExistingRule() throws Exception { + @Test void testRuleSetReferencesRulesetWithAExcludedNonExistingRule() throws Exception { SystemLambda.tapSystemErr(() -> { RuleSet rs = loadRuleSetWithDeprecationWarnings( - rulesetXml( - rulesetRef("rulesets/dummy/basic.xml", - excludeRule("NonExistingRule")) + rulesetXml( + rulesetRef("rulesets/dummy/basic.xml", + excludeRule("NonExistingRule")) - )); + )); assertEquals(2, rs.getRules().size()); assertNotNull(rs.getRuleByName("DummyBasicMockRule")); assertNotNull(rs.getRuleByName("SampleXPathRule")); }); verifyFoundWarningWithMessage( - Mockito.never(), - containing("Discontinue using Rule rulesets/dummy/basic.xml/DeprecatedRule") + Mockito.never(), + containing("Discontinue using Rule rulesets/dummy/basic.xml/DeprecatedRule") ); verifyFoundAWarningWithMessage(containing( - "Exclude pattern 'NonExistingRule' did not match any rule in ruleset" + "Exclude pattern 'NonExistingRule' did not match any rule in ruleset" )); } @@ -398,20 +379,19 @@ void testRuleSetReferencesRulesetWithAExcludedNonExistingRule() throws Exception * When a custom ruleset references a ruleset that only contains deprecated rules, then this ruleset itself is * considered deprecated and the user should get a deprecation warning for the ruleset. */ - @Test - void testRuleSetReferencesDeprecatedRuleset() throws Exception { + @Test void testRuleSetReferencesDeprecatedRuleset() throws Exception { SystemLambda.tapSystemErr(() -> { RuleSet rs = loadRuleSetWithDeprecationWarnings( - rulesetXml( - rulesetRef("rulesets/dummy/deprecated.xml") - )); + rulesetXml( + rulesetRef("rulesets/dummy/deprecated.xml") + )); assertEquals(2, rs.getRules().size()); assertNotNull(rs.getRuleByName("DummyBasicMockRule")); assertNotNull(rs.getRuleByName("SampleXPathRule")); }); verifyFoundAWarningWithMessage(containing( - "The RuleSet rulesets/dummy/deprecated.xml has been deprecated and will be removed in PMD" + "The RuleSet rulesets/dummy/deprecated.xml has been deprecated and will be removed in PMD" )); } @@ -420,35 +400,31 @@ void testRuleSetReferencesDeprecatedRuleset() throws Exception { * for backwards compatibility, because the rules have been moved to a different ruleset, then there should be * no warning about deprecation - since the deprecated rules are not used. */ - @Test - void testRuleSetReferencesRulesetWithAMovedRule() throws Exception { + @Test void testRuleSetReferencesRulesetWithAMovedRule() throws Exception { SystemLambda.tapSystemErr(() -> { RuleSet rs = loadRuleSetWithDeprecationWarnings( - rulesetXml( - ruleRef("rulesets/dummy/basic2.xml") - ) + rulesetXml( + ruleRef("rulesets/dummy/basic2.xml") + ) ); assertEquals(1, rs.getRules().size()); assertNotNull(rs.getRuleByName("DummyBasic2MockRule")); }); verifyFoundWarningWithMessage( - Mockito.never(), - containing("Use Rule name rulesets/dummy/basic.xml/DummyBasicMockRule instead of the deprecated Rule name rulesets/dummy/basic2.xml/DummyBasicMockRule") + Mockito.never(), + containing("Use Rule name rulesets/dummy/basic.xml/DummyBasicMockRule instead of the deprecated Rule name rulesets/dummy/basic2.xml/DummyBasicMockRule") ); } - @Test - @SuppressWarnings("unchecked") - void testXPath() { + @Test @SuppressWarnings("unchecked") void testXPath() { Rule r = loadFirstRule(XPATH); PropertyDescriptor xpathProperty = (PropertyDescriptor) r.getPropertyDescriptor("xpath"); assertNotNull(xpathProperty, "xpath property descriptor"); assertNotSame(r.getProperty(xpathProperty).indexOf("//Block"), -1); } - @Test - void testExternalReferenceOverride() { + @Test void testExternalReferenceOverride() { Rule r = loadFirstRule(REF_OVERRIDE); assertEquals("TestNameOverride", r.getName()); assertEquals("Test message override", r.getMessage()); @@ -464,17 +440,15 @@ void testExternalReferenceOverride() { assertEquals("override3", r.getProperty(test3Descriptor)); } - @Test - void testExternalReferenceOverrideNonExistent() { + @Test void testExternalReferenceOverrideNonExistent() { assertThrows(RuleSetLoadException.class, - () -> loadFirstRule(REF_OVERRIDE_NONEXISTENT)); + () -> loadFirstRule(REF_OVERRIDE_NONEXISTENT)); verifyFoundAnErrorWithMessage( - containing("Cannot set non-existent property 'test4' on rule TestNameOverride") + containing("Cannot set non-existent property 'test4' on rule TestNameOverride") ); } - @Test - void testReferenceInternalToInternal() { + @Test void testReferenceInternalToInternal() { RuleSet ruleSet = loadRuleSet(REF_INTERNAL_TO_INTERNAL); Rule rule = ruleSet.getRuleByName("MockRuleName"); @@ -484,8 +458,7 @@ void testReferenceInternalToInternal() { assertNotNull(ruleRef, "Could not find Rule MockRuleNameRef"); } - @Test - void testReferenceInternalToInternalChain() { + @Test void testReferenceInternalToInternalChain() { RuleSet ruleSet = loadRuleSet(REF_INTERNAL_TO_INTERNAL_CHAIN); Rule rule = ruleSet.getRuleByName("MockRuleName"); @@ -498,8 +471,7 @@ void testReferenceInternalToInternalChain() { assertNotNull(ruleRefRef, "Could not find Rule MockRuleNameRefRef"); } - @Test - void testReferenceInternalToExternal() { + @Test void testReferenceInternalToExternal() { RuleSet ruleSet = loadRuleSet(REF_INTERNAL_TO_EXTERNAL); Rule rule = ruleSet.getRuleByName("ExternalRefRuleName"); @@ -509,8 +481,7 @@ void testReferenceInternalToExternal() { assertNotNull(ruleRef, "Could not find Rule ExternalRefRuleNameRef"); } - @Test - void testReferenceInternalToExternalChain() { + @Test void testReferenceInternalToExternalChain() { RuleSet ruleSet = loadRuleSet(REF_INTERNAL_TO_EXTERNAL_CHAIN); Rule rule = ruleSet.getRuleByName("ExternalRefRuleName"); @@ -523,8 +494,7 @@ void testReferenceInternalToExternalChain() { assertNotNull(ruleRefRef, "Could not find Rule ExternalRefRuleNameRefRef"); } - @Test - void testReferencePriority() { + @Test void testReferencePriority() { RuleSetLoader config = new RuleSetLoader().warnDeprecated(false); RuleSetLoader rulesetLoader = config.filterAbovePriority(RulePriority.LOW); @@ -564,8 +534,7 @@ void testReferencePriority() { assertNotNull(ruleSet.getRuleByName("ExternalRefRuleNameRefRef")); } - @Test - void testOverridePriorityLoadWithMinimum() { + @Test void testOverridePriorityLoadWithMinimum() { RuleSetLoader rulesetLoader = new RuleSetLoader().filterAbovePriority(RulePriority.MEDIUM_LOW) .warnDeprecated(true); RuleSet ruleset = rulesetLoader.loadFromResource("net/sourceforge/pmd/rulesets/ruleset-minimum-priority.xml"); @@ -586,8 +555,7 @@ void testOverridePriorityLoadWithMinimum() { assertEquals(RulePriority.LOW, dummyBasicMockRule.getPriority(), "Wrong Priority"); } - @Test - void testExcludeWithMinimumPriority() { + @Test void testExcludeWithMinimumPriority() { RuleSetLoader rulesetLoader = new RuleSetLoader().filterAbovePriority(RulePriority.HIGH); RuleSet ruleset = rulesetLoader .loadFromResource("net/sourceforge/pmd/rulesets/ruleset-minimum-priority-exclusion.xml"); @@ -605,149 +573,134 @@ void testExcludeWithMinimumPriority() { assertNotNull(ruleset.getRuleByName("SampleXPathRule")); } - @Test - void testOverrideMessage() { + @Test void testOverrideMessage() { Rule r = loadFirstRule(REF_OVERRIDE_ORIGINAL_NAME); assertEquals("TestMessageOverride", r.getMessage()); } - @Test - void testOverrideMessageOneElem() { + @Test void testOverrideMessageOneElem() { Rule r = loadFirstRule(REF_OVERRIDE_ORIGINAL_NAME_ONE_ELEM); assertEquals("TestMessageOverride", r.getMessage()); } - @Test - void testIncorrectExternalRef() { + @Test void testIncorrectExternalRef() { assertCannotParse(REF_MISSPELLED_XREF); } - @Test - void testSetPriority() { + @Test void testSetPriority() { RuleSetLoader rulesetLoader = new RuleSetLoader().filterAbovePriority(RulePriority.MEDIUM_HIGH).warnDeprecated(false); assertEquals(0, rulesetLoader.loadFromString("ruleset.xml", SINGLE_RULE).size()); rulesetLoader = new RuleSetLoader().filterAbovePriority(RulePriority.MEDIUM_LOW).warnDeprecated(false); assertEquals(1, rulesetLoader.loadFromString("ruleset.xml", SINGLE_RULE).size()); } - @Test - void testLanguage() { + @Test void testLanguage() { Rule r = loadFirstRule(rulesetXml( - dummyRule( - attrs -> attrs.put(SchemaConstants.LANGUAGE, "dummy") - ) + dummyRule( + attrs -> attrs.put(SchemaConstants.LANGUAGE, "dummy") + ) )); assertEquals(dummyLanguage(), r.getLanguage()); } - @Test - void testIncorrectLanguage() { + @Test void testIncorrectLanguage() { assertCannotParse(rulesetXml( - dummyRule( - attrs -> attrs.put(SchemaConstants.LANGUAGE, "bogus") - ) + dummyRule( + attrs -> attrs.put(SchemaConstants.LANGUAGE, "bogus") + ) )); } - @Test - void testIncorrectPriority() { + @Test void testIncorrectPriority() { assertCannotParse(rulesetXml( - dummyRule( - priority("not a priority") - ) + dummyRule( + priority("not a priority") + ) )); verifyFoundAnErrorWithMessage(containing("Not a valid priority: 'not a priority'")); } - @Test - void testMinimumLanguageVersion() { + @Test void testMinimumLanguageVersion() { Rule r = loadFirstRule(rulesetXml( - dummyRule( - attrs -> attrs.put(SchemaConstants.MINIMUM_LANGUAGE_VERSION, "1.4") - ) + dummyRule( + attrs -> attrs.put(SchemaConstants.MINIMUM_LANGUAGE_VERSION, "1.4") + ) )); assertEquals(dummyLanguage().getVersion("1.4"), - r.getMinimumLanguageVersion()); + r.getMinimumLanguageVersion()); } - @Test - void testIncorrectMinimumLanguageVersion() { + @Test void testIncorrectMinimumLanguageVersion() { assertCannotParse(rulesetXml( - dummyRule( - attrs -> attrs.put(SchemaConstants.MINIMUM_LANGUAGE_VERSION, "bogus") - ) + dummyRule( + attrs -> attrs.put(SchemaConstants.MINIMUM_LANGUAGE_VERSION, "bogus") + ) )); verifyFoundAnErrorWithMessage( - containing("valid language version") - .and(containing("'1.0', '1.1', '1.2'")) // and not "dummy 1.0, dummy 1.1, ..." + containing("valid language version") + .and(containing("'1.0', '1.1', '1.2'")) // and not "dummy 1.0, dummy 1.1, ..." ); } - @Test - void testIncorrectMinimumLanguageVersionWithLanguageSetInJava() { + @Test void testIncorrectMinimumLanguageVersionWithLanguageSetInJava() { assertCannotParse("\n" - + "\n" - + " TODO\n" - + "\n" - + " \n" - + " TODO\n" - + " 2\n" - + " \n" - + "\n" - + ""); + + "\n" + + " TODO\n" + + "\n" + + " \n" + + " TODO\n" + + " 2\n" + + " \n" + + "\n" + + ""); verifyFoundAnErrorWithMessage( - containing("valid language version") + containing("valid language version") ); } - @Test - void testMaximumLanguageVersion() { + @Test void testMaximumLanguageVersion() { Rule r = loadFirstRule(rulesetXml( - dummyRule(attrs -> attrs.put(SchemaConstants.MAXIMUM_LANGUAGE_VERSION, "1.7")) + dummyRule(attrs -> attrs.put(SchemaConstants.MAXIMUM_LANGUAGE_VERSION, "1.7")) )); assertEquals(dummyLanguage().getVersion("1.7"), - r.getMaximumLanguageVersion()); + r.getMaximumLanguageVersion()); } - @Test - void testIncorrectMaximumLanguageVersion() { + @Test void testIncorrectMaximumLanguageVersion() { assertCannotParse(rulesetXml( - dummyRule(attrs -> attrs.put(SchemaConstants.MAXIMUM_LANGUAGE_VERSION, "bogus")) + dummyRule(attrs -> attrs.put(SchemaConstants.MAXIMUM_LANGUAGE_VERSION, "bogus")) )); verifyFoundAnErrorWithMessage( - containing("valid language version") - .and(containing("'1.0', '1.1', '1.2'")) + containing("valid language version") + .and(containing("'1.0', '1.1', '1.2'")) ); } - @Test - void testInvertedMinimumMaximumLanguageVersions() { + @Test void testInvertedMinimumMaximumLanguageVersions() { assertCannotParse(rulesetXml( - dummyRule( - attrs -> { - attrs.put(SchemaConstants.MINIMUM_LANGUAGE_VERSION, "1.7"); - attrs.put(SchemaConstants.MAXIMUM_LANGUAGE_VERSION, "1.4"); - } - ) + dummyRule( + attrs -> { + attrs.put(SchemaConstants.MINIMUM_LANGUAGE_VERSION, "1.7"); + attrs.put(SchemaConstants.MAXIMUM_LANGUAGE_VERSION, "1.4"); + } + ) )); verifyFoundAnErrorWithMessage(containing("version range")); } - @Test - void testDirectDeprecatedRule() { + @Test void testDirectDeprecatedRule() { Rule r = loadFirstRule(rulesetXml( - dummyRule(attrs -> attrs.put(DEPRECATED, "true")) + dummyRule(attrs -> attrs.put(DEPRECATED, "true")) )); assertNotNull(r, "Direct Deprecated Rule"); assertTrue(r.isDeprecated()); } - @Test - void testReferenceToDeprecatedRule() { + @Test void testReferenceToDeprecatedRule() { Rule r = loadFirstRule(REFERENCE_TO_DEPRECATED_RULE); assertNotNull(r, "Reference to Deprecated Rule"); assertTrue(r instanceof RuleReference, "Rule Reference"); @@ -756,8 +709,7 @@ void testReferenceToDeprecatedRule() { assertEquals(r.getName(), DEPRECATED_RULE_NAME, "Rule name"); } - @Test - void testRuleSetReferenceWithDeprecatedRule() { + @Test void testRuleSetReferenceWithDeprecatedRule() { RuleSet ruleSet = loadRuleSet(REFERENCE_TO_RULESET_WITH_DEPRECATED_RULE); assertNotNull(ruleSet, "RuleSet"); assertFalse(ruleSet.getRules().isEmpty(), "RuleSet empty"); @@ -770,25 +722,22 @@ void testRuleSetReferenceWithDeprecatedRule() { } } - @Test - void testDeprecatedRuleSetReference() { + @Test void testDeprecatedRuleSetReference() { RuleSet ruleSet = new RuleSetLoader().loadFromResource("net/sourceforge/pmd/rulesets/ruleset-deprecated.xml"); assertEquals(2, ruleSet.getRules().size()); } - @Test - void testExternalReferences() { + @Test void testExternalReferences() { RuleSet rs = loadRuleSet( - rulesetXml( - ruleRef("net/sourceforge/pmd/lang/rule/external-reference-ruleset.xml/MockRule") - ) + rulesetXml( + ruleRef("net/sourceforge/pmd/lang/rule/external-reference-ruleset.xml/MockRule") + ) ); assertEquals(1, rs.size()); assertEquals(MockRule.class.getName(), rs.getRuleByName("MockRule").getRuleClass()); } - @Test - void testIncludeExcludePatterns() { + @Test void testIncludeExcludePatterns() { RuleSet ruleSet = loadRuleSet(INCLUDE_EXCLUDE_RULESET); assertNotNull(ruleSet.getFileInclusions(), "Include patterns"); @@ -807,31 +756,29 @@ void testIncludeExcludePatterns() { * Rule reference can't be resolved - ref is used instead of class and the * class is old (pmd 4.3 and not pmd 5). */ - @Test - void testBug1202() { + @Test void testBug1202() { assertCannotParse( - rulesetXml( - ruleRef( - "net.sourceforge.pmd.rules.XPathRule", - priority("1"), - properties( - propertyWithValueAttr("xpath", "//TypeDeclaration"), - propertyWithValueAttr("message", "Foo") - ) + rulesetXml( + ruleRef( + "net.sourceforge.pmd.rules.XPathRule", + priority("1"), + properties( + propertyWithValueAttr("xpath", "//TypeDeclaration"), + propertyWithValueAttr("message", "Foo") + ) + ) ) - ) ); } /** * See https://sourceforge.net/p/pmd/bugs/1225/ */ - @Test - void testEmptyRuleSetFile() { + @Test void testEmptyRuleSetFile() { RuleSet ruleset = loadRuleSet( - rulesetXml( - excludePattern(".*Test.*") - )); + rulesetXml( + excludePattern(".*Test.*") + )); assertEquals(0, ruleset.getRules().size()); } @@ -839,12 +786,11 @@ void testEmptyRuleSetFile() { * See https://github.com/pmd/pmd/issues/782 * Empty ruleset should be interpreted as deprecated. */ - @Test - void testEmptyRuleSetReferencedShouldNotBeDeprecated() { + @Test void testEmptyRuleSetReferencedShouldNotBeDeprecated() { RuleSet ruleset = loadRuleSet( - rulesetXml( - ruleRef("rulesets/dummy/empty-ruleset.xml") - ) + rulesetXml( + ruleRef("rulesets/dummy/empty-ruleset.xml") + ) ); assertEquals(0, ruleset.getRules().size()); @@ -854,27 +800,25 @@ void testEmptyRuleSetReferencedShouldNotBeDeprecated() { /** * See https://sourceforge.net/p/pmd/bugs/1231/ */ - @Test - void testWrongRuleNameReferenced() { + @Test void testWrongRuleNameReferenced() { assertCannotParse(rulesetXml( - ruleRef("net/sourceforge/pmd/lang/rule/TestRuleset1.xml/ThisRuleDoesNotExist") + ruleRef("net/sourceforge/pmd/lang/rule/TestRuleset1.xml/ThisRuleDoesNotExist") )); } /** * Unit test for #1312 see https://sourceforge.net/p/pmd/bugs/1312/ */ - @Test - void testRuleReferenceWithNameOverridden() { + @Test void testRuleReferenceWithNameOverridden() { RuleSet rs = loadRuleSet("\n" - + "\n" - + " PMD Plugin preferences rule set\n" - + "\n" + "\n" + "\n" - + ""); + + "\n" + + " PMD Plugin preferences rule set\n" + + "\n" + "\n" + "\n" + + ""); Rule r = rs.getRules().iterator().next(); assertEquals("OverriddenDummyBasicMockRule", r.getName()); @@ -888,16 +832,15 @@ void testRuleReferenceWithNameOverridden() { *

    See https://github.com/pmd/pmd/issues/1978 - with that, it should not be an error anymore. * */ - @Test - void testWrongRuleNameExcluded() { + @Test void testWrongRuleNameExcluded() { RuleSet ruleset = loadRuleSet("\n" + "\n" - + " Custom ruleset for tests\n" - + " \n" - + " \n" + " \n" - + "\n"); + + " xmlns=\"http://pmd.sourceforge.net/ruleset/2.0.0\"\n" + + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + + " xsi:schemaLocation=\"http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd\">\n" + + " Custom ruleset for tests\n" + + " \n" + + " \n" + " \n" + + "\n"); assertEquals(4, ruleset.getRules().size()); } @@ -914,58 +857,55 @@ void testWrongRuleNameExcluded() { * "http://stackoverflow.com/questions/40299075/custom-pmd-ruleset-not-working">stackoverflow * - custom ruleset not working */ - @Test - void testExcludeAndImportTwice() { + @Test void testExcludeAndImportTwice() { RuleSet ruleset = loadRuleSet( - rulesetXml( - rulesetRef("rulesets/dummy/basic.xml", - excludeRule("DummyBasicMockRule") + rulesetXml( + rulesetRef("rulesets/dummy/basic.xml", + excludeRule("DummyBasicMockRule") + ) ) - ) ); assertNull(ruleset.getRuleByName("DummyBasicMockRule")); RuleSet ruleset2 = loadRuleSet( - rulesetXml( - rulesetRef("rulesets/dummy/basic.xml", - excludeRule("DummyBasicMockRule") - ), - rulesetRef("rulesets/dummy/basic.xml") - ) + rulesetXml( + rulesetRef("rulesets/dummy/basic.xml", + excludeRule("DummyBasicMockRule") + ), + rulesetRef("rulesets/dummy/basic.xml") + ) ); assertNotNull(ruleset2.getRuleByName("DummyBasicMockRule")); RuleSet ruleset3 = loadRuleSet( - rulesetXml( - rulesetRef("rulesets/dummy/basic.xml"), - rulesetRef("rulesets/dummy/basic.xml", - excludeRule("DummyBasicMockRule") + rulesetXml( + rulesetRef("rulesets/dummy/basic.xml"), + rulesetRef("rulesets/dummy/basic.xml", + excludeRule("DummyBasicMockRule") + ) ) - ) ); assertNotNull(ruleset3.getRuleByName("DummyBasicMockRule")); } - @Test - void testMissingRuleSetNameIsWarning() throws Exception { + @Test void testMissingRuleSetNameIsWarning() throws Exception { SystemLambda.tapSystemErr(() -> { loadRuleSetWithDeprecationWarnings( - "\n" + "\n" - + " Custom ruleset for tests\n" - + " \n" - + " \n" + "\n" + "\n" + + " Custom ruleset for tests\n" + + " \n" + + " \n" ); }); verifyFoundAWarningWithMessage(containing("RuleSet name is missing.")); } - @Test - void testMissingRuleSetDescriptionIsWarning() { + @Test void testMissingRuleSetDescriptionIsWarning() { loadRuleSetWithDeprecationWarnings( "\n" + "\n" - + "\n" - + " testdesc\n" - + " \n" - + "\n" - + " \n" - + ""; + + "\n" + + " testdesc\n" + + " \n" + + "\n" + + " \n" + + ""; private static final String REF_MISSPELLED_XREF = "\n" - + "\n" - + "\n" - + " testdesc\n" - + " \n" - + " \n" - + ""; + + "\n" + + "\n" + + " testdesc\n" + + " \n" + + " \n" + + ""; private static final String REF_OVERRIDE_ORIGINAL_NAME_ONE_ELEM = "\n" - + "\n" - + " testdesc\n" - + " \n" - + "\n" - + ""; + + "\n" + + " testdesc\n" + + " \n" + + "\n" + + ""; private static final String REF_OVERRIDE = "\n" - + "\n" - + " testdesc\n" - + " \n" - + " Test description override\n" - + " Test example override\n" - + " 3\n" - + " \n" - + " \n" - + " override3\n" - + "\n" - + " \n" - + " \n" - + ""; + + "\n" + + " testdesc\n" + + " \n" + + " Test description override\n" + + " Test example override\n" + + " 3\n" + + " \n" + + " \n" + + " override3\n" + + "\n" + + " \n" + + " \n" + + ""; private static final String REF_OVERRIDE_NONEXISTENT = "\n" - + "\n" - + "\n" - + " testdesc\n" - + " \n" - + " Test description override\n" - + " Test example override\n" - + " 3\n" - + " \n" - + " \n" - + " \n" - + " \n" - + ""; + + "\n" + + "\n" + + " testdesc\n" + + " \n" + + " Test description override\n" + + " Test example override\n" + + " 3\n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; private static final String REF_INTERNAL_TO_INTERNAL = "\n" - + "\n" - + " testdesc\n" - + "\n" - + "\n" - + " \n" - + ""; + + "\n" + + " testdesc\n" + + "\n" + + "\n" + + " \n" + + ""; private static final String REF_INTERNAL_TO_INTERNAL_CHAIN = "\n" - + "\n" - + " testdesc\n" - + "\n" - + "\n" - + " 2 \n" - + " 1 \n" - + ""; + + "\n" + + " testdesc\n" + + "\n" + + "\n" + + " 2 \n" + + " 1 \n" + + ""; private static final String REF_INTERNAL_TO_EXTERNAL = "\n" - + "\n" - + " testdesc\n" - + "\n" - + " \n" - + ""; + + "\n" + + " testdesc\n" + + "\n" + + " \n" + + ""; private static final String REF_INTERNAL_TO_EXTERNAL_CHAIN = "\n" - + "\n" - + " testdesc\n" - + "\n" - + " 2 \n" - + "\n" - + " 1 \n" - + "\n" - + ""; + + "\n" + + " testdesc\n" + + "\n" + + " 2 \n" + + "\n" + + " 1 \n" + + "\n" + + ""; private static final String EMPTY_RULESET = rulesetXml(); private static final String SINGLE_RULE = - rulesetXml( - rule( - dummyRuleDefAttrs(), - priority("3") - ) - ); + rulesetXml( + rule( + dummyRuleDefAttrs(), + priority("3") + ) + ); private static final String SINGLE_RULE_EMPTY_REF = - "\n" - + "\n" - + "testdesc\n" - + "\n" - + "3\n" - + ""; + "\n" + + "\n" + + "testdesc\n" + + "\n" + + "3\n" + + ""; private static final String PROPERTIES = - rulesetXml( - rule(dummyRuleDefAttrs(), - description("testdesc2"), - properties( - "\n", - "\n", - "", - "\n", - "\n" - )) - ); + rulesetXml( + rule(dummyRuleDefAttrs(), + description("testdesc2"), + properties( + "\n", + "\n", + "", + "\n", + "\n" + )) + ); private static final String XPATH = - rulesetXml( - rule( - dummyRuleDefAttrs(), - description("testDesc"), - properties( - "\n" - + "\n" - + "\n" - + "" - + "" - ) - ) - ); + rulesetXml( + rule( + dummyRuleDefAttrs(), + description("testDesc"), + properties( + "\n" + + "\n" + + "\n" + + "" + + "" + ) + ) + ); // Note: Update this RuleSet name to a different RuleSet with deprecated // Rules when the Rules are finally removed. @@ -1150,23 +1090,23 @@ void testMissingRuleSetDescriptionIsWarning() { private static final String DEPRECATED_RULE_NAME = "MockRule3"; private static final String REFERENCE_TO_DEPRECATED_RULE = - rulesetXml( - ruleRef(DEPRECATED_RULE_RULESET_NAME + "/" + DEPRECATED_RULE_NAME) - ); + rulesetXml( + ruleRef(DEPRECATED_RULE_RULESET_NAME + "/" + DEPRECATED_RULE_NAME) + ); private static final String REFERENCE_TO_RULESET_WITH_DEPRECATED_RULE = - rulesetXml( - rulesetRef(DEPRECATED_RULE_RULESET_NAME) - ); + rulesetXml( + rulesetRef(DEPRECATED_RULE_RULESET_NAME) + ); private static final String INCLUDE_EXCLUDE_RULESET = - rulesetXml( - includePattern("include1"), - includePattern("include2"), - excludePattern("exclude1"), - excludePattern("exclude2"), - excludePattern("exclude3") - ); + rulesetXml( + includePattern("include1"), + includePattern("include2"), + excludePattern("exclude1"), + excludePattern("exclude2"), + excludePattern("exclude3") + ); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetTest.java index 03706c3d325..450ba1b170d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetTest.java @@ -56,32 +56,27 @@ class RuleSetTest { - @RegisterExtension - private final DummyParsingHelper helper = new DummyParsingHelper(); + @RegisterExtension private final DummyParsingHelper helper = new DummyParsingHelper(); - @Test - void testRuleSetRequiresName() { + @Test void testRuleSetRequiresName() { assertThrows(NullPointerException.class, () -> - new RuleSetBuilder(new Random().nextLong()) - .withName(null)); + new RuleSetBuilder(new Random().nextLong()) + .withName(null)); } - @Test - void testRuleSetRequiresDescription() { + @Test void testRuleSetRequiresDescription() { assertThrows(NullPointerException.class, () -> - new RuleSetBuilder(new Random().nextLong()) - .withName("some name") - .withDescription(null)); + new RuleSetBuilder(new Random().nextLong()) + .withName("some name") + .withDescription(null)); } - @Test - void testRuleSetRequiresName2() { + @Test void testRuleSetRequiresName2() { assertThrows(NullPointerException.class, () -> - new RuleSetBuilder(new Random().nextLong()).build()); + new RuleSetBuilder(new Random().nextLong()).build()); } - @Test - void testAccessors() { + @Test void testAccessors() { RuleSet rs = new RuleSetBuilder(new Random().nextLong()) .withFileName("baz") .withName("foo") @@ -92,22 +87,19 @@ void testAccessors() { assertEquals("bar", rs.getDescription(), "description mismatch"); } - @Test - void testGetRuleByName() { + @Test void testGetRuleByName() { MockRule mock = new MockRule("name", "desc", "msg", "rulesetname"); RuleSet rs = RuleSet.forSingleRule(mock); assertEquals(mock, rs.getRuleByName("name"), "unable to fetch rule by name"); } - @Test - void testGetRuleByName2() { + @Test void testGetRuleByName2() { MockRule mock = new MockRule("name", "desc", "msg", "rulesetname"); RuleSet rs = RuleSet.forSingleRule(mock); assertNull(rs.getRuleByName("FooRule"), "the rule FooRule must not be found!"); } - @Test - void testRuleList() { + @Test void testRuleList() { MockRule rule = new MockRule("name", "desc", "msg", "rulesetname"); RuleSet ruleset = RuleSet.forSingleRule(rule); @@ -123,15 +115,14 @@ void testRuleList() { private RuleSetBuilder createRuleSetBuilder(String name) { return new RuleSetBuilder(new Random().nextLong()) - .withName(name) - .withDescription("Description for " + name); + .withName(name) + .withDescription("Description for " + name); } - @Test - void testAddRuleSet() { + @Test void testAddRuleSet() { RuleSet set1 = createRuleSetBuilder("ruleset1") - .addRule(new MockRule("name", "desc", "msg", "rulesetname")) - .build(); + .addRule(new MockRule("name", "desc", "msg", "rulesetname")) + .build(); RuleSet set2 = createRuleSetBuilder("ruleset2") .addRule(new MockRule("name2", "desc", "msg", "rulesetname")) .addRuleSet(set1) @@ -139,26 +130,24 @@ void testAddRuleSet() { assertEquals(2, set2.size(), "ruleset size wrong"); } - @Test - void testAddRuleSetByReferenceBad() { + @Test void testAddRuleSetByReferenceBad() { RuleSet set1 = createRuleSetBuilder("ruleset1") - .addRule(new MockRule("name", "desc", "msg", "rulesetname")) - .build(); + .addRule(new MockRule("name", "desc", "msg", "rulesetname")) + .build(); assertThrows(RuntimeException.class, () -> - createRuleSetBuilder("ruleset2") - .addRule(new MockRule("name2", "desc", "msg", "rulesetname")) - .addRuleSetByReference(set1, false) - .build()); + createRuleSetBuilder("ruleset2") + .addRule(new MockRule("name2", "desc", "msg", "rulesetname")) + .addRuleSetByReference(set1, false) + .build()); } - @Test - void testAddRuleSetByReferenceAllRule() { + @Test void testAddRuleSetByReferenceAllRule() { RuleSet set2 = createRuleSetBuilder("ruleset2") - .withFileName("foo") - .addRule(new MockRule("name", "desc", "msg", "rulesetname")) - .addRule(new MockRule("name2", "desc", "msg", "rulesetname")) - .build(); + .withFileName("foo") + .addRule(new MockRule("name", "desc", "msg", "rulesetname")) + .addRule(new MockRule("name2", "desc", "msg", "rulesetname")) + .build(); RuleSet set1 = createRuleSetBuilder("ruleset1") .addRuleSetByReference(set2, true) .build(); @@ -171,13 +160,12 @@ void testAddRuleSetByReferenceAllRule() { } } - @Test - void testAddRuleSetByReferenceSingleRule() { + @Test void testAddRuleSetByReferenceSingleRule() { RuleSet set2 = createRuleSetBuilder("ruleset2") - .withFileName("foo") - .addRule(new MockRule("name", "desc", "msg", "rulesetname")) - .addRule(new MockRule("name2", "desc", "msg", "rulesetname")) - .build(); + .withFileName("foo") + .addRule(new MockRule("name", "desc", "msg", "rulesetname")) + .addRule(new MockRule("name2", "desc", "msg", "rulesetname")) + .build(); RuleSet set1 = createRuleSetBuilder("ruleset1") .addRuleSetByReference(set2, false) .build(); @@ -190,27 +178,22 @@ void testAddRuleSetByReferenceSingleRule() { } } - @Test - void testApply0Rules() throws Exception { + @Test void testApply0Rules() throws Exception { RuleSet ruleset = createRuleSetBuilder("ruleset").build(); verifyRuleSet(ruleset, new HashSet()); } - @Test - void testEquals1() { + @Test void testEquals1() { RuleSet s = createRuleSetBuilder("ruleset").build(); assertFalse(s.equals(null), "A ruleset cannot be equals to null"); } - @Test - @SuppressWarnings("PMD.UseAssertEqualsInsteadOfAssertTrue") - void testEquals2() { + @Test @SuppressWarnings("PMD.UseAssertEqualsInsteadOfAssertTrue") void testEquals2() { RuleSet s = createRuleSetBuilder("ruleset").build(); assertTrue(s.equals(s), "A rulset must be equals to itself"); } - @Test - void testEquals3() { + @Test void testEquals3() { RuleSet s = new RuleSetBuilder(new Random().nextLong()) .withName("basic rules") .withDescription("desc") @@ -218,48 +201,44 @@ void testEquals3() { assertFalse(s.equals("basic rules"), "A ruleset cannot be equals to another kind of object"); } - @Test - void testEquals4() { + @Test void testEquals4() { RuleSet s1 = createRuleSetBuilder("my ruleset") - .addRule(new MockRule("name", "desc", "msg", "rulesetname")) - .build(); + .addRule(new MockRule("name", "desc", "msg", "rulesetname")) + .build(); RuleSet s2 = createRuleSetBuilder("my ruleset") - .addRule(new MockRule("name", "desc", "msg", "rulesetname")) - .build(); + .addRule(new MockRule("name", "desc", "msg", "rulesetname")) + .build(); assertEquals(s1, s2, "2 rulesets with same name and rules must be equals"); assertEquals(s1.hashCode(), s2.hashCode(), "Equals rulesets must have the same hashcode"); } - @Test - void testEquals5() { + @Test void testEquals5() { RuleSet s1 = createRuleSetBuilder("my ruleset") - .addRule(new MockRule("name", "desc", "msg", "rulesetname")) - .build(); + .addRule(new MockRule("name", "desc", "msg", "rulesetname")) + .build(); RuleSet s2 = createRuleSetBuilder("my other ruleset") - .addRule(new MockRule("name", "desc", "msg", "rulesetname")) - .build(); + .addRule(new MockRule("name", "desc", "msg", "rulesetname")) + .build(); assertFalse(s1.equals(s2), "2 rulesets with different name but same rules must not be equals"); } - @Test - void testEquals6() { + @Test void testEquals6() { RuleSet s1 = createRuleSetBuilder("my ruleset") - .addRule(new MockRule("name", "desc", "msg", "rulesetname")) - .build(); + .addRule(new MockRule("name", "desc", "msg", "rulesetname")) + .build(); RuleSet s2 = createRuleSetBuilder("my ruleset") - .addRule(new MockRule("other rule", "desc", "msg", "rulesetname")) - .build(); + .addRule(new MockRule("other rule", "desc", "msg", "rulesetname")) + .build(); assertFalse(s1.equals(s2), "2 rulesets with same name but different rules must not be equals"); } - @Test - void testLanguageApplies() { + @Test void testLanguageApplies() { Rule rule = new MockRule(); @@ -282,18 +261,16 @@ void testLanguageApplies() { "Same language with outside range of min/max should not apply"); } - @Test - void testAddExcludePattern() { + @Test void testAddExcludePattern() { RuleSet ruleSet = - createRuleSetBuilder("ruleset1") - .withFileExclusions(Pattern.compile(".*")) - .build(); + createRuleSetBuilder("ruleset1") + .withFileExclusions(Pattern.compile(".*")) + .build(); assertNotNull(ruleSet.getFileExclusions(), "Exclude patterns"); assertEquals(1, ruleSet.getFileExclusions().size(), "Invalid number of patterns"); } - @Test - void testExcludePatternAreOrdered() { + @Test void testExcludePatternAreOrdered() { RuleSet ruleSet2 = createRuleSetBuilder("ruleset2") .withFileExclusions(Pattern.compile(".*")) @@ -302,13 +279,12 @@ void testExcludePatternAreOrdered() { assertEquals(Arrays.asList(".*", ".*ha"), toStrings(ruleSet2.getFileExclusions()), "Exclude pattern"); } - @Test - void testIncludePatternsAreOrdered() { + @Test void testIncludePatternsAreOrdered() { RuleSet ruleSet2 = createRuleSetBuilder("ruleset2") - .withFileInclusions(Pattern.compile(".*")) - .withFileInclusions(Arrays.asList(Pattern.compile(".*ha"), Pattern.compile(".*hb"))) - .build(); + .withFileInclusions(Pattern.compile(".*")) + .withFileInclusions(Arrays.asList(Pattern.compile(".*ha"), Pattern.compile(".*hb"))) + .build(); assertEquals(Arrays.asList(".*", ".*ha", ".*hb"), toStrings(ruleSet2.getFileInclusions()), "Exclude pattern"); } @@ -316,11 +292,10 @@ private List toStrings(List strings) { return strings.stream().map(Pattern::pattern).collect(Collectors.toList()); } - @Test - void testAddExcludePatterns() { + @Test void testAddExcludePatterns() { RuleSet ruleSet = createRuleSetBuilder("ruleset1") - .withFileExclusions(Pattern.compile(".*")) - .build(); + .withFileExclusions(Pattern.compile(".*")) + .build(); assertNotNull(ruleSet.getFileExclusions(), "Exclude patterns"); assertEquals(1, ruleSet.getFileExclusions().size(), "Invalid number of patterns"); @@ -332,8 +307,7 @@ void testAddExcludePatterns() { assertEquals(1, ruleSet2.getFileExclusions().size(), "Invalid number of patterns"); } - @Test - void testSetExcludePatterns() { + @Test void testSetExcludePatterns() { List excludePatterns = new ArrayList<>(); excludePatterns.add(Pattern.compile("ah*")); excludePatterns.add(Pattern.compile(".*")); @@ -346,8 +320,7 @@ void testSetExcludePatterns() { assertEquals(0, ruleSet.getFileInclusions().size(), "Invalid number of include patterns"); } - @Test - void testAddIncludePattern() { + @Test void testAddIncludePattern() { RuleSet ruleSet = createRuleSetBuilder("ruleset") .withFileInclusions(Pattern.compile(".*")) .build(); @@ -358,11 +331,10 @@ void testAddIncludePattern() { assertEquals(0, ruleSet.getFileExclusions().size(), "Invalid number of exclude patterns"); } - @Test - void testAddIncludePatterns() { + @Test void testAddIncludePatterns() { RuleSet ruleSet = createRuleSetBuilder("ruleset1") - .withFileInclusions(Pattern.compile("ah*"), Pattern.compile(".*")) - .build(); + .withFileInclusions(Pattern.compile("ah*"), Pattern.compile(".*")) + .build(); RuleSet ruleSet2 = createRuleSetBuilder("ruleset1") .withFileInclusions(ruleSet.getFileInclusions()) .build(); @@ -374,22 +346,20 @@ void testAddIncludePatterns() { assertEquals(0, ruleSet.getFileExclusions().size(), "Invalid number of exclude patterns"); } - @Test - void testSetIncludePatterns() { + @Test void testSetIncludePatterns() { List includePatterns = new ArrayList<>(); includePatterns.add(Pattern.compile("ah*")); includePatterns.add(Pattern.compile(".*")); RuleSet ruleSet = createRuleSetBuilder("ruleset") - .replaceFileInclusions(includePatterns) - .build(); + .replaceFileInclusions(includePatterns) + .build(); assertEquals(includePatterns, ruleSet.getFileInclusions(), "Include patterns"); assertNotNull(ruleSet.getFileInclusions(), "Exclude patterns"); assertEquals(0, ruleSet.getFileExclusions().size(), "Invalid number of exclude patterns"); } - @Test - void testIncludeExcludeApplies() { + @Test void testIncludeExcludeApplies() { FileId fileId = TextFile.forPath(Paths.get("C:\\myworkspace\\project\\some\\random\\package\\RandomClass.java"), Charset.defaultCharset(), dummyVersion()) .getFileId(); @@ -422,8 +392,7 @@ void testIncludeExcludeApplies() { assertTrue(ruleSet.applies(fileId), "Matching include"); } - @Test - void testIncludeExcludeMultipleRuleSetWithRuleChainApplies() throws Exception { + @Test void testIncludeExcludeMultipleRuleSetWithRuleChainApplies() throws Exception { Rule rule = new FooRule(); rule.setName("FooRule1"); rule.setLanguage(dummyLanguage()); @@ -440,9 +409,9 @@ void testIncludeExcludeMultipleRuleSetWithRuleChainApplies() throws Exception { // One violation ruleSet1 = createRuleSetBuilder("RuleSet1") - .withFileExclusions(Pattern.compile(".*/package/.*")) - .addRule(rule) - .build(); + .withFileExclusions(Pattern.compile(".*/package/.*")) + .addRule(rule) + .build(); RuleSets ruleSets2 = new RuleSets(listOf(ruleSet1, ruleSet2)); @@ -450,13 +419,12 @@ void testIncludeExcludeMultipleRuleSetWithRuleChainApplies() throws Exception { assertEquals(1, report.getViolations().size(), "Violations"); } - @Test - void copyConstructorDeepCopies() { + @Test void copyConstructorDeepCopies() { Rule rule = new FooRule(); rule.setName("FooRule1"); RuleSet ruleSet1 = createRuleSetBuilder("RuleSet1") - .addRule(rule) - .build(); + .addRule(rule) + .build(); RuleSet ruleSet2 = new RuleSet(ruleSet1); assertEquals(ruleSet1, ruleSet2); @@ -491,16 +459,14 @@ private RootNode makeCompilationUnits(String filename) { return node; } - @Test - void ruleExceptionShouldBeReported() throws Exception { + @Test void ruleExceptionShouldBeReported() throws Exception { RuleSet ruleset = createRuleSetBuilder("ruleExceptionShouldBeReported") - .addRule(new MockRule() { - @Override - public void apply(Node nodes, RuleContext ctx) { - throw new IllegalStateException("Test exception while applying rule"); - } - }) - .build(); + .addRule(new MockRule() { + @Override public void apply(Node nodes, RuleContext ctx) { + throw new IllegalStateException("Test exception while applying rule"); + } + }) + .build(); Report report = getReportForRuleSetApply(ruleset, makeCompilationUnits()); @@ -513,16 +479,13 @@ public void apply(Node nodes, RuleContext ctx) { } - @Test - void ruleExceptionShouldNotStopProcessingFile() throws Exception { + @Test void ruleExceptionShouldNotStopProcessingFile() throws Exception { RuleSet ruleset = createRuleSetBuilder("ruleExceptionShouldBeReported").addRule(new MockRule() { - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { throw new IllegalStateException("Test exception while applying rule"); } }).addRule(new MockRule() { - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { ctx.addViolationWithMessage(target, "Test violation of the second rule in the ruleset"); } }).build(); @@ -540,28 +503,23 @@ public void apply(Node target, RuleContext ctx) { assertThat(report.getViolations(), hasSize(1)); } - @Test - void ruleExceptionShouldNotStopProcessingFileWithRuleChain() throws Exception { + @Test void ruleExceptionShouldNotStopProcessingFileWithRuleChain() throws Exception { RuleSet ruleset = createRuleSetBuilder("ruleExceptionShouldBeReported").addRule(new MockRule() { - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forXPathNames(setOf("dummyRootNode")); } - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { throw new UnsupportedOperationException("Test exception while applying rule"); } }).addRule(new MockRule() { - @Override - protected @NonNull RuleTargetSelector buildTargetSelector() { + @Override protected @NonNull RuleTargetSelector buildTargetSelector() { return RuleTargetSelector.forXPathNames(setOf("dummyRootNode")); } - @Override - public void apply(Node target, RuleContext ctx) { + @Override public void apply(Node target, RuleContext ctx) { ctx.addViolationWithMessage(target, "Test violation of the second rule in the ruleset"); } }).build(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetWriterTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetWriterTest.java index 44a5dfa48bb..aef4477317d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetWriterTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RuleSetWriterTest.java @@ -35,8 +35,7 @@ class RuleSetWriterTest extends RulesetFactoryTestBase { /** * Prepare the output stream. */ - @BeforeEach - void setupOutputStream() { + @BeforeEach void setupOutputStream() { out = new ByteArrayOutputStream(); writer = new RuleSetWriter(out); } @@ -44,8 +43,7 @@ void setupOutputStream() { /** * Closes the output stream at the end. */ - @AfterEach - void cleanupStream() { + @AfterEach void cleanupStream() { if (writer != null) { writer.close(); } @@ -57,8 +55,7 @@ void cleanupStream() { * @throws Exception * any error */ - @Test - void testWrite() throws Exception { + @Test void testWrite() throws Exception { RuleSet braces = new RuleSetLoader().loadFromResource("net/sourceforge/pmd/lang/rule/TestRuleset1.xml"); RuleSet ruleSet = new RuleSetBuilder(new Random().nextLong()) .withName("ruleset") @@ -78,8 +75,7 @@ void testWrite() throws Exception { * @throws Exception * any error */ - @Test - void testRuleReferenceOverriddenName() throws Exception { + @Test void testRuleReferenceOverriddenName() throws Exception { RuleSet rs = new RuleSetLoader().loadFromResource("rulesets/dummy/basic.xml"); RuleReference ruleRef = new RuleReference( @@ -95,8 +91,7 @@ void testRuleReferenceOverriddenName() throws Exception { assertTrue(written.contains("ref=\"rulesets/dummy/basic.xml/DummyBasicMockRule\"")); } - @Test - void testPropertyConstraintRange() throws Exception { + @Test void testPropertyConstraintRange() throws Exception { RuleSet ruleSet = loadRuleSet("created-on-the-fly.xml", rulesetXml( dummyRule( @@ -116,8 +111,7 @@ void testPropertyConstraintRange() throws Exception { assertThat(written, containsString("max=\"10\"")); } - @Test - void testPropertyConstraintAbove() throws Exception { + @Test void testPropertyConstraintAbove() throws Exception { RuleSet ruleSet = loadRuleSet("created-on-the-fly.xml", rulesetXml( dummyRule( @@ -137,8 +131,7 @@ void testPropertyConstraintAbove() throws Exception { assertThat(written, not(containsString("max=\""))); } - @Test - void testPropertyConstraintBelow() throws Exception { + @Test void testPropertyConstraintBelow() throws Exception { RuleSet ruleSet = loadRuleSet("created-on-the-fly.xml", rulesetXml( dummyRule( @@ -158,15 +151,14 @@ void testPropertyConstraintBelow() throws Exception { assertThat(written, containsString("max=\"10\"")); } - @Test - void overridingDefaultValueOfPropertyInReference() throws Exception { + @Test void overridingDefaultValueOfPropertyInReference() throws Exception { RuleSet ruleSet = loadRuleSet("created-on-the-fly.xml", rulesetXml( - ruleRef("net/sourceforge/pmd/lang/rule/rulesetwriter-test.xml/SampleXPathRuleWithProperty", - properties( - propertyWithValueAttr("minimum", "42") - ) - ) + ruleRef("net/sourceforge/pmd/lang/rule/rulesetwriter-test.xml/SampleXPathRuleWithProperty", + properties( + propertyWithValueAttr("minimum", "42") + ) + ) ) ); writer.write(ruleSet); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RulesetFactoryTestBase.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RulesetFactoryTestBase.java index 732f4095a69..7d11e350653 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RulesetFactoryTestBase.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/RulesetFactoryTestBase.java @@ -39,8 +39,7 @@ public class RulesetFactoryTestBase { protected PmdReporter mockReporter; - @BeforeEach - void setup() { + @BeforeEach void setup() { SimpleMessageReporter reporter = new SimpleMessageReporter(LoggerFactory.getLogger(RulesetFactoryTestBase.class)); mockReporter = spy(reporter); } @@ -51,14 +50,12 @@ protected void verifyNoWarnings() { protected static Predicate containing(String part) { return new Predicate() { - @Override - public boolean test(String it) { + @Override public boolean test(String it) { String format = MessageFormat.format(it, new Object[0]); return format.contains(part); } - @Override - public String toString() { + @Override public String toString() { return "string containing: " + part; } }; @@ -76,12 +73,12 @@ protected void verifyFoundAWarningWithMessage(Predicate messageTest) { */ protected void verifyFoundWarningWithMessage(VerificationMode mode, Predicate messageTest) { verify(mockReporter, mode) - .logEx(eq(Level.WARN), argThat(messageTest::test), any(), any()); + .logEx(eq(Level.WARN), argThat(messageTest::test), any(), any()); } protected void verifyFoundAnErrorWithMessage(Predicate messageTest) { verify(mockReporter, times(1)) - .logEx(eq(Level.ERROR), argThat(messageTest::test), any(), any()); + .logEx(eq(Level.ERROR), argThat(messageTest::test), any(), any()); } @@ -110,14 +107,15 @@ protected RuleSet loadRuleSetWithDeprecationWarnings(String ruleSetXml) { config.setReporter(mockReporter); try (PmdAnalysis pmd = PmdAnalysis.create(config)) { return pmd.newRuleSetLoader() - .warnDeprecated(true) - .loadFromString("dummyRuleset.xml", ruleSetXml); + .warnDeprecated(true) + .loadFromString("dummyRuleset.xml", ruleSetXml); } } protected RuleSetLoadException assertCannotParse(String xmlContent) { return assertThrows(RuleSetLoadException.class, () -> loadFirstRule(xmlContent)); } + /* DSL to build a ruleset XML file with method calls. */ @@ -125,12 +123,12 @@ protected RuleSetLoadException assertCannotParse(String xmlContent) { protected static @NonNull String rulesetXml(String... contents) { return "\n" + "\n" - + "\n" - + " Ruleset which references a empty ruleset\n" + "\n" - + body(contents) - + "\n"; + + "\n" + + " Ruleset which references a empty ruleset\n" + "\n" + + body(contents) + + "\n"; } protected static @NonNull String ruleRef(String ref) { @@ -139,8 +137,8 @@ protected RuleSetLoadException assertCannotParse(String xmlContent) { protected static @NonNull String rule(Map attrs, String... body) { return "\n" - + body(body) - + ""; + + body(body) + + ""; } protected static @NonNull String dummyRule(Consumer> attributes, String... body) { @@ -148,7 +146,8 @@ protected RuleSetLoadException assertCannotParse(String xmlContent) { } protected static @NonNull String dummyRule(String... body) { - return dummyRule(m -> { }, body); + return dummyRule(m -> { + }, body); } /** @@ -156,19 +155,19 @@ protected RuleSetLoadException assertCannotParse(String xmlContent) { */ protected static Map dummyRuleDefAttrs() { return buildMap( - map -> { - map.put(SchemaConstants.NAME, "MockRuleName"); - map.put(SchemaConstants.LANGUAGE, DummyLanguageModule.TERSE_NAME); - map.put(SchemaConstants.CLASS, net.sourceforge.pmd.lang.rule.MockRuleWithNoProperties.class.getName()); - map.put(SchemaConstants.MESSAGE, "avoid the mock rule"); - } + map -> { + map.put(SchemaConstants.NAME, "MockRuleName"); + map.put(SchemaConstants.LANGUAGE, DummyLanguageModule.TERSE_NAME); + map.put(SchemaConstants.CLASS, net.sourceforge.pmd.lang.rule.MockRuleWithNoProperties.class.getName()); + map.put(SchemaConstants.MESSAGE, "avoid the mock rule"); + } ); } private static @NonNull String attrs(Map str) { return str.entrySet().stream() - .map(it -> it.getKey().xmlName() + "=\"" + it.getValue() + "\"") - .collect(Collectors.joining(" ")); + .map(it -> it.getKey().xmlName() + "=\"" + it.getValue() + "\"") + .collect(Collectors.joining(" ")); } @@ -178,8 +177,8 @@ protected static Map dummyRuleDefAttrs() { protected static @NonNull String ruleRef(String ref, String... body) { return "\n" - + body(body) - + "\n"; + + body(body) + + "\n"; } protected static @NonNull String excludePattern(String pattern) { @@ -215,17 +214,17 @@ protected static Map dummyRuleDefAttrs() { } protected static @NonNull String propertyDefWithValueAttr(String name, - String description, - String type, - String valueAttr) { + String description, + String type, + String valueAttr) { return propertyDefWithValueAttr(name, description, type, valueAttr, Collections.emptyMap()); } protected static @NonNull String propertyDefWithValueAttr(String name, - String description, - String type, - String valueAttr, - Map constraints) { + String description, + String type, + String valueAttr, + Map constraints) { return emptyTag("property", buildMap( map -> { map.put(SchemaConstants.NAME, name); @@ -240,8 +239,8 @@ protected static Map dummyRuleDefAttrs() { protected static @NonNull String tag(String tagName, String... body) { return "<" + tagName + ">\n" - + body(body) - + ""; + + body(body) + + ""; } protected static @NonNull String emptyTag(String tagName, Map attrs) { diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java index 0808a9d5e0e..e1799d0ea48 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/XPathRuleTest.java @@ -27,11 +27,9 @@ class XPathRuleTest { - @RegisterExtension - private final DummyParsingHelper helper = new DummyParsingHelper(); + @RegisterExtension private final DummyParsingHelper helper = new DummyParsingHelper(); - @Test - void testAttributeDeprecation() throws Exception { + @Test void testAttributeDeprecation() throws Exception { testDeprecation(XPathVersion.DEFAULT); } @@ -93,42 +91,37 @@ XPathRule makeXPath(String xpathExpr) { return xpr; } - @Test - void testFileNameInXpath() { + @Test void testFileNameInXpath() { Report report = executeRule(makeXPath("//*[pmd:fileName() = 'Foo.cls']"), - newRoot("src/Foo.cls")); + newRoot("src/Foo.cls")); assertThat(report.getViolations(), hasSize(1)); } - @Test - void testBeginLine() { + @Test void testBeginLine() { Report report = executeRule(makeXPath("//*[pmd:startLine(.)=1]"), - newRoot("src/Foo.cls")); + newRoot("src/Foo.cls")); assertThat(report.getViolations(), hasSize(1)); } - @Test - void testBeginCol() { + @Test void testBeginCol() { Report report = executeRule(makeXPath("//*[pmd:startColumn(.)=1]"), - newRoot("src/Foo.cls")); + newRoot("src/Foo.cls")); assertThat(report.getViolations(), hasSize(1)); } - @Test - void testEndLine() { + @Test void testEndLine() { Report report = executeRule(makeXPath("//*[pmd:endLine(.)=1]"), - newRoot("src/Foo.cls")); + newRoot("src/Foo.cls")); assertThat(report.getViolations(), hasSize(1)); } - @Test - void testEndColumn() { + @Test void testEndColumn() { Report report = executeRule(makeXPath("//*[pmd:endColumn(.)>1]"), - newRoot("src/Foo.cls")); + newRoot("src/Foo.cls")); assertThat(report.getViolations(), hasSize(1)); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelationTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelationTest.java index df237b9d6d7..6378c9a3596 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelationTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/internal/LatticeRelationTest.java @@ -28,8 +28,7 @@ class LatticeRelationTest { - @Test - void testCustomTopo() { + @Test void testCustomTopo() { LatticeRelation, String, Set> lattice = setLattice(PredicateUtil.always()); @@ -47,8 +46,7 @@ void testCustomTopo() { assertEquals(emptySet(), lattice.get(setOf(5))); } - @Test - void testClearing() { + @Test void testClearing() { LatticeRelation, String, Set> lattice = setLattice(PredicateUtil.always()); @@ -74,8 +72,7 @@ void testClearing() { } - @Test - void testTopoFilter() { + @Test void testTopoFilter() { // filter out sets with size 2 // this cuts out one level of the graph @@ -109,16 +106,15 @@ void testTopoFilter() { } - @Test - void testInitialSetFilter() { + @Test void testInitialSetFilter() { LatticeRelation, String, Set> lattice = - new LatticeRelation<>( - setTopoOrder(), - setOf(setOf(1, 2), setOf(1, 2, 3), setOf(2, 3), emptySet()), - Objects::toString, - Collectors.toSet() - ); + new LatticeRelation<>( + setTopoOrder(), + setOf(setOf(1, 2), setOf(1, 2, 3), setOf(2, 3), emptySet()), + Objects::toString, + Collectors.toSet() + ); lattice.put(setOf(1, 2, 3), "123"); lattice.put(setOf(1, 2), "12"); @@ -141,8 +137,7 @@ void testInitialSetFilter() { } - @Test - void testDiamond() { + @Test void testDiamond() { LatticeRelation, String, Set> lattice = setLattice(PredicateUtil.always()); @@ -167,8 +162,7 @@ void testDiamond() { } - @Test - void testFilterOnChainSetup() { + @Test void testFilterOnChainSetup() { // setup for the next test (difference here is no filter) LatticeRelation> lattice = stringLattice(PredicateUtil.always()); @@ -184,8 +178,7 @@ void testFilterOnChainSetup() { assertEquals(emptySet(), lattice.get("d")); } - @Test - void testFilterOnChain() { + @Test void testFilterOnChain() { LatticeRelation> lattice = stringLattice(s -> s.length() != 2 && s.length() != 1); @@ -203,11 +196,10 @@ void testFilterOnChain() { assertEquals(emptySet(), lattice.get("d")); } - @Test - void testTransitiveSucc() { + @Test void testTransitiveSucc() { LatticeRelation> lattice = - stringLattice(s -> "c".equals(s) || "bc".equals(s)); + stringLattice(s -> "c".equals(s) || "bc".equals(s)); lattice.put("abc", "val"); lattice.put("bc", "v2"); @@ -230,11 +222,10 @@ void testTransitiveSucc() { assertEquals(emptySet(), lattice.get("d")); } - @Test - void testTransitiveSuccWithHoleInTheMiddle() { + @Test void testTransitiveSuccWithHoleInTheMiddle() { LatticeRelation> lattice = - stringLattice(setOf("abc", "bbc", "c")::contains); + stringLattice(setOf("abc", "bbc", "c")::contains); lattice.put("abc", "v1"); lattice.put("bbc", "v2"); @@ -264,8 +255,7 @@ void testTransitiveSuccWithHoleInTheMiddle() { } - @Test - void testToString() { + @Test void testToString() { LatticeRelation, String, Set> lattice = setLattice(set -> set.size() < 2); lattice.put(setOf(1, 2), "12"); @@ -279,20 +269,19 @@ void testToString() { // all {1}, {2}, and { } are query nodes, not {1,2} assertEquals("strict digraph {\n" - + "n0 [ shape=box, color=black, label=\"[1, 2]\" ];\n" - + "n1 [ shape=box, color=green, label=\"[1]\" ];\n" - + "n2 [ shape=box, color=green, label=\"[2]\" ];\n" - + "n3 [ shape=box, color=green, label=\"[]\" ];\n" - + "n0 -> n1;\n" // {1} -> { } - + "n0 -> n2;\n" // {2} -> { } - + "n0 -> n3;\n" // {1,2} -> { } - + "n1 -> n3;\n" // {1,2} -> {1} - + "n2 -> n3;\n" // {1,2} -> {2} - + "}", lattice.toString()); + + "n0 [ shape=box, color=black, label=\"[1, 2]\" ];\n" + + "n1 [ shape=box, color=green, label=\"[1]\" ];\n" + + "n2 [ shape=box, color=green, label=\"[2]\" ];\n" + + "n3 [ shape=box, color=green, label=\"[]\" ];\n" + + "n0 -> n1;\n" // {1} -> { } + + "n0 -> n2;\n" // {2} -> { } + + "n0 -> n3;\n" // {1,2} -> { } + + "n1 -> n3;\n" // {1,2} -> {1} + + "n2 -> n3;\n" // {1,2} -> {2} + + "}", lattice.toString()); } - @Test - void testCycleDetection() { + @Test void testCycleDetection() { List cycle = Arrays.asList("a", "b", "c", "d"); TopoOrder cyclicOrder = str -> { @@ -301,7 +290,7 @@ void testCycleDetection() { }; LatticeRelation> lattice = - new LatticeRelation<>(cyclicOrder, PredicateUtil.always(), Objects::toString, Collectors.toSet()); + new LatticeRelation<>(cyclicOrder, PredicateUtil.always(), Objects::toString, Collectors.toSet()); IllegalStateException exception = assertThrows(IllegalStateException.class, () -> { lattice.put("a", "1"); @@ -310,14 +299,12 @@ void testCycleDetection() { } - @NonNull - private LatticeRelation> stringLattice(Predicate filter) { + @NonNull private LatticeRelation> stringLattice(Predicate filter) { return new LatticeRelation<>(stringTopoOrder(), filter, Objects::toString, Collectors.toSet()); } - @NonNull - private LatticeRelation, String, Set> setLattice(Predicate> filter) { + @NonNull private LatticeRelation, String, Set> setLattice(Predicate> filter) { return new LatticeRelation<>(setTopoOrder(), filter, Objects::toString, Collectors.toSet()); } @@ -358,7 +345,7 @@ private static TopoOrder> setTopoOrder() { */ private static TopoOrder stringTopoOrder() { return str -> str.isEmpty() ? emptyList() - : singletonList(str.substring(1)); + : singletonList(str.substring(1)); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceIdTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceIdTest.java index 3de2efd91db..eabc7a541f6 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceIdTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/internal/RuleSetReferenceIdTest.java @@ -26,50 +26,42 @@ private static void assertRuleSetReferenceId(final boolean expectedAbsolute, fin assertEquals(expectedNormalizedReference, reference.toNormalizedReference(), "Wrong normalized reference"); } - @Test - void testCommaInSingleId() { + @Test void testCommaInSingleId() { assertThrows(IllegalArgumentException.class, () -> new RuleSetReferenceId("bad,id")); } - @Test - void testAbsoluteWithAbsolute() { + @Test void testAbsoluteWithAbsolute() { assertThrows(IllegalArgumentException.class, () -> new RuleSetReferenceId("ruleset.xml/SomeRule", new RuleSetReferenceId("ruleset2.xml"))); } - @Test - void testAbsoluteWithAbsolute2() { + @Test void testAbsoluteWithAbsolute2() { assertThrows(IllegalArgumentException.class, () -> new RuleSetReferenceId("someruleset.xml/SomeRule", new RuleSetReferenceId("someruleset.xml/SomeOtherRule"))); } - @Test - void testRelativeWithRelative() { + @Test void testRelativeWithRelative() { assertThrows(IllegalArgumentException.class, () -> - new RuleSetReferenceId("SomeRule", new RuleSetReferenceId("SomeOtherRule"))); + new RuleSetReferenceId("SomeRule", new RuleSetReferenceId("SomeOtherRule"))); } - @Test - void testAbsoluteWithRelative() { + @Test void testAbsoluteWithRelative() { assertThrows(IllegalArgumentException.class, () -> - new RuleSetReferenceId("someruleset.xml/SomeRule", new RuleSetReferenceId("SomeOtherRule"))); + new RuleSetReferenceId("someruleset.xml/SomeRule", new RuleSetReferenceId("SomeOtherRule"))); } - @Test - void testRelativeWithAbsolute() { + @Test void testRelativeWithAbsolute() { assertRuleSetReferenceId(true, "someruleset.xml", false, "SomeRule", "someruleset.xml/SomeRule", // This is okay new RuleSetReferenceId("SomeRule", new RuleSetReferenceId("someruleset.xml/SomeOtherRule"))); } - @Test - void testNullReference() { + @Test void testNullReference() { assertThrows(IllegalArgumentException.class, () -> new RuleSetReferenceId(null)); } - @Test - void testRelativeWithAbsoluteRuleSet() { + @Test void testRelativeWithAbsoluteRuleSet() { // This is representative of how the RuleSetFactory temporarily pairs a // relative reference (rule only) with an absolute reference. RuleSetReferenceId relativeRuleSetReferenceId = new RuleSetReferenceId("MockRuleName"); @@ -83,8 +75,7 @@ void testRelativeWithAbsoluteRuleSet() { "rulesets/java/basic.xml/MockRuleName", pairRuleSetReferenceId); } - @Test - void testExamplesFromJavaDoc() { + @Test void testExamplesFromJavaDoc() { assertRuleSetReferenceId(true, "rulesets/java/basic.xml", true, null, "rulesets/java/basic.xml", new RuleSetReferenceId("rulesets/java/basic.xml")); assertRuleSetReferenceId(true, "rulesets/java/basic.xml", false, "EmptyCatchBlock", "rulesets/java/basic.xml/EmptyCatchBlock", @@ -99,22 +90,19 @@ void testExamplesFromJavaDoc() { new RuleSetReferenceId("https://example.org/ruleset.xml/MyRule")); } - @Test - void testConstructorGivenHttpUrlIdSucceedsAndProcessesIdCorrectly() { + @Test void testConstructorGivenHttpUrlIdSucceedsAndProcessesIdCorrectly() { final String sonarRulesetUrlId = "http://localhost:54321/profiles/export?format=pmd&language=java&name=Sonar%2520way"; RuleSetReferenceId ruleSetReferenceId = new RuleSetReferenceId(" " + sonarRulesetUrlId + " "); assertRuleSetReferenceId(true, sonarRulesetUrlId, true, null, sonarRulesetUrlId, ruleSetReferenceId); } - @Test - void testOldSimpleRuleSetReferences() { + @Test void testOldSimpleRuleSetReferences() { assertRuleSetReferenceId(false, null, false, "dummy-basic", "dummy-basic", new RuleSetReferenceId("dummy-basic")); } - @Test - void testRuleSetReferenceWithSpaces() { + @Test void testRuleSetReferenceWithSpaces() { assertRuleSetReferenceId(false, null, false, "MyRule", "MyRule", new RuleSetReferenceId(" MyRule ")); assertRuleSetReferenceId(true, "ruleset.xml", true, null, "ruleset.xml", @@ -126,8 +114,7 @@ void testRuleSetReferenceWithSpaces() { /** * See https://sourceforge.net/p/pmd/bugs/1201/ */ - @Test - void testMultipleRulesWithSpaces() { + @Test void testMultipleRulesWithSpaces() { List references = RuleSetReferenceId.parse("rulesets/dummy/basic.xml, rulesets/dummy/unusedcode.xml, rulesets/dummy2/basic.xml"); assertEquals(3, references.size()); assertRuleSetReferenceId(true, "rulesets/dummy/basic.xml", true, null, "rulesets/dummy/basic.xml", @@ -138,24 +125,21 @@ void testMultipleRulesWithSpaces() { references.get(2)); } - @Test - void testOneFullRuleSet() { + @Test void testOneFullRuleSet() { List references = RuleSetReferenceId.parse("rulesets/java/unusedcode.xml"); assertEquals(1, references.size()); assertRuleSetReferenceId(true, "rulesets/java/unusedcode.xml", true, null, "rulesets/java/unusedcode.xml", references.get(0)); } - @Test - void testOneFullRuleSetURL() { + @Test void testOneFullRuleSetURL() { List references = RuleSetReferenceId.parse("file://somepath/rulesets/java/unusedcode.xml"); assertEquals(1, references.size()); assertRuleSetReferenceId(true, "file://somepath/rulesets/java/unusedcode.xml", true, null, "file://somepath/rulesets/java/unusedcode.xml", references.get(0)); } - @Test - void testMultipleFullRuleSet() { + @Test void testMultipleFullRuleSet() { List references = RuleSetReferenceId .parse("rulesets/java/unusedcode.xml,rulesets/java/basic.xml"); assertEquals(2, references.size()); @@ -165,23 +149,20 @@ void testMultipleFullRuleSet() { references.get(1)); } - @Test - void testUnknownRuleSet() { + @Test void testUnknownRuleSet() { List references = RuleSetReferenceId.parse("nonexistant.xml"); assertEquals(1, references.size()); assertRuleSetReferenceId(true, "nonexistant.xml", true, null, "nonexistant.xml", references.get(0)); } - @Test - void testFullRuleSetAndRule() { + @Test void testFullRuleSetAndRule() { List references = RuleSetReferenceId.parse("rulesets/java/basic.xml/EmptyCatchBlock"); assertEquals(1, references.size()); assertRuleSetReferenceId(true, "rulesets/java/basic.xml", false, "EmptyCatchBlock", "rulesets/java/basic.xml/EmptyCatchBlock", references.get(0)); } - @Test - void testFullRuleSetURLAndRule() { + @Test void testFullRuleSetURLAndRule() { List references = RuleSetReferenceId .parse("file://somepath/rulesets/java/unusedcode.xml/EmptyCatchBlock"); assertEquals(1, references.size()); @@ -189,30 +170,26 @@ void testFullRuleSetURLAndRule() { "file://somepath/rulesets/java/unusedcode.xml/EmptyCatchBlock", references.get(0)); } - @Test - void testRelativeRule() { + @Test void testRelativeRule() { List references = RuleSetReferenceId.parse("EmptyCatchBlock"); assertEquals(1, references.size()); assertRuleSetReferenceId(false, null, false, "EmptyCatchBlock", "EmptyCatchBlock", references.get(0)); } - @Test - void testRelativePathRuleSet() { + @Test void testRelativePathRuleSet() { List references = RuleSetReferenceId.parse("pmd/pmd-ruleset.xml"); assertEquals(1, references.size()); assertRuleSetReferenceId(true, "pmd/pmd-ruleset.xml", true, null, "pmd/pmd-ruleset.xml", references.get(0)); } - @Test - void testAbsolutePathRuleSet() { + @Test void testAbsolutePathRuleSet() { List references = RuleSetReferenceId.parse("/home/foo/pmd/pmd-ruleset.xml"); assertEquals(1, references.size()); assertRuleSetReferenceId(true, "/home/foo/pmd/pmd-ruleset.xml", true, null, "/home/foo/pmd/pmd-ruleset.xml", references.get(0)); } - @Test - void testFooRules() throws Exception { + @Test void testFooRules() throws Exception { String fooRulesFile = new File("./src/test/resources/net/sourceforge/pmd/rulesets/foo-project/foo-rules") .getCanonicalPath(); List references = RuleSetReferenceId.parse(fooRulesFile); @@ -220,8 +197,7 @@ void testFooRules() throws Exception { assertRuleSetReferenceId(true, fooRulesFile, true, null, fooRulesFile, references.get(0)); } - @Test - void testNullRulesetString() throws Exception { + @Test void testNullRulesetString() throws Exception { List references = RuleSetReferenceId.parse(null); assertTrue(references.isEmpty()); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/NoAttributeTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/NoAttributeTest.java index 07af73173fc..a541242eab5 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/NoAttributeTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/NoAttributeTest.java @@ -25,8 +25,7 @@ class NoAttributeTest { - @Test - void testNoAttrInherited() { + @Test void testNoAttrInherited() { Node child = new NodeNoInherited(); Set attrNames = IteratorUtil.toList(child.getXPathAttributesIterator()).stream().map(Attribute::getName).collect(Collectors.toSet()); @@ -42,8 +41,7 @@ void testNoAttrInherited() { } - @Test - void testNoAttrAll() { + @Test void testNoAttrAll() { assertTrue(0 < IteratorUtil.count(new NodeAllAttr(12).getXPathAttributesIterator())); @@ -56,8 +54,7 @@ void testNoAttrAll() { } - @Test - void testNoAttrAllIsNotInherited() { + @Test void testNoAttrAllIsNotInherited() { NodeNoAttrAllChild child = new NodeNoAttrAllChild(); @@ -93,8 +90,7 @@ public long getSomeLong2() { } - @Override - public Iterator getXPathAttributesIterator() { + @Override public Iterator getXPathAttributesIterator() { return new AttributeAxisIterator(this); } } @@ -110,21 +106,17 @@ public static class NodeNoInherited extends DummyNodeParent { // isChild overrides nothing so with INHERITED it's not filtered out - @Override - public int getSomeInt() { + @Override public int getSomeInt() { return 43; } @NoAttribute // Notice - @Override - public long getSomeLong() { + @Override public long getSomeLong() { return 43; } - @NoAttribute(scope = NoAttrScope.INHERITED) - @Override - public String getImage() { + @NoAttribute(scope = NoAttrScope.INHERITED) @Override public String getImage() { return super.getImage(); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/impl/AttributeAxisIteratorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/impl/AttributeAxisIteratorTest.java index e674bbe56c6..dfab10d4cae 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/impl/AttributeAxisIteratorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/impl/AttributeAxisIteratorTest.java @@ -35,8 +35,7 @@ class AttributeAxisIteratorTest { /** * Test hasNext and next. */ - @Test - void testAttributeAxisIterator() { + @Test void testAttributeAxisIterator() { DummyNode dummyNode = new DummyNode(); AttributeAxisIterator it = new AttributeAxisIterator(dummyNode); @@ -46,8 +45,7 @@ void testAttributeAxisIterator() { assertEquals(expected, toMap(it).keySet()); } - @Test - void testAttributeAxisIteratorWithEnum() { + @Test void testAttributeAxisIteratorWithEnum() { DummyNodeWithEnum dummyNode = new DummyNodeWithEnum(); AttributeAxisIterator it = new AttributeAxisIterator(dummyNode); @@ -57,8 +55,7 @@ void testAttributeAxisIteratorWithEnum() { assertEquals(expected, toMap(it).keySet()); } - @Test - void testAttributeAxisIteratorWithList() { + @Test void testAttributeAxisIteratorWithList() { // list attributes are not supported anymore DummyNodeWithList dummyNode = new DummyNodeWithList(); @@ -73,8 +70,7 @@ void testAttributeAxisIteratorWithList() { * Exercises the case described in * [java] AssertionError: Method should be accessible #4885. */ - @Test - void accessPublicMethodWithAPackagePrivateImplementationInSuperclass() { + @Test void accessPublicMethodWithAPackagePrivateImplementationInSuperclass() { final String ATTRIBUTE_NAME = "Value"; ConcreteNode node = new ConcreteNode(); AttributeAxisIterator it = new AttributeAxisIterator(node); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/impl/dummyast/ConcreteNode.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/impl/dummyast/ConcreteNode.java index ebc4c3d6341..2bca4aa7b9b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/impl/dummyast/ConcreteNode.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/impl/dummyast/ConcreteNode.java @@ -7,8 +7,7 @@ import net.sourceforge.pmd.lang.document.Chars; public final class ConcreteNode extends AbstractNode implements ValueNode { - @Override - public Chars getValue() { + @Override public Chars getValue() { return super.getValue(); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/ElementNodeTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/ElementNodeTest.java index d838c7c230f..6bb499609d8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/ElementNodeTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/ElementNodeTest.java @@ -23,14 +23,12 @@ class ElementNodeTest { - @RegisterExtension - private final DummyParsingHelper helper = new DummyParsingHelper(); + @RegisterExtension private final DummyParsingHelper helper = new DummyParsingHelper(); - @Test - void testCompareOrder() { + @Test void testCompareOrder() { DummyRootNode root = helper.parse( - "(#foo)" - + "(#foo)" + "(#foo)" + + "(#foo)" ); DummyNode c0 = root.getChild(0); @@ -64,8 +62,7 @@ void testCompareOrder() { } - @Test - void verifyTextNodeType() { + @Test void verifyTextNodeType() { DummyRootNode root = helper.parse("(foo)(#text)"); DummyNode c0 = root.getChild(0); @@ -90,8 +87,7 @@ void verifyTextNodeType() { assertSame(elementText1, treeInfo.findWrapperFor(c1)); } - @Test - void verifyCommentNodeType() { + @Test void verifyCommentNodeType() { DummyRootNode root = helper.parse("(#comment)"); DummyNode c1 = root.getChild(0); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQueryTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQueryTest.java index a1c8cd355bd..705d3bdb56f 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQueryTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/internal/SaxonXPathRuleQueryTest.java @@ -38,8 +38,7 @@ class SaxonXPathRuleQueryTest { - @RegisterExtension - private final DummyParsingHelper helper = new DummyParsingHelper(); + @RegisterExtension private final DummyParsingHelper helper = new DummyParsingHelper(); // Unsupported: https://github.com/pmd/pmd/issues/2451 // @Test @@ -57,16 +56,15 @@ class SaxonXPathRuleQueryTest { // assertQuery(0, "//dummyNode[@EmptyList = (\"A\")]", dummy); // } - @Test - void testHigherOrderFuns() { // XPath 3.1 + @Test void testHigherOrderFuns() { // XPath 3.1 DummyRootNode tree = helper.parse("(oha)"); assertQuery(1, "//dummyRootNode[" - + "(@Image => substring-after('[') => substring-before(']')) " - // -------------------- --------------------- - // Those are higher order functions, - // the arrow operator applies it to the left expression - + "! . = '']", tree); + + "(@Image => substring-after('[') => substring-before(']')) " + // -------------------- --------------------- + // Those are higher order functions, + // the arrow operator applies it to the left expression + + "! . = '']", tree); // ^ This is the mapping operator, it applies a function on // the right to every element of the sequence on the left @@ -81,20 +79,18 @@ void testHigherOrderFuns() { // XPath 3.1 } - @Test - void testListProperty() { + @Test void testListProperty() { RootNode dummy = new DummyNodeWithListAndEnum(); PropertyDescriptor> prop = PropertyFactory.stringListProperty("prop") - .defaultValues("FOO", "BAR") - .desc("description").build(); + .defaultValues("FOO", "BAR") + .desc("description").build(); assertQuery(1, "//dummyRootNode[@Enum = $prop]", dummy, prop); } - @Test - void testInvalidReturn() { + @Test void testInvalidReturn() { DummyNodeWithListAndEnum dummy = new DummyNodeWithListAndEnum(); PmdXPathException exception = assertThrows(PmdXPathException.class, () -> { @@ -104,24 +100,21 @@ void testInvalidReturn() { assertThat(exception.getMessage(), CoreMatchers.containsString("Int64Value")); } - @Test - void testRootExpression() { + @Test void testRootExpression() { DummyRootNode dummy = helper.parse("(oha)"); List result = assertQuery(1, "/", dummy); assertEquals(dummy, result.get(0)); } - @Test - void testRootExpressionIsADocumentNode() { + @Test void testRootExpressionIsADocumentNode() { DummyRootNode dummy = helper.parse("(oha)"); List result = assertQuery(1, "(/)[self::document-node()]", dummy); assertEquals(dummy, result.get(0)); } - @Test - void testRootExpressionWithName() { + @Test void testRootExpressionWithName() { DummyRootNode dummy = helper.parse("(oha)"); String xpathName = dummy.getXPathNodeName(); @@ -131,8 +124,7 @@ void testRootExpressionWithName() { assertQuery(0, "(/)[self::document-node(element(DummyNodeX))]", dummy); } - @Test - void testListAttributes() { + @Test void testListAttributes() { DummyRootNode dummy = helper.parse("(a(b))"); List result = assertQuery(1, "//dummyNode[count(distinct-values(@Lines)) > 0 and not(empty(index-of(@Lines, 'a')))]", dummy); @@ -140,8 +132,7 @@ void testListAttributes() { assertEquals(dummy.getChild(0), result.get(0)); } - @Test - void ruleChainVisits() { + @Test void ruleChainVisits() { SaxonXPathRuleQuery query = createQuery("//dummyNode[@Image='baz']/foo | //bar[@Public = 'true'] | //dummyNode[@Public = false()] | //dummyNode"); List ruleChainVisits = query.getRuleChainVisits(); assertEquals(2, ruleChainVisits.size()); @@ -156,8 +147,7 @@ void ruleChainVisits() { assertExpression("(((docOrder((((/)/descendant::element(dummyNode))[(data(attribute::attribute(Image))) = baz])/child::element(foo))) | (((/)/descendant::element(bar))[(data(attribute::attribute(Public))) = true])) | (((/)/descendant::element(dummyNode))[(data(attribute::attribute(Public))) = false])) | ((/)/descendant::element(dummyNode))", query.getFallbackExpr()); } - @Test - void ruleChainVisitsMultipleFilters() { + @Test void ruleChainVisitsMultipleFilters() { SaxonXPathRuleQuery query = createQuery("//dummyNode[@Test1 = false()][@Test2 = true()]"); List ruleChainVisits = query.getRuleChainVisits(); assertEquals(1, ruleChainVisits.size()); @@ -167,8 +157,7 @@ void ruleChainVisitsMultipleFilters() { assertExpression("(((/)/descendant::element(dummyNode))[(data(attribute::attribute(Test1))) = false])[(data(attribute::attribute(Test2))) = true]", query.getFallbackExpr()); } - @Test - void ruleChainVisitsCustomFunctions() { + @Test void ruleChainVisitsCustomFunctions() { SaxonXPathRuleQuery query = createQuery("//dummyNode[pmd-dummy:imageIs(@Image)]"); List ruleChainVisits = query.getRuleChainVisits(); assertEquals(1, ruleChainVisits.size()); @@ -182,8 +171,7 @@ void ruleChainVisitsCustomFunctions() { * If a query contains another unbounded path expression other than the first one, it must be * excluded from rule chain execution. Saxon itself optimizes this quite good already. */ - @Test - void ruleChainVisitsUnboundedPathExpressions() { + @Test void ruleChainVisitsUnboundedPathExpressions() { SaxonXPathRuleQuery query = createQuery("//dummyNode[//ClassOrInterfaceType]"); List ruleChainVisits = query.getRuleChainVisits(); assertEquals(0, ruleChainVisits.size()); @@ -205,8 +193,7 @@ void ruleChainVisitsUnboundedPathExpressions() { assertExpression("let $Q{http://saxon.sf.net/generated-variable}v0 := (exists((/)/descendant::element(Q{}ClassOrInterfaceType))) or (exists((/)/descendant::element(Q{}OtherNode))) return (((/)/descendant::element(Q{}dummyNode))[$Q{http://saxon.sf.net/generated-variable}v0])", query.getFallbackExpr()); } - @Test - void ruleChainVisitsNested() { + @Test void ruleChainVisitsNested() { SaxonXPathRuleQuery query = createQuery("//dummyNode/foo/*/bar[@Test = 'false']"); List ruleChainVisits = query.getRuleChainVisits(); assertEquals(1, ruleChainVisits.size()); @@ -216,8 +203,7 @@ void ruleChainVisitsNested() { assertExpression("docOrder(((docOrder((((/)/descendant::element(dummyNode))/child::element(foo))/child::element()))/child::element(bar))[(data(attribute::attribute(Test))) = false])", query.getFallbackExpr()); } - @Test - void ruleChainVisitsNested2() { + @Test void ruleChainVisitsNested2() { SaxonXPathRuleQuery query = createQuery("//dummyNode/foo[@Baz = 'a']/*/bar[@Test = 'false']"); List ruleChainVisits = query.getRuleChainVisits(); assertEquals(1, ruleChainVisits.size()); @@ -227,17 +213,16 @@ void ruleChainVisitsNested2() { assertExpression("docOrder(((docOrder(((((/)/descendant::element(dummyNode))/child::element(foo))[(data(attribute::attribute(Baz))) = a])/child::element()))/child::element(bar))[(data(attribute::attribute(Test))) = false])", query.getFallbackExpr()); } - @Test - void unionBeforeSlash() { + @Test void unionBeforeSlash() { SaxonXPathRuleQuery query = createQuery("(//dummyNode | //dummyNodeB)/dummyNode[@Image = '10']"); DummyRootNode tree = tree(() -> root( - node( - node() - ), - nodeB( - node() - ) + node( + node() + ), + nodeB( + node() + ) )); tree.descendantsOrSelf().forEach(n -> { @@ -249,17 +234,16 @@ void unionBeforeSlash() { assertExpression("docOrder((((/)/descendant::(element(dummyNode) | element(dummyNodeB)))/child::element(dummyNode))[(data(attribute::attribute(Image))) = 10])", query.getExpressionsForLocalNameOrDefault("dummyNode").get(0)); } - @Test - void unionBeforeSlashWithFilter() { + @Test void unionBeforeSlashWithFilter() { SaxonXPathRuleQuery query = createQuery("(//dummyNode[@Image='0'] | //dummyNodeB[@Image='1'])/dummyNode[@Image = '10']"); DummyRootNode tree = tree(() -> root( - node( - node() - ), - nodeB( - node() - ) + node( + node() + ), + nodeB( + node() + ) )); assertEquals(0, query.getRuleChainVisits().size()); @@ -272,19 +256,18 @@ void unionBeforeSlashWithFilter() { }); } - @Test - void unionBeforeSlashDeeper() { + @Test void unionBeforeSlashDeeper() { SaxonXPathRuleQuery query = createQuery("(//dummyNode | //dummyNodeB)/dummyNode/dummyNode"); DummyRootNode tree = tree(() -> root( - node( node( - node() + node( + node() + ) + ), + nodeB( + node() ) - ), - nodeB( - node() - ) )); assertEquals(0, query.getRuleChainVisits().size()); @@ -297,8 +280,7 @@ void unionBeforeSlashDeeper() { }); } - @Test - void ruleChainVisitWithVariable() { + @Test void ruleChainVisitWithVariable() { PropertyDescriptor testClassPattern = PropertyFactory.stringProperty("testClassPattern").desc("test").defaultValue("a").build(); SaxonXPathRuleQuery query = createQuery("//dummyNode[matches(@SimpleName, $testClassPattern)]", testClassPattern); List ruleChainVisits = query.getRuleChainVisits(); @@ -309,8 +291,7 @@ void ruleChainVisitWithVariable() { assertExpression("((/)/descendant::element(Q{}dummyNode))[matches(zero-or-one(convertTo_xs:string(data(attribute::attribute(SimpleName)))), a, )]", query.getFallbackExpr()); } - @Test - void ruleChainVisitWithVariable2() { + @Test void ruleChainVisitWithVariable2() { PropertyDescriptor testClassPattern = PropertyFactory.stringProperty("testClassPattern").desc("test").defaultValue("a").build(); SaxonXPathRuleQuery query = createQuery("//dummyNode[matches(@SimpleName, $testClassPattern)]/foo", testClassPattern); List ruleChainVisits = query.getRuleChainVisits(); @@ -321,8 +302,7 @@ void ruleChainVisitWithVariable2() { assertExpression("docOrder((((/)/descendant::element(Q{}dummyNode))[matches(zero-or-one(convertTo_xs:string(data(attribute::attribute(SimpleName)))), a, )])/child::element(Q{}foo))", query.getFallbackExpr()); } - @Test - void ruleChainVisitWithTwoFunctions() { + @Test void ruleChainVisitWithTwoFunctions() { SaxonXPathRuleQuery query = createQuery("//dummyNode[ends-with(@Image, 'foo')][pmd-dummy:imageIs('bar')]"); List ruleChainVisits = query.getRuleChainVisits(); assertEquals(1, ruleChainVisits.size()); @@ -331,39 +311,34 @@ void ruleChainVisitWithTwoFunctions() { assertExpression("let $v0 := imageIs(bar) return ((self::node()[ends-with(zero-or-one(convertTo_xs:string(data(attribute::attribute(Image)))), foo)])[$v0])", query.nodeNameToXPaths.get("dummyNode").get(0)); } - @Test - void ruleChainWithUnions() { + @Test void ruleChainWithUnions() { SaxonXPathRuleQuery query = createQuery("(//ForStatement | //WhileStatement | //DoStatement)//AssignmentOperator"); List ruleChainVisits = query.getRuleChainVisits(); assertEquals(0, ruleChainVisits.size()); } - @Test - void ruleChainWithUnionsAndFilter() { + @Test void ruleChainWithUnionsAndFilter() { SaxonXPathRuleQuery query = createQuery("(//ForStatement | //WhileStatement | //DoStatement)//AssignmentOperator[@Image='foo']"); List ruleChainVisits = query.getRuleChainVisits(); assertEquals(0, ruleChainVisits.size()); } - @Test - void ruleChainWithUnionsCustomFunctionsVariant1() { + @Test void ruleChainWithUnionsCustomFunctionsVariant1() { SaxonXPathRuleQuery query = createQuery("(//ForStatement | //WhileStatement | //DoStatement)//dummyNode[pmd-dummy:imageIs(@Image)]"); List ruleChainVisits = query.getRuleChainVisits(); assertEquals(0, ruleChainVisits.size()); } - @Test - void ruleChainWithUnionsCustomFunctionsVariant2() { + @Test void ruleChainWithUnionsCustomFunctionsVariant2() { SaxonXPathRuleQuery query = createQuery("//(ForStatement | WhileStatement | DoStatement)//dummyNode[pmd-dummy:imageIs(@Image)]"); List ruleChainVisits = query.getRuleChainVisits(); assertEquals(0, ruleChainVisits.size()); } - @Test - void ruleChainWithUnionsCustomFunctionsVariant3() { + @Test void ruleChainWithUnionsCustomFunctionsVariant3() { SaxonXPathRuleQuery query = createQuery("//ForStatement//dummyNode[pmd-dummy:imageIs(@Image)]" - + " | //WhileStatement//dummyNode[pmd-dummy:imageIs(@Image)]" - + " | //DoStatement//dummyNode[pmd-dummy:imageIs(@Image)]"); + + " | //WhileStatement//dummyNode[pmd-dummy:imageIs(@Image)]" + + " | //DoStatement//dummyNode[pmd-dummy:imageIs(@Image)]"); List ruleChainVisits = query.getRuleChainVisits(); assertEquals(3, ruleChainVisits.size()); assertTrue(ruleChainVisits.contains("ForStatement")); @@ -376,8 +351,7 @@ void ruleChainWithUnionsCustomFunctionsVariant3() { assertExpression(expectedSubexpression, query.nodeNameToXPaths.get("DoStatement").get(0)); } - @Test - void ruleChainVisitsWithUnionsAndLets() { + @Test void ruleChainVisitsWithUnionsAndLets() { PropertyDescriptor boolProperty = PropertyFactory.booleanProperty("checkAll").desc("test").defaultValue(true).build(); SaxonXPathRuleQuery query = createQuery("//dummyNode[$checkAll and ClassOrInterfaceType] | //ForStatement[not($checkAll)]", boolProperty); List ruleChainVisits = query.getRuleChainVisits(); @@ -388,14 +362,14 @@ void ruleChainVisitsWithUnionsAndLets() { private static void assertExpression(String expected, Expression actual) { assertEquals(normalizeExprDump(expected), - normalizeExprDump(actual.toString())); + normalizeExprDump(actual.toString())); } private static String normalizeExprDump(String dump) { return dump.replaceAll("Q\\{[^}]*+}", "") // remove namespaces - // generated variable ids - .replaceAll("\\$qq:qq-?\\d+", "\\$qq:qq000") - .replaceAll("\\$zz:zz-?\\d+", "\\$zz:zz000"); + // generated variable ids + .replaceAll("\\$qq:qq-?\\d+", "\\$qq:qq000") + .replaceAll("\\$zz:zz-?\\d+", "\\$zz:zz000"); } private static List assertQuery(int resultSize, String xpath, Node node, PropertyDescriptor... descriptors) { @@ -414,11 +388,11 @@ private static SaxonXPathRuleQuery createQuery(String xpath, PropertyDescriptor< } return new SaxonXPathRuleQuery( - xpath, - XPathVersion.DEFAULT, - props, - XPathHandler.getHandlerForFunctionDefs(DummyLanguageModule.imageIsFunction()), - DeprecatedAttrLogger.noop() + xpath, + XPathVersion.DEFAULT, + props, + XPathHandler.getHandlerForFunctionDefs(DummyLanguageModule.imageIsFunction()), + DeprecatedAttrLogger.noop() ); } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/symboltable/ApplierTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/symboltable/ApplierTest.java index 4f27b551706..c1180df46e2 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/symboltable/ApplierTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/symboltable/ApplierTest.java @@ -22,8 +22,7 @@ private static class MyFunction implements Predicate { this.maxCallbacks = maxCallbacks; } - @Override - public boolean test(Object o) { + @Override public boolean test(Object o) { this.numCallbacks++; return numCallbacks < maxCallbacks; } @@ -33,8 +32,7 @@ public int getNumCallbacks() { } } - @Test - void testSimple() { + @Test void testSimple() { MyFunction f = new MyFunction(Integer.MAX_VALUE); List l = new ArrayList<>(); l.add(new Object()); @@ -44,8 +42,7 @@ void testSimple() { assertEquals(l.size(), f.getNumCallbacks()); } - @Test - void testLimit() { + @Test void testLimit() { MyFunction f = new MyFunction(2); List l = new ArrayList<>(); l.add(new Object()); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/NumericConstraintsTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/NumericConstraintsTest.java index 8dc320b3ed7..43ad5b9a18c 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/NumericConstraintsTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/NumericConstraintsTest.java @@ -13,8 +13,7 @@ class NumericConstraintsTest { - @Test - void testInRangeInteger() { + @Test void testInRangeInteger() { PropertyConstraint constraint = NumericConstraints.inRange(1, 10); assertNull(errorAsString(constraint, 1)); assertNull(errorAsString(constraint, 5)); @@ -34,8 +33,7 @@ void testInRangeInteger() { } } - @Test - void testInRangeDouble() { + @Test void testInRangeDouble() { PropertyConstraint constraint = NumericConstraints.inRange(1.0, 10.0); assertNull(errorAsString(constraint, 1.0)); assertNull(errorAsString(constraint, 5.5)); @@ -46,8 +44,7 @@ void testInRangeDouble() { assertNotNull(errorAsString(constraint, 100.0)); } - @Test - void testPositive() { + @Test void testPositive() { PropertyConstraint constraint = NumericConstraints.positive(); assertNull(errorAsString(constraint, 1)); assertNull(errorAsString(constraint, 1.5f)); @@ -62,8 +59,7 @@ void testPositive() { assertNotNull(errorAsString(constraint, -0.1d)); } - @Test - void testBelow() { + @Test void testBelow() { PropertyConstraint constraint = NumericConstraints.below(5); assertNull(errorAsString(constraint, 5)); assertNull(errorAsString(constraint, 3)); @@ -74,8 +70,7 @@ void testBelow() { assertNotNull(errorAsString(constraint, 10)); } - @Test - void testAbove() { + @Test void testAbove() { PropertyConstraint constraint = NumericConstraints.above(2.5); assertNull(errorAsString(constraint, 2.5)); assertNull(errorAsString(constraint, 3d)); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertyDescriptorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertyDescriptorTest.java index 89a8788ef29..f21fdac47c8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertyDescriptorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertyDescriptorTest.java @@ -37,45 +37,41 @@ class PropertyDescriptorTest { - - @Test - void testDefaultValueConstraintViolationCausesFailure() { + @Test void testDefaultValueConstraintViolationCausesFailure() { PropertyConstraint constraint = inRange(1, 10); IllegalArgumentException thrown = assertThrows(ConstraintViolatedException.class, () -> - PropertyFactory.intProperty("fooProp") - .desc("hello") - .defaultValue(1000) - .require(constraint) - .build()); + PropertyFactory.intProperty("fooProp") + .desc("hello") + .defaultValue(1000) + .require(constraint) + .build()); assertThat(thrown.getMessage(), containsIgnoreCase(constraint.getConstraintDescription())); } - @Test - void testDefaultValueConstraintViolationCausesFailureMulti() { + @Test void testDefaultValueConstraintViolationCausesFailureMulti() { PropertyConstraint constraint = inRange(1d, 10d); IllegalArgumentException thrown = assertThrows(ConstraintViolatedException.class, () -> - PropertyFactory.doubleListProperty("fooProp") - .desc("hello") - .defaultValues(2., 11.) // 11. is out of range - .requireEach(constraint) - .build()); + PropertyFactory.doubleListProperty("fooProp") + .desc("hello") + .defaultValues(2., 11.) // 11. is out of range + .requireEach(constraint) + .build()); assertThat(thrown.getMessage(), containsIgnoreCase(constraint.getConstraintDescription())); } - @Test - void testNoConstraintViolationCausesIsOkMulti() { + @Test void testNoConstraintViolationCausesIsOkMulti() { PropertyDescriptor> descriptor = PropertyFactory.doubleListProperty("fooProp") - .desc("hello") - .defaultValues(2., 11.) // 11. is in range - .requireEach(inRange(1d, 20d)) - .build(); + .desc("hello") + .defaultValues(2., 11.) // 11. is in range + .requireEach(inRange(1d, 20d)) + .build(); assertEquals("fooProp", descriptor.name()); assertEquals("hello", descriptor.description()); @@ -83,22 +79,19 @@ void testNoConstraintViolationCausesIsOkMulti() { } - - @Test - void testNoConstraintViolationCausesIsOk() { + @Test void testNoConstraintViolationCausesIsOk() { PropertyDescriptor descriptor = PropertyFactory.stringProperty("fooProp") - .desc("hello") - .defaultValue("bazooli") - .build(); + .desc("hello") + .defaultValue("bazooli") + .build(); assertEquals("fooProp", descriptor.name()); assertEquals("hello", descriptor.description()); assertEquals("bazooli", descriptor.defaultValue()); } - @Test - void testIntProperty() { + @Test void testIntProperty() { PropertyDescriptor descriptor = PropertyFactory.intProperty("intProp") .desc("hello") .defaultValue(1) @@ -120,20 +113,18 @@ void testIntProperty() { assertEquals(Arrays.asList(5, 7), listDescriptor.serializer().fromString(" 5 , 7 ")); } - @Test - void testIntPropertyInvalidValue() { + @Test void testIntPropertyInvalidValue() { PropertyDescriptor descriptor = PropertyFactory.intProperty("intProp") .desc("hello") .defaultValue(1) .build(); NumberFormatException thrown = assertThrows(NumberFormatException.class, () -> - descriptor.serializer().fromString("not a number")); + descriptor.serializer().fromString("not a number")); assertThat(thrown.getMessage(), containsString("not a number")); } - @Test - void testDoubleProperty() { + @Test void testDoubleProperty() { PropertyDescriptor descriptor = PropertyFactory.doubleProperty("doubleProp") .desc("hello") .defaultValue(1.0) @@ -155,19 +146,17 @@ void testDoubleProperty() { assertEquals(Arrays.asList(2.0, 3.0), listDescriptor.serializer().fromString(" 2.0 , 3.0 ")); } - @Test - void testDoublePropertyInvalidValue() { + @Test void testDoublePropertyInvalidValue() { PropertyDescriptor descriptor = PropertyFactory.doubleProperty("doubleProp") .desc("hello") .defaultValue(1.0) .build(); NumberFormatException thrown = assertThrows(NumberFormatException.class, () -> - descriptor.serializer().fromString("this is not a number")); + descriptor.serializer().fromString("this is not a number")); assertThat(thrown.getMessage(), containsString("this is not a number")); } - @Test - void testStringProperty() { + @Test void testStringProperty() { PropertyDescriptor descriptor = PropertyFactory.stringProperty("stringProp") .desc("hello") .defaultValue("default value") @@ -180,8 +169,7 @@ void testStringProperty() { } - @Test - void testStringListProperty() { + @Test void testStringListProperty() { PropertyDescriptor> listDescriptor = PropertyFactory.stringListProperty("stringListProp") .desc("hello") .defaultValues("v1", "v2") @@ -193,7 +181,8 @@ void testStringListProperty() { assertEquals(Arrays.asList("foo", "bar"), listDescriptor.serializer().fromString(" foo , bar ")); } - private enum SampleEnum { A, B, C } + private enum SampleEnum { A, B, C + } private static final Map NAME_MAP = new LinkedHashMap<>(); @@ -203,8 +192,7 @@ private enum SampleEnum { A, B, C } NAME_MAP.put("TEST_C", SampleEnum.C); } - @Test - void testEnumProperty() { + @Test void testEnumProperty() { PropertyDescriptor descriptor = PropertyFactory.enumProperty("enumProp", NAME_MAP) .desc("hello") .defaultValue(SampleEnum.B) @@ -225,42 +213,38 @@ void testEnumProperty() { } - @Test - void testEnumPropertyNullValueFailsBuild() { + @Test void testEnumPropertyNullValueFailsBuild() { Map map = new HashMap<>(NAME_MAP); map.put("TEST_NULL", null); IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> - PropertyFactory.enumProperty("enumProp", map)); + PropertyFactory.enumProperty("enumProp", map)); assertThat(thrown.getMessage(), containsIgnoreCase("null value")); } - @Test - void testEnumListPropertyNullValueFailsBuild() { + @Test void testEnumListPropertyNullValueFailsBuild() { Map map = new HashMap<>(NAME_MAP); map.put("TEST_NULL", null); IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> - PropertyFactory.enumListProperty("enumProp", map)); + PropertyFactory.enumListProperty("enumProp", map)); assertThat(thrown.getMessage(), containsIgnoreCase("null value")); } - @Test - void testEnumPropertyInvalidValue() { + @Test void testEnumPropertyInvalidValue() { PropertyDescriptor descriptor = PropertyFactory.enumProperty("enumProp", NAME_MAP) .desc("hello") .defaultValue(SampleEnum.B) .build(); IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> - descriptor.serializer().fromString("InvalidEnumValue")); + descriptor.serializer().fromString("InvalidEnumValue")); assertThat(thrown.getMessage(), containsString("'InvalidEnumValue' should be one of 'TEST_A', 'TEST_B', 'TEST_C'")); } - @Test - void testRegexProperty() { + @Test void testRegexProperty() { PropertyDescriptor descriptor = PropertyFactory.regexProperty("regexProp") .desc("hello") .defaultValue("^[A-Z].*$") @@ -271,25 +255,23 @@ void testRegexProperty() { assertEquals("[0-9]+", descriptor.serializer().fromString("[0-9]+").toString()); } - @Test - void testRegexPropertyInvalidValue() { + @Test void testRegexPropertyInvalidValue() { PropertyDescriptor descriptor = PropertyFactory.regexProperty("regexProp") .desc("hello") .defaultValue("^[A-Z].*$") .build(); PatternSyntaxException thrown = assertThrows(PatternSyntaxException.class, () -> - descriptor.serializer().fromString("[open class")); + descriptor.serializer().fromString("[open class")); assertThat(thrown.getMessage(), containsString("Unclosed character class")); } - @Test - void testRegexPropertyInvalidDefaultValue() { + @Test void testRegexPropertyInvalidDefaultValue() { PatternSyntaxException thrown = assertThrows(PatternSyntaxException.class, () -> - PropertyFactory.regexProperty("regexProp") - .desc("hello") - .defaultValue("[open class") - .build()); + PropertyFactory.regexProperty("regexProp") + .desc("hello") + .defaultValue("[open class") + .build()); assertThat(thrown.getMessage(), containsString("Unclosed character class")); } @@ -298,47 +280,40 @@ private static List parseEscaped(String s, char d) { return PropertyParsingUtil.parseListWithEscapes(s, d, Function.identity()); } - @Test - void testStringParserEmptyString() { + @Test void testStringParserEmptyString() { assertEquals(emptyList(), parseEscaped("", ',')); } - @Test - void testStringParserSimple() { + @Test void testStringParserSimple() { assertEquals(listOf("a", "b", "c"), - parseEscaped("a,b,c", ',')); + parseEscaped("a,b,c", ',')); } - @Test - void testStringParserEscapedChar() { + @Test void testStringParserEscapedChar() { assertEquals(listOf("a", "b,c"), - parseEscaped("a,b\\,c", ',')); + parseEscaped("a,b\\,c", ',')); } - @Test - void testStringParserEscapedEscapedChar() { + @Test void testStringParserEscapedEscapedChar() { assertEquals(listOf("a", "b\\", "c"), - parseEscaped("a,b\\\\,c", ',')); + parseEscaped("a,b\\\\,c", ',')); } - @Test - void testStringParserDelimIsBackslash() { + @Test void testStringParserDelimIsBackslash() { assertEquals(listOf("a,b", "", ",c"), - parseEscaped("a,b\\\\,c", '\\')); + parseEscaped("a,b\\\\,c", '\\')); } - @Test - void testStringParserTrailingBackslash() { + @Test void testStringParserTrailingBackslash() { assertEquals(listOf("a", "b\\"), - parseEscaped("a,b\\", ',')); + parseEscaped("a,b\\", ',')); } private static Matcher containsIgnoreCase(final String substring) { return new SubstringMatcher("containing (ignoring case)", true, substring) { - @Override - protected boolean evalSubstringOf(String string) { + @Override protected boolean evalSubstringOf(String string) { return StringUtils.indexOfIgnoreCase(string, substring) != -1; } }; diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java index 387490202c1..f115993e88d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/properties/PropertySyntaxTest.java @@ -28,36 +28,34 @@ private PropertyDescriptor defineProperty(String propDef) { ArrayList> descriptors = new ArrayList<>(rule.getPropertyDescriptors()); descriptors.removeAll(setOf(Rule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR, - Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR)); + Rule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR)); return descriptors.get(0); } private static String contextForPropertyDef(String propDef) { return rulesetXml( - dummyRule( - properties( - propDef + dummyRule( + properties( + propDef + ) ) - ) ); } - @Test - void testPropDefXml() { + @Test void testPropDefXml() { PropertyDescriptor prop = defineProperty( - propertyDefWithValueAttr("pname", "pdesc", "String", "strvalue") + propertyDefWithValueAttr("pname", "pdesc", "String", "strvalue") ); assertEquals("pname", prop.name()); assertEquals("strvalue", prop.defaultValue()); } - @Test - void testNumericPropDefWithoutBounds() { + @Test void testNumericPropDefWithoutBounds() { // https://github.com/pmd/pmd/issues/1204 PropertyDescriptor prop = defineProperty( - "" + "" ); assertEquals("pname", prop.name()); @@ -65,11 +63,10 @@ void testNumericPropDefWithoutBounds() { assertEquals(emptyList(), prop.serializer().getConstraints()); } - @Test - void testNumericPropDefWithMinBound() { + @Test void testNumericPropDefWithMinBound() { // https://github.com/pmd/pmd/issues/1204 PropertyDescriptor prop = defineProperty( - "" + "" ); assertEquals("pname", prop.name()); @@ -79,55 +76,49 @@ void testNumericPropDefWithMinBound() { } - @Test - void testNumericPropDefWithMaxBound() { + @Test void testNumericPropDefWithMaxBound() { // https://github.com/pmd/pmd/issues/1204 PropertyDescriptor prop = defineProperty( - "" + "" ); assertEquals("Should be smaller or equal to 6", prop.serializer().getConstraints().get(0).getConstraintDescription()); } - @Test - void testNumericPropDefWithMaxAndMin() { + @Test void testNumericPropDefWithMaxAndMin() { // https://github.com/pmd/pmd/issues/1204 PropertyDescriptor prop = defineProperty( - "" + "" ); assertEquals("Should be between 2 and 6", prop.serializer().getConstraints().get(0).getConstraintDescription()); } - @Test - void testNumericPropDefWithMaxAndMinUnordered() { + @Test void testNumericPropDefWithMaxAndMinUnordered() { assertCannotParse( - contextForPropertyDef( - "" - ) + contextForPropertyDef( + "" + ) ); verifyFoundAnErrorWithMessage(containing(XmlErrorMessages.ERR__INVALID_VALUE_RANGE)); } - @Test - void testNumericPropConstraintViolated() { + @Test void testNumericPropConstraintViolated() { // https://github.com/pmd/pmd/issues/1204 assertCannotParse(contextForPropertyDef( - "" + "" )); verifyFoundAnErrorWithMessage(containing("'4' should be smaller or equal to 1")); } - @Test - void testStringProp() { + @Test void testStringProp() { assertValueRoundTrip(PropertyParsingUtil.STRING, "ad", "ad"); assertValueRoundTrip(PropertyParsingUtil.STRING, "", ""); } - @Test - void testStringListProp() { + @Test void testStringListProp() { assertValueRoundTrip(PropertyParsingUtil.STRING_LIST, "ad,j", listOf("ad", "j")); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java index 89110711601..0d7b4d62280 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/AbstractRendererTest.java @@ -42,12 +42,10 @@ abstract class AbstractRendererTest { - @RegisterExtension - protected final DummyParsingHelper helper = new DummyParsingHelper(); + @RegisterExtension protected final DummyParsingHelper helper = new DummyParsingHelper(); protected static final String EOL = System.lineSeparator(); - @TempDir - private Path tempDir; + @TempDir private Path tempDir; abstract Renderer getRenderer(); @@ -81,10 +79,9 @@ String getSourceCodeFilename() { return "notAvailable.ext"; } - @Test - void testNullPassedIn() throws Exception { + @Test void testNullPassedIn() throws Exception { assertThrows(NullPointerException.class, () -> - getRenderer().renderFileReport(null)); + getRenderer().renderFileReport(null)); } protected Consumer reportOneViolation() { @@ -146,8 +143,7 @@ protected String readFile(String relativePath) { } } - @Test - void testRuleWithProperties() throws Exception { + @Test void testRuleWithProperties() throws Exception { RuleWithProperties theRule = new RuleWithProperties(); theRule.setProperty(RuleWithProperties.STRING_PROPERTY_DESCRIPTOR, "the string value\nsecond line with \"quotes\""); @@ -156,8 +152,7 @@ void testRuleWithProperties() throws Exception { assertEquals(filter(getExpectedWithProperties()), filter(rendered)); } - @Test - void testRenderer() throws Exception { + @Test void testRenderer() throws Exception { testRenderer(Charset.defaultCharset()); } @@ -166,27 +161,24 @@ protected void testRenderer(Charset expectedCharset) throws Exception { assertEquals(filter(getExpected()), filter(actual)); } - @Test - void testRendererEmpty() throws Exception { - String actual = render(it -> {}); + @Test void testRendererEmpty() throws Exception { + String actual = render(it -> { + }); assertEquals(filter(getExpectedEmpty()), filter(actual)); } - @Test - void testRendererMultiple() throws Exception { + @Test void testRendererMultiple() throws Exception { String actual = render(reportTwoViolations()); assertEquals(filter(getExpectedMultiple()), filter(actual)); } - @Test - void testError() throws Exception { + @Test void testError() throws Exception { Report.ProcessingError err = new Report.ProcessingError(new RuntimeException("Error"), FileId.fromPathLikeString("file")); String actual = render(it -> it.onError(err)); assertEquals(filter(getExpectedError(err)), filter(actual)); } - @Test - void testErrorWithoutMessage() throws Exception { + @Test void testErrorWithoutMessage() throws Exception { Report.ProcessingError err = new Report.ProcessingError(new NullPointerException(), FileId.fromPathLikeString("file")); String actual = render(it -> it.onError(err)); assertEquals(filter(getExpectedErrorWithoutMessage(err)), filter(actual)); @@ -196,8 +188,7 @@ private String render(Consumer listenerEffects) throws IOE return renderReport(getRenderer(), listenerEffects); } - @Test - void testConfigError() throws Exception { + @Test void testConfigError() throws Exception { Report.ConfigurationError err = new Report.ConfigurationError(new FooRule(), "a configuration error"); String actual = renderGlobal(getRenderer(), it -> it.onConfigError(err)); assertEquals(filter(getExpectedError(err)), filter(actual)); @@ -208,7 +199,7 @@ protected String renderReport(Renderer renderer, Consumer listenerEffects, - Charset expectedEncoding) throws IOException { + Charset expectedEncoding) throws IOException { return renderGlobal(renderer, globalListener -> { LanguageVersion version = DummyLanguageModule.getInstance().getDefaultVersion(); @@ -226,7 +217,7 @@ private String renderGlobal(Renderer renderer, Consumer listenerEffects, - Charset expectedEncoding) throws IOException { + Charset expectedEncoding) throws IOException { File file = tempDir.resolve("report.out").toFile(); renderer.setReportFile(file.getAbsolutePath()); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java index 644a3de23e4..42ad4472cb2 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CSVRendererTest.java @@ -9,36 +9,30 @@ class CSVRendererTest extends AbstractRendererTest { - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { return new CSVRenderer(); } - @Override - String getExpected() { + @Override String getExpected() { return getHeader() + "\"1\",\"\",\"" + getSourceCodeFilename() + "\",\"5\",\"1\",\"blah\",\"RuleSet\",\"Foo\"" + EOL; } - @Override - String getExpectedEmpty() { + @Override String getExpectedEmpty() { return getHeader(); } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return getHeader() + "\"1\",\"\",\"" + getSourceCodeFilename() + "\",\"5\",\"1\",\"blah\",\"RuleSet\",\"Foo\"" + EOL + "\"2\",\"\",\"" + getSourceCodeFilename() + "\",\"1\",\"1\",\"blah\",\"RuleSet\",\"Boo\"" + EOL; } - @Override - String getExpectedError(ProcessingError error) { + @Override String getExpectedError(ProcessingError error) { return getHeader(); } - @Override - String getExpectedError(ConfigurationError error) { + @Override String getExpectedError(ConfigurationError error) { return getHeader(); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java index 293daca9b38..2ca7a4478b8 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/CodeClimateRendererTest.java @@ -16,13 +16,11 @@ class CodeClimateRendererTest extends AbstractRendererTest { private static final String VERSION_PART = PMDVersion.isUnknown() || PMDVersion.isSnapshot() ? "latest" : "pmd-doc-" + PMDVersion.VERSION; - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { return new CodeClimateRenderer(); } - @Override - String getExpected() { + @Override String getExpected() { return "{\"type\":\"issue\",\"check_name\":\"Foo\",\"description\":\"blah\"," + "\"content\":{\"body\":\"## Foo\\n\\nSince: PMD null\\n\\nPriority: Low\\n\\n" + "[Categories](https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#categories): Style\\n\\n" @@ -36,8 +34,7 @@ String getExpected() { + "\u0000" + EOL; } - @Override - String getExpectedWithProperties() { + @Override String getExpectedWithProperties() { return "{\"type\":\"issue\",\"check_name\":\"Foo\",\"description\":\"blah\"," + "\"content\":{\"body\":\"## Foo\\n\\nSince: PMD null\\n\\nPriority: Low\\n\\n" + "[Categories](https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#categories): Style\\n\\n" @@ -53,13 +50,11 @@ String getExpectedWithProperties() { + "\u0000" + EOL; } - @Override - String getExpectedEmpty() { + @Override String getExpectedEmpty() { return ""; } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return "{\"type\":\"issue\",\"check_name\":\"Foo\",\"description\":\"blah\"," + "\"content\":{\"body\":\"## Foo\\n\\nSince: PMD null\\n\\nPriority: Low\\n\\n" + "[Categories](https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#categories): Style\\n\\n" @@ -83,8 +78,7 @@ String getExpectedMultiple() { + "\u0000" + EOL; } - @Test - void testXPathRule() throws Exception { + @Test void testXPathRule() throws Exception { FileLocation node = createLocation(1, 1, 1, 1); XPathRule theRule = new XPathRule(XPathVersion.XPATH_3_1, "//dummyNode"); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/EmacsRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/EmacsRendererTest.java index cb65d9fa17b..60323f38587 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/EmacsRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/EmacsRendererTest.java @@ -6,23 +6,19 @@ class EmacsRendererTest extends AbstractRendererTest { - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { return new EmacsRenderer(); } - @Override - String getExpected() { + @Override String getExpected() { return getSourceCodeFilename() + ":1: blah" + EOL; } - @Override - String getExpectedEmpty() { + @Override String getExpectedEmpty() { return ""; } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return getSourceCodeFilename() + ":1: blah" + EOL + getSourceCodeFilename() + ":1: blah" + EOL; } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/EmptyRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/EmptyRendererTest.java index 778c070b4ab..0aa9fa7f857 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/EmptyRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/EmptyRendererTest.java @@ -6,29 +6,24 @@ class EmptyRendererTest extends AbstractRendererTest { - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { return new EmptyRenderer(); } - @Override - void testNullPassedIn() throws Exception { + @Override void testNullPassedIn() throws Exception { // Overriding test from the super class, this renderer doesn't care, so no NPE. getRenderer().renderFileReport(null); } - @Override - String getExpected() { + @Override String getExpected() { return ""; } - @Override - String getExpectedEmpty() { + @Override String getExpectedEmpty() { return ""; } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return ""; } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/HTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/HTMLRendererTest.java index 669faa13372..61d9cd72af7 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/HTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/HTMLRendererTest.java @@ -16,8 +16,7 @@ class HTMLRendererTest extends AbstractRendererTest { - @Override - protected String getSourceCodeFilename() { + @Override protected String getSourceCodeFilename() { // note: the file name should still be a valid file name on both win and nix. // This precludes using chars like <> to test escaping (https://stackoverflow.com/questions/1976007/what-characters-are-forbidden-in-windows-and-linux-directory-names) return "someFilename\u00A0thatNeedsEscaping.ext"; @@ -27,13 +26,11 @@ private String getEscapedFilename() { return "someFilename thatNeedsEscaping.ext"; } - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { return new HTMLRenderer(); } - @Override - String getExpected() { + @Override String getExpected() { return getExpected(null, null); } @@ -49,14 +46,12 @@ private String getExpected(String linkPrefix, String lineAnchor) { + "blah" + EOL + "" + EOL + "" + EOL; } - @Override - String getExpectedEmpty() { + @Override String getExpectedEmpty() { return getHeader() + "" + EOL; } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return getHeader() + " " + EOL + "1" + EOL + "" + getEscapedFilename() + "" + EOL + "1" + EOL @@ -66,8 +61,7 @@ String getExpectedMultiple() { + EOL + "" + EOL; } - @Override - String getExpectedError(ProcessingError error) { + @Override String getExpectedError(ProcessingError error) { return getHeader() + "

    Processing errors

    " + EOL + "" + EOL + " " + EOL @@ -75,8 +69,7 @@ String getExpectedError(ProcessingError error) { + EOL; } - @Override - String getExpectedError(ConfigurationError error) { + @Override String getExpectedError(ConfigurationError error) { return getHeader() + "
    FileProblem

    Configuration errors

    " + EOL + "" + EOL + " " + EOL @@ -90,8 +83,7 @@ private String getHeader() { + EOL + "" + EOL; } - @Test - void testLinkPrefix() throws IOException { + @Test void testLinkPrefix() throws IOException { final HTMLRenderer renderer = new HTMLRenderer(); final String linkPrefix = "https://github.com/pmd/pmd/blob/main/"; final String linePrefix = "L"; @@ -103,8 +95,7 @@ void testLinkPrefix() throws IOException { assertEquals(filter(getExpected(linkPrefix, "L1")), filter(actual)); } - @Test - void testLinePrefixNotSet() throws IOException { + @Test void testLinePrefixNotSet() throws IOException { final HTMLRenderer renderer = new HTMLRenderer(); final String linkPrefix = "https://github.com/pmd/pmd/blob/main/"; renderer.setProperty(HTMLRenderer.LINK_PREFIX, linkPrefix); @@ -115,8 +106,7 @@ void testLinePrefixNotSet() throws IOException { assertEquals(filter(getExpected(linkPrefix, "")), filter(actual)); } - @Test - void testEmptyLinePrefix() throws IOException { + @Test void testEmptyLinePrefix() throws IOException { final HTMLRenderer renderer = new HTMLRenderer(); final String linkPrefix = "https://github.com/pmd/pmd/blob/main/"; renderer.setProperty(HTMLRenderer.LINK_PREFIX, linkPrefix); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/IDEAJRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/IDEAJRendererTest.java index 8a97b526950..a577def2de4 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/IDEAJRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/IDEAJRendererTest.java @@ -6,8 +6,7 @@ class IDEAJRendererTest extends AbstractRendererTest { - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { Renderer result = new IDEAJRenderer(); result.setProperty(IDEAJRenderer.SOURCE_PATH, ""); result.setProperty(IDEAJRenderer.CLASS_AND_METHOD_NAME, "Foo "); @@ -15,18 +14,15 @@ Renderer getRenderer() { return result; } - @Override - String getExpected() { + @Override String getExpected() { return "blah" + EOL + " at Foo (Foo.java:1)" + EOL; } - @Override - String getExpectedEmpty() { + @Override String getExpectedEmpty() { return ""; } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return "blah" + EOL + " at Foo (Foo.java:1)" + EOL + "blah" + EOL + " at Foo (Foo.java:1)" + EOL; } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/JsonRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/JsonRendererTest.java index dd5945d36b2..b9f9b38ce60 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/JsonRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/JsonRendererTest.java @@ -19,28 +19,23 @@ class JsonRendererTest extends AbstractRendererTest { - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { return new JsonRenderer(); } - @Override - String getExpected() { + @Override String getExpected() { return readFile("expected.json"); } - @Override - String getExpectedEmpty() { + @Override String getExpectedEmpty() { return readFile("empty.json"); } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return readFile("expected-multiple.json"); } - @Override - String getExpectedError(ProcessingError error) { + @Override String getExpectedError(ProcessingError error) { String expected = readFile("expected-processingerror.json"); expected = expected.replace("###REPLACE_ME###", error.getDetail() .replaceAll("\r", "\\\\r") @@ -49,13 +44,11 @@ String getExpectedError(ProcessingError error) { return expected; } - @Override - String getExpectedError(ConfigurationError error) { + @Override String getExpectedError(ConfigurationError error) { return readFile("expected-configurationerror.json"); } - @Override - String getExpectedErrorWithoutMessage(ProcessingError error) { + @Override String getExpectedErrorWithoutMessage(ProcessingError error) { String expected = readFile("expected-processingerror-no-message.json"); expected = expected.replace("###REPLACE_ME###", error.getDetail() .replaceAll("\r", "\\\\r") @@ -64,25 +57,22 @@ String getExpectedErrorWithoutMessage(ProcessingError error) { return expected; } - @Override - protected String readFile(String relativePath) { + @Override protected String readFile(String relativePath) { return super.readFile("json/" + relativePath); } - @Override - String filter(String expected) { + @Override String filter(String expected) { return expected .replaceAll("\"timestamp\":\\s*\"[^\"]+\"", "\"timestamp\": \"--replaced--\"") .replaceAll("\"pmdVersion\":\\s*\"[^\"]+\"", "\"pmdVersion\": \"unknown\"") .replaceAll("\\R", "\n"); // make the test run on Windows, too } - @Test - void suppressedViolations() throws IOException { + @Test void suppressedViolations() throws IOException { SuppressedViolation suppressed = new SuppressedViolation( - newRuleViolation(1, 1, 1, 1, new FooRule()), - ViolationSuppressor.NOPMD_COMMENT_SUPPRESSOR, - "test" + newRuleViolation(1, 1, 1, 1, new FooRule()), + ViolationSuppressor.NOPMD_COMMENT_SUPPRESSOR, + "test" ); String actual = renderReport(getRenderer(), it -> it.onSuppressedRuleViolation(suppressed)); String expected = readFile("expected-suppressed.json"); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/RenderersTests.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/RenderersTests.java index 46443e82eb0..7a2546acc25 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/RenderersTests.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/RenderersTests.java @@ -14,21 +14,21 @@ */ @Suite @SelectClasses({ - CodeClimateRendererTest.class, - CSVRendererTest.class, - EmacsRendererTest.class, - HTMLRendererTest.class, - IDEAJRendererTest.class, - JsonRendererTest.class, - TextColorRendererTest.class, - SarifRendererTest.class, - SummaryHTMLRendererTest.class, - TextPadRendererTest.class, - TextRendererTest.class, - VBHTMLRendererTest.class, - XMLRendererTest.class, - XSLTRendererTest.class, - YAHTMLRendererTest.class + CodeClimateRendererTest.class, + CSVRendererTest.class, + EmacsRendererTest.class, + HTMLRendererTest.class, + IDEAJRendererTest.class, + JsonRendererTest.class, + TextColorRendererTest.class, + SarifRendererTest.class, + SummaryHTMLRendererTest.class, + TextPadRendererTest.class, + TextRendererTest.class, + VBHTMLRendererTest.class, + XMLRendererTest.class, + XSLTRendererTest.class, + YAHTMLRendererTest.class }) class RenderersTests { } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java index 87a17197b48..1711f0827f9 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SarifRendererTest.java @@ -22,36 +22,30 @@ class SarifRendererTest extends AbstractRendererTest { - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { return new SarifRenderer(); } - @Test - void testRendererWithASCII() throws Exception { + @Test void testRendererWithASCII() throws Exception { SystemLambda.restoreSystemProperties(() -> { System.setProperty("file.encoding", StandardCharsets.US_ASCII.name()); testRenderer(StandardCharsets.UTF_8); }); } - @Override - String getExpected() { + @Override String getExpected() { return readFile("expected.sarif.json"); } - @Override - String getExpectedEmpty() { + @Override String getExpectedEmpty() { return readFile("empty.sarif.json"); } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return readFile("expected-multiple.sarif.json"); } - @Override - String getExpectedError(Report.ProcessingError error) { + @Override String getExpectedError(Report.ProcessingError error) { String expected = readFile("expected-error.sarif.json"); expected = expected.replace("###REPLACE_ME###", error.getDetail() .replaceAll("\r", "\\\\r") @@ -60,13 +54,11 @@ String getExpectedError(Report.ProcessingError error) { return expected; } - @Override - String getExpectedError(Report.ConfigurationError error) { + @Override String getExpectedError(Report.ConfigurationError error) { return readFile("expected-configerror.sarif.json"); } - @Override - String getExpectedErrorWithoutMessage(Report.ProcessingError error) { + @Override String getExpectedErrorWithoutMessage(Report.ProcessingError error) { String expected = readFile("expected-error-nomessage.sarif.json"); expected = expected.replace("###REPLACE_ME###", error.getDetail() .replaceAll("\r", "\\\\r") @@ -75,8 +67,7 @@ String getExpectedErrorWithoutMessage(Report.ProcessingError error) { return expected; } - @Override - String filter(String expected) { + @Override String filter(String expected) { return expected.replaceAll("\r\n", "\n") // make the test run on Windows, too .replaceAll("\"version\": \".+\",", "\"version\": \"unknown\","); } @@ -87,8 +78,7 @@ String filter(String expected) { * @see [core] SARIF formatter reports multiple locations * when it should report multiple results #3768 */ - @Test - void testRendererMultipleLocations() throws Exception { + @Test void testRendererMultipleLocations() throws Exception { String actual = renderReport(getRenderer(), reportThreeViolationsTwoRules()); Gson gson = new Gson(); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java index 28a91e9c834..757c142703f 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/SummaryHTMLRendererTest.java @@ -22,8 +22,7 @@ class SummaryHTMLRendererTest extends AbstractRendererTest { - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { Renderer result = new SummaryHTMLRenderer(); result.setProperty(HTMLRenderer.LINK_PREFIX, "link_prefix"); result.setProperty(HTMLRenderer.LINE_PREFIX, Optional.of("line_prefix")); @@ -31,13 +30,11 @@ Renderer getRenderer() { return result; } - @Override - protected String getSourceCodeFilename() { + @Override protected String getSourceCodeFilename() { return "notAvailable"; } - @Override - String getExpected() { + @Override String getExpected() { return "PMD" + EOL + "

    Summary

    " + EOL + "
    RuleProblem
    #FileLineProblem
    " + EOL + "" + EOL @@ -53,8 +50,7 @@ String getExpected() { } - @Override - String getExpectedEmpty() { + @Override String getExpectedEmpty() { return "PMD" + EOL + "

    Summary

    " + EOL + "
    Rule nameNumber of violations
    " + EOL + "" + EOL + "
    Rule nameNumber of violations
    " + EOL @@ -65,8 +61,7 @@ String getExpectedEmpty() { + "" + EOL; } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return "PMD" + EOL + "

    Summary

    " + EOL + "" + EOL + "" + EOL @@ -85,8 +80,7 @@ String getExpectedMultiple() { + EOL + "
    Rule nameNumber of violations
    " + EOL; } - @Override - String getExpectedError(ProcessingError error) { + @Override String getExpectedError(ProcessingError error) { return "PMD" + EOL + "

    Summary

    " + EOL + "" + EOL + "" + EOL + "
    Rule nameNumber of violations
    " + EOL @@ -100,8 +94,7 @@ String getExpectedError(ProcessingError error) { + "" + EOL; } - @Override - String getExpectedError(ConfigurationError error) { + @Override String getExpectedError(ConfigurationError error) { return "PMD" + EOL + "

    Summary

    " + EOL + "" + EOL + "" + EOL + "
    Rule nameNumber of violations
    " + EOL @@ -115,8 +108,7 @@ String getExpectedError(ConfigurationError error) { + "" + EOL; } - @Test - void testShowSuppressions() throws Exception { + @Test void testShowSuppressions() throws Exception { Renderer renderer = getRenderer(); renderer.setShowSuppressedViolations(true); String actual = renderReport(renderer, createEmptyReportWithSuppression()); @@ -129,15 +121,14 @@ void testShowSuppressions() throws Exception { + EOL + "#FileLineProblem" + EOL + "

    Suppressed warnings

    " + EOL + "" - + EOL + " " + EOL + "" + EOL + + EOL + " " + EOL + "" + EOL + "" + EOL + "" + EOL - + "" + EOL + "" + EOL - + "" + + "" + EOL + "" + EOL + + "" + EOL + "
    FileLineRuleNOPMD or AnnotationReason
    " + getSourceCodeFilename() + "
    " + getSourceCodeFilename() + "1Foo//NOPMDtest
    //NOPMDtest
    " + EOL, actual); } - @Test - void testHideSuppressions() throws Exception { + @Test void testHideSuppressions() throws Exception { Renderer renderer = getRenderer(); renderer.setShowSuppressedViolations(false); String actual = renderReport(renderer, createEmptyReportWithSuppression()); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextColorRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextColorRendererTest.java index 9514bbfc553..86d67ed538b 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextColorRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextColorRendererTest.java @@ -13,59 +13,53 @@ class TextColorRendererTest extends AbstractRendererTest { - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { TextColorRenderer result = new TextColorRenderer() { - @Override - protected Reader getReader(String sourceFile) throws FileNotFoundException { + @Override protected Reader getReader(String sourceFile) throws FileNotFoundException { return new StringReader("public class Foo {}"); } }; return result; } - @Override - String getExpected() { + @Override String getExpected() { return "\u001B[1;33m*\u001B[0m file: \u001B[1;37m" + getSourceCodeFilename() + "\u001B[0m" + EOL - + "\u001B[0;32m src: \u001B[0;36m" + getSourceCodeFilename() + "\u001B[0m:\u001B[0;36m1:1\u001B[0m" + EOL - + "\u001B[0;32m rule: \u001B[0mFoo" + EOL - + "\u001B[0;32m msg: \u001B[0mblah" + EOL - + "\u001B[0;32m code: \u001B[0mpublic class Foo {}" + EOL - + EOL - + EOL - + EOL - + "Summary:" + EOL - + EOL - + "\u001B[1;33m*\u001B[0m warnings: \u001B[1;37m1\u001B[0m" + EOL; + + "\u001B[0;32m src: \u001B[0;36m" + getSourceCodeFilename() + "\u001B[0m:\u001B[0;36m1:1\u001B[0m" + EOL + + "\u001B[0;32m rule: \u001B[0mFoo" + EOL + + "\u001B[0;32m msg: \u001B[0mblah" + EOL + + "\u001B[0;32m code: \u001B[0mpublic class Foo {}" + EOL + + EOL + + EOL + + EOL + + "Summary:" + EOL + + EOL + + "\u001B[1;33m*\u001B[0m warnings: \u001B[1;37m1\u001B[0m" + EOL; } - @Override - String getExpectedEmpty() { + @Override String getExpectedEmpty() { return EOL + EOL + "Summary:" + EOL + EOL + "\u001B[1;33m*\u001B[0m warnings: \u001B[1;37m0\u001B[0m" + EOL; } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return "\u001B[1;33m*\u001B[0m file: \u001B[1;37m" + getSourceCodeFilename() + "\u001B[0m" + EOL - + "\u001B[0;32m src: \u001B[0;36m" + getSourceCodeFilename() + "\u001B[0m:\u001B[0;36m1:1\u001B[0m" + EOL - + "\u001B[0;32m rule: \u001B[0mFoo" + EOL - + "\u001B[0;32m msg: \u001B[0mblah" + EOL - + "\u001B[0;32m code: \u001B[0mpublic class Foo {}" + EOL - + "" + EOL - + "\u001B[0;32m src: \u001B[0;36m" + getSourceCodeFilename() + "\u001B[0m:\u001B[0;36m1:1\u001B[0m" + EOL - + "\u001B[0;32m rule: \u001B[0mBoo" + EOL - + "\u001B[0;32m msg: \u001B[0mblah" + EOL - + "\u001B[0;32m code: \u001B[0mpublic class Foo {}" + EOL - + EOL - + EOL - + EOL - + "Summary:" + EOL - + EOL - + "\u001B[1;33m*\u001B[0m warnings: \u001B[1;37m2\u001B[0m" + EOL; + + "\u001B[0;32m src: \u001B[0;36m" + getSourceCodeFilename() + "\u001B[0m:\u001B[0;36m1:1\u001B[0m" + EOL + + "\u001B[0;32m rule: \u001B[0mFoo" + EOL + + "\u001B[0;32m msg: \u001B[0mblah" + EOL + + "\u001B[0;32m code: \u001B[0mpublic class Foo {}" + EOL + + "" + EOL + + "\u001B[0;32m src: \u001B[0;36m" + getSourceCodeFilename() + "\u001B[0m:\u001B[0;36m1:1\u001B[0m" + EOL + + "\u001B[0;32m rule: \u001B[0mBoo" + EOL + + "\u001B[0;32m msg: \u001B[0mblah" + EOL + + "\u001B[0;32m code: \u001B[0mpublic class Foo {}" + EOL + + EOL + + EOL + + EOL + + "Summary:" + EOL + + EOL + + "\u001B[1;33m*\u001B[0m warnings: \u001B[1;37m2\u001B[0m" + EOL; } - @Override - String getExpectedError(ProcessingError error) { + @Override String getExpectedError(ProcessingError error) { return EOL + EOL + "Summary:" + EOL + EOL + "\u001B[1;31m*\u001B[0m file: \u001B[1;37mfile\u001B[0m" + EOL + "\u001B[0;32m err: \u001B[0;36mRuntimeException: Error\u001B[0m" + EOL + "\u001B[0;31m" + error.getDetail() + "\u001B[0m" + EOL + EOL @@ -73,8 +67,7 @@ String getExpectedError(ProcessingError error) { + "\u001B[1;33m*\u001B[0m warnings: \u001B[1;37m0\u001B[0m" + EOL; } - @Override - String getExpectedErrorWithoutMessage(ProcessingError error) { + @Override String getExpectedErrorWithoutMessage(ProcessingError error) { return EOL + EOL + "Summary:" + EOL + EOL + "\u001B[1;31m*\u001B[0m file: \u001B[1;37mfile\u001B[0m" + EOL + "\u001B[0;32m err: \u001B[0;36mNullPointerException: null\u001B[0m" + EOL + "\u001B[0;31m" + error.getDetail() + "\u001B[0m" + EOL + EOL @@ -82,15 +75,14 @@ String getExpectedErrorWithoutMessage(ProcessingError error) { + "\u001B[1;33m*\u001B[0m warnings: \u001B[1;37m0\u001B[0m" + EOL; } - @Override - String getExpectedError(ConfigurationError error) { + @Override String getExpectedError(ConfigurationError error) { return EOL + EOL - + "Summary:" + EOL - + EOL - + "\u001B[1;31m*\u001B[0m rule: \u001B[1;37mFoo\u001B[0m" + EOL - + "\u001B[0;32m err: \u001B[0;36ma configuration error\u001B[0m" + EOL - + EOL - + "\u001B[1;31m*\u001B[0m errors: \u001B[1;37m1\u001B[0m" + EOL - + "\u001B[1;33m*\u001B[0m warnings: \u001B[1;37m0\u001B[0m" + EOL; + + "Summary:" + EOL + + EOL + + "\u001B[1;31m*\u001B[0m rule: \u001B[1;37mFoo\u001B[0m" + EOL + + "\u001B[0;32m err: \u001B[0;36ma configuration error\u001B[0m" + EOL + + EOL + + "\u001B[1;31m*\u001B[0m errors: \u001B[1;37m1\u001B[0m" + EOL + + "\u001B[1;33m*\u001B[0m warnings: \u001B[1;37m0\u001B[0m" + EOL; } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextPadRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextPadRendererTest.java index d5b2dc0a261..545d7229a6d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextPadRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextPadRendererTest.java @@ -6,23 +6,19 @@ class TextPadRendererTest extends AbstractRendererTest { - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { return new TextPadRenderer(); } - @Override - String getExpected() { + @Override String getExpected() { return getSourceCodeFilename() + "(1, Foo): blah" + EOL; } - @Override - String getExpectedEmpty() { + @Override String getExpectedEmpty() { return ""; } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return getSourceCodeFilename() + "(1, Foo): blah" + EOL + getSourceCodeFilename() + "(1, Boo): blah" + EOL; } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextRendererTest.java index 72c1d88c8d2..5a216a119ad 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/TextRendererTest.java @@ -9,39 +9,32 @@ class TextRendererTest extends AbstractRendererTest { - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { return new TextRenderer(); } - @Override - String getExpected() { + @Override String getExpected() { return getSourceCodeFilename() + ":1:\tFoo:\tblah" + EOL; } - @Override - String getExpectedEmpty() { + @Override String getExpectedEmpty() { return ""; } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return getSourceCodeFilename() + ":1:\tFoo:\tblah" + EOL + getSourceCodeFilename() + ":1:\tBoo:\tblah" + EOL; } - @Override - String getExpectedError(ProcessingError error) { + @Override String getExpectedError(ProcessingError error) { return "file\t-\tRuntimeException: Error" + EOL; } - @Override - String getExpectedErrorWithoutMessage(ProcessingError error) { + @Override String getExpectedErrorWithoutMessage(ProcessingError error) { return "file\t-\tNullPointerException: null" + EOL; } - @Override - String getExpectedError(ConfigurationError error) { + @Override String getExpectedError(ConfigurationError error) { return "Foo\t-\ta configuration error" + EOL; } } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java index e3f6f5155bd..4eca136508d 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/renderers/VBHTMLRendererTest.java @@ -9,13 +9,11 @@ class VBHTMLRendererTest extends AbstractRendererTest { - @Override - Renderer getRenderer() { + @Override Renderer getRenderer() { return new VBHTMLRenderer(); } - @Override - String getExpected() { + @Override String getExpected() { return "PMD

    " + EOL; } - @Override - String getExpectedMultiple() { + @Override String getExpectedMultiple() { return "PMD