Using Python packages

Hello,

I'm trying to develop a multi language plugin using Java and Python. In one of my Java classes I'm trying to get the PSI for a given Python file using the Python PSI library in jetbrains, but "com.jetbrains.python" doesn't resolve.

It looks like the SDK only recognizes "com.jetbrains.javascript" and "com.jetbrains.jsonSchema"

I looked at the version of Community Edition that I checked out, and the packages for supporting python exist.

Is there a solution for this?

3 comments
Comment actions Permalink

I don't believe that the Python packages are included in the SDK classpath by default.  Go to your project structure dialog (File->Project Structure...->SDKs [left panel]->Classpath [right panel]) and add all of the jars from your IDEA installation /lib directory to the SDK.  (Duplicates will be discarded, so pick _all_ of the jars.)  Anything in blue at the bottom of the list is what has been added during this step.

0
Comment actions Permalink

I tried doing that and then reloading the project, yet the modules still aren't recognized.

0
Comment actions Permalink

I'm attempting to do something similar where I need to use the PSI for multiple languages and am having the same problem.

 

from plugin.xml:

<depends>com.intellij.modules.lang</depends>

<!-- the path to the python module is red -->
<depends optional="true">com.intellij.modules.python</depends>

<extensions defaultExtensionNs="com.intellij">

<!-- this one works for the JAVA PSI consumer -->
<annotator language="JAVA" implementationClass="com.trendmicro.codemetrics.impl.JavaCodeComplexityAnnotator"/>

<!-- the "Python" is red for the language selection -->
<annotator language="Python" implementationClass="com.trendmicro.codemetrics.impl.PythonCodeComplexityAnnotator"/>
</extensions>

Then inside the later module, "python" is red in:

import com.jetbrains.python.psi.*;

and cannot resolve any of the Py*Statement psi element types.

I even tried adding pycharm's lib/*.jar then restarting Intellij. No luck.

 

2

Please sign in to leave a comment.