Skip to content

Commit

Permalink
Fix pmd#4396 - Fix PLSQL CPD being case-sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
oowekyala committed Apr 8, 2024
1 parent d4b99bb commit 44f29c3
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

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

import java.util.Locale;

import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.impl.JavaccCpdLexer;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
Expand Down Expand Up @@ -37,16 +39,21 @@ protected String getImage(JavaccToken plsqlToken) {
String image = plsqlToken.getImage();

if (ignoreIdentifiers && plsqlToken.kind == PLSQLTokenKinds.IDENTIFIER) {
image = String.valueOf(plsqlToken.kind);
}

if (ignoreLiterals && (plsqlToken.kind == PLSQLTokenKinds.UNSIGNED_NUMERIC_LITERAL
image = "<identifier>";
} else if (ignoreLiterals && (plsqlToken.kind == PLSQLTokenKinds.UNSIGNED_NUMERIC_LITERAL
|| plsqlToken.kind == PLSQLTokenKinds.FLOAT_LITERAL
|| plsqlToken.kind == PLSQLTokenKinds.INTEGER_LITERAL
|| plsqlToken.kind == PLSQLTokenKinds.CHARACTER_LITERAL
|| plsqlToken.kind == PLSQLTokenKinds.STRING_LITERAL
|| plsqlToken.kind == PLSQLTokenKinds.QUOTED_LITERAL)) {
image = String.valueOf(plsqlToken.kind);
// note that all tokens kinds are mapped to the same type.
image = "<literal>";
} else if (plsqlToken.kind != PLSQLTokenKinds.CHARACTER_LITERAL
&& plsqlToken.kind != PLSQLTokenKinds.STRING_LITERAL
&& plsqlToken.kind != PLSQLTokenKinds.QUOTED_LITERAL) {
// PLSQL is case-insensitive, but of course the contents of
// string literals and the like are case-sensitive
image = image.toLowerCase(Locale.ROOT);
}
return image;
}
Expand Down

0 comments on commit 44f29c3

Please sign in to comment.