RuleContext.getSourceCodeFile() returns null

Developers
2012-06-07
2012-10-07
  • Artjom Kochtchi

    Artjom Kochtchi - 2012-06-07

    Hello everyone,

    I'm trying to find out what source code file I'm analyzing (to read config
    files accordingly), but unfortunately, RuleContext.getSourceCodeFile() always
    returns null (I'm overriding AbstractJavaRule.start(RuleContext)).

    The PMD version I am currently using is 4.2.x. Do you have any insight on
    this?

    Regards,
    Artjom

     
  • Ryan Gustafson

    Ryan Gustafson - 2012-06-07

    That API is not called per AST, it is meant to be called across ASTs. For a
    Java rule, visit 'ASTCompilationUnit' and the RuleContext will have source
    code file set.

     
  • Artjom Kochtchi

    Artjom Kochtchi - 2012-06-10

    Thank you! I didn't realize that the data object passed to visit methods is
    the RuleContext.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks