Fix plsql module

This commit is contained in:
Clément Fournier
2021-07-08 19:29:09 +02:00
parent fa31d54bd7
commit ab1e3f974e
5 changed files with 9 additions and 8 deletions

View File

@ -1,17 +1,17 @@
[Image] or [Truncated image[ Bcol Ecol
L1
[<%--] 1 5
[\nBSD-style license; for more info[ 5 1
[\nBSD-style license; for more info[ 5 78
L3
[--%>] 1 5
L5
[<%] 1 3
[\nString nodeContent = "<% %>";\n] 3 1
[\nString nodeContent = "<% %>";\n] 3 31
L7
[%>] 1 3
L8
[<%] 1 3
[\n<!\[cdata\[\nString nodeContent [ 3 1
[\n<!\[cdata\[\nString nodeContent [ 3 5
L12
[%>] 1 3
EOF

View File

@ -160,6 +160,7 @@ import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
import net.sourceforge.pmd.lang.plsql.ast.internal.ParsingExclusion;
import net.sourceforge.pmd.util.document.Chars;
public class PLSQLParserImpl {
@ -3472,7 +3473,7 @@ ASTPrimarySuffix PrimarySuffix() :
)
)
|
( arguments = Arguments() ) {sb.append(arguments) ; }
( arguments = Arguments() ) {sb.append("Arguments") ; } // was broken before...
)
{
jjtThis.setImage(sb.toString()); return jjtThis;
@ -5234,6 +5235,7 @@ TOKEN :
<IN_STRING_LITERAL> MORE : {
<~["'"]>
| <"'"> {
Chars image = input_stream.getTokenImageCs();
int quoteDelimiter = image.charAt(2);
if (image.charAt(0) == 'n' || image.charAt(0) == 'N') {
quoteDelimiter = image.charAt(3);
@ -5241,7 +5243,6 @@ TOKEN :
int beforeQuote = image.charAt(image.length() - 2);
if (quoteDelimiter == beforeQuote) {
input_stream.backup(1);
image.setLength(image.length() - 1);
SwitchTo(IN_STRING_LITERAL_TOKENIZE);
}
}

View File

@ -8,8 +8,8 @@ import java.util.Properties;
import net.sourceforge.pmd.cpd.internal.JavaCCTokenizer;
import net.sourceforge.pmd.lang.TokenManager;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream;
import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken;
import net.sourceforge.pmd.lang.plsql.ast.PLSQLTokenKinds;
public class PLSQLTokenizer extends JavaCCTokenizer {

View File

@ -1,4 +1,4 @@
+- Input[@CanonicalImage = null, @ExcludedLinesCount = "6", @ExcludedRangesCount = "2", @Sourcecode = "begin\n do_something();\n -- pmd-exclude-begin: PMD does not like dbms_lob.trim (clash with TrimExpression)\n dbms_lob.trim(the_blob, 1000);\n -- pmd-exclude-end\n do_something_else(x);\nend;\n/\n\nselect dummy from dual a\nwhere 1=1\n -- pmd-exclude-begin: PMD does not like scalar subqueries in WHERE conditions\n and \'J\' = (select max(\'J\') from dual b)\n -- pmd-exclude-end\n;\n"]
+- Input[@CanonicalImage = null, @ExcludedLinesCount = "6", @ExcludedRangesCount = "2"]
+- Global[@CanonicalImage = null]
| +- Block[@CanonicalImage = null]
| +- Statement[@CanonicalImage = null]

View File

@ -1,3 +1,3 @@
+- Input[@CanonicalImage = null, @ExcludedLinesCount = "0", @ExcludedRangesCount = "0", @Sourcecode = "\n-- see https://github.com/pmd/pmd/issues/195\n-- both define and spool are SQL*Plus commands, and they should not be ended with a semi-colon.\n\ndefine patch_name = acme_module\nspool &patch_name..log\n"]
+- Input[@CanonicalImage = null, @ExcludedLinesCount = "0", @ExcludedRangesCount = "0"]
+- SqlPlusCommand[@CanonicalImage = "DEFINE PATCH_NAME = ACME_MODULE", @Image = "define patch_name = acme_module "]
+- SqlPlusCommand[@CanonicalImage = "SPOOL &PATCH_NAME. . LOG", @Image = "spool &patch_name. . log "]