Is there a plugin API I can use to hide (or deprioritize) classes from import assistance?

In many of our projects, we end up with multiple classes on the classpath that have the same simple name but different fully qualified names. For example, We may have two classes on the classpath "org.foo.Foo" and "org.bar.Foo". In some cases, we know which of these is the "correct" one to import for our developers. We'd like to write a plugin that would either hide or deprioritize (as in, lower in the list) other import suggestions that Idea provides when it assists for an unresolved simple name.

For example, if I have this code:

Foo f = new Foo();

IntelliJ will give me the option of importing either org.bar.Foo or org.foo.Foo. I'd like to write a plugin that would hide org.bar.Foo from the list of suggestions, or at least lower it in the list.

Is this possible?

Thanks,
Brian

0

An obvious choice would be to remove those classed from classpath (the module's "Dependencies" tab).
If that is not possible (because you need those classes in the classpath), you can exclude them from import/completion: File -> Settngs -> Editor -> Auto Import -> Exclude from Import and Completion.

0
Avatar
Permanently deleted user

I was looking for a programmatic way to do this in a plugin. I guess I might be able to find the settings object used by the Auto Import preferences you mention and poke values into it.

Thanks,
Brian

0

do you know that next IDEA version Maya will have this feature?
afaik Maya's EAP builds already bundled with it
http://blogs.jetbrains.com/idea/2009/04/easy-exclusion-of-classes/

0
Avatar
Permanently deleted user

Yep, that's a nice feature But it's still something the end user has to do rather than something a plugin can control. At our site, there are classes that we know are *always* wrong for import assistance. We'd like to write a plugin that's on our user's machines that, by default, excludes such classes. We've had cases in the past where people have been stung by accidentally importing the wrong classes, and it's almost always because they were using IntelliJ.

I think I can probably poke the settings as mentioned in the previous post. I'll try to get around to actually trying that Real Soon Now

Thanks,
Brian

0

Hello Brian,

I was looking for a programmatic way to do this in a plugin. I guess I
might be able to find the settings object used by the Auto Import
preferences you mention and poke values into it.


The values are stored in CodeInsightSettings.EXCLUDED_PACKAGES string array.

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


0

请先登录再写评论。