1 11 package org.eclipse.jdt.ui.actions; 12 13 import org.eclipse.ui.IWorkbenchSite; 14 import org.eclipse.ui.PlatformUI; 15 16 import org.eclipse.jdt.core.ICompilationUnit; 17 import org.eclipse.jdt.core.IField; 18 import org.eclipse.jdt.core.IJavaElement; 19 import org.eclipse.jdt.core.ILocalVariable; 20 import org.eclipse.jdt.core.IMethod; 21 import org.eclipse.jdt.core.IType; 22 import org.eclipse.jdt.core.ITypeParameter; 23 import org.eclipse.jdt.core.JavaModelException; 24 import org.eclipse.jdt.core.search.IJavaSearchScope; 25 import org.eclipse.jdt.core.search.SearchEngine; 26 27 import org.eclipse.jdt.ui.search.ElementQuerySpecification; 28 import org.eclipse.jdt.ui.search.QuerySpecification; 29 30 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 31 import org.eclipse.jdt.internal.ui.JavaPluginImages; 32 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; 33 import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory; 34 import org.eclipse.jdt.internal.ui.search.SearchMessages; 35 36 46 public class FindReferencesInHierarchyAction extends FindReferencesAction { 47 48 55 public FindReferencesInHierarchyAction(IWorkbenchSite site) { 56 super(site); 57 } 58 59 63 public FindReferencesInHierarchyAction(JavaEditor editor) { 64 super(editor); 65 } 66 67 Class [] getValidTypes() { 68 return new Class [] { ICompilationUnit.class, IType.class, IMethod.class, IField.class, ILocalVariable.class, ITypeParameter.class }; 69 } 70 71 void init() { 72 setText(SearchMessages.Search_FindHierarchyReferencesAction_label); 73 setToolTipText(SearchMessages.Search_FindHierarchyReferencesAction_tooltip); 74 setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_REF); 75 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_HIERARCHY_ACTION); 76 } 77 78 QuerySpecification createQuery(IJavaElement element) throws JavaModelException, InterruptedException { 79 IType type= getType(element); 80 if (type == null) { 81 return super.createQuery(element); 82 } 83 JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); 84 IJavaSearchScope scope= SearchEngine.createHierarchyScope(type); 85 String description= factory.getHierarchyScopeDescription(type); 86 return new ElementQuerySpecification(element, getLimitTo(), scope, description); 87 } 88 89 } 90 | Popular Tags |