#1090 cpp parser exception with inline asm
This commit is contained in:
@ -62,6 +62,13 @@ public class CPDConfiguration extends AbstractConfiguration {
|
||||
@Parameter(names = "--skip-lexical-errors", description = "Skip files which can't be tokenized due to invalid characters instead of aborting CPD", required = false)
|
||||
private boolean skipLexicalErrors = false;
|
||||
|
||||
@Parameter(names = "--no-skip-blocks", description = "Do not skip code blocks marked with --skip-blocks-pattern (e.g. #if 0 until #endif)", required = false)
|
||||
private boolean noSkipBlocks = false;
|
||||
|
||||
@Parameter(names = "--skip-blocks-pattern", description = "Pattern to find the blocks to skip. Start and End pattern separated by |. "
|
||||
+ "Default is \"" + Tokenizer.DEFAULT_SKIP_BLOCKS_PATTERN + "\".", required = false)
|
||||
private String skipBlocksPattern = Tokenizer.DEFAULT_SKIP_BLOCKS_PATTERN;
|
||||
|
||||
@Parameter(names = "--files", variableArity = true, description = "List of files and directories to process", required = false)
|
||||
private List<String> files;
|
||||
|
||||
@ -180,6 +187,8 @@ public class CPDConfiguration extends AbstractConfiguration {
|
||||
} else {
|
||||
properties.remove(Tokenizer.IGNORE_ANNOTATIONS);
|
||||
}
|
||||
properties.setProperty(Tokenizer.OPTION_SKIP_BLOCKS, Boolean.toString(!configuration.isNoSkipBlocks()));
|
||||
properties.setProperty(Tokenizer.OPTION_SKIP_BLOCKS_PATTERN, configuration.getSkipBlocksPattern());
|
||||
configuration.getLanguage().setProperties(properties);
|
||||
}
|
||||
|
||||
@ -341,4 +350,20 @@ public class CPDConfiguration extends AbstractConfiguration {
|
||||
public String getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
public boolean isNoSkipBlocks() {
|
||||
return noSkipBlocks;
|
||||
}
|
||||
|
||||
public void setNoSkipBlocks(boolean noSkipBlocks) {
|
||||
this.noSkipBlocks = noSkipBlocks;
|
||||
}
|
||||
|
||||
public String getSkipBlocksPattern() {
|
||||
return skipBlocksPattern;
|
||||
}
|
||||
|
||||
public void setSkipBlocksPattern(String skipBlocksPattern) {
|
||||
this.skipBlocksPattern = skipBlocksPattern;
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,8 @@ public class CPDTask extends Task {
|
||||
private boolean ignoreAnnotations;
|
||||
private boolean skipLexicalErrors;
|
||||
private boolean skipDuplicateFiles;
|
||||
private boolean skipBlocks = true;
|
||||
private String skipBlocksPattern = Tokenizer.DEFAULT_SKIP_BLOCKS_PATTERN;
|
||||
private File outputFile;
|
||||
private String encoding = System.getProperty("file.encoding");
|
||||
private List<FileSet> filesets = new ArrayList<FileSet>();
|
||||
@ -102,6 +104,8 @@ public class CPDTask extends Task {
|
||||
if (ignoreAnnotations) {
|
||||
p.setProperty(Tokenizer.IGNORE_ANNOTATIONS, "true");
|
||||
}
|
||||
p.setProperty(Tokenizer.OPTION_SKIP_BLOCKS, Boolean.toString(skipBlocks));
|
||||
p.setProperty(Tokenizer.OPTION_SKIP_BLOCKS_PATTERN, skipBlocksPattern);
|
||||
return LanguageFactory.createLanguage(language, p);
|
||||
}
|
||||
|
||||
@ -208,6 +212,14 @@ public class CPDTask extends Task {
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
public void setSkipBlocks(boolean skipBlocks) {
|
||||
this.skipBlocks = skipBlocks;
|
||||
}
|
||||
|
||||
public void setSkipBlocksPattern(String skipBlocksPattern) {
|
||||
this.skipBlocksPattern = skipBlocksPattern;
|
||||
}
|
||||
|
||||
public static class FormatAttribute extends EnumeratedAttribute {
|
||||
private static final String[] FORMATS = new String[]{XML_FORMAT, TEXT_FORMAT, CSV_FORMAT};
|
||||
public String[] getValues() {
|
||||
|
@ -9,6 +9,23 @@ public interface Tokenizer {
|
||||
String IGNORE_LITERALS = "ignore_literals";
|
||||
String IGNORE_IDENTIFIERS = "ignore_identifiers";
|
||||
String IGNORE_ANNOTATIONS = "ignore_annotations";
|
||||
/**
|
||||
* Enables or disabled skipping of blocks like a pre-processor.
|
||||
* It is a boolean property.
|
||||
* The default value is <code>true</code>.
|
||||
* @see #OPTION_SKIP_BLOCKS_PATTERN
|
||||
*/
|
||||
String OPTION_SKIP_BLOCKS = "net.sourceforge.pmd.cpd.Tokenizer.skipBlocks";
|
||||
/**
|
||||
* Configures the pattern, to find the blocks to skip.
|
||||
* It is a string property and contains of two parts, separated by {@code |}.
|
||||
* The first part is the start pattern, the second part is the ending pattern.
|
||||
* Default value is "{@code #if 0|#endif}".
|
||||
* @see #DEFAULT_SKIP_BLOCKS_PATTERN
|
||||
*/
|
||||
String OPTION_SKIP_BLOCKS_PATTERN = "net.sourceforge.pmd.cpd.Tokenizer.skipBlocksPattern";
|
||||
|
||||
String DEFAULT_SKIP_BLOCKS_PATTERN = "#if 0|#endif";
|
||||
|
||||
void tokenize(SourceCode sourceCode, Tokens tokenEntries) throws IOException;
|
||||
}
|
||||
|
Reference in New Issue
Block a user