Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 259756 Details for
Bug 477340
[search] No way to search all references to a type or its subtypes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Multi selection search
Bug 477340 - [search] No way to search all references to a type or its subtypes Patch1.patch (text/plain), 27.27 KB, created by
Sarika Sinha
on 2016-02-15 05:28:09 EST
(
hide
)
Description:
Multi selection search
Filename:
MIME Type:
Creator:
Sarika Sinha
Created:
2016-02-15 05:28:09 EST
Size:
27.27 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchQuery.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchQuery.java >index e433971..acd8526 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchQuery.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchQuery.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2016 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -43,12 +43,16 @@ > import org.eclipse.jdt.ui.search.IMatchPresentation; > import org.eclipse.jdt.ui.search.IQueryParticipant; > import org.eclipse.jdt.ui.search.ISearchRequestor; >+import org.eclipse.jdt.ui.search.MultipleElementQuerySpecification; > import org.eclipse.jdt.ui.search.PatternQuerySpecification; > import org.eclipse.jdt.ui.search.QuerySpecification; > > import org.eclipse.jdt.internal.ui.JavaPlugin; > import org.eclipse.jdt.internal.ui.JavaPluginImages; > import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; >+ >+import java.util.ArrayList; >+import java.util.Iterator; > > public class JavaSearchQuery implements ISearchQuery { > >@@ -116,8 +120,8 @@ > totalTicks+= ticks[i]; > } > >- SearchPattern pattern; >- String stringPattern; >+ SearchPattern pattern= null; >+ String stringPattern= null; > > if (fPatternData instanceof ElementQuerySpecification) { > IJavaElement element= ((ElementQuerySpecification) fPatternData).getElement(); >@@ -126,6 +130,20 @@ > return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(SearchMessages.JavaSearchQuery_error_element_does_not_exist, stringPattern), null); > } > pattern= SearchPattern.createPattern(element, fPatternData.getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE); >+ }else if (fPatternData instanceof MultipleElementQuerySpecification) { >+ ArrayList<IJavaElement> elementList = ((MultipleElementQuerySpecification) fPatternData).getElement(); >+ for (Iterator iterator= elementList.iterator(); iterator.hasNext();) { >+ IJavaElement element= (IJavaElement) iterator.next(); >+ stringPattern= JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT); >+ if (!element.exists()) { >+ return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(SearchMessages.JavaSearchQuery_error_element_does_not_exist, stringPattern), null); >+ } >+ SearchPattern elementPattern = SearchPattern.createPattern(element, fPatternData.getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE); >+ if (pattern == null) >+ pattern= elementPattern; >+ else >+ pattern= SearchPattern.createOrPattern(pattern, elementPattern); >+ } > } else { > PatternQuerySpecification patternSpec = (PatternQuerySpecification) fPatternData; > stringPattern= patternSpec.getPattern(); >@@ -245,6 +263,19 @@ > IJavaElement element= ((ElementQuerySpecification) fPatternData).getElement(); > return JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT > | JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.USE_RESOLVED | JavaElementLabels.P_COMPRESSED); >+ } else if (fPatternData instanceof MultipleElementQuerySpecification){ >+ ArrayList<IJavaElement> elements= ((MultipleElementQuerySpecification) fPatternData).getElement(); >+ StringBuffer description = new StringBuffer(); >+ for (Iterator<IJavaElement> iterator= elements.iterator(); iterator.hasNext();) { >+ IJavaElement element= iterator.next(); >+ if (description.length() != 0 && iterator.hasNext()) >+ description.append(", "); //$NON-NLS-1$ >+ else if (description.length() > 0) >+ description.append(" and "); //$NON-NLS-1$ >+ description.append(JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT >+ | JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.USE_RESOLVED | JavaElementLabels.P_COMPRESSED)); >+ } >+ return description.toString(); > } > return BasicElementLabels.getFilePattern(((PatternQuerySpecification) fPatternData).getPattern()); > } >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchMessages.java >index f28f357..d55b1bf 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchMessages.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchMessages.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2014 IBM Corporation and others. >+ * Copyright (c) 2000, 2016 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -268,6 +268,7 @@ > > public static String JavaSearchQuery_error_element_does_not_exist; > public static String JavaSearchQuery_pluralReferencesWithMatchLocations; >+ public static String JavaSearchQuery_multi_selection_search_and; > public static String MatchFilter_PotentialFilter_name; > public static String MatchFilter_PotentialFilter_actionLabel; > public static String MatchFilter_PotentialFilter_description; >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchMessages.properties >index 4c4ad13..9d5f86d 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchMessages.properties >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchMessages.properties >@@ -1,5 +1,5 @@ > ############################################################################### >-# Copyright (c) 2000, 2011 IBM Corporation and others. >+# Copyright (c) 2000, 2016 IBM Corporation and others. > # All rights reserved. This program and the accompanying materials > # are made available under the terms of the Eclipse Public License v1.0 > # which accompanies this distribution, and is available at >@@ -255,6 +255,8 @@ > JavaSearchQuery_error_participant_search=An error occurred during participant search. The participant has been disabled for the current session. > JavaSearchQuery_pluralReferencesWithMatchLocations=''{0}'' in ''{3}'' - {1} references in {2} > >+JavaSearchQuery_multi_selection_search_and=and >+ > SearchParticipant_error_noID=Missing id attribute on search participant extension {0} > SearchParticipant_error_noNature=Missing nature attribute on search participant {0} > SearchParticipant_error_noClass=Missing class attribute on search participant {0} >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewer.java >index 7cb81ef..ad2e939 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewer.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewer.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2016 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -41,7 +41,7 @@ > > > public TypeHierarchyViewer(Composite parent, IContentProvider contentProvider, TypeHierarchyLifeCycle lifeCycle) { >- super(new Tree(parent, SWT.SINGLE)); >+ super(new Tree(parent, SWT.MULTI)); > > fLabelProvider= new HierarchyLabelProvider(lifeCycle); > >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java >index a9e2f15..730d5fe 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2016 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -11,6 +11,8 @@ > package org.eclipse.jdt.ui.actions; > > import java.lang.reflect.InvocationTargetException; >+import java.util.ArrayList; >+import java.util.Iterator; > > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IStatus; >@@ -98,7 +100,7 @@ > */ > abstract Class<?>[] getValidTypes(); > >- private boolean canOperateOn(IStructuredSelection sel) { >+ boolean canOperateOn(IStructuredSelection sel) { > return sel != null && !sel.isEmpty() && canOperateOn(getJavaElement(sel, true)); > } > >@@ -139,6 +141,19 @@ > } > } > >+ IJavaElement getJavaElement(Object firstElement, boolean silent) { >+ IJavaElement elem= null; >+ if (firstElement instanceof IJavaElement) >+ elem= (IJavaElement) firstElement; >+ else if (firstElement instanceof IAdaptable) >+ elem= ((IAdaptable) firstElement).getAdapter(IJavaElement.class); >+ if (elem != null) { >+ return getTypeIfPossible(elem, silent); >+ } >+ >+ return null; >+ } >+ > IJavaElement getJavaElement(IStructuredSelection selection, boolean silent) { > if (selection.size() == 1) { > Object firstElement= selection.getFirstElement(); >@@ -153,6 +168,22 @@ > > } > return null; >+ } >+ >+ ArrayList<IJavaElement> getMultipleJavaElement(IStructuredSelection selection, boolean silent) { >+ ArrayList<IJavaElement> javaElementList = new ArrayList<>(); >+ for (Iterator<?> iter= selection.iterator(); iter.hasNext();) { >+ Object firstElement= iter.next(); >+ IJavaElement elem= null; >+ if (firstElement instanceof IJavaElement) >+ elem= (IJavaElement) firstElement; >+ else if (firstElement instanceof IAdaptable) >+ elem= ((IAdaptable) firstElement).getAdapter(IJavaElement.class); >+ if (elem != null) { >+ javaElementList.add(getTypeIfPossible(elem, silent)); >+ } >+ } >+ return javaElementList; > } > > private void showOperationUnavailableDialog() { >@@ -201,15 +232,32 @@ > */ > @Override > public void run(IStructuredSelection selection) { >- IJavaElement element= getJavaElement(selection, false); >- if (element == null || !element.exists()) { >- showOperationUnavailableDialog(); >- return; >+ if (selection.size() == 1) { >+ IJavaElement element= getJavaElement(selection, false); >+ if (element == null || !element.exists()) { >+ showOperationUnavailableDialog(); >+ return; >+ } >+ else if (element == RETURN_WITHOUT_BEEP) >+ return; >+ >+ run(element); > } >- else if (element == RETURN_WITHOUT_BEEP) >- return; >- >- run(element); >+ else { >+ ArrayList<IJavaElement> elementList = getMultipleJavaElement(selection, false); >+ for (Iterator iterator= elementList.iterator(); iterator.hasNext();) { >+ IJavaElement element= (IJavaElement) iterator.next(); >+ if (element == null || !element.exists()) { >+ showOperationUnavailableDialog(); >+ return; >+ } >+ else if (!ActionUtil.isProcessable(getShell(), element)) >+ return; >+ else if (element == RETURN_WITHOUT_BEEP) >+ return; >+ } >+ run(elementList); >+ } > } > > /* >@@ -275,8 +323,49 @@ > // cancelled > } > } >+ >+ /** >+ * Executes this action for the given java element List. >+ * @param element The java element in Lists to be found. >+ * @since 3.12 >+ */ >+ public void run(ArrayList<IJavaElement> element) { >+ // will return true except for debugging purposes. >+ try { >+ performNewSearch(element); >+ } catch (JavaModelException ex) { >+ ExceptionHandler.handle(ex, getShell(), SearchMessages.Search_Error_search_notsuccessful_title, SearchMessages.Search_Error_search_notsuccessful_message); >+ } catch (InterruptedException e) { >+ // cancelled >+ } >+ } > > private void performNewSearch(IJavaElement element) throws JavaModelException, InterruptedException { >+ JavaSearchQuery query= new JavaSearchQuery(createQuery(element)); >+ if (query.canRunInBackground()) { >+ /* >+ * This indirection with Object as parameter is needed to prevent the loading >+ * of the Search plug-in: the VM verifies the method call and hence loads the >+ * types used in the method signature, eventually triggering the loading of >+ * a plug-in (in this case ISearchQuery results in Search plug-in being loaded). >+ */ >+ SearchUtil.runQueryInBackground(query); >+ } else { >+ IProgressService progressService= PlatformUI.getWorkbench().getProgressService(); >+ /* >+ * This indirection with Object as parameter is needed to prevent the loading >+ * of the Search plug-in: the VM verifies the method call and hence loads the >+ * types used in the method signature, eventually triggering the loading of >+ * a plug-in (in this case it would be ISearchQuery). >+ */ >+ IStatus status= SearchUtil.runQueryInForeground(progressService, query); >+ if (status.matches(IStatus.ERROR | IStatus.INFO | IStatus.WARNING)) { >+ ErrorDialog.openError(getShell(), SearchMessages.Search_Error_search_title, SearchMessages.Search_Error_search_message, status); >+ } >+ } >+ } >+ >+ private void performNewSearch(ArrayList<IJavaElement> element) throws JavaModelException, InterruptedException { > JavaSearchQuery query= new JavaSearchQuery(createQuery(element)); > if (query.canRunInBackground()) { > /* >@@ -316,7 +405,23 @@ > String description= factory.getWorkspaceScopeDescription(true); > return new ElementQuerySpecification(element, getLimitTo(), scope, description); > } >- >+ >+ /** >+ * Creates a query for the given element. Subclasses reimplement this method. >+ * >+ * @param elementList the elements to create a query for >+ * >+ * @return returns the query >+ * @throws JavaModelException thrown when accessing the element failed >+ * @throws InterruptedException thrown when the user interrupted the query selection >+ */ >+ QuerySpecification createQuery(ArrayList<IJavaElement> elementList) throws JavaModelException, InterruptedException { >+ IJavaElement element = elementList.get(0); >+ JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); >+ IJavaSearchScope scope= factory.createWorkspaceScope(true); >+ String description= factory.getWorkspaceScopeDescription(true); >+ return new ElementQuerySpecification(element, getLimitTo(), scope, description); >+ } > abstract int getLimitTo(); > > IType getType(IJavaElement element) { >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReadReferencesInProjectAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReadReferencesInProjectAction.java >index 6d21f7b..15c3f3f 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReadReferencesInProjectAction.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReadReferencesInProjectAction.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2016 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -13,11 +13,14 @@ > import org.eclipse.ui.IWorkbenchSite; > import org.eclipse.ui.PlatformUI; > >+import java.util.ArrayList; >+ > import org.eclipse.jdt.core.IJavaElement; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.search.IJavaSearchScope; > > import org.eclipse.jdt.ui.search.ElementQuerySpecification; >+import org.eclipse.jdt.ui.search.MultipleElementQuerySpecification; > import org.eclipse.jdt.ui.search.QuerySpecification; > > import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; >@@ -87,4 +90,28 @@ > return new ElementQuerySpecification(element, getLimitTo(), scope, description); > } > >+ @Override >+ QuerySpecification createQuery(ArrayList<IJavaElement> elementList) throws JavaModelException, InterruptedException { >+ JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); >+ JavaEditor editor= getEditor(); >+ >+ IJavaSearchScope scope; >+ String description; >+ boolean isInsideJRE= factory.isInsideJRE(elementList.get(0)); >+ if (editor != null) { >+ scope= factory.createJavaProjectSearchScope(editor.getEditorInput(), isInsideJRE); >+ description= factory.getProjectScopeDescription(editor.getEditorInput(), isInsideJRE); >+ } else { >+ String[] elementNames= new String[elementList.size()]; >+ int i= 0; >+ for (IJavaElement element : elementList) { >+ elementNames[i++]= element.getElementName(); >+ } >+ scope= factory.createJavaProjectSearchScope(elementNames, isInsideJRE); >+ description= factory.getProjectScopeDescription(elementList.get(0).getJavaProject(), isInsideJRE); >+ } >+ return new MultipleElementQuerySpecification(elementList, getLimitTo(), scope, description); >+ } >+ >+ > } >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesAction.java >index a134df7..7d20099 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesAction.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesAction.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2016 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -12,6 +12,9 @@ > > import org.eclipse.ui.IWorkbenchSite; > import org.eclipse.ui.PlatformUI; >+ >+import java.util.ArrayList; >+import java.util.Iterator; > > import org.eclipse.jdt.core.ICompilationUnit; > import org.eclipse.jdt.core.IField; >@@ -28,8 +31,9 @@ > import org.eclipse.jdt.core.search.IJavaSearchScope; > > import org.eclipse.jdt.ui.search.ElementQuerySpecification; >+import org.eclipse.jdt.ui.search.MultipleElementQuerySpecification; > import org.eclipse.jdt.ui.search.QuerySpecification; >- >+import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; > import org.eclipse.jdt.internal.ui.JavaPluginImages; > import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; >@@ -99,10 +103,35 @@ > String description= factory.getWorkspaceScopeDescription(isInsideJRE); > return new ElementQuerySpecification(element, getLimitTo(), scope, description); > } >+ >+ @Override >+ QuerySpecification createQuery(ArrayList<IJavaElement> element) throws JavaModelException, InterruptedException { >+ JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); >+ boolean isInsideJRE= factory.isInsideJRE(element.get(0)); >+ >+ IJavaSearchScope scope= factory.createWorkspaceScope(isInsideJRE); >+ String description= factory.getWorkspaceScopeDescription(isInsideJRE); >+ return new MultipleElementQuerySpecification(element, getLimitTo(), scope, description); >+ } > > @Override > public void run(IJavaElement element) { > SearchUtil.warnIfBinaryConstant(element, getShell()); > super.run(element); > } >+ >+ @Override >+ boolean canOperateOn(IStructuredSelection sel) { >+ if ( sel == null || sel.isEmpty() ){ >+ return false; >+ } >+ for (Iterator<?> iter= sel.iterator(); iter.hasNext();) { >+ Object element= iter.next(); >+ if( !canOperateOn(getJavaElement(element, true))){ >+ return false; >+ } >+ } >+ return true; >+ } >+ > } >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInProjectAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInProjectAction.java >index f4a2e69..18e4188 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInProjectAction.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInProjectAction.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2016 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -12,6 +12,8 @@ > > import org.eclipse.ui.IWorkbenchSite; > import org.eclipse.ui.PlatformUI; >+ >+import java.util.ArrayList; > > import org.eclipse.jdt.core.ICompilationUnit; > import org.eclipse.jdt.core.IField; >@@ -27,6 +29,7 @@ > import org.eclipse.jdt.core.search.IJavaSearchScope; > > import org.eclipse.jdt.ui.search.ElementQuerySpecification; >+import org.eclipse.jdt.ui.search.MultipleElementQuerySpecification; > import org.eclipse.jdt.ui.search.QuerySpecification; > > import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; >@@ -102,4 +105,27 @@ > return new ElementQuerySpecification(element, getLimitTo(), scope, description); > } > >+ @Override >+ QuerySpecification createQuery(ArrayList<IJavaElement> elementList) throws JavaModelException, InterruptedException { >+ JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); >+ JavaEditor editor= getEditor(); >+ >+ IJavaSearchScope scope; >+ String description; >+ boolean isInsideJRE= factory.isInsideJRE(elementList.get(0)); >+ if (editor != null) { >+ scope= factory.createJavaProjectSearchScope(editor.getEditorInput(), isInsideJRE); >+ description= factory.getProjectScopeDescription(editor.getEditorInput(), isInsideJRE); >+ } else { >+ String[] elementNames= new String[elementList.size()]; >+ int i= 0; >+ for (IJavaElement element : elementList) { >+ elementNames[i++]= element.getElementName(); >+ } >+ scope= factory.createJavaProjectSearchScope(elementNames, isInsideJRE); >+ description= factory.getProjectScopeDescription(elementList.get(0).getJavaProject(), isInsideJRE); >+ } >+ return new MultipleElementQuerySpecification(elementList, getLimitTo(), scope, description); >+ } >+ > } >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInWorkingSetAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInWorkingSetAction.java >index 5c53979..47f62a5 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInWorkingSetAction.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInWorkingSetAction.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2016 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,23 +10,23 @@ > *******************************************************************************/ > package org.eclipse.jdt.ui.actions; > >-import org.eclipse.ui.IWorkbenchSite; >-import org.eclipse.ui.IWorkingSet; >-import org.eclipse.ui.PlatformUI; >+import java.util.ArrayList; > > import org.eclipse.jdt.core.IJavaElement; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.search.IJavaSearchScope; >- >-import org.eclipse.jdt.ui.search.ElementQuerySpecification; >-import org.eclipse.jdt.ui.search.QuerySpecification; >- > import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; > import org.eclipse.jdt.internal.ui.JavaPluginImages; > import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; > import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory; > import org.eclipse.jdt.internal.ui.search.SearchMessages; > import org.eclipse.jdt.internal.ui.search.SearchUtil; >+import org.eclipse.jdt.ui.search.ElementQuerySpecification; >+import org.eclipse.jdt.ui.search.MultipleElementQuerySpecification; >+import org.eclipse.jdt.ui.search.QuerySpecification; >+import org.eclipse.ui.IWorkbenchSite; >+import org.eclipse.ui.IWorkingSet; >+import org.eclipse.ui.PlatformUI; > > > /** >@@ -115,4 +115,20 @@ > String description= factory.getWorkingSetScopeDescription(workingSets, JavaSearchScopeFactory.NO_PROJ); > return new ElementQuerySpecification(element, getLimitTo(), scope, description); > } >+ >+ @Override >+ QuerySpecification createQuery(ArrayList<IJavaElement> element) throws JavaModelException, InterruptedException { >+ JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance(); >+ >+ IWorkingSet[] workingSets= fWorkingSets; >+ if (fWorkingSets == null) { >+ workingSets= factory.queryWorkingSets(); >+ if (workingSets == null) >+ return super.createQuery(element); // in workspace >+ } >+ SearchUtil.updateLRUWorkingSets(workingSets); >+ IJavaSearchScope scope= factory.createJavaSearchScope(workingSets, JavaSearchScopeFactory.NO_PROJ); >+ String description= factory.getWorkingSetScopeDescription(workingSets, JavaSearchScopeFactory.NO_PROJ); >+ return new MultipleElementQuerySpecification(element, getLimitTo(), scope, description); >+ } > } >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/search/MultipleElementQuerySpecification.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/search/MultipleElementQuerySpecification.java >new file mode 100644 >index 0000000..1436e19 >--- /dev/null >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/search/MultipleElementQuerySpecification.java >@@ -0,0 +1,57 @@ >+/******************************************************************************* >+ * Copyright (c) 2016 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.ui.search; >+ >+import java.util.ArrayList; >+ >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.search.IJavaSearchScope; >+ >+/** >+ * <p> >+ * Describes a search query by giving the multiple {@link IJavaElement} to search for. >+ * </p> >+ * <p> >+ * This class is not intended to be instantiated or subclassed by clients. >+ * </p> >+ * >+ * @see org.eclipse.jdt.ui.search.QuerySpecification >+ * >+ * @since 3.12 >+ * >+ * @noinstantiate This class is not intended to be instantiated by clients. >+ * @noextend This class is not intended to be subclassed by clients. >+ */ >+public class MultipleElementQuerySpecification extends QuerySpecification { >+ private ArrayList<IJavaElement> fElements; >+ >+ /** >+ * A constructor. >+ * >+ * @param javaElement The java element the query should search for. >+ * @param limitTo The kind of occurrence the query should search for. >+ * @param scope The scope to search in. >+ * @param scopeDescription A human readable description of the search scope. >+ */ >+ public MultipleElementQuerySpecification(ArrayList<IJavaElement> javaElements, int limitTo, IJavaSearchScope scope, String scopeDescription) { >+ super(limitTo, scope, scopeDescription); >+ fElements= javaElements; >+ } >+ >+ /** >+ * Returns the element to search for. >+ * >+ * @return The element to search for. >+ */ >+ public ArrayList<IJavaElement> getElement() { >+ return fElements; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 477340
:
259756
|
260379
|
260661
|
260757
|
260774