Menu

#270 add to CPD support for language Perl

Unstable_(example)
closed
None
5
2016-11-06
2012-01-24
Anonymous
No

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

    }

}

Discussion

  • Jason

    Jason - 2012-08-06

    Just to make things easier... I've built a maven project and hosted it on github

    https://github.com/jyn/pmd-perlsupport

     
  • Romain PELISSE

    Romain PELISSE - 2012-08-06

    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 !

     
  • Andreas Dangel

    Andreas Dangel - 2016-11-06
    • status: open --> closed
    • Group: --> Unstable_(example)
     
  • Andreas Dangel

    Andreas Dangel - 2016-11-06

    This is now obsolete with https://github.com/pmd/pmd/pull/82 which was integrated in PMD 5.5.0.

     

Log in to post a comment.