Open vs. Closed components

From within a simple action that I've bound to a key, I can't
seem to be able to get instances of 'closed' components when
it works just fine for 'opened' components.

For example, this works (both are OpenAPI):
HighlightManager.getInstance(project)
IntentionManager.getInstance(project)

but this doesn't (LookupManager is NOT OpenAPI) and returns null:
LookupManager.getInstance(project)

Is this expected and/or intentional?

Thanks,

Vince.


6 comments
Comment actions Permalink

Is this expected and/or intentional?

Nope. Frankly saying I hardly beleive that may indeed return null (at least
if you aren't running unit tests). This way none of the completions would
work in IDEA itself.

-


Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"

From within a simple action that I've bound to a key, I can't seem to
be able to get instances of 'closed' components when it works just
fine for 'opened' components.

For example, this works (both are OpenAPI):
HighlightManager.getInstance(project)
IntentionManager.getInstance(project)
but this doesn't (LookupManager is NOT OpenAPI) and returns null:
LookupManager.getInstance(project)

Thanks,

Vince.



0
Comment actions Permalink

I was confused too, but here's an example:

============ src/foo/BarAction.java =======
package foo;

import com.intellij.codeInsight.highlighting.HighlightManager;
import com.intellij.codeInsight.intention.IntentionManager;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.project.Project;

public class BarAction extends AnAction {
public void actionPerformed(AnActionEvent e) {
DataContext datacontext = e.getDataContext();
Project project = (Project) datacontext.getData("project");

System.out.println("IntentionManager.getInstance(project): " +
IntentionManager.getInstance(project));
System.out.println("HighlightManager.getInstance(project): " +
HighlightManager.getInstance(project));
System.out.println("LookupManager.getInstance(project) : " +
LookupManager.getInstance(project));
}
}
=====================================


============ META-INF/plugin.xml =======
Plugin name here short description of the plugin 1.0 YourCompany ]]>
=====================================


============ console output after pressing Ctrl-Shift-O (with a project
open) =======
IntentionManager.getInstance(project):
com.intellij.codeInsight.intention.impl.config.IntentionManagerImpl@f85fd3
HighlightManager.getInstance(project):
com.intellij.codeInsight.highlighting.HighlightManagerImpl@1826b5c
LookupManager.getInstance(project) : null

=====================================


Now knowing that it's not supposed to happen, I'm really confused :)

Thanks,

Vince.


0
Comment actions Permalink

Hey Maxim,

any luck reproducing the behavior with the simple example?

Thanks,

Vince.


0
Comment actions Permalink

Hey Max,

I'm still seeing that behavior with 3281. I'm thinking I must be
doing something wrong but I'm not sure what, it's pretty straightforward
at this point.

If you have any input on this that would be great.

Thanks,

Vince.


0
Comment actions Permalink

Sorry for late answer Vince.

I'm not able to reproduce the problem. All three "managers" are queried successfully.
I suspect you have problems with your IDEA SDK configuration (you're using
DevKit, right?). Thus I'd suggest to recreate the SDK from the scratch pointing
to the fresh IDEA build.
BTW, How to you get the stuff compiled? Do you adding idea.jar to SDK manually
or attaching it as a module library?

-


Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"

Hey Max,

I'm still seeing that behavior with 3281. I'm thinking I must be
doing something wrong but I'm not sure what, it's pretty
straightforward
at this point.
If you have any input on this that would be great.

Thanks,

Vince.



0
Comment actions Permalink

Ha ha ha!
All that time spent wondering if you guys had done something
funky to force non-open components to be invisible from
plugins, when it was just the way I used idea.jar :)

I had defined a global 'idea.jar' library that my DevKit module
was using. At deploy time, idea.jar would be copied to the lib/
directory of my plugin and mess things up.

I defined a new Idea-SDK with idea.jar manually added to it
and now everything works perfectly. Sorry for not having thought
about that before.

Thanks,

Vince.


0

Please sign in to leave a comment.