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.IImportDeclaration; 19 import org.eclipse.jdt.core.IJavaElement; 20 import org.eclipse.jdt.core.ILocalVariable; 21 import org.eclipse.jdt.core.IMethod; 22 import org.eclipse.jdt.core.IPackageDeclaration; 23 import org.eclipse.jdt.core.IPackageFragment; 24 import org.eclipse.jdt.core.IType; 25 import org.eclipse.jdt.core.ITypeParameter; 26 import org.eclipse.jdt.core.JavaModelException; 27 import org.eclipse.jdt.core.search.IJavaSearchConstants; 28 import org.eclipse.jdt.core.search.IJavaSearchScope; 29 30 import org.eclipse.jdt.ui.search.ElementQuerySpecification; 31 import org.eclipse.jdt.ui.search.QuerySpecification; 32 33 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 34 import org.eclipse.jdt.internal.ui.JavaPluginImages; 35 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; 36 import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory; 37 import org.eclipse.jdt.internal.ui.search.SearchMessages; 38 import org.eclipse.jdt.internal.ui.search.SearchUtil; 39 40 50 public class FindReferencesAction extends FindAction { 51 52 59 public FindReferencesAction(IWorkbenchSite site) { 60 super(site); 61 } 62 63 67 public FindReferencesAction(JavaEditor editor) { 68 super(editor); 69 } 70 71 Class [] getValidTypes() { 72 return new Class [] { ICompilationUnit.class, IType.class, IMethod.class, IField.class, IPackageDeclaration.class, IImportDeclaration.class, IPackageFragment.class, ILocalVariable.class, ITypeParameter.class }; 73 } 74 75 void init() { 76 setText(SearchMessages.Search_FindReferencesAction_label); 77 setToolTipText(SearchMessages.Search_FindReferencesAction_tooltip); 78 setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_REF); 79 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_WORKSPACE_ACTION); 80 } 81 82 int getLimitTo() { 83 return IJavaSearchConstants.REFERENCES; 84 } 85 86 QuerySpecification createQuery(IJavaElement element) throws JavaModelException, InterruptedException { 87 JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); 88 boolean isInsideJRE= factory.isInsideJRE(element); 89 90 IJavaSearchScope scope= factory.createWorkspaceScope(isInsideJRE); 91 String description= factory.getWorkspaceScopeDescription(isInsideJRE); 92 return new ElementQuerySpecification(element, getLimitTo(), scope, description); 93 } 94 95 public void run(IJavaElement element) { 96 SearchUtil.warnIfBinaryConstant(element, getShell()); 97 super.run(element); 98 } 99 } 100 | Popular Tags |