diff --git a/Dangerfile b/Dangerfile index daba7c415c..aaa19c33bc 100644 --- a/Dangerfile +++ b/Dangerfile @@ -9,7 +9,7 @@ def run_pmdtester argv = ['-r', './pmd', '-b', "#{ENV['TRAVIS_BRANCH']}", '-p', 'FETCH_HEAD', '-m', 'online', '-a'] begin runner = PmdTester::Runner.new(argv) - @new_errors, @removed_errors, @new_violations, @removed_violations = runner.run + @new_errors, @removed_errors, @new_violations, @removed_violations, @new_configerrors, @removed_configerrors = runner.run upload_report rescue StandardError => e warn("Running pmdtester failed, this message is mainly used to remind the maintainers of PMD.") @@ -27,14 +27,17 @@ def upload_report end `tar -cf #{tar_filename} diff/` - report_url = `curl -u #{ENV['CHUNK_TOKEN']} -T #{tar_filename} chunk.io` - if $?.success? - @logger.info "Successfully uploaded #{tar_filename} to chunk.io" + report_url = `curl -u #{ENV['CHUNK_TOKEN']} -T #{tar_filename} chunk.io` + if $?.success? + @logger.info "Successfully uploaded #{tar_filename} to chunk.io" # set value of sticky to true and the message is kept after new commits are submited to the PR - message("This changeset introduces #{@new_violations} new violations and #{@new_errors} new errors,\n" + - "removes #{@removed_violations} violations and #{@removed_errors} errors. [Full report](#{report_url.chomp}/diff/index.html)", sticky: true) - else + message("This changeset introduces #{@new_violations} new violations, #{@new_errors} new errors and " + + "#{@new_configerrors} new configuration errors,\n" + + "removes #{@removed_violations} violations, #{@removed_errors} errors and " + + "#{@removed_configerrors} configuration errors.\n" + + "[Full report](#{report_url.chomp}/diff/index.html)", sticky: true) + else @logger.error "Error while uploading #{tar_filename} to chunk.io: #{report_url}" warn("Uploading the diff report failed, this message is mainly used to remind the maintainers of PMD.") end diff --git a/docs/_plugins/javadoc_tag.rb b/docs/_plugins/javadoc_tag.rb index 7bdf60560c..940c2826e2 100644 --- a/docs/_plugins/javadoc_tag.rb +++ b/docs/_plugins/javadoc_tag.rb @@ -97,7 +97,7 @@ class JavadocTag < Liquid::Tag QNAME_NO_NAMESPACE_REGEX = /((?:\w+\.)*\w+)/ ARG_REGEX = Regexp.new(Regexp.union(JDocNamespaceDeclaration::NAMESPACED_FQCN_REGEX, QNAME_NO_NAMESPACE_REGEX).source + '(\[\])*') - ARGUMENTS_REGEX = Regexp.new('\(\)|\((' + ARG_REGEX.source + "(?:," + ARG_REGEX.source + ")*" + ')\)') + ARGUMENTS_REGEX = Regexp.new('\(\)|\((' + ARG_REGEX.source + "(?:,(?:" + ARG_REGEX.source + "))*" + ')\)') def initialize(tag_name, doc_ref, tokens) diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 8eb3a646dc..2700c98ae5 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -18,6 +18,8 @@ This is a {{ site.pmd.release_type }} release. * The Apex language support has been bumped to version 45 (Spring '19). All new language features are now properly parsed and processed. +* Many nodes now expose more informations, such as the operator for BooleanExpressions. This makes these operators + consumable by XPath rules, e.g. `//BooleanExpression[@Operator='&&']`. #### New Rules @@ -57,6 +59,7 @@ This is a {{ site.pmd.release_type }} release. * apex * [#1542](https://github.com/pmd/pmd/pull/1542): \[apex] Include the documentation category * [#1546](https://github.com/pmd/pmd/issues/1546): \[apex] PMD parsing exception for Apex classes using 'inherited sharing' keyword + * [#1568](https://github.com/pmd/pmd/pull/1568): \[apex] AST node attribute @Image not usable / always null in XPath rule / Designer * cpp * [#1559](https://github.com/pmd/pmd/issues/1559): \[cpp] CPD: Lexical error in file (no file name provided) * java @@ -79,17 +82,18 @@ This is a {{ site.pmd.release_type }} release. * [#1508](https://github.com/pmd/pmd/issues/1508): \[plsql] Parse Exception when using SELECT COUNT(\*) * [#1509](https://github.com/pmd/pmd/issues/1509): \[plsql] Parse Exception with OUTER/INNER Joins * [#1511](https://github.com/pmd/pmd/issues/1511): \[plsql] Parse Exception with IS NOT NULL + * [#1583](https://github.com/pmd/pmd/issues/1583): \[plsql] Update Set Clause should allow multiple columns + * [#1586](https://github.com/pmd/pmd/issues/1586): \[plsql] Parse Exception when functions are used with LIKE ### API Changes -#### Deprecated API - * {% jdoc core::lang.rule.stat.StatisticalRule %} and the related helper classes and base rule classes are deprecated for removal in 7.0.0. This includes all of {% jdoc_package core::stat %} and {% jdoc_package core::lang.rule.stat %}, and also {% jdoc java::lang.java.rule.AbstractStatisticalJavaRule %}, {% jdoc apex::lang.apex.rule.AbstractStatisticalApexRule %} and the like. The methods {% jdoc !c!core::Report#addMetric(core::stat.Metric) %} and {% jdoc core::ThreadSafeReportListener#metricAdded(core::stat.Metric) %} will also be removed. - +* {% jdoc core::properties.PropertySource#setProperty(core::properties.MultiValuePropertyDescriptor, Object[]) %} is deprecated, +because {% jdoc core::properties.MultiValuePropertyDescriptor %} is deprecated as well ### External Contributions @@ -104,6 +108,7 @@ will also be removed. * [#1551](https://github.com/pmd/pmd/pull/1551): \[java] InvalidSlf4jMessageFormatRule should not throw NPE for enums - [Robbie Martinus](https://github.com/rmartinus) * [#1552](https://github.com/pmd/pmd/pull/1552): \[core] Upgrading Google Gson from 2.5 to 2.8.5 - [Thunderforge](https://github.com/Thunderforge) * [#1553](https://github.com/pmd/pmd/pull/1553): \[core] Upgrading System Rules dependency from 1.8.0 to 1.19.0 - [Thunderforge](https://github.com/Thunderforge) +* [#1554](https://github.com/pmd/pmd/pull/1554): \[plsql] updates should allow for multiple statements - [tashiscool](https://github.com/tashiscool) * [#1584](https://github.com/pmd/pmd/pull/1584): \[core] Fixes 1196: inconsistencies of clones returned by different CPD executions for the same files - [Bruno Ferreira](https://github.com/bmbferreira) {% endtocmaker %} 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 29f466692b..de3531be71 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 @@ -4,6 +4,7 @@ package net.sourceforge.pmd.lang.apex.ast; +import apex.jorje.data.ast.AssignmentOp; import apex.jorje.semantic.ast.expression.AssignmentExpression; public class ASTAssignmentExpression extends AbstractApexNode { @@ -16,4 +17,8 @@ public class ASTAssignmentExpression extends AbstractApexNode { @@ -16,4 +17,8 @@ public class ASTBinaryExpression extends AbstractApexNode { public Object jjtAccept(ApexParserVisitor visitor, Object data) { return visitor.visit(this, data); } + + public BinaryOp getOperator() { + return node.getOp(); + } } 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 f2e44dbc4a..efd46f2a2b 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 @@ -4,16 +4,25 @@ package net.sourceforge.pmd.lang.apex.ast; +import apex.jorje.data.ast.BooleanOp; import apex.jorje.semantic.ast.expression.BooleanExpression; + public class ASTBooleanExpression extends AbstractApexNode { public ASTBooleanExpression(BooleanExpression booleanExpression) { super(booleanExpression); } + @Override public Object jjtAccept(ApexParserVisitor visitor, Object data) { return visitor.visit(this, data); } + + + public BooleanOp getOperator() { + return this.node.getOp(); + } + } 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 19e7440fac..35b04e7d37 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 @@ -4,16 +4,24 @@ package net.sourceforge.pmd.lang.apex.ast; +import apex.jorje.data.ast.LiteralType; import apex.jorje.semantic.ast.expression.LiteralExpression; + public class ASTLiteralExpression extends AbstractApexNode { public ASTLiteralExpression(LiteralExpression literalExpression) { super(literalExpression); } + @Override public Object jjtAccept(ApexParserVisitor visitor, Object data) { return visitor.visit(this, data); } + + + public LiteralType getLiteralType() { + return node.getLiteralType(); + } } 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 4d2bd2b017..5a760da8b2 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 @@ -4,16 +4,24 @@ package net.sourceforge.pmd.lang.apex.ast; +import apex.jorje.data.ast.PostfixOp; import apex.jorje.semantic.ast.expression.PostfixExpression; + public class ASTPostfixExpression extends AbstractApexNode { public ASTPostfixExpression(PostfixExpression postfixExpression) { super(postfixExpression); } + @Override public Object jjtAccept(ApexParserVisitor visitor, Object data) { return visitor.visit(this, data); } + + + public PostfixOp getOperator() { + return node.getOp(); + } } 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 11db2fb4a3..4dd4a20cde 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 @@ -4,6 +4,7 @@ package net.sourceforge.pmd.lang.apex.ast; +import apex.jorje.data.ast.PrefixOp; import apex.jorje.semantic.ast.expression.PrefixExpression; public class ASTPrefixExpression extends AbstractApexNode { @@ -16,4 +17,10 @@ public class ASTPrefixExpression extends AbstractApexNode { public Object jjtAccept(ApexParserVisitor visitor, Object data) { return visitor.visit(this, data); } + + + public PrefixOp getOperator() { + return node.getOp(); + } + } 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 32e91d26bb..ef3db237a3 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 @@ -4,7 +4,10 @@ package net.sourceforge.pmd.lang.apex.ast; +import apex.jorje.semantic.ast.expression.IdentifierContext; import apex.jorje.semantic.ast.expression.ReferenceExpression; +import apex.jorje.semantic.ast.expression.ReferenceType; + public class ASTReferenceExpression extends AbstractApexNode { @@ -12,8 +15,19 @@ public class ASTReferenceExpression extends AbstractApexNode extends AbstractApexNo protected final T node; - public AbstractApexNode(T node) { + protected AbstractApexNode(T node) { super(node.getClass()); this.node = node; } diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserXPathTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserXPathTest.java new file mode 100644 index 0000000000..a7b1f2012d --- /dev/null +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/ast/ApexParserXPathTest.java @@ -0,0 +1,35 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.apex.ast; + +import static net.sourceforge.pmd.lang.apex.ast.ApexParserTestHelpers.parse; + +import java.nio.charset.StandardCharsets; +import java.util.List; + +import org.apache.commons.io.IOUtils; +import org.junit.Assert; +import org.junit.Test; + +import net.sourceforge.pmd.lang.ast.Node; + +import apex.jorje.semantic.ast.compilation.Compilation; + +public class ApexParserXPathTest { + + @Test + public void testBooleanExpressions() throws Exception { + ApexNode node = parse(IOUtils.toString(ApexParserXPathTest.class.getResourceAsStream("BooleanExpressions.cls"), + StandardCharsets.UTF_8)); + List booleanExpressions = node.findDescendantsOfType(ASTBooleanExpression.class); + Assert.assertEquals(2, booleanExpressions.size()); + Assert.assertEquals("&&", booleanExpressions.get(0).getOperator().toString()); + Assert.assertEquals("!=", booleanExpressions.get(1).getOperator().toString()); + + List xpathResult = node.findChildNodesWithXPath("//BooleanExpression[@Operator='&&']"); + Assert.assertEquals(1, xpathResult.size()); + Assert.assertSame(booleanExpressions.get(0), xpathResult.get(0)); + } +} diff --git a/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/ast/BooleanExpressions.cls b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/ast/BooleanExpressions.cls new file mode 100644 index 0000000000..d70885a456 --- /dev/null +++ b/pmd-apex/src/test/resources/net/sourceforge/pmd/lang/apex/ast/BooleanExpressions.cls @@ -0,0 +1,9 @@ +// See https://github.com/pmd/pmd/issues/1568 + +class MyApexClass { + void bar(){ + if(!alist.isEmpty() && alist != null) { + foo(); + } + } +} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IteratorUtil.java b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IteratorUtil.java new file mode 100644 index 0000000000..b7ae345175 --- /dev/null +++ b/pmd-core/src/main/java/net/sourceforge/pmd/internal/util/IteratorUtil.java @@ -0,0 +1,49 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.internal.util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + + +/** + * @author Clément Fournier + * @since 6.11.0 + */ +public final class IteratorUtil { + + private IteratorUtil() { + + } + + + public static Iterator reverse(Iterator it) { + List tmp = toList(it); + Collections.reverse(tmp); + return tmp.iterator(); + } + + + public static List toList(Iterator it) { + List list = new ArrayList<>(); + while (it.hasNext()) { + list.add(it.next()); + } + return list; + } + + + public static Iterable toIterable(final Iterator it) { + return new Iterable() { + @Override + public Iterator iterator() { + return it; + } + }; + } + +} diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/Attribute.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/Attribute.java index 6f57f00dab..ef05342008 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/Attribute.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/Attribute.java @@ -6,6 +6,7 @@ package net.sourceforge.pmd.lang.ast.xpath; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.logging.Level; @@ -18,6 +19,9 @@ import net.sourceforge.pmd.lang.ast.Node; * Attributes know their name, the node they wrap, * and have access to their value. * + *

Two attributes are equal if they have the same name + * and their parent nodes are equal. + * * @author daniels */ public class Attribute { @@ -28,8 +32,8 @@ public class Attribute { private static final Object[] EMPTY_OBJ_ARRAY = new Object[0]; - private Node parent; - private String name; + private final Node parent; + private final String name; private Method method; private Object value; private String stringValue; @@ -41,7 +45,6 @@ public class Attribute { this.method = m; } - /** Creates a new attribute belonging to the given node using its string value. */ public Attribute(Node parent, String name, String value) { this.parent = parent; @@ -93,12 +96,33 @@ public class Attribute { return stringValue; } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Attribute attribute = (Attribute) o; + return Objects.equals(parent, attribute.parent) + && Objects.equals(name, attribute.name); + } + + + @Override + public int hashCode() { + return Objects.hash(parent, name); + } + + private String getLoggableAttributeName() { return parent.getXPathNodeName() + "/@" + name; } @Override public String toString() { - return name + ':' + getValue() + ':' + parent; + return name + ':' + getValue() + ':' + parent.getXPathNodeName(); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.java index 75807ecd71..13397c16e1 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.java @@ -69,7 +69,6 @@ public class AttributeAxisIterator implements Iterator { this.currObj = getNextAttribute(); } - /** * Returns whether the given method is an attribute accessor, * in which case a corresponding Attribute will be added to @@ -80,12 +79,16 @@ public class AttributeAxisIterator implements Iterator { protected boolean isAttributeAccessor(Method method) { String methodName = method.getName(); - return CONSIDERED_RETURN_TYPES.contains(method.getReturnType()) + return isConsideredReturnType(method.getReturnType()) && method.getParameterTypes().length == 0 && !methodName.startsWith("jjt") && !FILTERED_OUT_NAMES.contains(methodName); } + private boolean isConsideredReturnType(Class klass) { + return CONSIDERED_RETURN_TYPES.contains(klass) || klass.isEnum(); + } + @Override public Attribute next() { diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/SaxonXPathRuleQuery.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/SaxonXPathRuleQuery.java index ddbe17615b..b369007c68 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/SaxonXPathRuleQuery.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/rule/xpath/SaxonXPathRuleQuery.java @@ -236,7 +236,9 @@ public class SaxonXPathRuleQuery extends AbstractXPathRuleQuery { */ if (value == null) { return UntypedAtomicValue.ZERO_LENGTH_UNTYPED; - + } else if (value instanceof Enum) { + // enums use their toString + return new StringValue(value.toString()); } else if (value instanceof String) { return new StringValue((String) value); } else if (value instanceof Boolean) { 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 386837f0a9..71463940cf 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 @@ -164,6 +164,7 @@ public abstract class AbstractPropertySource implements PropertySource { @Override + @Deprecated public void setProperty(MultiValuePropertyDescriptor propertyDescriptor, V... values) { checkValidPropertyDescriptor(propertyDescriptor); propertyValuesByDescriptor.put(propertyDescriptor, Collections.unmodifiableList(Arrays.asList(values))); diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertySource.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertySource.java index 7b24644164..7a516714bd 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertySource.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertySource.java @@ -112,7 +112,10 @@ public interface PropertySource { * @param propertyDescriptor The property descriptor for which to add a value * @param values Values * @param The type of the values + * + * @deprecated {@link MultiValuePropertyDescriptor} is deprecated */ + @Deprecated void setProperty(MultiValuePropertyDescriptor propertyDescriptor, V... values); diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIteratorTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIteratorTest.java index e8326ca32d..4827e8f544 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIteratorTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIteratorTest.java @@ -6,6 +6,7 @@ package net.sourceforge.pmd.lang.ast.xpath; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.HashMap; @@ -52,6 +53,17 @@ public class AttributeAxisIteratorTest { assertTrue(atts.containsKey("EndLine")); } + @Test + public void testAttributeAxisIteratorWithEnum() { + DummyNodeWithEnum dummyNode = new DummyNodeWithEnum(1); + + AttributeAxisIterator it = new AttributeAxisIterator(dummyNode); + Map atts = toMap(it); + Assert.assertEquals(8, atts.size()); + assertTrue(atts.containsKey("Enum")); + assertEquals(DummyNodeWithEnum.MyEnum.FOO, atts.get("Enum").getValue()); + } + private Map toMap(AttributeAxisIterator it) { Map atts = new HashMap<>(); @@ -61,4 +73,19 @@ public class AttributeAxisIteratorTest { } return atts; } + + public static class DummyNodeWithEnum extends DummyNode { + + public DummyNodeWithEnum(int id) { + super(id); + } + + public enum MyEnum { + FOO, BAR + } + + public MyEnum getEnum() { + return MyEnum.FOO; + } + } } diff --git a/pmd-plsql/etc/grammar/PldocAST.jjt b/pmd-plsql/etc/grammar/PldocAST.jjt index eb0b20cfce..066a9eab8a 100644 --- a/pmd-plsql/etc/grammar/PldocAST.jjt +++ b/pmd-plsql/etc/grammar/PldocAST.jjt @@ -91,9 +91,9 @@ options { CACHE_TOKENS = true; - MULTI = true; + MULTI = true; VISITOR = true; - NODE_USES_PARSER = true; + NODE_USES_PARSER = true; NODE_PACKAGE="net.sourceforge.pmd.lang.plsql.ast"; NODE_CLASS = "net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode"; } @@ -153,7 +153,7 @@ public class PLSQLParser { */ public static String canonicalName(String name) { - StringBuilder s = null ; + StringBuilder s = null ; if (null == name) { @@ -181,9 +181,9 @@ public class PLSQLParser { } else { - s.append( quotedCharacter - ? s.charAt(i) - : Character.toUpperCase(s.charAt(i)) + s.append( quotedCharacter + ? s.charAt(i) + : Character.toUpperCase(s.charAt(i)) ); } } @@ -207,88 +207,88 @@ ASTInput Input() : {} { // SRT 2011-04-17 This syntax breaks the parser when fields of record.attach* are referenced (attachLibrary())* ( - (LOOKAHEAD(7) PackageSpecification() - | LOOKAHEAD(7) PackageBody() - | LOOKAHEAD(6) TypeSpecification() - | LOOKAHEAD(6) Table() - | LOOKAHEAD(6) View() - | LOOKAHEAD(6) TriggerUnit() - | LOOKAHEAD(6) AlterTrigger() - | LOOKAHEAD(6) Synonym() - | LOOKAHEAD(6) Directory() - | LOOKAHEAD(6) DatabaseLink() - | LOOKAHEAD(6) Global() - | LOOKAHEAD(6) DDLCommand() //Ignore any other DDL Event + (LOOKAHEAD(7) PackageSpecification() + | LOOKAHEAD(7) PackageBody() + | LOOKAHEAD(6) TypeSpecification() + | LOOKAHEAD(6) Table() + | LOOKAHEAD(6) View() + | LOOKAHEAD(6) TriggerUnit() + | LOOKAHEAD(6) AlterTrigger() + | LOOKAHEAD(6) Synonym() + | LOOKAHEAD(6) Directory() + | LOOKAHEAD(6) DatabaseLink() + | LOOKAHEAD(6) Global() + | LOOKAHEAD(6) DDLCommand() //Ignore any other DDL Event | LOOKAHEAD(2) SqlPlusCommand() - | LOOKAHEAD(2) UpdateStatement() + | LOOKAHEAD(2) UpdateStatement() | LOOKAHEAD(2) DeleteStatement() |(|||||||||||) SqlStatement(null,";") [";"] + LOOKAHEAD(["("]
||) SqlStatement(null,";") [";"] | LOOKAHEAD(3) ContinueStatement() ";" // CONTINUE keyword was added in 11G, so Oracle compilation supports CONTINUE as a variable name | CaseStatement() ";" | IfStatement() ";" @@ -1781,7 +1781,7 @@ ASTUnlabelledStatement UnlabelledStatement() : | Block() ";" | EmbeddedSqlStatement() ";" | PipelineStatement() ";" - | ConditionalCompilationStatement() // Conditional Compilation works outside the normal parsing rules + | ConditionalCompilationStatement() // Conditional Compilation works outside the normal parsing rules | InlinePragma() ";" | Expression() ";" ) @@ -1793,9 +1793,9 @@ ASTStatement Statement() : {} { ( - //SQL Developer compiler allows 0, 1 or many labels immediately before a statement - //SQL Developer compiler requires a statement after a sequence of labels - LabelledStatement() + //SQL Developer compiler allows 0, 1 or many labels immediately before a statement + //SQL Developer compiler requires a statement after a sequence of labels + LabelledStatement() | UnlabelledStatement() ) @@ -1812,15 +1812,15 @@ PLSQLNode simpleNode = null; } { ( - //SQL Developer compiler allows 0, 1 or many labels immediately before a statement - //SQL Developer compiler requires a statement after a sequence of labels - //Use the last label + //SQL Developer compiler allows 0, 1 or many labels immediately before a statement + //SQL Developer compiler requires a statement after a sequence of labels + //Use the last label (simpleNode = Label() )+ UnlabelledStatement() ) - { - jjtThis.setImage( simpleNode.getImage() ) ; - return jjtThis ; + { + jjtThis.setImage( simpleNode.getImage() ) ; + return jjtThis ; } } @@ -1831,7 +1831,7 @@ ASTCaseStatement CaseStatement() : ( Expression() )? ( CaseWhenClause() )* [ ElseClause() ] - [] + [] ) { return jjtThis ; } } @@ -1839,28 +1839,28 @@ ASTCaseStatement CaseStatement() : ASTCaseWhenClause CaseWhenClause() : {} { - Expression() (Statement())+ + Expression() (Statement())+ { return jjtThis ; } } ASTElseClause ElseClause() : {} { - (Statement())+ + (Statement())+ { return jjtThis ; } } ASTElsifClause ElsifClause() : {} { - Expression() (Statement())+ + Expression() (Statement())+ { return jjtThis ; } } ASTLoopStatement LoopStatement() : {} { - (Statement())+ [] + (Statement())+ [] { return jjtThis ; } } @@ -1906,6 +1906,7 @@ ASTUpdateSetClause UpdateSetClause() : "=" ID() | Column() "=" ( Expression() | <_DEFAULT> ) + ( "," Column() "=" ( Expression() | <_DEFAULT> )*)* ) { return jjtThis; } } @@ -1923,14 +1924,14 @@ ASTDeleteStatement DeleteStatement() : ASTForStatement ForStatement() : {} { - ForIndex() [] Expression()[".."Expression()] (Statement())+ [] + ForIndex() [] Expression()[".."Expression()] (Statement())+ [] { return jjtThis ; } } ASTWhileStatement WhileStatement() : {} { - Expression() (Statement())+ [] + Expression() (Statement())+ [] { return jjtThis ; } } @@ -1940,7 +1941,7 @@ ASTIfStatement IfStatement() : Expression() (Statement())+ ( ElsifClause() {jjtThis.setHasElse();} )* [ ElseClause() {jjtThis.setHasElse();} ] - + { return jjtThis ; } } @@ -1953,7 +1954,7 @@ ASTForIndex ForIndex() : PLSQLNode simpleNode = null ; } { - simpleNode = ID() + simpleNode = ID() { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } @@ -1965,19 +1966,19 @@ ASTForAllIndex ForAllIndex() : PLSQLNode simpleNode = null; } { - simpleNode = ID() + simpleNode = ID() { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTForAllStatement ForAllStatement() : {} { - ForAllIndex() + ForAllIndex() ( ( | ) Expression() // Add support for sparse collections | Expression() [".." Expression()] ) - [ ] SqlStatement(null,";") + [ ] SqlStatement(null,";") { return jjtThis ; } } @@ -1986,14 +1987,14 @@ ASTGotoStatement GotoStatement() : PLSQLNode label = null; } { - label = QualifiedName() + label = QualifiedName() { jjtThis.setImage(label.getImage()) ; return jjtThis ; } } ASTReturnStatement ReturnStatement() : {} { - [Expression()] + [Expression()] { return jjtThis ; } } @@ -2002,7 +2003,7 @@ ASTContinueStatement ContinueStatement() : PLSQLNode label = null; } { - [ label = UnqualifiedID() ] [ Expression() ] + [ label = UnqualifiedID() ] [ Expression() ] { if (null != label) { jjtThis.setImage(label.getImage()) ; } return jjtThis ; } } @@ -2011,14 +2012,14 @@ ASTExitStatement ExitStatement() : PLSQLNode label = null; } { - [ label = UnqualifiedID() ] [ Expression() ] + [ label = UnqualifiedID() ] [ Expression() ] { if (null != label) { jjtThis.setImage(label.getImage()) ; } return jjtThis ; } } ASTRaiseStatement RaiseStatement() : {PLSQLNode exception = null ; } { - [exception = QualifiedName()] + [exception = QualifiedName()] { if (null != exception) { jjtThis.setImage(exception.getImage()) ; } return jjtThis ; } } @@ -2026,7 +2027,7 @@ ASTCloseStatement CloseStatement() : {PLSQLNode cursor = null ; } { - cursor = QualifiedName() + cursor = QualifiedName() { jjtThis.setImage(cursor.getImage()) ; return jjtThis ; } } @@ -2035,7 +2036,7 @@ ASTOpenStatement OpenStatement() : { [Expression()] //[LOOKAHEAD(functionCall()) functionCall() | QualifiedName()] - [ Expression() [ ( | | )? Expression() ("," ( | | )? Expression())*]] + [ Expression() [ ( | | )? Expression() ("," ( | | )? Expression())*]] { return jjtThis ; } } @@ -2044,7 +2045,7 @@ ASTFetchStatement FetchStatement() : { QualifiedName() [ ] //MMUE 04/08/2005 (LOOKAHEAD(functionCall()) functionCall() | QualifiedName()) ("," (LOOKAHEAD(functionCall()) functionCall() | QualifiedName()))* ";" - Expression() ("," Expression())* [ Expression()] + Expression() ("," Expression())* [ Expression()] // { return jjtThis ; } } @@ -2052,11 +2053,11 @@ ASTFetchStatement FetchStatement() : ASTEmbeddedSqlStatement EmbeddedSqlStatement() : {} { - Expression() // StringLiteral() /* */ + Expression() // StringLiteral() /* */ //SRT 20110429 | StringExpression() [ Expression() ("," Expression())*] ";" - //SRT 20121126 | StringExpression() - [ Name() ("," Name())* ] - [ [ [ ] | ] Expression() ("," [ [ ] | ] Expression())* ] + //SRT 20121126 | StringExpression() + [ Name() ("," Name())* ] + [ [ [ ] | ] Expression() ("," [ [ ] | ] Expression())* ] [ ( | ) Expression() ("," Expression())*] ";" // PIPELINED FUNCTION OUTPUT { return jjtThis ; } @@ -2065,7 +2066,7 @@ ASTEmbeddedSqlStatement EmbeddedSqlStatement() : ASTPipelineStatement PipelineStatement() : {} { - Expression() + Expression() { return jjtThis ; } } @@ -2075,8 +2076,8 @@ ASTConditionalCompilationStatement ConditionalCompilationStatement() : ( ConditionalOrExpression() (Statement())* ( ConditionalOrExpression() (Statement())+ )* ( (Statement())+ )* - - | Expression() + + | Expression() ) { return jjtThis ; } } @@ -2093,9 +2094,9 @@ ASTSubTypeDefinition SubTypeDefinition() : { ( - ( - name = QualifiedID() // SRT 20110605 to Parse SYS.standard need to allow normally reserved words which are low-level types - Datatype() + ( + name = QualifiedID() // SRT 20110605 to Parse SYS.standard need to allow normally reserved words which are low-level types + Datatype() [ ( "(" ")") // SRT 20110604 [ ] | @@ -2104,20 +2105,20 @@ ASTSubTypeDefinition SubTypeDefinition() : [ ] //SRT 20110604 ) | - ( name = QualifiedID() // SRT 20110605 to Parse SYS.standars ned to allow nprmally reserved words which are low-level types + ( name = QualifiedID() // SRT 20110605 to Parse SYS.standars ned to allow nprmally reserved words which are low-level types (|) ( LOOKAHEAD(2) ( - - | - | - | - | - | - ) - + + | + | + | + | + | + ) + | - //SRT 20110606 SYS.STANDRD + //SRT 20110606 SYS.STANDRD ( "(" FieldDeclaration() ("," FieldDeclaration())* ")" ) | ( "(" FieldDeclaration() ("," FieldDeclaration())* ")" ) @@ -2126,14 +2127,14 @@ ASTSubTypeDefinition SubTypeDefinition() : Datatype() ( )? ( Datatype())?) | [ Datatype()] - //Enumeration - | ( "(" - Expression() - ( "," Expression() )* - ")" + //Enumeration + | ( "(" + Expression() + ( "," Expression() )* + ")" ) - //Alias for existing type - | Datatype() + //Alias for existing type + | Datatype() ) ) ) @@ -2148,7 +2149,7 @@ ASTFieldDeclaration FieldDeclaration() : PLSQLNode defaultValue = null; } { - name = ID() Datatype() [[] ] [ (":" "=" | <_DEFAULT>) Expression() ] + name = ID() Datatype() [[] ] [ (":" "=" | <_DEFAULT>) Expression() ] { jjtThis.setImage(name.getImage()) ; return jjtThis ; } } @@ -2174,8 +2175,8 @@ ASTCallSpecTail CallSpecTail() : { ) | ( ( | /* C */| StringLiteral() /* JAVA */ ) ) - //SRT 20110517 Need to cope with CallSpecTails in ObjectTypes // Skip2NextTerminator(null,";") - //SkipPastNextOccurrence(")") // Read until we have eaten the closing bracket ")" + //SRT 20110517 Need to cope with CallSpecTails in ObjectTypes // Skip2NextTerminator(null,";") + //SkipPastNextOccurrence(")") // Read until we have eaten the closing bracket ")" | ( @@ -2183,7 +2184,7 @@ ASTCallSpecTail CallSpecTail() : { | ( - SkipPastNextOccurrence(")") // Read until we have eaten the closing bracket ")" + SkipPastNextOccurrence(")") // Read until we have eaten the closing bracket ")" ) )* ) @@ -2217,14 +2218,14 @@ ASTCallSpecTail CallSpecTail() : { [ ] - [ + [ "(" - + ( "," ( [ | [ ( [ | ] ) | | | | ] ] - | ( - ( | ) + | ( + ( | ) [ | [ ( [ | ] ) | | | | ] ] [ ] [ ] @@ -2254,7 +2255,7 @@ ASTCursorUnit CursorUnit() : { ( simpleNode = ID() - [ FormalParameters() ] + [ FormalParameters() ] [ Datatype() ] ) @@ -2294,50 +2295,50 @@ String expression() : ASTExpression Expression() : -{ +{ PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { // Need syntactic lookahead to discriminate between Assignment and a procedure call ( - LOOKAHEAD( PrimaryExpression() ":" "=" ) (simpleNode = Assignment()) {sb.append(simpleNode.getImage()); } - | (simpleNode = ConditionalOrExpression() ) {sb.append(simpleNode.getImage()); } - | (simpleNode = CompilationExpression() ) {sb.append(simpleNode.getImage()); } + LOOKAHEAD( PrimaryExpression() ":" "=" ) (simpleNode = Assignment()) {sb.append(simpleNode.getImage()); } + | (simpleNode = ConditionalOrExpression() ) {sb.append(simpleNode.getImage()); } + | (simpleNode = CompilationExpression() ) {sb.append(simpleNode.getImage()); } ) - { - jjtThis.setImage(sb.toString()); return jjtThis; + { + jjtThis.setImage(sb.toString()); return jjtThis; } } ASTCompilationExpression CompilationExpression() : -{ +{ PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { ( - {sb.append(" "); sb.append(token.image) ; } - simpleNode = ConditionalOrExpression() {sb.append(" "); sb.append(simpleNode.getImage()); } - {sb.append(" "); sb.append(token.image); } - simpleNode = Expression() {sb.append(" "); sb.append(simpleNode.getImage()); } + {sb.append(" "); sb.append(token.image) ; } + simpleNode = ConditionalOrExpression() {sb.append(" "); sb.append(simpleNode.getImage()); } + {sb.append(" "); sb.append(token.image); } + simpleNode = Expression() {sb.append(" "); sb.append(simpleNode.getImage()); } - ( - {sb.append(" "); sb.append(token.image); } - simpleNode = ConditionalOrExpression() {sb.append(" "); sb.append(simpleNode.getImage()); } - {sb.append(" "); sb.append(token.image); } - simpleNode = Expression() {sb.append(" "); sb.append(simpleNode.getImage()); } - )* - - ( - {sb.append(" "); sb.append(token.image); } - simpleNode = Expression() {sb.append(" "); sb.append(simpleNode.getImage()); } + ( + {sb.append(" "); sb.append(token.image); } + simpleNode = ConditionalOrExpression() {sb.append(" "); sb.append(simpleNode.getImage()); } + {sb.append(" "); sb.append(token.image); } + simpleNode = Expression() {sb.append(" "); sb.append(simpleNode.getImage()); } )* - {sb.append(" "); sb.append(token.image); } + ( + {sb.append(" "); sb.append(token.image); } + simpleNode = Expression() {sb.append(" "); sb.append(simpleNode.getImage()); } + )* + + {sb.append(" "); sb.append(token.image); } ) - { - jjtThis.setImage(sb.toString()); return jjtThis; + { + jjtThis.setImage(sb.toString()); return jjtThis; } } @@ -2346,12 +2347,12 @@ ASTAssignment Assignment() : { PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { ( - (simpleNode = PrimaryExpression() ) {sb.append(simpleNode.getImage());} - (":" "=" ) {sb.append(" := ");} - (simpleNode = Expression()) {sb.append(simpleNode.getImage());} + (simpleNode = PrimaryExpression() ) {sb.append(simpleNode.getImage());} + (":" "=" ) {sb.append(" := ");} + (simpleNode = Expression()) {sb.append(simpleNode.getImage());} ) - { - jjtThis.setImage(sb.toString()); return jjtThis; + { + jjtThis.setImage(sb.toString()); return jjtThis; } } @@ -2359,20 +2360,20 @@ ASTCaseExpression CaseExpression() : { Token thisToken; PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { ( - thisToken = { sb.append(thisToken.image);} + thisToken = { sb.append(thisToken.image);} ( simpleNode = Expression() { sb.append(" "); sb.append(simpleNode.getImage()); } )? - ( thisToken = { sb.append(" "); sb.append(thisToken.image); } + ( thisToken = { sb.append(" "); sb.append(thisToken.image); } simpleNode = Expression() { sb.append(" "); sb.append(simpleNode.getImage()); } thisToken = { sb.append(" "); sb.append(thisToken.image); } - Expression() { sb.append(" "); sb.append(simpleNode.getImage()); } + Expression() { sb.append(" "); sb.append(simpleNode.getImage()); } )+ - [ thisToken = { sb.append(" "); sb.append(thisToken.image);} + [ thisToken = { sb.append(" "); sb.append(thisToken.image);} Expression() { sb.append(" "); sb.append(simpleNode.getImage()); } ] thisToken = { sb.append(" "); sb.append(thisToken.image);} ) - { - jjtThis.setImage(sb.toString()); return jjtThis; + { + jjtThis.setImage(sb.toString()); return jjtThis; } } @@ -2384,20 +2385,20 @@ ASTLikeExpression LikeExpression() : { ( simpleNode = PrimaryExpression() { sb.append(" "); sb.append(simpleNode.getImage()); } - (thisToken = ) { sb.append(thisToken.image);} + (thisToken = ) { sb.append(thisToken.image);} //["(" { sb.append("(");} ] ( simpleNode = StringExpression() { sb.append(" "); sb.append(simpleNode.getImage()); } ) //[ ")" { sb.append(")");} ] [ - { sb.append(" ESCAPE ");} - ( { sb.append(" "); sb.append(token.toString()); } - | simpleNode = StringLiteral() { sb.append(" "); sb.append(simpleNode.getImage()); } + { sb.append(" ESCAPE ");} + ( { sb.append(" "); sb.append(token.toString()); } + | simpleNode = StringLiteral() { sb.append(" "); sb.append(simpleNode.getImage()); } ) ] ) ( "." simpleNode = Expression() { sb.append("."); sb.append(simpleNode.getImage()); } )* - { - jjtThis.setImage(sb.toString()); return jjtThis; + { + jjtThis.setImage(sb.toString()); return jjtThis; } } @@ -2405,16 +2406,16 @@ ASTTrimExpression TrimExpression() : { Token thisToken; PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { ( - (thisToken = ) { sb.append(thisToken.image);} - "(" { sb.append("(");} + (thisToken = ) { sb.append(thisToken.image);} + "(" { sb.append("(");} [ ( | | ){ sb.append(" "); sb.append(token.toString()); } ] [ simpleNode = StringExpression() { sb.append(" "); sb.append(simpleNode.getImage()); } ] - ( ) { sb.append(thisToken.image);} - simpleNode = StringExpression() { sb.append(" "); sb.append(simpleNode.getImage()); } - ")" { sb.append(")");} + ( ) { sb.append(thisToken.image);} + simpleNode = StringExpression() { sb.append(" "); sb.append(simpleNode.getImage()); } + ")" { sb.append(")");} ) - { - jjtThis.setImage(sb.toString()); return jjtThis; + { + jjtThis.setImage(sb.toString()); return jjtThis; } } @@ -2427,19 +2428,19 @@ ASTObjectExpression ObjectExpression() : { Token thisToken; PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { ( - (thisToken = | thisToken = ) { sb.append(thisToken.image);} - "(" { sb.append("(");} + (thisToken = | thisToken = ) { sb.append(thisToken.image);} + "(" { sb.append("(");} ( simpleNode = Expression() { sb.append(" "); sb.append(simpleNode.getImage()); } ) [
ID() [LOOKAHEAD(2) ID()"."] ID() |[LOOKAHEAD(2) ID()"."] ID() //includes 11g schema. table === ) - - - // referencing_clause - there may be ZERO subclauses + + + // referencing_clause - there may be ZERO subclauses [ (( | | ) ID())*] - + [] // end of simple_dml_trigger (incorporating compound_dml_trigger ) - - + + [ [|] ] // 11G Syntax to specify Cross Edition Trigger - [ (|) ( [LOOKAHEAD(2) ID() "."] ID() ) ( "," ( [ LOOKAHEAD(2) ID() "."] ID() ) )* ] // 11G Syntax to specify trigger firing order - [ | ] // 11G Syntax can create the trigger enabled or disabled explcitly + [ (|) ( [LOOKAHEAD(2) ID() "."] ID() ) ( "," ( [ LOOKAHEAD(2) ID() "."] ID() ) )* ] // 11G Syntax to specify trigger firing order + [ | ] // 11G Syntax can create the trigger enabled or disabled explcitly [ "(" ConditionalOrExpression() ")" ] //Trigger Body follows : - //plsql_block | compound_trigger_block | routine + //plsql_block | compound_trigger_block | routine ( PrimaryExpression() ";" - //compound_trigger_block + //compound_trigger_block | CompoundTriggerBlock() - |//plsql_block + |//plsql_block Block() ";" - //| // routine + //| // routine ) { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } @@ -3775,15 +3776,15 @@ ASTTriggerTimingPointSection TriggerTimingPointSection() : } { ( - ( | | ) { sb.append(token.image) ; } - ( | ) {sb.append(" "); sb.append(token.image) ; } - + ( | | ) { sb.append(token.image) ; } + ( | ) {sb.append(" "); sb.append(token.image) ; } + - (Statement())+ + (Statement())+ ( | | ) ( | ) ";" ) { - //Add a TRIGGER ENTRY for each timing point section + //Add a TRIGGER ENTRY for each timing point section } { jjtThis.setImage(sb.toString()) ; return jjtThis ; } } @@ -3794,7 +3795,7 @@ ASTCompoundTriggerBlock CompoundTriggerBlock() : { } { - + ( //Problems making the declaration optional @@ -3813,7 +3814,7 @@ ASTCompoundTriggerBlock CompoundTriggerBlock() : CursorSpecification() | CursorBody() | CollectionDeclaration() | - ProgramUnit() + ProgramUnit() )* @@ -3826,7 +3827,7 @@ ASTCompoundTriggerBlock CompoundTriggerBlock() : /* non_dml_trigger : -(BEFORE> | ) +(BEFORE> | ) (DDLEvent | database_event) ( OR (DDLEvent | database_event))* ON (DATABASE | [schema.]SCHEMA @@ -3835,10 +3836,10 @@ ASTNonDMLTrigger NonDMLTrigger() : { } { - ( | ) + ( | ) ( DDLEvent() | DatabaseEvent() ) ( ( DDLEvent() | DatabaseEvent() ) )* - + ( | [LOOKAHEAD(2) ID()"."] ) { return jjtThis ; } } @@ -3846,9 +3847,9 @@ ASTNonDMLTrigger NonDMLTrigger() : ASTDDLEvent DDLEvent(): {} { - ( - | - | + ( + | + | | | | @@ -3868,18 +3869,18 @@ ASTDDLEvent DDLEvent(): {} ASTDatabaseEvent DatabaseEvent(): {} { ( - | - | - | - | - | + | + | + | + | + | ) { jjtThis.setImage(token.toString()) ; jjtThis.value = token ; return jjtThis ; } } ASTNonDMLEvent NonDMLEvent(): {} { - (DDLEvent() | DatabaseEvent()) + (DDLEvent() | DatabaseEvent()) { return jjtThis; } } @@ -3894,7 +3895,7 @@ void AlterTrigger() : {} { - Skip2NextTerminator(null,";") + Skip2NextTerminator(null,";") ";" { return; @@ -3907,7 +3908,7 @@ void AlterTrigger() : SKIP : { - //Tracker Issue 1433480 - Skip2 and SkipPast need to be able to check for EOL - so the characters + //Tracker Issue 1433480 - Skip2 and SkipPast need to be able to check for EOL - so the characters //cannot be SKIPped //" " | "\t" | "\n" | "\r" | "\f" " " | "\t" | "\f" @@ -3924,8 +3925,8 @@ MORE : SPECIAL_TOKEN : { - //Remove terminating EOL from Single Comment Token definition: it causes failurs if no other newline exists before next production - + //Remove terminating EOL from Single Comment Token definition: it causes failurs if no other newline exists before next production + } //Tracker Issue 1433480 - Skip2 and SkipPast need to be able to check for EOL - so it cannot be SKIPped @@ -3973,7 +3974,7 @@ TOKEN [IGNORE_CASE]: | | -| // PRAGMA INLINE +| // PRAGMA INLINE } /* PL/SQL RESERVED WORDS */ @@ -4044,7 +4045,7 @@ TOKEN [IGNORE_CASE]: | | | - | // Needed for 11G Trigger Syntax + | // Needed for 11G Trigger Syntax | | | @@ -4053,7 +4054,7 @@ TOKEN [IGNORE_CASE]: | | | - | // Needed for 11G Trigger Syntax + | // Needed for 11G Trigger Syntax | | | @@ -4121,15 +4122,15 @@ TOKEN [IGNORE_CASE]: | | | - | + | | | | | | | - | - | + | + | | | | @@ -4208,7 +4209,7 @@ TOKEN [IGNORE_CASE]: | | | - | + | | //SRT 2011-04-17 | //SRT 2011-04-17 | @@ -4310,24 +4311,24 @@ TOKEN [IGNORE_CASE]: | | | - | - | - | - | - | - | - | - | + | + | + | + | + | + | + | + | | -| -| -| -| -| -| -| -| +| +| +| +| +| +| +| +| | | | @@ -4356,17 +4357,17 @@ TOKEN [IGNORE_CASE]: | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax -| //XE testing -| //XE testing -| //XE testing non-PLSQL functions -| //XE testing non-PLSQL functions -| //XE testing non-PLSQL functions -| //XE testing non-PLSQL functions -| //XE testing non-PLSQL functions -| //XE testing non-PLSQL functions -| //XE testing non-PLSQL functions -| //XE testing non-PLSQL functions -| //XE testing non-PLSQL functions +| //XE testing +| //XE testing +| //XE testing non-PLSQL functions +| //XE testing non-PLSQL functions +| //XE testing non-PLSQL functions +| //XE testing non-PLSQL functions +| //XE testing non-PLSQL functions +| //XE testing non-PLSQL functions +| //XE testing non-PLSQL functions +| //XE testing non-PLSQL functions +| //XE testing non-PLSQL functions //SQLPlus Commands | | @@ -4453,44 +4454,44 @@ TOKEN : < #_WHATEVER_CHARACTER_WO_ASTERISK: (~["'"]) > | < CHARACTER_LITERAL: "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | )? "'" > -//|< STRING_LITERAL: -// (["q","Q"])* "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | | "''")* "'" -//> //Cope with Q-quoted stringswithout single quotes in them -|< STRING_LITERAL: -// Hard-code the most likely q-quote strings - "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | | "''")* "'" -|(["n","N"]) "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | | "''")* "'" //National Character Set String +//|< STRING_LITERAL: +// (["q","Q"])* "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | | "''")* "'" +//> //Cope with Q-quoted stringswithout single quotes in them +|< STRING_LITERAL: +// Hard-code the most likely q-quote strings + "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | | "''")* "'" +|(["n","N"]) "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | | "''")* "'" //National Character Set String |(["q","Q"]) "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | | "''")* "'" // Bug 160632 -|(["q","Q"]) "'[" (~["[","]"])* "]'" -|(["q","Q"]) "'{" (~["{","}"])* "}'" -|(["q","Q"]) "'<" (~["<",">"])* ">'" -|(["q","Q"]) "'(" (~["(",")"])* ")'" -|(["q","Q"]) "'/" (~["/"])* "/'" -|(["q","Q"]) "'!" (~["!"])* "!'" -|(["q","Q"]) "'#" (~["#"])* "#'" -> //Cope with Q-quoted stringswithout single quotes in them +|(["q","Q"]) "'[" (~["[","]"])* "]'" +|(["q","Q"]) "'{" (~["{","}"])* "}'" +|(["q","Q"]) "'<" (~["<",">"])* ">'" +|(["q","Q"]) "'(" (~["(",")"])* ")'" +|(["q","Q"]) "'/" (~["/"])* "/'" +|(["q","Q"]) "'!" (~["!"])* "!'" +|(["q","Q"]) "'#" (~["#"])* "#'" +> //Cope with Q-quoted stringswithout single quotes in them | < #_WHATEVER_CHARACTER_WO_QUOTE: (~["\""]) > | < QUOTED_LITERAL: "\"" (<_WHATEVER_CHARACTER_WO_QUOTE> | | "\\\"")* "\"" > -| +| < SQLDATA_CLASS: "SQLData" > -| +| < CUSTOMDATUM_CLASS: "CustomDatum" > -| +| < ORADATA_CLASS: "OraData" > -| +| < JAVA_INTERFACE_CLASS: ( "SQLData" | "CustomDatum" | "OraData" ) > //| //< #BOOLEAN_LITERAL: "TRUE" | "FALSE" > -| +| } -//SRT 2011-04-17 - START +//SRT 2011-04-17 - START ASTKEYWORD_RESERVED KEYWORD_RESERVED (): {} { -// PL/SQL RESERVED WORDS - V$RESERVED.RESERVED='Y' +// PL/SQL RESERVED WORDS - V$RESERVED.RESERVED='Y' ( | | @@ -4577,7 +4578,7 @@ ASTKEYWORD_RESERVED KEYWORD_RESERVED (): {} ASTKEYWORD_UNRESERVED KEYWORD_UNRESERVED (): {} { -// PL/SQL UNRESERVED KEYWORDS - V$RESERVED.RESERVED='N' +// PL/SQL UNRESERVED KEYWORDS - V$RESERVED.RESERVED='N' ( | | @@ -4721,12 +4722,12 @@ ASTKEYWORD_UNRESERVED KEYWORD_UNRESERVED (): {} //| | //| -| +| //| //| //| | -| +| //| | | @@ -4771,7 +4772,7 @@ ASTKEYWORD_UNRESERVED KEYWORD_UNRESERVED (): {} //| //| //| -| // SQL*Plus command +| // SQL*Plus command //| | | @@ -4951,7 +4952,7 @@ ASTKEYWORD_UNRESERVED KEYWORD_UNRESERVED (): {} | //| | -| // FORALL i I INDICES OF collection - SPARSE COLLECTIONS +| // FORALL i I INDICES OF collection - SPARSE COLLECTIONS | //| //| @@ -5503,7 +5504,7 @@ ASTKEYWORD_UNRESERVED KEYWORD_UNRESERVED (): {} //| //| | -| // XDBPM_ANALYZE_XMLSCHEMA +| // XDBPM_ANALYZE_XMLSCHEMA | //| //| @@ -5661,15 +5662,15 @@ ASTKEYWORD_UNRESERVED KEYWORD_UNRESERVED (): {} | | | -| // APEX_0400000.WWW_CALCUATOR.SHOW -| // APEX_0400000.WWW_CALCUATOR.SHOW -| //Not a keyword - just a type defined in standard -| -| -| -| +| // APEX_0400000.WWW_CALCUATOR.SHOW +| // APEX_0400000.WWW_CALCUATOR.SHOW +| //Not a keyword - just a type defined in standard +| +| +| +| | //Although RENAME is an Oracle reserved word, it may be used as a PL/SQL name. -| //Although RELEASE is an Oracle reserved word, it may be used as a PL/SQL name. +| //Although RELEASE is an Oracle reserved word, it may be used as a PL/SQL name. | // PRAGMA INLINE is not a PLSQL reserved word ) @@ -5685,195 +5686,195 @@ ASTID ID(): {} ( | | KEYWORD_UNRESERVED() //SRT 2011-04-17 - /*KEYWORDS_UNRESERVED - | | | | | | | | | - | | | | + /*KEYWORDS_UNRESERVED + | | | | | | | | | + | | | | */ - | //SYNTAX - //20120501 | - | | + | //SYNTAX + //20120501 | + | | | | // | - //| //RESERVED WORD - | //SYNTAX //RESERVED WORD - | //SYNTAX //RESERVED WORD - | //RESERVED WORD - | - | //SYNTAX //RESERVED WORD - | //RESERVED WORD - //20120429 | | - | + //| //RESERVED WORD + | //SYNTAX //RESERVED WORD + | //SYNTAX //RESERVED WORD + | //RESERVED WORD + | + | //SYNTAX //RESERVED WORD + | //RESERVED WORD + //20120429 | | + | // | | //RESERVED WORD - | - | //SYNTAX - | - //201020430 | - //| //RESERVED WORD - //201020430 | - | //SYNTAX - | //RESERVED WPRDS - | - | //RESERVED WPRDS - //20120501 | //SYNTAX + | + | //SYNTAX + | + //201020430 | + //| //RESERVED WORD + //201020430 | + | //SYNTAX + | //RESERVED WPRDS + | + | //RESERVED WPRDS + //20120501 | //SYNTAX | //- | - //20120501 | - | //RESERVED WPRDS - | //SYNTAX //RESERVED WORD - | - | //SYNTAX //RESERVED WORD - //20120501 | - | - | //RESERVED WORD - | //SYNTAX - | //RESERVED WORD - | <_DEFAULT> //RESERVED WORD - | //RESERVED WORD - | //RESERVED WORD - //| //RESERVED WORD - | - | //RESERVED WORD - | //SYNTAX //RESERVED WORD - | //SYNTAX - - //| | - | //SYNTAX - | //SYNTAX //RESERVED WORD - | //SYNTAX - | //SYNTAX //RESERVED WORD - //| //SYNTAX - //20120501 | - | //SYNTAX - | //SYNTAX //RESERVED WORD - | //RESERVED WORD - | //SYNTAX - | //RESERVED WORD - + //20120501 | + | //RESERVED WPRDS + | //SYNTAX //RESERVED WORD + | + | //SYNTAX //RESERVED WORD + //20120501 | + | + | //RESERVED WORD + | //SYNTAX + | //RESERVED WORD + | <_DEFAULT> //RESERVED WORD + | //RESERVED WORD + | //RESERVED WORD + //| //RESERVED WORD + | + | //RESERVED WORD + | //SYNTAX //RESERVED WORD + | //SYNTAX + + //| | + | //SYNTAX + | //SYNTAX //RESERVED WORD + | //SYNTAX + | //SYNTAX //RESERVED WORD + //| //SYNTAX + //20120501 | + | //SYNTAX + | //SYNTAX //RESERVED WORD + | //RESERVED WORD + | //SYNTAX + | //RESERVED WORD + // | | // this causes bug 643043 Procedure w/o params appears as variable - | //SYNTAX - //| //RESERVED WORD - | //RESERVED WORD - //20120501 | - | //SYNTAX - //20120501 | - | //RESERVED WORD - | //RESERVED WORD - //20120501 | - | //SYNTAX //RESERVED WORD - | //RESERVED WORD - | - | //RESERVED WORD - //20120501 | - | //RESERVED WORD + | //SYNTAX + //| //RESERVED WORD + | //RESERVED WORD + //20120501 | + | //SYNTAX + //20120501 | + | //RESERVED WORD + | //RESERVED WORD + //20120501 | + | //SYNTAX //RESERVED WORD + | //RESERVED WORD + | + | //RESERVED WORD + //20120501 | + | //RESERVED WORD | //SYNTAX - //20120501 | | | - | //RESERVED WORD - | - | //SYNTAX //RESERVED WORD - | //RESERVED WORD - | //SYNTAX - //20120501 | | - | //RESERVED WORD - //20120501 | - | - | //RESERVED WORD - //20120501 | - | | | - | //SYNTAX //RESERVED WORD - | //RESERVED WORD - | //RESERVED WORD - //| - | //RESERVED WORD - | - | - | //RESERVED WORD - //| //RESERVED WORD - //20120501 | - | + //20120501 | | | + | //RESERVED WORD + | + | //SYNTAX //RESERVED WORD + | //RESERVED WORD + | //SYNTAX + //20120501 | | + | //RESERVED WORD + //20120501 | + | + | //RESERVED WORD + //20120501 | + | | | + | //SYNTAX //RESERVED WORD + | //RESERVED WORD + | //RESERVED WORD + //| + | //RESERVED WORD + | + | + | //RESERVED WORD + //| //RESERVED WORD + //20120501 | + | | | // | | - - //20120501 | - | |
//RESERVED WORD - | //SYNTAX //RESERVED WORD - // |
//RESERVED WORD + | //SYNTAX //RESERVED WORD + // |