invisible Editor created by dialog showing up?!

I'm puzzled :
- In an editor.creation listener, I get a lot of NPE when it tries to
access its associated psiFile, because there is none. How is that possible?
- What's even stranger, is that it happens when I press F5, to copy a
class, and only the CopyClass dialog is showing up => I haven't created
anything => no new editor was created by me !?

Any clue?

Alain

6 comments
Comment actions Permalink

(continued)
..
I also run into Editor having no project associated, so I must write
code like


Is that 'normal', or expected?

Alain

0
Comment actions Permalink

This is absolutely normal since editor aren't only used for project file
editing but smart text fields or consolve view as well.

(continued)
...
I also run into Editor having no project associated, so I must write
code like

 public static PsiFile psiFileOf  (Editor i_editor) {
> Project project = i_editor.getProject ();
> if (null == project)
> return null ;
> return PsiDocumentManager.getInstance (project)
> .getPsiFile (i_editor.getDocument ());
> }
> ]]>

Is that 'normal', or expected?

Alain



0
Comment actions Permalink

Maxim

> This is absolutely normal since editor aren't only used for project
file editing but smart text fields or consolve view as well.


I get it.
Don't you think it would be worth/cleaner to split the EditorFactory, or
just give it a little sister:


FileEditorFactory

, so we could write
FileEditorFactory.getInstance ().addFileEditorFactoryListener (..);


That would save us from adding the filtering plumbing in every single
editor listeners we write, to make sure we only watch file editors?
Does it make sense to you?

Alain

0
Comment actions Permalink

just give it a little sister:
FileEditorFactory


There's already one called FileEditorManager :)

FileEditorManager.getInstance(project).addFileEditorManagerListener(xxx);

0
Comment actions Permalink

Maxim

>> just give it a little sister:
>> FileEditorFactory
>
> There's already one called FileEditorManager :)
>
FileEditorManager.getInstance(project).addFileEditorManagerListener(xxx);


1/
Thanks.
Memo to self:
EditorFactory.
is the sister/cousin of
FileEditorManager


2/
When all you can do to find answers is guessing with poles and
Alt-Ctrl-N, names are important.
Once again, it shows there is a need for some solid base documentation
on the openAPI. Plugins are important to the success of IDEA. You
shouldn't delay this step too long.

Alain


0
Comment actions Permalink

Alain Ravet wrote:

When all you can do to find answers is guessing with poles and
Alt-Ctrl-N,



It's Shift-Alt-Ctrl-N of course,
and
"Ctrl-N : accept package in pattern. "
http://www.intellij.net/tracker/idea/viewSCR?publicId=19948

(!! it's still "to be discussed" )

would help a LOT: looking for *Manager, without being able to say "look
only in com.intellij.*", brings a lot of noise in the result.

Alain

0

Please sign in to leave a comment.