|
Lines 39-45
Link Here
|
| 39 |
import org.eclipse.jdt.core.IJavaElement; |
39 |
import org.eclipse.jdt.core.IJavaElement; |
| 40 |
import org.eclipse.jdt.core.IMethod; |
40 |
import org.eclipse.jdt.core.IMethod; |
| 41 |
import org.eclipse.jdt.core.IType; |
41 |
import org.eclipse.jdt.core.IType; |
|
|
42 |
import org.eclipse.jdt.core.ITypeHierarchy; |
| 42 |
import org.eclipse.jdt.core.ITypeRoot; |
43 |
import org.eclipse.jdt.core.ITypeRoot; |
|
|
44 |
import org.eclipse.jdt.core.JavaModelException; |
| 43 |
import org.eclipse.jdt.core.dom.ASTNode; |
45 |
import org.eclipse.jdt.core.dom.ASTNode; |
| 44 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
46 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
| 45 |
import org.eclipse.jdt.core.dom.Expression; |
47 |
import org.eclipse.jdt.core.dom.Expression; |
|
Lines 59-64
Link Here
|
| 59 |
import org.eclipse.jdt.internal.corext.dom.Bindings; |
61 |
import org.eclipse.jdt.internal.corext.dom.Bindings; |
| 60 |
import org.eclipse.jdt.internal.corext.util.JdtFlags; |
62 |
import org.eclipse.jdt.internal.corext.util.JdtFlags; |
| 61 |
import org.eclipse.jdt.internal.corext.util.Messages; |
63 |
import org.eclipse.jdt.internal.corext.util.Messages; |
|
|
64 |
import org.eclipse.jdt.internal.corext.util.MethodOverrideTester; |
| 62 |
|
65 |
|
| 63 |
import org.eclipse.jdt.ui.JavaElementLabels; |
66 |
import org.eclipse.jdt.ui.JavaElementLabels; |
| 64 |
import org.eclipse.jdt.ui.SharedASTProvider; |
67 |
import org.eclipse.jdt.ui.SharedASTProvider; |
|
Lines 184-191
Link Here
|
| 184 |
parentTypeBinding= Bindings.getBindingOfParentType(node); |
187 |
parentTypeBinding= Bindings.getBindingOfParentType(node); |
| 185 |
} |
188 |
} |
| 186 |
} |
189 |
} |
| 187 |
final IType type= parentTypeBinding != null ? (IType) parentTypeBinding.getJavaElement() : null; |
190 |
final IType recieverType= parentTypeBinding != null ? (IType)parentTypeBinding.getJavaElement() : null; |
| 188 |
if (type == null) { |
191 |
if (recieverType == null) { |
| 189 |
openQuickHierarchy(editor); |
192 |
openQuickHierarchy(editor); |
| 190 |
return; |
193 |
return; |
| 191 |
} |
194 |
} |
|
Lines 200-206
Link Here
|
| 200 |
} |
203 |
} |
| 201 |
try { |
204 |
try { |
| 202 |
String methodLabel= JavaElementLabels.getElementLabel(javaElement, JavaElementLabels.DEFAULT_QUALIFIED); |
205 |
String methodLabel= JavaElementLabels.getElementLabel(javaElement, JavaElementLabels.DEFAULT_QUALIFIED); |
| 203 |
monitor.beginTask(Messages.format(JavaEditorMessages.JavaElementImplementationHyperlink_search_method_implementors, methodLabel), 100); |
206 |
monitor.beginTask(Messages.format(JavaEditorMessages.JavaElementImplementationHyperlink_search_method_implementors, methodLabel), 10); |
|
|
207 |
ITypeHierarchy superTypeHierarchy= recieverType.newSupertypeHierarchy(new SubProgressMonitor(monitor, 3)); |
| 208 |
IType type; |
| 209 |
type= getDeclaringType(superTypeHierarchy, (IMethod)javaElement, recieverType); |
| 204 |
SearchRequestor requestor= new SearchRequestor() { |
210 |
SearchRequestor requestor= new SearchRequestor() { |
| 205 |
public void acceptSearchMatch(SearchMatch match) throws CoreException { |
211 |
public void acceptSearchMatch(SearchMatch match) throws CoreException { |
| 206 |
if (match.getAccuracy() == SearchMatch.A_ACCURATE) { |
212 |
if (match.getAccuracy() == SearchMatch.A_ACCURATE) { |
|
Lines 219-225
Link Here
|
| 219 |
Assert.isNotNull(pattern); |
225 |
Assert.isNotNull(pattern); |
| 220 |
SearchParticipant[] participants= new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }; |
226 |
SearchParticipant[] participants= new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }; |
| 221 |
SearchEngine engine= new SearchEngine(); |
227 |
SearchEngine engine= new SearchEngine(); |
| 222 |
engine.search(pattern, participants, SearchEngine.createHierarchyScope(type), requestor, new SubProgressMonitor(monitor, 100)); |
228 |
engine.search(pattern, participants, SearchEngine.createHierarchyScope(type), requestor, new SubProgressMonitor(monitor, 7)); |
| 223 |
|
229 |
|
| 224 |
if (monitor.isCanceled()) { |
230 |
if (monitor.isCanceled()) { |
| 225 |
throw new OperationCanceledException(); |
231 |
throw new OperationCanceledException(); |
|
Lines 256-261
Link Here
|
| 256 |
} |
262 |
} |
| 257 |
|
263 |
|
| 258 |
/** |
264 |
/** |
|
|
265 |
* Return the declaring type for the given method if the method is abstract in the receiver |
| 266 |
* type, else return the receiver type. |
| 267 |
* <p> |
| 268 |
* Note: A declaring type has the 'original' method declaration that does not override nor |
| 269 |
* implement a method. |
| 270 |
* </p> |
| 271 |
* |
| 272 |
* @param superTypeHierarchy the super type hierarchy |
| 273 |
* @param method the method |
| 274 |
* @param recieverType the receiver type for the method |
| 275 |
* @return the declaring type of the method if the given method is abstract in the receiver |
| 276 |
* type, else return the receiver type |
| 277 |
* @throws JavaModelException if the java element does not exist or if an exception occurs while |
| 278 |
* accessing its corresponding resource |
| 279 |
* @since 3.6 |
| 280 |
*/ |
| 281 |
private static IType getDeclaringType(ITypeHierarchy superTypeHierarchy, IMethod method, IType recieverType) throws JavaModelException { |
| 282 |
MethodOverrideTester methodOverrideTester= new MethodOverrideTester(recieverType, superTypeHierarchy); |
| 283 |
if (!JdtFlags.isAbstract(methodOverrideTester.findOverriddenMethodInType(recieverType, method))) |
| 284 |
return recieverType; |
| 285 |
|
| 286 |
IMethod overridenMethod= methodOverrideTester.findDeclaringMethod(method, true); |
| 287 |
return overridenMethod != null ? overridenMethod.getDeclaringType() : method.getDeclaringType(); |
| 288 |
} |
| 289 |
|
| 290 |
/** |
| 259 |
* Opens the quick type hierarchy for the given editor. |
291 |
* Opens the quick type hierarchy for the given editor. |
| 260 |
* |
292 |
* |
| 261 |
* @param editor the editor for which to open the quick hierarchy |
293 |
* @param editor the editor for which to open the quick hierarchy |