Community
Participate
Working Groups
If you search for implementors of a method from the java editor, it will not find any results. The reason for this can be found using this stack trace: Thread [ModalContext] (Suspended) org.eclipse.jdt.internal.core.search.matching.SearchPattern.createPattern(org.eclipse.jdt.core.IJavaElement, int) line: 1000 org.eclipse.jdt.core.search.SearchEngine.createSearchPattern(org.eclipse.jdt.core.IJavaElement, int) line: 217 org.eclipse.jdt.core.search.SearchEngine.search(org.eclipse.core.resources.IWorkspace, org.eclipse.jdt.core.IJavaElement, int, org.eclipse.jdt.core.search.IJavaSearchScope, org.eclipse.jdt.core.search.IJavaSearchResultCollector) line: 290 org.eclipse.jdt.internal.ui.search.JavaSearchOperation.execute(org.eclipse.core.runtime.IProgressMonitor) line: 79 org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(org.eclipse.core.runtime.IProgressMonitor) line: 64 org.eclipse.core.internal.resources.Workspace.run(org.eclipse.core.resources.IWorkspaceRunnable, org.eclipse.core.runtime.IProgressMonitor) line: 1232 org.eclipse.jdt.internal.ui.search.JavaSearchOperation(org.eclipse.ui.actions.WorkspaceModifyOperation).run(org.eclipse.core.runtime.IProgressMonitor) line: 78 org.eclipse.jface.operation.ModalContext$ModalContextThread.run() line: 98 The switch statemetn found on line 905 of SearchPattern.createPattern(IJavaElement, int). Does not have a case for IJavaSearchConstants.IMPLEMENTORS. This causes the method to return null, and the search stops without looking.
IMPLEMENTORS should be used only for interfaces. What you want is the declarations of a method. The UI should not allow the user to select implementors for a method. If not possible, maybe DECLARATIONS should be passed to the search engine in this case. Moving to JDT/UI
Note: there's no error/exception dialog. It starts searching and finds no result. Now a beep will sound if the selection is invalid (e.g. method selected and implementors chosen). Fixed > 20020109
Hold on guys! As an example, in a selfhosting workbench, open IPath. At the bottom of the class is the declaration public IPath uptoSegment(int count); Select "uptoSegment" and right click. You should get an implementors option under the search submenu. If you search for implementors at this point, you will get the stack trace I included at the beginning of this bug report. It really looks like there should be an IMPLEMENTORS case in the switch statement. Am I missing something?
Ah-ha. I get it now. Core has defined IMPLELMENTORS to only be applicable to types. Either core must broaden this definition to methods, or the UI should not expose implementors on methods. This may be an issue because of our smalltalk past. I don't think "implementors " and "declarations" are synonomous terms. As I see it, "implementors" and "declarations" are two separate queries. Implementors means: go find all implementing classes of the interface and return the corresponding implemented methods. Declarations means: find all (non-abstract) methods with the same signature as the method I have selected. I suggest we only have "declarations" of methods because the queries are very similar.
As Jerome pointed out the term "implementors" in Java only means TYPES which implement the given INTERFACE. If you try search directly on Java elements (e.g. in Outline view or Type Hierarchy view) you will see that "Implementors" is only available for interfaces. Most actions work on Java elements therefore the text selection in the editor needs to be converted (if possible) to a Java element. If each action in the editor context menu would do the conversion to test if it is valid then it would take too long for the context menu to be opened - that's why you always see ALL system wide available Search actions. If an action is started it tries to get a Java element from the selected text and then tests if the (Search) action is valid for the current selection - if not a beep sounds. The bug (which is now fixed) was that the check was not performed correctly and therefore a search for implementors in the Java editor was not rejected with a beep.