[core] Create CpdLanguageProperties

This commit is contained in:
Andreas Dangel
2023-08-24 11:14:08 +02:00
parent 932ac33d15
commit 681c52836c
21 changed files with 119 additions and 98 deletions

View File

@ -28,8 +28,8 @@ import net.sourceforge.pmd.cpd.CPDReport;
import net.sourceforge.pmd.cpd.CPDReportRenderer;
import net.sourceforge.pmd.cpd.CSVRenderer;
import net.sourceforge.pmd.cpd.CpdAnalysis;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.SimpleRenderer;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.XMLRenderer;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageRegistry;
@ -73,7 +73,7 @@ public class CPDTask extends Task {
private boolean skipLexicalErrors;
private boolean skipDuplicateFiles;
private boolean skipBlocks = true;
private String skipBlocksPattern = Tokenizer.DEFAULT_SKIP_BLOCKS_PATTERN;
private String skipBlocksPattern = CpdLanguageProperties.DEFAULT_SKIP_BLOCKS_PATTERN;
private File outputFile;
private String encoding = System.getProperty("file.encoding");
private List<FileSet> filesets = new ArrayList<>();

View File

@ -17,7 +17,7 @@ import net.sourceforge.pmd.cli.commands.typesupport.internal.CpdLanguageTypeSupp
import net.sourceforge.pmd.cli.internal.CliExitCode;
import net.sourceforge.pmd.cpd.CPDConfiguration;
import net.sourceforge.pmd.cpd.CpdAnalysis;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.internal.LogMessages;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.util.StringUtil;
@ -78,7 +78,7 @@ public class CpdCommand extends AbstractAnalysisPmdSubcommand<CPDConfiguration>
@Option(names = "--skip-blocks-pattern",
description = "Pattern to find the blocks to skip. Start and End pattern separated by |.",
defaultValue = Tokenizer.DEFAULT_SKIP_BLOCKS_PATTERN)
defaultValue = CpdLanguageProperties.DEFAULT_SKIP_BLOCKS_PATTERN)
private String skipBlocksPattern;
@Option(names = "--exclude", arity = "1..*", description = "Files to be excluded from the analysis")

View File

@ -68,7 +68,7 @@ public class CPDConfiguration extends AbstractConfiguration {
private boolean noSkipBlocks = false;
private String skipBlocksPattern = Tokenizer.DEFAULT_SKIP_BLOCKS_PATTERN;
private String skipBlocksPattern = CpdLanguageProperties.DEFAULT_SKIP_BLOCKS_PATTERN;
private boolean help;

View File

@ -79,13 +79,14 @@ public final class CpdAnalysis implements AutoCloseable {
private void setLanguageProperties(Language language, CPDConfiguration configuration) {
LanguagePropertyBundle props = configuration.getLanguageProperties(language);
setPropertyIfMissing(Tokenizer.CPD_ANONYMIZE_LITERALS, props, configuration.isIgnoreLiterals());
setPropertyIfMissing(Tokenizer.CPD_ANONYMIZE_IDENTIFIERS, props, configuration.isIgnoreIdentifiers());
setPropertyIfMissing(Tokenizer.CPD_IGNORE_METADATA, props, configuration.isIgnoreAnnotations());
setPropertyIfMissing(Tokenizer.CPD_IGNORE_IMPORTS, props, configuration.isIgnoreUsings());
setPropertyIfMissing(Tokenizer.CPD_IGNORE_LITERAL_SEQUENCES, props, configuration.isIgnoreLiteralSequences());
setPropertyIfMissing(Tokenizer.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES, props, configuration.isIgnoreIdentifierAndLiteralSequences());
setPropertyIfMissing(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS, props, configuration.isIgnoreLiterals());
setPropertyIfMissing(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS, props, configuration.isIgnoreIdentifiers());
setPropertyIfMissing(CpdLanguageProperties.CPD_IGNORE_METADATA, props, configuration.isIgnoreAnnotations());
setPropertyIfMissing(CpdLanguageProperties.CPD_IGNORE_IMPORTS, props, configuration.isIgnoreUsings());
setPropertyIfMissing(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES, props, configuration.isIgnoreLiteralSequences());
setPropertyIfMissing(CpdLanguageProperties.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES, props, configuration.isIgnoreIdentifierAndLiteralSequences());
if (!configuration.isNoSkipBlocks()) {
// see net.sourceforge.pmd.lang.cpp.CppLanguageModule.CPD_SKIP_BLOCKS
PropertyDescriptor<String> skipBlocks = (PropertyDescriptor) props.getPropertyDescriptor("cpdSkipBlocksPattern");
setPropertyIfMissing(skipBlocks, props, configuration.getSkipBlocksPattern());
}

View File

@ -0,0 +1,54 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import net.sourceforge.pmd.properties.PropertyDescriptor;
import net.sourceforge.pmd.properties.PropertyFactory;
/**
* These are language properties common to multiple {@link CpdCapableLanguage}s.
*
* @see net.sourceforge.pmd.lang.LanguagePropertyBundle
*/
public final class CpdLanguageProperties {
private CpdLanguageProperties() {
// utility class
}
public static final PropertyDescriptor<Boolean> CPD_IGNORE_LITERAL_SEQUENCES =
PropertyFactory.booleanProperty("cpdIgnoreLiteralSequences")
.defaultValue(false)
.desc("Ignore sequences of literals, eg `0, 0, 0, 0`")
.build();
public static final PropertyDescriptor<Boolean> CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES =
PropertyFactory.booleanProperty("cpdIgnoreLiteralAndIdentifierSequences")
.defaultValue(false)
.desc("Ignore sequences of literals, eg `a, b, 0, 0`")
.build();
public static final PropertyDescriptor<Boolean> 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();
public static final PropertyDescriptor<Boolean> 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();
public static final PropertyDescriptor<Boolean> CPD_IGNORE_IMPORTS =
PropertyFactory.booleanProperty("cpdIgnoreImports")
.defaultValue(true)
.desc("Ignore import statements and equivalent (eg using statements in C#).")
.build();
public static final PropertyDescriptor<Boolean> CPD_IGNORE_METADATA =
PropertyFactory.booleanProperty("cpdIgnoreMetadata")
.defaultValue(false)
.desc("Ignore metadata such as Java annotations or C# attributes.")
.build();
@Deprecated
// TODO what to do with this?
public static final String DEFAULT_SKIP_BLOCKS_PATTERN = "#if 0|#endif";
}

View File

@ -90,27 +90,27 @@ public class GUI implements CPDListener {
}
public boolean canIgnoreIdentifiers() {
return getLanguage().newPropertyBundle().hasDescriptor(Tokenizer.CPD_ANONYMIZE_IDENTIFIERS);
return getLanguage().newPropertyBundle().hasDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS);
}
public boolean canIgnoreLiterals() {
return getLanguage().newPropertyBundle().hasDescriptor(Tokenizer.CPD_ANONYMIZE_LITERALS);
return getLanguage().newPropertyBundle().hasDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS);
}
public boolean canIgnoreAnnotations() {
return getLanguage().newPropertyBundle().hasDescriptor(Tokenizer.CPD_IGNORE_METADATA);
return getLanguage().newPropertyBundle().hasDescriptor(CpdLanguageProperties.CPD_IGNORE_METADATA);
}
public boolean canIgnoreUsings() {
return getLanguage().newPropertyBundle().hasDescriptor(Tokenizer.CPD_IGNORE_IMPORTS);
return getLanguage().newPropertyBundle().hasDescriptor(CpdLanguageProperties.CPD_IGNORE_IMPORTS);
}
public boolean canIgnoreLiteralSequences() {
return getLanguage().newPropertyBundle().hasDescriptor(Tokenizer.CPD_IGNORE_LITERAL_SEQUENCES);
return getLanguage().newPropertyBundle().hasDescriptor(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES);
}
public boolean canIgnoreIdentifierAndLiteralSequences() {
return getLanguage().newPropertyBundle().hasDescriptor(Tokenizer.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES);
return getLanguage().newPropertyBundle().hasDescriptor(CpdLanguageProperties.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES);
}
}

View File

@ -7,51 +7,12 @@ package net.sourceforge.pmd.cpd;
import java.io.IOException;
import net.sourceforge.pmd.lang.document.TextDocument;
import net.sourceforge.pmd.properties.PropertyDescriptor;
import net.sourceforge.pmd.properties.PropertyFactory;
/**
* Tokenizes a source file into tokens consumable by CPD.
*/
public interface Tokenizer {
PropertyDescriptor<Boolean> CPD_IGNORE_LITERAL_SEQUENCES =
PropertyFactory.booleanProperty("cpdIgnoreLiteralSequences")
.defaultValue(false)
.desc("Ignore sequences of literals, eg `0, 0, 0, 0`")
.build();
PropertyDescriptor<Boolean> CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES =
PropertyFactory.booleanProperty("cpdIgnoreLiteralAndIdentifierSequences")
.defaultValue(false)
.desc("Ignore sequences of literals, eg `a, b, 0, 0`")
.build();
PropertyDescriptor<Boolean> 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();
PropertyDescriptor<Boolean> 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();
PropertyDescriptor<Boolean> CPD_IGNORE_IMPORTS =
PropertyFactory.booleanProperty("cpdIgnoreImports")
.defaultValue(true)
.desc("Ignore import statements and equivalent (eg using statements in C#).")
.build();
PropertyDescriptor<Boolean> CPD_IGNORE_METADATA =
PropertyFactory.booleanProperty("cpdIgnoreMetadata")
.defaultValue(false)
.desc("Ignore metadata such as Java annotations or C# attributes.")
.build();
@Deprecated // TODO what to do with this?
String DEFAULT_SKIP_BLOCKS_PATTERN = "#if 0|#endif";
/**
* Tokenize the source code and record tokens using the provided token factory.
*/

View File

@ -8,7 +8,7 @@ import java.util.Objects;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.cpd.CpdCapableLanguage;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.lang.ast.DummyNode;
import net.sourceforge.pmd.lang.ast.DummyNode.DummyRootNode;
import net.sourceforge.pmd.lang.ast.ParseException;
@ -50,8 +50,8 @@ public class DummyLanguageModule extends SimpleLanguageModuleBase implements Cpd
@Override
public LanguagePropertyBundle newPropertyBundle() {
LanguagePropertyBundle bundle = super.newPropertyBundle();
bundle.definePropertyDescriptor(Tokenizer.CPD_ANONYMIZE_LITERALS);
bundle.definePropertyDescriptor(Tokenizer.CPD_ANONYMIZE_IDENTIFIERS);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS);
return bundle;
}

View File

@ -4,6 +4,7 @@
package net.sourceforge.pmd.lang.cpp;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
import net.sourceforge.pmd.lang.LanguageRegistry;
@ -20,7 +21,7 @@ public class CppLanguageModule extends CpdOnlyLanguageModuleBase {
public static final PropertyDescriptor<String> CPD_SKIP_BLOCKS =
PropertyFactory.stringProperty("cpdSkipBlocksPattern")
.defaultValue("#if 0|#endif")
.defaultValue(CpdLanguageProperties.DEFAULT_SKIP_BLOCKS_PATTERN)
.desc("Specifies a start and end delimiter for CPD to completely ignore. "
+ "The delimiters are separated by a pipe |. The default skips code "
+ " that is conditionally compiled out. Set this property to empty to disable this.")
@ -43,8 +44,8 @@ public class CppLanguageModule extends CpdOnlyLanguageModuleBase {
@Override
public LanguagePropertyBundle newPropertyBundle() {
LanguagePropertyBundle bundle = super.newPropertyBundle();
bundle.definePropertyDescriptor(Tokenizer.CPD_IGNORE_LITERAL_SEQUENCES);
bundle.definePropertyDescriptor(Tokenizer.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES);
bundle.definePropertyDescriptor(CPD_SKIP_BLOCKS);
return bundle;
}

View File

@ -8,7 +8,7 @@ import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.impl.JavaCCTokenFilter;
import net.sourceforge.pmd.cpd.impl.TokenizerBase;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
@ -33,8 +33,8 @@ public class CPPTokenizer extends TokenizerBase<JavaccToken> {
private final boolean ignoreLiteralSequences;
public CPPTokenizer(LanguagePropertyBundle cppProperties) {
ignoreLiteralSequences = cppProperties.getProperty(Tokenizer.CPD_IGNORE_LITERAL_SEQUENCES);
ignoreIdentifierAndLiteralSeqences = cppProperties.getProperty(Tokenizer.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES);
ignoreLiteralSequences = cppProperties.getProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES);
ignoreIdentifierAndLiteralSeqences = cppProperties.getProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES);
String skipBlocksPattern = cppProperties.getProperty(CppLanguageModule.CPD_SKIP_BLOCKS);
if (StringUtils.isNotBlank(skipBlocksPattern)) {
skipBlocks = true;

View File

@ -9,6 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.Tokens;
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
@ -171,8 +172,8 @@ class CPPTokenizerTest extends CpdTextComparisonTest {
} else if (skipPattern != null) {
properties.setProperty(CppLanguageModule.CPD_SKIP_BLOCKS, skipPattern);
}
properties.setProperty(Tokenizer.CPD_IGNORE_LITERAL_SEQUENCES, skipLiteralSequences);
properties.setProperty(Tokenizer.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES, skipSequences);
properties.setProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES, skipLiteralSequences);
properties.setProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_AND_IDENTIFIER_SEQUENCES, skipSequences);
};
}
}

View File

@ -4,6 +4,7 @@
package net.sourceforge.pmd.lang.cs;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
import net.sourceforge.pmd.lang.LanguageRegistry;
@ -29,9 +30,9 @@ public class CsLanguageModule extends CpdOnlyLanguageModuleBase {
@Override
public LanguagePropertyBundle newPropertyBundle() {
LanguagePropertyBundle bundle = super.newPropertyBundle();
bundle.definePropertyDescriptor(Tokenizer.CPD_IGNORE_LITERAL_SEQUENCES);
bundle.definePropertyDescriptor(Tokenizer.CPD_IGNORE_IMPORTS);
bundle.definePropertyDescriptor(Tokenizer.CPD_IGNORE_METADATA);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_IGNORE_IMPORTS);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_IGNORE_METADATA);
return bundle;
}

View File

@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.cs.cpd;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Lexer;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.impl.AntlrTokenFilter;
import net.sourceforge.pmd.cpd.impl.AntlrTokenizer;
import net.sourceforge.pmd.cpd.impl.BaseTokenFilter;
@ -26,9 +26,9 @@ public class CsTokenizer extends AntlrTokenizer {
private final boolean ignoreAttributes;
public CsTokenizer(LanguagePropertyBundle properties) {
ignoreUsings = properties.getProperty(Tokenizer.CPD_IGNORE_IMPORTS);
ignoreLiteralSequences = properties.getProperty(Tokenizer.CPD_IGNORE_LITERAL_SEQUENCES);
ignoreAttributes = properties.getProperty(Tokenizer.CPD_IGNORE_METADATA);
ignoreUsings = properties.getProperty(CpdLanguageProperties.CPD_IGNORE_IMPORTS);
ignoreLiteralSequences = properties.getProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES);
ignoreAttributes = properties.getProperty(CpdLanguageProperties.CPD_IGNORE_METADATA);
}
@Override

View File

@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
import net.sourceforge.pmd.cpd.test.LanguagePropertyConfig;
import net.sourceforge.pmd.lang.ast.TokenMgrError;
@ -120,9 +120,9 @@ class CsTokenizerTest extends CpdTextComparisonTest {
private LanguagePropertyConfig properties(boolean ignoreUsings, boolean ignoreLiteralSequences, boolean ignoreAttributes) {
return properties -> {
properties.setProperty(Tokenizer.CPD_IGNORE_IMPORTS, ignoreUsings);
properties.setProperty(Tokenizer.CPD_IGNORE_LITERAL_SEQUENCES, ignoreLiteralSequences);
properties.setProperty(Tokenizer.CPD_IGNORE_METADATA, ignoreAttributes);
properties.setProperty(CpdLanguageProperties.CPD_IGNORE_IMPORTS, ignoreUsings);
properties.setProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES, ignoreLiteralSequences);
properties.setProperty(CpdLanguageProperties.CPD_IGNORE_METADATA, ignoreAttributes);
};
}
}

View File

@ -7,9 +7,9 @@ package net.sourceforge.pmd.lang.java.cpd;
import java.util.Deque;
import java.util.LinkedList;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.TokenEntry;
import net.sourceforge.pmd.cpd.TokenFactory;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.impl.JavaCCTokenFilter;
import net.sourceforge.pmd.cpd.impl.JavaCCTokenizer;
import net.sourceforge.pmd.lang.TokenManager;
@ -32,9 +32,9 @@ public class JavaTokenizer extends JavaCCTokenizer {
private final ConstructorDetector constructorDetector;
public JavaTokenizer(JavaLanguageProperties properties) {
ignoreAnnotations = properties.getProperty(Tokenizer.CPD_IGNORE_METADATA);
ignoreLiterals = properties.getProperty(Tokenizer.CPD_ANONYMIZE_LITERALS);
ignoreIdentifiers = properties.getProperty(Tokenizer.CPD_ANONYMIZE_IDENTIFIERS);
ignoreAnnotations = properties.getProperty(CpdLanguageProperties.CPD_IGNORE_METADATA);
ignoreLiterals = properties.getProperty(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS);
ignoreIdentifiers = properties.getProperty(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS);
constructorDetector = new ConstructorDetector(ignoreIdentifiers);
}

View File

@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.java.internal;
import org.apache.commons.lang3.EnumUtils;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.lang.JvmLanguagePropertyBundle;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.lang.java.JavaLanguageModule;
@ -28,9 +28,9 @@ public class JavaLanguageProperties extends JvmLanguagePropertyBundle {
public JavaLanguageProperties() {
super(JavaLanguageModule.getInstance());
definePropertyDescriptor(INTERNAL_INFERENCE_LOGGING_VERBOSITY);
definePropertyDescriptor(Tokenizer.CPD_IGNORE_METADATA);
definePropertyDescriptor(Tokenizer.CPD_ANONYMIZE_IDENTIFIERS);
definePropertyDescriptor(Tokenizer.CPD_ANONYMIZE_LITERALS);
definePropertyDescriptor(CpdLanguageProperties.CPD_IGNORE_METADATA);
definePropertyDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS);
definePropertyDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS);
}
public static boolean isPreviewEnabled(LanguageVersion version) {

View File

@ -6,7 +6,7 @@ package net.sourceforge.pmd.lang.java.cpd;
import org.junit.jupiter.api.Test;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
import net.sourceforge.pmd.cpd.test.LanguagePropertyConfig;
import net.sourceforge.pmd.lang.java.JavaLanguageModule;
@ -100,9 +100,9 @@ class JavaTokenizerTest extends CpdTextComparisonTest {
boolean ignoreLiterals,
boolean ignoreIdents) {
return properties -> {
properties.setProperty(Tokenizer.CPD_IGNORE_METADATA, ignoreAnnotations);
properties.setProperty(Tokenizer.CPD_ANONYMIZE_IDENTIFIERS, ignoreIdents);
properties.setProperty(Tokenizer.CPD_ANONYMIZE_LITERALS, ignoreLiterals);
properties.setProperty(CpdLanguageProperties.CPD_IGNORE_METADATA, ignoreAnnotations);
properties.setProperty(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS, ignoreIdents);
properties.setProperty(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS, ignoreLiterals);
};
}

View File

@ -4,6 +4,7 @@
package net.sourceforge.pmd.lang.lua;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
import net.sourceforge.pmd.lang.impl.CpdOnlyLanguageModuleBase;
@ -21,7 +22,7 @@ public class LuaLanguageModule extends CpdOnlyLanguageModuleBase {
@Override
public LanguagePropertyBundle newPropertyBundle() {
LanguagePropertyBundle bundle = super.newPropertyBundle();
bundle.definePropertyDescriptor(Tokenizer.CPD_IGNORE_LITERAL_SEQUENCES);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES);
return bundle;
}

View File

@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.lua.cpd;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Lexer;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.impl.AntlrTokenFilter;
import net.sourceforge.pmd.cpd.impl.AntlrTokenizer;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
@ -23,7 +23,7 @@ public class LuaTokenizer extends AntlrTokenizer {
private final boolean ignoreLiteralSequences;
public LuaTokenizer(LanguagePropertyBundle bundle) {
ignoreLiteralSequences = bundle.getProperty(Tokenizer.CPD_IGNORE_LITERAL_SEQUENCES);
ignoreLiteralSequences = bundle.getProperty(CpdLanguageProperties.CPD_IGNORE_LITERAL_SEQUENCES);
}
@Override

View File

@ -4,6 +4,7 @@
package net.sourceforge.pmd.lang.plsql;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
import net.sourceforge.pmd.lang.impl.SimpleLanguageModuleBase;
@ -45,8 +46,8 @@ public class PLSQLLanguageModule extends SimpleLanguageModuleBase {
@Override
public LanguagePropertyBundle newPropertyBundle() {
LanguagePropertyBundle bundle = super.newPropertyBundle();
bundle.definePropertyDescriptor(Tokenizer.CPD_ANONYMIZE_LITERALS);
bundle.definePropertyDescriptor(Tokenizer.CPD_ANONYMIZE_IDENTIFIERS);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS);
bundle.definePropertyDescriptor(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS);
return bundle;
}

View File

@ -4,7 +4,7 @@
package net.sourceforge.pmd.lang.plsql.cpd;
import net.sourceforge.pmd.cpd.Tokenizer;
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
import net.sourceforge.pmd.cpd.impl.JavaCCTokenizer;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
import net.sourceforge.pmd.lang.TokenManager;
@ -25,8 +25,8 @@ public class PLSQLTokenizer extends JavaCCTokenizer {
* interested in comment variation, so we shall default ignoreComments
* to true
*/
ignoreIdentifiers = properties.getProperty(Tokenizer.CPD_ANONYMIZE_IDENTIFIERS);
ignoreLiterals = properties.getProperty(Tokenizer.CPD_ANONYMIZE_LITERALS);
ignoreIdentifiers = properties.getProperty(CpdLanguageProperties.CPD_ANONYMIZE_IDENTIFIERS);
ignoreLiterals = properties.getProperty(CpdLanguageProperties.CPD_ANONYMIZE_LITERALS);
}
@Override