Psi-WHAT??

So trying to figure out how to write a plugin that wants to modify the code in the current editor. Needless to say I am pretty much stuck as I can't find any documentation for this. How does IntelliJ have all these plugins if the documentation is really horrible, how did everyone figure out how to do it? Am I just a retard or something??

What are all these "Psi" classes? PsiElementFactory appears to be what I want but I can't figure out how to get a reference to it. Saw some forumn post (from the FAQ) about PsiManager.getInstance(project).getElementFactory() but the "getElementFactory()" method doesn't appear to exist.

Is there some documentation I am missing somewhere? How do I even start to figure this out?

I have read everthing linked to on this page:

http://www.jetbrains.com/idea/plugins/plugin_developers.html

Everything on that page appears to tell you how to get started on a plugin (like how to add it to a menu and such) but nothing tells you how to do anything once you have the plugin all setup.

3 comments
Comment actions Permalink

Actually finding out what you have to do achieve something in an IDEA plugin is one of the exciting challenges while programming a plugin for IDEA PSI is the program structure interface and is described in one of the articles linked on the page you linked to ( http://www.jetbrains.com/idea/plugins/developing_custom_language_plugins.html ).

You should download the IDEA plugin SDK. It contains the sources of the OpenAPI which is part of the API you'll need for plugin development. It also contains the sources of some plugins and for many plugins on ( http://plugins.intellij.net/ ) the source code is also available on the page of the respective plugin. Jetbrains' Subversion server at http://svn.jetbrains.org/idea also contains the source code of more plugins such as the Groovy integration.

Also I'd highly recommend to install IntelliJad 8. Although it has some usability issues, you'll need it to decompile the closed source (and partly obfuscated) APIs that you'll need to look into to find out how to use the OpenAPI or just because an API that you need to use is not part of the OpenAPI.

The best ways to find out how something is achieved or how some API is used:
* Find a plugin that does something similar and look at the source code of that plugin.
* Search for an API-class in all plugin source codes.
* Search for the usage of a class in IDEA's code and decompile the classes containing references if they are not part of the OpenAPI.

Normally when you create an IDEA plugin JDK idea. jar is not added to the JDK-classpath. Adding it manually to the JDK-classpath will make avvailable some closed source APIs that are sometimes useful.

Best regards,
  Robert

0
Comment actions Permalink

Hello Michael,

What are all these "Psi" classes? PsiElementFactory appears to be what
I want but I can't figure out how to get a reference to it. Saw some
forumn post (from the FAQ) about
PsiManager.getInstance(project).getElementFactory() but the
"getElementFactory()" method doesn't appear to exist.


Most of the PSI classes actually have at least some JavaDoc, and actually
the JavaDoc for PsiElementFactory describes how to get hold of one:
JavaPsiFacade.getInstance(project).getElementFactory()

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Robert, Dmitry, thanks for the information! I think I am moving in the right direction now. I didn't realize the plugin dev kit had some sample plugin source in it (maybe I should have taken a closer look at what was in the dev kit before posting:-)). Between the sample sources and the open api java doc I should be able to make some progress...might be back with more questions soon though:-)

0

Please sign in to leave a comment.