Added file encoding option to CPD GUI, which already existed for the command line and Ant

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/branches/pmd/4.2.x@6000 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Xavier Le Vourch 2008-04-09 16:00:10 +00:00
parent d61aa6189f
commit ce49bdd986
3 changed files with 17 additions and 1 deletions

View File

@ -5,6 +5,7 @@ Fixed bug 1928009 - Error using migration ruleset in PMD 4.2
Fixed bug 1932242 - EmptyMethodInAbstractClassShouldBeAbstract false +
ruleset.dtd and ruleset_xml_schema.xsd added to jar file in rulesets directory
Update RuleSetWriter to handle non-Apache TRAX implementations, add an option to not use XML Namespaces
Added file encoding option to CPD GUI, which already existed for the command line and Ant
bin and java14/bin scripts:
retroweaver version was not correct in java14/bin scripts
support for extra languages in cpd.sh

View File

@ -221,6 +221,7 @@ public class GUI implements CPDListener {
private JTextField rootDirectoryField = new JTextField(System.getProperty("user.home"));
private JTextField minimumLengthField = new JTextField(Integer.toString(defaultCPDMinimumLength));
private JTextField encodingField = new JTextField(System.getProperty("file.encoding"));
private JTextField timeField = new JTextField(6);
private JLabel phaseLabel = new JLabel();
private JProgressBar tokenizingFilesBar = new JProgressBar();
@ -351,6 +352,13 @@ public class GUI implements CPDListener {
helper.add(goButton);
helper.add(cxButton);
helper.nextRow();
helper.addLabel("File encoding (defaults based upon locale):");
encodingField.setColumns(1);
helper.add(encodingField);
helper.addLabel("");
helper.addLabel("");
helper.nextRow();
// settingsPanel.setBorder(BorderFactory.createTitledBorder("Settings"));
return settingsPanel;
}
@ -510,6 +518,7 @@ public class GUI implements CPDListener {
LanguageConfig conf = languageConfigFor((String)languageBox.getSelectedItem());
Language language = conf.languageFor(new LanguageFactory(), p);
CPD cpd = new CPD(Integer.parseInt(minimumLengthField.getText()), language);
cpd.setEncoding(encodingField.getText());
cpd.setCpdListener(this);
tokenizingFilesBar.setMinimum(0);
phaseLabel.setText("");

View File

@ -50,7 +50,9 @@
will be seen as equivalent. You may want to run PMD with this option off to start with and
then switch it on to see what it turns up. There's also a <code>ignoreIdentifiers="true"</code> option
that does the same thing with identifiers; i.e., variable names, methods names, and so forth.
The same guidelines apply. Finally, there's an optional <code>language="cpp|java|php|ruby"</code> flag
The same guidelines apply. There's also an <code>encoding</code> option which allows the encoding used
when parsing files to be specified; the default is based upon the locale.
Finally, there's an optional <code>language="cpp|java|php|ruby"</code> flag
to select the appropriate language; the default language is "java".
</p>
<p>Also, you can get verbose output from this task by running ant with the <code>-v</code> flag; i.e.:</p>
@ -84,6 +86,10 @@ $ java net.sourceforge.pmd.cpd.CPD --minimum-tokens 100 --files /path/to/other/s
you can skip those using --skip-duplicate-files:</p>
<source>
$ java net.sourceforge.pmd.cpd.CPD --minimum-tokens 100 --files /path/to/c/source --language cpp --skip-duplicate-files
</source>
<p>You can also the encoding to use when parsing files:</p>
<source>
$ java net.sourceforge.pmd.cpd.CPD --minimum-tokens 100 --files /usr/local/java/src/java --encoding utf-16le
</source>
<p>You can also specify a report format - here we're using the XML report:</p>
<source>