Menu ▾ ▴

does pydev code analysis resolve java classes

2009-07-06
2013-03-15
  • Christiaan Kelly

    I have a jython script which runs successfully using pydev.  But the code analysis complains about 'unresolved imports' for the java classes.  Is this expected?  In other words, does pydev extensions code analysis resolve only jython modules and not java classes?  Same question for code completion.

     
    • Fabio Zadrozny

      Fabio Zadrozny - 2009-07-06

      Well, the right answer is that it depends. Pydev should be able to analyze the most common cases successfully, but there can be some cases where things don't go so well (mainly because of the dynamic nature of python).

      So, without your particular use-case, it's hard to actually know if it should work for you or not (and have in mind that those are usually exceptions, and there are ways you can help pydev to know about those cases, or at least mark it to ignore those warnings).

      Cheers,

      Fabio

       
    • Christiaan Kelly

      OK, code analysis and completion is working but *only* if I jar up my Java classes and put the jar file on the project pythonpath. 

      But, previously, I had the folder where these standalone class files exist also on my pythonpath, but in that case, the code analysis complained about unresolved imports.  Also (as mentioned previously), PyDev successfully ran my jython script with the non-jar'd classes even though it still complained about the unresolved imports.

      So the bottom line: does code analysis and completion depend on the class files being Jar'd?  If not, I'll post more details about my (very standard and simple) configuration.

      Thanks.

       
      • Fabio Zadrozny

        Fabio Zadrozny - 2009-07-13

        Sorry for the delay in getting back to you...

        Ok, it should work in the following scenarios: considering you have a java (JDT) project, all you need to do is add that project as a reference in your current project (it doesn't even need a pydev nature in it -- but you need it as a JDT project), otherwise, you really need a jar (just extracted classes in the filesystem won't really work -- sorry about that).

        Cheers,

        Fabio

         
        • Fabio Zadrozny

          Fabio Zadrozny - 2009-07-13

          Oops,

          I just realized I said something wrong: your referred project must have the pydev config and the pythonpath must contain the bin directory (where jdt creates the .class files).

          Cheers,

          Fabio

           
          • Christiaan Kelly

            I have a single project which has both java nature and python nature (intepreter type set to jython) and their associated builders.  I have set the pythonpath property for the project to both the jython source directory AND the output folder for the java classes (and I've confirmed that the .class files are there).

            Could the problem be that the java class files are in the same project?  It sounds unlikely, but I don't have any other explanation.

             
            • Fabio Zadrozny

              Fabio Zadrozny - 2009-07-13

              Yeap, that's it... right now it treats other referred JDT projects, but it doesn't check if the project itself is a JDT/pydev project.

              Cheers,

              Fabio