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.IField; 17 import org.eclipse.jdt.core.IJavaElement; 18 import org.eclipse.jdt.core.ILocalVariable; 19 import org.eclipse.jdt.core.IMethod; 20 import org.eclipse.jdt.core.IType; 21 import org.eclipse.jdt.core.ITypeParameter; 22 import org.eclipse.jdt.core.JavaModelException; 23 import org.eclipse.jdt.core.search.IJavaSearchScope; 24 import org.eclipse.jdt.core.search.SearchEngine; 25 26 import org.eclipse.jdt.ui.search.ElementQuerySpecification; 27 import org.eclipse.jdt.ui.search.QuerySpecification; 28 29 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 30 import org.eclipse.jdt.internal.ui.JavaPluginImages; 31 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; 32 import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory; 33 import org.eclipse.jdt.internal.ui.search.SearchMessages; 34 35 45 public class FindDeclarationsInHierarchyAction extends FindDeclarationsAction { 46 47 54 public FindDeclarationsInHierarchyAction(IWorkbenchSite site) { 55 super(site); 56 } 57 58 62 public FindDeclarationsInHierarchyAction(JavaEditor editor) { 63 super(editor); 64 } 65 66 Class [] getValidTypes() { 67 return new Class [] { IField.class, IMethod.class, ILocalVariable.class, ITypeParameter.class }; 68 } 69 70 void init() { 71 setText(SearchMessages.Search_FindHierarchyDeclarationsAction_label); 72 setToolTipText(SearchMessages.Search_FindHierarchyDeclarationsAction_tooltip); 73 setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_DECL); 74 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_DECLARATIONS_IN_HIERARCHY_ACTION); 75 } 76 77 QuerySpecification createQuery(IJavaElement element) throws JavaModelException, InterruptedException { 78 JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); 79 80 IType type= getType(element); 81 if (type == null) { 82 return super.createQuery(element); 83 } 84 IJavaSearchScope scope= SearchEngine.createHierarchyScope(type); 85 String description= factory.getHierarchyScopeDescription(type); 86 return new ElementQuerySpecification(element, getLimitTo(), scope, description); 87 } 88 } 89 | Popular Tags |