Nothing fancy here, Just look for the extensions and separate by whites pace mostly
package net.sourceforge.pmd.cpd;
import java.util.Properties;
public class PerlLanguage extends AbstractLanguage {
public PerlLanguage() {
this(System.getProperties());
}
public PerlLanguage(Properties properties) {
super(new PerlTokenizer(), ".pm", ".pl");
PerlTokenizer tokenizer = (PerlTokenizer)getTokenizer();
tokenizer.setProperties(properties);
}
}
package net.sourceforge.pmd.cpd;
import java.util.List;
import java.util.Properties;
public class PerlTokenizer implements Tokenizer {
public void tokenize(SourceCode tokens, Tokens tokenEntries) {
List<String> code = tokens.getCode();
for (int i = 0; i < code.size(); i++) {
String currentLine = code.get(i);
for (int j = 0; j < currentLine.length(); j++) {
char tok = currentLine.charAt(j);
if (!Character.isWhitespace(tok) && tok != '{' && tok != '}'
&& tok != ';') {
tokenEntries.add(new TokenEntry(String.valueOf(tok), tokens
.getFileName(), i + 1));
}
}
}
tokenEntries.add(TokenEntry.getEOF());
}
public void setProperties(Properties properties) {
// TODO Auto-generated method stub
}
}
Just to make things easier... I've built a maven project and hosted it on github
https://github.com/jyn/pmd-perlsupport
HI Jason,
Thanks for your contribution ! As your proposed some code, i move this entry to "Patches". Also, as you seems to be fluent with git, I wonder if you wouldn't mind forking PMD on github, add your changes and send us a pull request ? This will greatly reviewing and adding quickly your changes to PMD !
https://github.com/pmd/pmd
Thanks !
This is now obsolete with https://github.com/pmd/pmd/pull/82 which was integrated in PMD 5.5.0.