Please read and review: Draft of article "Developing custom language plugins for IDEA"

Hello everyone,

A very commonly requested documentation item was an article explaining the
concepts and usage of the IDEA Language API. Well, now there is one - or
at least, a draft for one. Before the article is published officially, I'd
like to give you the chance to review and comment on it.

What I'm most interested in is:
- if you have already used the Language API - are there any difficulties
or pitfalls that you encountered and that are not described in the article?
- if you have not used the Language API - does the article give you a clear
idea of how to use it, or are there any concepts that should be explained
in more detail?

The current draft of the article is posted at:
http://www.yole.ru/CustomLanguagePlugins.html

Thanks in advance for your help!

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


40 comments
Comment actions Permalink

Hello Oliver,

OM> Although I can only get code completion to work for symbols defined
OM> in my test.py file. I am assuming this is not implemented yet.

That's correct.

OM> Will there be completion on the standard python modules in future ?

I certainly would like to implement this, but currently I have very little
time to work on the Python plugin. The project is open-source, so if you're
willing to contribute to it, this could help get the functionality implemented
much faster.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0
Comment actions Permalink

How is the source file and its corresponding AST kept in sync?

For example, if I type a space in the middle of a source file, would it not be necessary to change all the text ranges in the ASTs following that text?

If I rename a method, is the entire source file re-written?

Just explaning the above scenarios would make things clear.

There are hints in the document with regard to this sync, but more explanation would be great.

0
Comment actions Permalink

Farokh Morshed wrote:

How is the source file and its corresponding AST kept in sync?

For example, if I type a space in the middle of a source file, would
it not be necessary to change all the text ranges in the ASTs
following that text?


I believe text ranges are not recomputed, but rather the entire file is
reparsed, and old ASTNodes and PsiElements are marked invalid.

If I rename a method, is the entire source file re-written?


I believe all changes cause a full reparse. (Lexing is another issue.)

0
Comment actions Permalink

Hello Keith,

Farokh Morshed wrote:

>> How is the source file and its corresponding AST kept in sync?
>>
>> For example, if I type a space in the middle of a source file, would
>> it not be necessary to change all the text ranges in the ASTs
>> following that text?
>>

I believe text ranges are not recomputed, but rather the entire file
is reparsed, and old ASTNodes and PsiElements are marked invalid.

Not the entire file is reparsed, but a certain region of it, e.g. when IDEA
detects the changes are isolated in the code block, then only that block
is reparsed.

>> If I rename a method, is the entire source file re-written?
>>

I believe all changes cause a full reparse. (Lexing is another issue.)


No, you are wrong. Changes via PSI write interface do not cause reparse,
but are done on the parsed tree and synchronized back to document. Otherwise
no refactoring could work:)

Eugene.


0
Comment actions Permalink

Eugene Vigdorchik (JetBrains) wrote:

Hello Keith,

>> Farokh Morshed wrote:
>>
>>> How is the source file and its corresponding AST kept in sync?
>>>
>>> For example, if I type a space in the middle of a source file, would
>>> it not be necessary to change all the text ranges in the ASTs
>>> following that text?
>>>
>> I believe text ranges are not recomputed, but rather the entire file
>> is reparsed, and old ASTNodes and PsiElements are marked invalid.


Not the entire file is reparsed, but a certain region of it, e.g. when
IDEA detects the changes are isolated in the code block, then only that
block is reparsed.


How does this happen? I've noticed that even after any change, my parser
is called from the beginning (there's not even a mechanism to parse
incrementally).

>>
>>> If I rename a method, is the entire source file re-written?
>>>
>> I believe all changes cause a full reparse. (Lexing is another issue.)


No, you are wrong. Changes via PSI write interface do not cause reparse,
but are done on the parsed tree and synchronized back to document.
Otherwise no refactoring could work:)


I thought Farokh meant changes to text.

0
Comment actions Permalink

The element type that should be incrementally reparsable should implement IChameleonElementType. Using this class should be documented however.

0
Comment actions Permalink

Hi Dmitry,

I was excited to find PythonID this morning. I put the JAR in my /plugins directory and fired up Selena 7343. Unfortunately, it tells me that PythonID is incompatible. Any plans to update it? I'm using Komodo for my first Python IDE, but of course I'd prefer IntelliJ if it were available to me.

Brilliant product, by the way. Please do keep it up - you're way ahead of the Eclipses and NetBeans of the world in my eyes. Sincerely, Michael

0
Comment actions Permalink

Hello Michael,

I was excited to find PythonID this morning. I put the JAR in my
/plugins directory and fired up Selena 7343. Unfortunately, it tells
me that PythonID is incompatible. Any plans to update it? I'm using
Komodo for my first Python IDE, but of course I'd prefer IntelliJ if
it were available to me.


In fact the CVS version of Pythonid (which is available on pythonid.dev.java.net)
has already been updated for Selena compatibility. I'll put up a release
on plugins.intellij.net soon.

Brilliant product, by the way. Please do keep it up - you're way
ahead of the Eclipses and NetBeans of the world in my eyes.


Thanks for the feedback. :)

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


0
Comment actions Permalink

I was able to follow the directions above to check out and build the pythonid plugin for Idea 7. It works for me. Thanks!

0
Comment actions Permalink

Brilliant - I'll check it out. Thanks again. - %

0

Please sign in to leave a comment.