2 quick questions Follow
(ideal code snippets candidates for the "OpenAPI online Almanac")
1/
How can I open a project file/class in an editor when I only know its
path/name (and not its module)?
2/
How can I "install" a LvcsLabelListener?
Alain
Please sign in to leave a comment.
Hello Alain,
AR> 1/
AR> How can I open a project file/class in an editor when I only know
AR> its path/name (and not its module)?
You can use FileEditorManager to open files in editors for given file type.
FileEditorManager.openFile(VirtualFile file);
Thanks!
--
Alexey Efimov, Java Developer
Tops BI
http://www.topsbi.ru
Alexey
> You can ..
Thanks.
Now question 2 , sorry for being so blind, but how do I turn a FQN into
a VirtualFile?
String classFQN = "a.Foo";
VirtualFile fooVF = ???
Alain
Alain Ravet wrote:
psiManager.findClass(classFQN).getContainingFile().getVirtualFile()
--
Maxim Shafirov
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
Checking for nulls every call out there is a must.
--
Maxim Shafirov
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
3/ How can I find the module, associated to an editor/psiFile?
TIA
Alain
<![CDATA[ Call me blind, but I couldn't figure this one out. I wish there were a superCompletion tool to help me fill the blank in Module m = aPsiFile. It would visit the tree, breadth first, of variables and methods starting at the source (aPsiFile.), and display all the matches/candidate. ]]>
This supercompletion will be of no help here I afraid...
final ProjectFileIndex fileIndex =
ProjectRootManager.getInstance(project).getFileIndex();
final VirtualFile virtualFile = containingFile.getVirtualFile();
return fileIndex.getModuleForFile(virtualFile);
--
regards,
Alexey Kudravtsev
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Alain Ravet" <alain.ravet@biz.tiscali.be> wrote in message
news:cqu14u$6lo$1@is.intellij.net...
>
>
>
>
>
>
Alexey
>This supercompletion will be of no help here I afraid...
>
>ProjectRootManager.getInstance(project).getFileIndex();
>
Thanks a lot. It will help me finish the next version of the MiniWiki.
This info/code snippet should be the openAPI javadoc.
Alain
Alexey Kudravtsev (JetBrains) wrote:
>This supercompletion will be of no help here I afraid...
>
>
What would be helpful is a way to ask:
"what method has a virtualFile as (one of its) parameter(s), and
returns a module."
Alain
Hi, there is a way to ask (but not very easy enough yet:)
class $a$ {
$Module$ $getModule$($BeforeParamType$ $BeforeParamName$, VirtualFile
$parameter$, $AfterParamType$ $AfterParamName$);
}
$Module$ is Module in type hierarchy
$getModule$ is target of the search.
$AfterParamType$, $AfterParamName$, $BeforeParamType$, $BeforeParamName$
0..1000
Alain Ravet wrote:
>> This supercompletion will be of no help here I afraid...
>>
>>
>>
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"