Skip to content

Commit

Permalink
Merge pull request pmd#3928 from LiGaOg:master
Browse files Browse the repository at this point in the history
[plsql] Fix plsql parsing error in parenthesis groups pmd#3928
  • Loading branch information
adangel committed Apr 21, 2022
2 parents be2618b + cb4b981 commit a6d8c1b
Show file tree
Hide file tree
Showing 11 changed files with 826 additions and 64 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -6594,6 +6594,15 @@
"code",
"doc"
]
},
{
"login": "LiGaOg",
"name": "LiGaOg",
"avatar_url": "https://avatars.githubusercontent.com/u/72175888?v=4",
"profile": "https://github.com/LiGaOg",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
121 changes: 61 additions & 60 deletions docs/pages/pmd/projectdocs/credits.md

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions docs/pages/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ This is a {{ site.pmd.release_type }} release.
* core
* [#3881](https://github.com/pmd/pmd/issues/3881): \[core] SARIF renderer depends on platform default encoding
* [#3882](https://github.com/pmd/pmd/pull/3882): \[core] Fix AssertionError about exhaustive switch
* [#3884](https://github.com/pmd/pmd/issues/3884): \[core] XML report via ant task contains XML header twice
* doc
* [#2505](https://github.com/pmd/pmd/issues/2505): \[doc] Improve side bar to show release date
* java
* [#3889](https://github.com/pmd/pmd/pull/3889): \[java] Catch LinkageError in UselessOverridingMethodRule

* core
* [#3884](https://github.com/pmd/pmd/issues/3884): \[core] XML report via ant task contains XML header twice
* plsql
* [#3706](https://github.com/pmd/pmd/issues/3706): \[plsql] Parsing exception CURSOR statement with parenthesis groupings

### API Changes

### External Contributions
* [#3883](https://github.com/pmd/pmd/pull/3883): \[doc] Improve side bar by Adding Release Date - [@jasonqiu98](https://github.com/jasonqiu98)
* [#3928](https://github.com/pmd/pmd/pull/3928): \[plsql] Fix plsql parsing error in parenthesis groups - [@LiGaOg](https://github.com/LiGaOg)

{% endtocmaker %}

6 changes: 5 additions & 1 deletion pmd-plsql/etc/grammar/PldocAST.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,11 @@ void QueryTableExpression() #void :
|
TableCollectionExpression()
|
[ <LATERAL> ] "(" Subquery() [ SubqueryRestrictionClause() ] ")"
LOOKAHEAD(5) "(" [ LOOKAHEAD(2) SchemaName() "." ] TableName() [TableAlias()] ")"
|
LOOKAHEAD(5) [ <LATERAL> ] "(" Subquery() [ SubqueryRestrictionClause() ] ")"
|
"(" JoinClause() ")"
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/

package net.sourceforge.pmd.lang.plsql.ast;

import org.junit.Test;

import net.sourceforge.pmd.lang.ast.test.BaseParsingHelper;
import net.sourceforge.pmd.lang.ast.test.BaseTreeDumpTest;
import net.sourceforge.pmd.lang.ast.test.RelevantAttributePrinter;
import net.sourceforge.pmd.lang.plsql.PlsqlParsingHelper;

public class ParenthesisGroupTest extends BaseTreeDumpTest {

public ParenthesisGroupTest() {
super(new RelevantAttributePrinter(), ".pls");
}

@Override
public BaseParsingHelper<?, ?> getParser() {
return PlsqlParsingHelper.WITH_PROCESSING.withResourceContext(getClass());
}

@Test
public void parseParenthesisGroup0() {
doTest("ParenthesisGroup0");
}

@Test
public void parseParenthesisGroup1() {
doTest("ParenthesisGroup1");
}

@Test
public void parseParenthesisGroup2() {
doTest("ParenthesisGroup2");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE OR REPLACE PROCEDURE EXAMPLE_PROCEDURE IS
--
CURSOR c_example IS
SELECT a.owner, u.object_name, p.aggregate
FROM (USER_OBJECTS u) INNER JOIN (ALL_OBJECTS a) ON
u.object_name = a.object_name AND u.object_type = a.object_type AND u.object_id = a.object_id
INNER JOIN (ALL_PROCEDURES p) ON
p.owner = a.owner AND p.object_name = a.object_name AND p.object_type = a.object_type
WHERE a.owner = USER;
--
BEGIN
--
FOR l_object IN c_example LOOP
--
DBMS_OUTPUT.Put_Line(l_object.owner);
DBMS_OUTPUT.Put_Line(l_object.object_name);
DBMS_OUTPUT.Put_Line(l_object.aggregate);
--
END LOOP;
--
END EXAMPLE_PROCEDURE;

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE OR REPLACE PROCEDURE EXAMPLE_PROCEDURE IS
--
CURSOR c_example IS
SELECT a.owner, u.object_name, p.aggregate
FROM (((USER_OBJECTS u) INNER JOIN (ALL_OBJECTS a) ON
u.object_name = a.object_name AND u.object_type = a.object_type AND u.object_id = a.object_id)
INNER JOIN (ALL_PROCEDURES p) ON
p.owner = a.owner AND p.object_name = a.object_name AND p.object_type = a.object_type)
WHERE a.owner = USER;
--
BEGIN
--
FOR l_object IN c_example LOOP
--
DBMS_OUTPUT.Put_Line(l_object.owner);
DBMS_OUTPUT.Put_Line(l_object.object_name);
DBMS_OUTPUT.Put_Line(l_object.aggregate);
--
END LOOP;
--
END EXAMPLE_PROCEDURE;
Loading

0 comments on commit a6d8c1b

Please sign in to comment.