IDEA Compiler API and PSI questions

I posted these 2 questions in plugins forum deep in an unrelated thread, but I think no one saw it.

First, when implementing a JavaSourceTransformingCompiler, how am I supposed to get the Project instance from the (CompileContext context, VirtualFile file) which is passed to transform()? It looks like I can't call getModuleForFile(file), probably because the file is not in the project, it is temporary. My current solution is this:

Project project = context.getCompileScope().getAffectedModules()[0].getProject();

But that's sort of messy. Is that the recommended way?

Secondly, from within my JavaSourceTransformingCompiler, I'm calling:

Document doc = docmgr.getDocument(file);
Project project = context.getCompileScope().getAffectedModules()[0].getProject();

PsiDocumentManager psiMgr = PsiDocumentManager.getInstance(project);
PsiFile psiFile = psiMgr.getPsiFile(doc);

This PsiFile is not a Java PSI File, it's a plaintext file. How can I load it as a Java PSI File?

Thanks, if anyone can help that would be great.

0
4 comments

See my answers in

http://www.intellij.net/forums/thread.jsp?forum=18&thread=114270&tstart=0&trange=100

--
Best regards,
Eugene Zhuravlev
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"



0


>See my answers in
>

>
Our only source of information is reverse-engineering the OpenAPI
methods signatures and existing plugins. Working that way, we obviously
miss, or misunderstand a lot.
If would be immensely useful to the community if JetBrains developers
were to write a few rough and informal how-to guides on the OpenAPI,
and update them when the subject covered changes.

Alain

0

+100 :)
Where should I put my votes?

--
Guillaume Laforge
http://glaforge.free.fr/weblog

Alain Ravet wrote:

>> See my answers in
>>
>>
>>

Our only source of information is reverse-engineering the OpenAPI
methods signatures and existing plugins. Working that way, we obviously
miss, or misunderstand a lot.
If would be immensely useful to the community if JetBrains developers
were to write a few rough and informal how-to guides on the OpenAPI,
and update them when the subject covered changes.

Alain

0

Guillaume Laforge wrote:

+100 :)
Where should I put my votes?



Put that on the
"please revive the Weekly Update report"
category.
I feel they'll get the same attention :(

Alain

0

Please sign in to leave a comment.