Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Searching for implementors of an interface
Searching for implementors of an interface [message #226911] Fri, 31 March 2006 08:50 Go to next message
Eclipse UserFriend
Suppose I have the following types in a workspace:

interface A
interface B extends A
class MyA implements A
abstract class MyB implements B
class MyC extends MyB

How could I construct a JDT search to find all concrete classes that
implement the interface A? (in the example I would expect results to include
MyC and MyA)

I have tried using a pattern like:

SearchPattern superPattern = SearchPattern.createPattern(aType,
IJavaSearchConstants.IMPLEMENTORS);

Where aType is an IType for interface A.

I was expecting to see that include the abstract classes and interface B...
but I get no results!?

Any tips appreciated...

- Chris
Re: Searching for implementors of an interface [message #226925 is a reply to message #226911] Fri, 31 March 2006 09:33 Go to previous messageGo to next message
Eclipse UserFriend
Chris Senior wrote:

> SearchPattern superPattern = SearchPattern.createPattern(aType,
> IJavaSearchConstants.IMPLEMENTORS);

> Where aType is an IType for interface A.

After a bit more testing it seemed the search only works with interfaces?

If the aType is an abstract class it does not return classes that "extend"
that class. But the documentation for the IMPLEMENTORS flag states that:

"The search result is a type that implements an interface or extends a
class. Used in conjunction with either TYPE or CLASS or INTERFACE, it will
respectively search for any type implementing/extending a type, or rather
exclusively search for classes implementing/extending the type, or
interfaces extending the type."

Which is what confused me ... it seems I have a choice of TYPE, CLASS or
INTERFACE? I thought it might deduce CLASS or INTERFACE from the IType I
passed in, and only do a TYPE search if I specify that.

- Chris
Re: Searching for implementors of an interface [message #226931 is a reply to message #226925] Fri, 31 March 2006 09:45 Go to previous messageGo to next message
Eclipse UserFriend
While I am on the subject...

Has anyone noticed the JavaDoc for
SearchPattern.createPattern(IJavaElement[], .. etc) methods contains HTML
unordered lists that do not match up. I am looking at the 3.1 online help.

The indentation goes all weird and the @return comments end up in the
wrong place.

Looking at the source code it seems it is opening a new UL element when
they mean to be closing the last one, i.e. the '/' character is missing.

- Chris
Re: Searching for implementors of an interface [message #227027 is a reply to message #226925] Mon, 03 April 2006 10:58 Go to previous messageGo to next message
Eclipse UserFriend
Chris Senior wrote:
> Chris Senior wrote:
>
>> SearchPattern superPattern = SearchPattern.createPattern(aType,
>> IJavaSearchConstants.IMPLEMENTORS);
>
>
>> Where aType is an IType for interface A.
>
>
> After a bit more testing it seemed the search only works with interfaces?
>
> If the aType is an abstract class it does not return classes that
> "extend" that class. But the documentation for the IMPLEMENTORS flag
> states that:
>
> "The search result is a type that implements an interface or extends a
> class. Used in conjunction with either TYPE or CLASS or INTERFACE, it
> will respectively search for any type implementing/extending a type, or
> rather exclusively search for classes implementing/extending the type,
> or interfaces extending the type."
>
> Which is what confused me ... it seems I have a choice of TYPE, CLASS or
> INTERFACE? I thought it might deduce CLASS or INTERFACE from the IType I
> passed in, and only do a TYPE search if I specify that.
>
> - Chris
>
It's a known problem and we're also confused on the subject :-(
See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=124645.
We'll try to make it clear for 3.2 RC1...
Re: Searching for implementors of an interface [message #227033 is a reply to message #226931] Mon, 03 April 2006 11:13 Go to previous message
Eclipse UserFriend
Chris wrote:

> While I am on the subject...
> Has anyone noticed the JavaDoc for
> SearchPattern.createPattern(IJavaElement[], .. etc) methods contains
> HTML unordered lists that do not match up. I am looking at the 3.1
> online help.
> The indentation goes all weird and the @return comments end up in the
> wrong place.
>
> Looking at the source code it seems it is opening a new UL element when
> they mean to be closing the last one, i.e. the '/' character is missing.
>
> - Chris
>
That's true, I'll fix it.
Thanks for pointing this out.
Previous Topic:managing source directories from a plugin
Next Topic:Get default value of field without using AST
Goto Forum:
  


Current Time: Fri Nov 07 05:23:33 EST 2025

Powered by FUDForum. Page generated in 0.07223 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top