public JavaReferenceCodeMining(IJavaElement element, JavaEditor editor, IDocument document, ICodeMiningProvider provider, boolean referencesCodeMiningsAtLeastOne) throws JavaModelException, BadLocationException { super(element, document, provider, e -> new FindReferencesAction(editor).run(element)); this.referencesCodeMiningsAtLeastOne = referencesCodeMiningsAtLeastOne; }
@Override public void run(IJavaElement element) { SearchUtil.warnIfBinaryConstant(element, getShell()); super.run(element); } }
void init() { setText(SearchMessages.Search_FindReferencesAction_label); setToolTipText(SearchMessages.Search_FindReferencesAction_tooltip); setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_REF); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_WORKSPACE_ACTION); }
/** * Note: This constructor is for internal use only. Clients should not call this constructor. * @param editor the Java editor */ public ReferencesSearchGroup(JavaEditor editor) { Assert.isNotNull(editor); fEditor= editor; fSite= fEditor.getSite(); fGroupId= ITextEditorActionConstants.GROUP_FIND; fFindReferencesAction= new FindReferencesAction(editor); fFindReferencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKSPACE); fEditor.setAction("SearchReferencesInWorkspace", fFindReferencesAction); //$NON-NLS-1$ fFindReferencesInProjectAction= new FindReferencesInProjectAction(fEditor); fFindReferencesInProjectAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_PROJECT); fEditor.setAction("SearchReferencesInProject", fFindReferencesInProjectAction); //$NON-NLS-1$ fFindReferencesInHierarchyAction= new FindReferencesInHierarchyAction(fEditor); fFindReferencesInHierarchyAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_HIERARCHY); fEditor.setAction("SearchReferencesInHierarchy", fFindReferencesInHierarchyAction); //$NON-NLS-1$ fFindReferencesInWorkingSetAction= new FindReferencesInWorkingSetAction(fEditor); fFindReferencesInWorkingSetAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKING_SET); fEditor.setAction("SearchReferencesInWorkingSet", fFindReferencesInWorkingSetAction); //$NON-NLS-1$ }
@Override QuerySpecification createQuery(IJavaElement element) throws JavaModelException, InterruptedException { IType type= getType(element); if (type == null) { return super.createQuery(element); } JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); IJavaSearchScope scope= SearchEngine.createHierarchyScope(type); String description= factory.getHierarchyScopeDescription(type); return new ElementQuerySpecification(element, getLimitTo(), scope, description); }
@Override QuerySpecification createQuery(IJavaElement element) throws JavaModelException, InterruptedException { JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); boolean isInsideJRE= factory.isInsideJRE(element); IJavaSearchScope scope= factory.createWorkspaceScope(isInsideJRE); String description= factory.getWorkspaceScopeDescription(isInsideJRE); return new ElementQuerySpecification(element, getLimitTo(), scope, description); }
@Override boolean canOperateOn(IStructuredSelection sel) { if (sel == null || sel.isEmpty() || sel.size() > 1) { return false; } return super.canOperateOn(sel); } }
/** * Note: This constructor is for internal use only. Clients should not call this constructor. * @param editor the Java editor * * @noreference This constructor is not intended to be referenced by clients. */ public ReferencesSearchGroup(JavaEditor editor) { Assert.isNotNull(editor); fEditor= editor; fSite= fEditor.getSite(); fGroupId= ITextEditorActionConstants.GROUP_FIND; fFindReferencesAction= new FindReferencesAction(editor); fFindReferencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKSPACE); fEditor.setAction("SearchReferencesInWorkspace", fFindReferencesAction); //$NON-NLS-1$ fFindReferencesInProjectAction= new FindReferencesInProjectAction(fEditor); fFindReferencesInProjectAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_PROJECT); fEditor.setAction("SearchReferencesInProject", fFindReferencesInProjectAction); //$NON-NLS-1$ fFindReferencesInHierarchyAction= new FindReferencesInHierarchyAction(fEditor); fFindReferencesInHierarchyAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_HIERARCHY); fEditor.setAction("SearchReferencesInHierarchy", fFindReferencesInHierarchyAction); //$NON-NLS-1$ fFindReferencesInWorkingSetAction= new FindReferencesInWorkingSetAction(fEditor); fFindReferencesInWorkingSetAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKING_SET); fEditor.setAction("SearchReferencesInWorkingSet", fFindReferencesInWorkingSetAction); //$NON-NLS-1$ }
QuerySpecification createQuery(IJavaElement element) throws JavaModelException, InterruptedException { IType type= getType(element); if (type == null) { return super.createQuery(element); } JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); IJavaSearchScope scope= SearchEngine.createHierarchyScope(type); String description= factory.getHierarchyScopeDescription(type); return new ElementQuerySpecification(element, getLimitTo(), scope, description); }
QuerySpecification createQuery(IJavaElement element) throws JavaModelException, InterruptedException { JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); boolean isInsideJRE= factory.isInsideJRE(element); IJavaSearchScope scope= factory.createWorkspaceScope(isInsideJRE); String description= factory.getWorkspaceScopeDescription(isInsideJRE); return new ElementQuerySpecification(element, getLimitTo(), scope, description); }
@Override boolean canOperateOn(IStructuredSelection sel) { if (sel == null || sel.isEmpty() || sel.size() > 1) { return false; } return super.canOperateOn(sel); } }
/** * Note: This constructor is for internal use only. Clients should not call this constructor. * @param editor the Java editor * * @noreference This constructor is not intended to be referenced by clients. */ public ReferencesSearchGroup(JavaEditor editor) { Assert.isNotNull(editor); fEditor= editor; fSite= fEditor.getSite(); fGroupId= ITextEditorActionConstants.GROUP_FIND; fFindReferencesAction= new FindReferencesAction(editor); fFindReferencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKSPACE); fEditor.setAction("SearchReferencesInWorkspace", fFindReferencesAction); //$NON-NLS-1$ fFindReferencesInProjectAction= new FindReferencesInProjectAction(fEditor); fFindReferencesInProjectAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_PROJECT); fEditor.setAction("SearchReferencesInProject", fFindReferencesInProjectAction); //$NON-NLS-1$ fFindReferencesInHierarchyAction= new FindReferencesInHierarchyAction(fEditor); fFindReferencesInHierarchyAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_HIERARCHY); fEditor.setAction("SearchReferencesInHierarchy", fFindReferencesInHierarchyAction); //$NON-NLS-1$ fFindReferencesInWorkingSetAction= new FindReferencesInWorkingSetAction(fEditor); fFindReferencesInWorkingSetAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKING_SET); fEditor.setAction("SearchReferencesInWorkingSet", fFindReferencesInWorkingSetAction); //$NON-NLS-1$ }
@Override void init() { setText(SearchMessages.Search_FindReferencesAction_label); setToolTipText(SearchMessages.Search_FindReferencesAction_tooltip); setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_REF); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_WORKSPACE_ACTION); }
@SuppressWarnings("boxing") @Override protected CompletableFuture<Void> doResolve(ITextViewer viewer, IProgressMonitor monitor) { return CompletableFuture.runAsync(() -> { try { monitor.isCanceled(); IJavaElement element = super.getElement(); long refCount= countReferences(element, monitor); monitor.isCanceled(); action= refCount > 0 ? e -> new FindReferencesAction(editor).run(element) : null; if (refCount == 0 && showReferencesAtLeastOne) { super.setLabel(""); //$NON-NLS-1$ } else { super.setLabel(MessageFormat.format(JavaCodeMiningMessages.JavaReferenceCodeMining_label, refCount)); } } catch (JavaModelException e) { // Should never occur } catch (CoreException e) { // Should never occur } }); }
@Override QuerySpecification createQuery(IJavaElement element) throws JavaModelException, InterruptedException { IType type= getType(element); if (type == null) { return super.createQuery(element); } JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); IJavaSearchScope scope= SearchEngine.createHierarchyScope(type); String description= factory.getHierarchyScopeDescription(type); return new ElementQuerySpecification(element, getLimitTo(), scope, description); }
@Override QuerySpecification createQuery(IJavaElement element) throws JavaModelException, InterruptedException { JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); boolean isInsideJRE= factory.isInsideJRE(element); IJavaSearchScope scope= factory.createWorkspaceScope(isInsideJRE); String description= factory.getWorkspaceScopeDescription(isInsideJRE); return new ElementQuerySpecification(element, getLimitTo(), scope, description); }
public void run(IJavaElement element) { SearchUtil.warnIfBinaryConstant(element, getShell()); super.run(element); } }
/** * Creates a new <code>ReferencesSearchGroup</code>. The group requires * that the selection provided by the site's selection provider is of type <code> * org.eclipse.jface.viewers.IStructuredSelection</code>. * * @param site the view part that owns this action group */ public ReferencesSearchGroup(IWorkbenchSite site) { fSite= site; fGroupId= IContextMenuConstants.GROUP_SEARCH; fFindReferencesAction= new FindReferencesAction(site); fFindReferencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKSPACE); fFindReferencesInProjectAction= new FindReferencesInProjectAction(site); fFindReferencesInProjectAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_PROJECT); fFindReferencesInHierarchyAction= new FindReferencesInHierarchyAction(site); fFindReferencesInHierarchyAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_HIERARCHY); fFindReferencesInWorkingSetAction= new FindReferencesInWorkingSetAction(site); fFindReferencesInWorkingSetAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKING_SET); // register the actions as selection listeners ISelectionProvider provider= fSite.getSelectionProvider(); ISelection selection= provider.getSelection(); registerAction(fFindReferencesAction, provider, selection); registerAction(fFindReferencesInProjectAction, provider, selection); registerAction(fFindReferencesInHierarchyAction, provider, selection); registerAction(fFindReferencesInWorkingSetAction, provider, selection); }
@Override void init() { setText(SearchMessages.Search_FindReferencesAction_label); setToolTipText(SearchMessages.Search_FindReferencesAction_tooltip); setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_REF); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_WORKSPACE_ACTION); }
private void doSearch(ISelection sel) { IPackageFragment frag = getPackageFragment(sel); if (frag != null) { FindReferencesAction action = new FindReferencesAction(getPage().getEditorSite()); action.run(frag); } else if (sel instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) sel; PackageObject exportObject = (PackageObject) selection.getFirstElement(); NewSearchUI.runQueryInBackground(new BlankQuery(exportObject)); } }