6 comments
Comment actions Permalink

Hello Joern,

My IDEA 7.0.3 plugin is using
psiManager.findClass(String className, GlobalSearchScope scope)
as well as
new OpenFileDescriptor(PsiMethod)
Both methods aren't available anymore in IDEA 8.0 and I can't find any
documentation about what to use instead...


See here for the plugin migration guide:
http://www.jetbrains.net/confluence/display/IDEADEV/DianaPluginMigration+Guide

"new OpenFileDescriptor(PsiMethod)" shouldn't be necessary at all because
PsiMethod itself implements Navigatable, so you can call the navigation methods
on the PsiMethod directly.

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


0
Comment actions Permalink

Dmitry Jemerov wrote:

Hello Joern,

>> My IDEA 7.0.3 plugin is using
>> psiManager.findClass(String className, GlobalSearchScope scope)
>> as well as
>> new OpenFileDescriptor(PsiMethod)
>> Both methods aren't available anymore in IDEA 8.0 and I can't find any
>> documentation about what to use instead...


See here for the plugin migration guide:
http://www.jetbrains.net/confluence/display/IDEADEV/DianaPluginMigration+Guide


"new OpenFileDescriptor(PsiMethod)" shouldn't be necessary at all
because PsiMethod itself implements Navigatable, so you can call the
navigation methods on the PsiMethod directly.


First of all, thank you for your quick response!

I fixed the PsiManager part, the link is very useful indeed.

I don't really understand your second suggestion, though.
My plugin is doing something quite simple: it opens the code
corresponding to a given StackTraceElement. I check all open Projects to
see if one of it contains the relevant sourcecode. Otherwise I just
stick with the binary one (i.e. class file).

In any case, I open the editor using
Editor editor = fileEditorManager.openTextEditor(fileDescriptor, true);
so I need the filedescriptor for a given PsiMethod, right?

Perhaps I'm just doing something horribly wrong ;) but this worked as
expected in 7.0.3...

What is the new way to get a filedescriptor for a given method?

Regards,
Joern.

0
Comment actions Permalink

Hello Joern,

=> My plugin is doing something quite simple: it opens the code

corresponding to a given StackTraceElement. I check all open Projects
to
see if one of it contains the relevant sourcecode. Otherwise I just
stick with the binary one (i.e. class file).
In any case, I open the editor using
Editor editor = fileEditorManager.openTextEditor(fileDescriptor,
true);
so I need the filedescriptor for a given PsiMethod, right?


No. You can simply call:
psiMethod.navigate(true);

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


0
Comment actions Permalink

Dmitry Jemerov wrote:

Hello Joern,

=> My plugin is doing something quite simple: it opens the code

>> corresponding to a given StackTraceElement. I check all open Projects
>> to
>> see if one of it contains the relevant sourcecode. Otherwise I just
>> stick with the binary one (i.e. class file).
>> In any case, I open the editor using
>> Editor editor = fileEditorManager.openTextEditor(fileDescriptor,
>> true);
>> so I need the filedescriptor for a given PsiMethod, right?


No. You can simply call:
psiMethod.navigate(true);

But I need the editor to execute the following code:


Editor editor = fileEditorManager.openTextEditor(fileDescriptor, true);
//System.out.println("editor: "+editor);
fileDescriptor.navigate(true);
if(editor!=null)
{
JComponent component = editor.getComponent();

// now I'll just do my best to focus the correct IDEA frame...
JFrame frame=resolveFrame(component);
if(frame!=null)
{
if((frame.getState() & Frame.ICONIFIED) != 0)
{
frame.setState(Frame.NORMAL);
}
frame.toFront();
}
component.requestFocusInWindow();
}

private JFrame resolveFrame(JComponent component)
{
Container c=component.getParent();
while(c!=null)
{
if(c instanceof JFrame)
{
return (JFrame) c;
}
c=c.getParent();
}
return null;
}


Simply calling (in my case) fileDescriptor.navigate(true); didn't do the
trick.
The reason for the above code is that I want to focus the correct IDEA
frame that's containing the code in question. I try to somewhat
remote-control idea with my plugin.

Regards, Joern.

0
Comment actions Permalink

That's what I'm doing in a similar situation:

Method method = ...;
method.navigate(true);
WindowManager.getInstance().suggestParentWindow(project).toFront();


Joern Huxhorn wrote:

Dmitry Jemerov wrote:

>> Hello Joern,
>>
>> => My plugin is doing something quite simple: it opens the code
>>> corresponding to a given StackTraceElement. I check all open Projects
>>> to
>>> see if one of it contains the relevant sourcecode. Otherwise I just
>>> stick with the binary one (i.e. class file).
>>> In any case, I open the editor using
>>> Editor editor = fileEditorManager.openTextEditor(fileDescriptor,
>>> true);
>>> so I need the filedescriptor for a given PsiMethod, right?
>> No. You can simply call:
>> psiMethod.navigate(true);
>>

But I need the editor to execute the following code:


Editor editor = fileEditorManager.openTextEditor(fileDescriptor, true);
//System.out.println("editor: "+editor);
fileDescriptor.navigate(true);
if(editor!=null)
{
JComponent component = editor.getComponent();

// now I'll just do my best to focus the correct IDEA frame...
JFrame frame=resolveFrame(component);
if(frame!=null)
{
if((frame.getState() & Frame.ICONIFIED) != 0)
{
frame.setState(Frame.NORMAL);
}
frame.toFront();
}
component.requestFocusInWindow();
}

private JFrame resolveFrame(JComponent component)
{
Container c=component.getParent();
while(c!=null)
{
if(c instanceof JFrame)
{
return (JFrame) c;
}
c=c.getParent();
}
return null;
}


Simply calling (in my case) fileDescriptor.navigate(true); didn't do the
trick.
The reason for the above code is that I want to focus the correct IDEA
frame that's containing the code in question. I try to somewhat
remote-control idea with my plugin.

Regards, Joern.


--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

0
Comment actions Permalink

Martin Fuhrer wrote:

That's what I'm doing in a similar situation:

Method method = ...;
method.navigate(true);
WindowManager.getInstance().suggestParentWindow(project).toFront();


Thank you very much, I'll try that!

Joern.

0

Please sign in to leave a comment.