Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-core-dev] Referendum on search for declarations behavior

Here is a scenario, where the current accurate search is too restrictive.

If you select a method (which is also defined in a superclass), and search
for declarations in hierarchy, then it will not find the super method, but
it would find methods defined in subtypes.

e.g.:

public class X {
   public  void foo(){}
}

public class Y extends X {
  public void foo(){} // SEARCH DECL IN HIERARCHY
}

public class Z extends Y {
  public void foo(){}
}

Searching for declarations of Y.foo() in hierarchy would not find X.foo(),
but it would find Z.foo().

The reason for this behavior is that this particular search action is using
'Y.foo()', and not simply 'foo()'. Then the implementation of search for
declarations is implemented to check the declaring class if it was
specified in the search pattern, in which case it will only tolerate
declarations on type or subtypes.

There are 2 ways of solving this:
1) The search engine should also tolerate supertypes (somewhat
polymorphic).
2) The UI should not use 'Y.foo()' in this case, but simply 'foo()' (like
it does already for search declarations in workspace and working sets)

Do you have an opinion ? I think basically it comes down to:

When performing a search for declarations in the search page of 'Y.foo()',
do you expect X.foo(), or not ?




Back to the top