How to make lazy parser do its work?
I'm trying to compile a source file with my own SourceGeneratingCompiler, but must know some details to create output filename.
My PsiFIle implementation provides me with all I need, but I can't actually get a PSI tree if the file has not been opened in an editor yet. Thus, I see empty PSI tree at the compile moment.
It works fine if the file had been opened in editor and parsed. But if it hadn't, or it had, but PSI cache had expired I get empty PSI when compiling.
I've found a solution:
ASTNode node = flexPsiFile.getNode();
node.getPsi().getChildren();
It works, but seems a bit odd.
Is there a proper way to make parser actually parse the PsiFile if it was not parsed before?
Please sign in to leave a comment.
Hello Max,
How are you actually requesting the PSI tree? As far as I understand, PsiManager.findFile(VirtualFile)
should give you the correct PSI tree regardless of whether the file was previously
opened.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Unfortunately, that's the way I do.
PsiFile psiFile = PsiManager.getInstance(module.getProject()).findFile(file) to be correct.
You can see the source code here: http://code.google.com/p/idea-jflex/source/browse/trunk/src/org/intellij/lang/jflex/compiler/JFlexSourceGeneratingCompiler.java#134