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 260774 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]
Patch
Sarika.patch (text/plain), 26.35 KB, created by
Noopur Gupta
on 2016-04-07 09:41:13 EDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Noopur Gupta
Created:
2016-04-07 09:41:13 EDT
Size:
26.35 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaMatchFilter.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaMatchFilter.java >index 4166377..f22439d 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaMatchFilter.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaMatchFilter.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,7 @@ > > import java.util.ArrayList; > import java.util.HashSet; >+import java.util.List; > import java.util.StringTokenizer; > > import org.eclipse.search.ui.text.Match; >@@ -213,23 +214,27 @@ > > @Override > public boolean isApplicable(JavaSearchQuery query) { >- QuerySpecification spec= query.getSpecification(); >- if (spec instanceof ElementQuerySpecification) { >- ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec; >- IJavaElement element= elementSpec.getElement(); >- switch (element.getElementType()) { >- case IJavaElement.TYPE: >- case IJavaElement.METHOD: >- case IJavaElement.FIELD: >- case IJavaElement.PACKAGE_FRAGMENT: >- return true; >- default: >- return false; >+ List<QuerySpecification> specList= query.getSpecification(); >+ boolean isApplicable= false; >+ for (QuerySpecification spec : specList) { >+ if (spec instanceof ElementQuerySpecification) { >+ ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec; >+ IJavaElement element= elementSpec.getElement(); >+ switch (element.getElementType()) { >+ case IJavaElement.TYPE: >+ case IJavaElement.METHOD: >+ case IJavaElement.FIELD: >+ case IJavaElement.PACKAGE_FRAGMENT: >+ isApplicable= true; >+ break; >+ default: >+ return false; >+ } >+ } else if (spec instanceof PatternQuerySpecification) { >+ return true; > } >- } else if (spec instanceof PatternQuerySpecification) { >- return true; > } >- return false; >+ return isApplicable; > } > > @Override >@@ -241,16 +246,21 @@ > abstract class VariableFilter extends JavaMatchFilter { > @Override > public boolean isApplicable(JavaSearchQuery query) { >- QuerySpecification spec= query.getSpecification(); >- if (spec instanceof ElementQuerySpecification) { >- ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec; >- IJavaElement element= elementSpec.getElement(); >- return element instanceof IField || element instanceof ILocalVariable; >- } else if (spec instanceof PatternQuerySpecification) { >- PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec; >- return patternSpec.getSearchFor() == IJavaSearchConstants.FIELD; >+ List<QuerySpecification> speclist= query.getSpecification(); >+ boolean isApplicable= false; >+ for (QuerySpecification spec : speclist) { >+ if (spec instanceof ElementQuerySpecification) { >+ ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec; >+ IJavaElement element= elementSpec.getElement(); >+ isApplicable= element instanceof IField || element instanceof ILocalVariable; >+ if (!isApplicable) >+ return false; >+ } else if (spec instanceof PatternQuerySpecification) { >+ PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec; >+ return patternSpec.getSearchFor() == IJavaSearchConstants.FIELD; >+ } > } >- return false; >+ return isApplicable; > } > > } >@@ -351,20 +361,26 @@ > > @Override > public boolean isApplicable(JavaSearchQuery query) { >- QuerySpecification spec= query.getSpecification(); >- switch (spec.getLimitTo()) { >- case IJavaSearchConstants.REFERENCES: >- case IJavaSearchConstants.ALL_OCCURRENCES: >- if (spec instanceof ElementQuerySpecification) { >- ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec; >- return elementSpec.getElement() instanceof IMethod; >- } else if (spec instanceof PatternQuerySpecification) { >- PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec; >- return patternSpec.getSearchFor() == IJavaSearchConstants.METHOD; >- } >- } >- return false; >- } >+ List<QuerySpecification> speclist= query.getSpecification(); >+ boolean isApplicable= false; >+ for (QuerySpecification spec : speclist) { >+ switch (spec.getLimitTo()) { >+ case IJavaSearchConstants.REFERENCES: >+ case IJavaSearchConstants.ALL_OCCURRENCES: >+ if (spec instanceof ElementQuerySpecification) { >+ ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec; >+ isApplicable= elementSpec.getElement() instanceof IMethod; >+ if (!isApplicable) { >+ return false; >+ } >+ } else if (spec instanceof PatternQuerySpecification) { >+ PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec; >+ return patternSpec.getSearchFor() == IJavaSearchConstants.METHOD; >+ } >+ } >+ } >+ return isApplicable; >+ } > > @Override > public String getID() { >@@ -375,13 +391,20 @@ > abstract class GenericTypeFilter extends JavaMatchFilter { > @Override > public boolean isApplicable(JavaSearchQuery query) { >- QuerySpecification spec= query.getSpecification(); >- if (spec instanceof ElementQuerySpecification) { >- ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec; >- IJavaElement element= elementSpec.getElement(); >- return isParameterizedElement(element); >+ List<QuerySpecification> specList= query.getSpecification(); >+ boolean isApplicable= false; >+ for (QuerySpecification spec : specList) { >+ if (spec instanceof ElementQuerySpecification) { >+ ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec; >+ IJavaElement element= elementSpec.getElement(); >+ isApplicable= isParameterizedElement(element); >+ if (!isApplicable) >+ return false; >+ } else { >+ return false; >+ } > } >- return false; >+ return isApplicable; > } > > private static boolean isParameterizedElement(IJavaElement element) { >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..8ccb584 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 >@@ -9,6 +9,9 @@ > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.search; >+ >+import java.util.ArrayList; >+import java.util.List; > > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >@@ -55,13 +58,21 @@ > private static final String PERF_SEARCH_PARTICIPANT= "org.eclipse.jdt.ui/perf/search/participants"; //$NON-NLS-1$ > > private ISearchResult fResult; >- private final QuerySpecification fPatternData; >+ private final List<QuerySpecification> fPatternDataList; > > public JavaSearchQuery(QuerySpecification data) { > if (data == null) { > throw new IllegalArgumentException("data must not be null"); //$NON-NLS-1$ > } >- fPatternData= data; >+ fPatternDataList= new ArrayList<>(); >+ fPatternDataList.add(data); >+ } >+ >+ public JavaSearchQuery(List<QuerySpecification> dataList) { >+ if (dataList == null) { >+ throw new IllegalArgumentException("data must not be null"); //$NON-NLS-1$ >+ } >+ fPatternDataList= dataList; > } > > private static class SearchRequestor implements ISearchRequestor { >@@ -93,7 +104,7 @@ > try { > > int totalTicks= 1000; >- IProject[] projects= JavaSearchScopeFactory.getInstance().getProjects(fPatternData.getScope()); >+ IProject[] projects= JavaSearchScopeFactory.getInstance().getProjects(getPatternData().getScope()); > final SearchParticipantRecord[] participantDescriptors= SearchParticipantsExtensionPoint.getInstance().getSearchParticipants(projects); > final int[] ticks= new int[participantDescriptors.length]; > for (int i= 0; i < participantDescriptors.length; i++) { >@@ -108,7 +119,9 @@ > > @Override > public void run() throws Exception { >- ticks[iPrime]= participantDescriptors[iPrime].getParticipant().estimateTicks(fPatternData); >+ for (QuerySpecification querySpecification : fPatternDataList) { >+ ticks[iPrime]+= participantDescriptors[iPrime].getParticipant().estimateTicks(querySpecification); >+ } > } > }; > >@@ -116,23 +129,41 @@ > totalTicks+= ticks[i]; > } > >- SearchPattern pattern; >- String stringPattern; >- >- if (fPatternData instanceof ElementQuerySpecification) { >- IJavaElement element= ((ElementQuerySpecification) fPatternData).getElement(); >- 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 pattern= null; >+ String stringPattern= null; >+ >+ if (fPatternDataList.size() == 1) { >+ if (getPatternData() instanceof ElementQuerySpecification) { >+ IJavaElement element= ((ElementQuerySpecification) getPatternData()).getElement(); >+ 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); >+ } >+ pattern= SearchPattern.createPattern(element, getPatternData().getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE); >+ } else if (getPatternData() instanceof PatternQuerySpecification) { >+ PatternQuerySpecification patternSpec= (PatternQuerySpecification) getPatternData(); >+ stringPattern= patternSpec.getPattern(); >+ int matchMode= getMatchMode(stringPattern) | SearchPattern.R_ERASURE_MATCH; >+ if (patternSpec.isCaseSensitive()) >+ matchMode|= SearchPattern.R_CASE_SENSITIVE; >+ pattern= SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode); > } >- pattern= SearchPattern.createPattern(element, fPatternData.getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE); > } else { >- PatternQuerySpecification patternSpec = (PatternQuerySpecification) fPatternData; >- stringPattern= patternSpec.getPattern(); >- int matchMode= getMatchMode(stringPattern) | SearchPattern.R_ERASURE_MATCH; >- if (patternSpec.isCaseSensitive()) >- matchMode |= SearchPattern.R_CASE_SENSITIVE; >- pattern= SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode); >+ for (QuerySpecification querySpecification : fPatternDataList) { >+ if (!(querySpecification instanceof ElementQuerySpecification)) >+ break; >+ IJavaElement element= ((ElementQuerySpecification) querySpecification).getElement(); >+ 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, getPatternData().getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE); >+ if (pattern == null) { >+ pattern= elementPattern; >+ } else { >+ pattern= SearchPattern.createOrPattern(pattern, elementPattern); >+ } >+ } > } > > if (pattern == null) { >@@ -145,7 +176,7 @@ > NewSearchResultCollector collector= new NewSearchResultCollector(textResult, ignorePotentials); > > >- engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, fPatternData.getScope(), collector, mainSearchPM); >+ engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, getPatternData().getScope(), collector, mainSearchPM); > for (int i= 0; i < participantDescriptors.length; i++) { > final ISearchRequestor requestor= new SearchRequestor(participantDescriptors[i].getParticipant(), textResult); > final IProgressMonitor participantPM= new SubProgressMonitor(monitor, ticks[i]); >@@ -167,7 +198,9 @@ > final PerformanceStats stats= PerformanceStats.getStats(PERF_SEARCH_PARTICIPANT, participant); > stats.startRun(); > >- participant.search(requestor, fPatternData, participantPM); >+ for (QuerySpecification querySpecification : fPatternDataList) { >+ participant.search(requestor, querySpecification, participantPM); >+ } > > stats.endRun(); > } >@@ -200,7 +233,7 @@ > public String getResultLabel(int nMatches) { > int limitTo= getMaskedLimitTo(); > if (nMatches == 1) { >- String[] args= { getSearchPatternDescription(), fPatternData.getScopeDescription() }; >+ String[] args= { getSearchPatternDescription(), getPatternData().getScopeDescription() }; > switch (limitTo) { > case IJavaSearchConstants.IMPLEMENTORS: > return Messages.format(SearchMessages.JavaSearchOperation_singularImplementorsPostfix, args); >@@ -219,7 +252,7 @@ > return Messages.format(SearchMessages.JavaSearchQuery_singularReferencesWithMatchLocations, new Object[] { args[0], args[1], matchLocations }); > } > } else { >- Object[] args= { getSearchPatternDescription(), new Integer(nMatches), fPatternData.getScopeDescription() }; >+ Object[] args= { getSearchPatternDescription(), new Integer(nMatches), getPatternData().getScopeDescription() }; > switch (limitTo) { > case IJavaSearchConstants.IMPLEMENTORS: > return Messages.format(SearchMessages.JavaSearchOperation_pluralImplementorsPostfix, args); >@@ -241,16 +274,37 @@ > } > > private String getSearchPatternDescription() { >- if (fPatternData instanceof ElementQuerySpecification) { >- IJavaElement element= ((ElementQuerySpecification) fPatternData).getElement(); >- return JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT >- | JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.USE_RESOLVED | JavaElementLabels.P_COMPRESSED); >+ if (fPatternDataList.size() == 1) { >+ if (getPatternData() instanceof ElementQuerySpecification) { >+ IJavaElement element= ((ElementQuerySpecification) getPatternData()).getElement(); >+ return JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT >+ | JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.USE_RESOLVED | JavaElementLabels.P_COMPRESSED); >+ } else if (getPatternData() instanceof PatternQuerySpecification) { >+ return BasicElementLabels.getFilePattern(((PatternQuerySpecification) getPatternData()).getPattern()); >+ } >+ } else { >+ StringBuilder description= new StringBuilder(); >+ for (int i= 0; i < fPatternDataList.size(); i++) { >+ QuerySpecification querySpecification= fPatternDataList.get(i); >+ if (!(querySpecification instanceof ElementQuerySpecification)) { >+ return new String(""); //$NON-NLS-1$ >+ } >+ IJavaElement element= ((ElementQuerySpecification) querySpecification).getElement(); >+ if (description.length() != 0 && i < (fPatternDataList.size() - 1)) { >+ description.append(", "); //$NON-NLS-1$ >+ } else if (description.length() > 0) { >+ description.append(" " + SearchMessages.JavaSearchQuery_multi_selection_search_and + " "); //$NON-NLS-1$//$NON-NLS-2$ >+ } >+ 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()); >+ return new String(""); //$NON-NLS-1$ > } > > private int getMaskedLimitTo() { >- return fPatternData.getLimitTo() & ~(IJavaSearchConstants.IGNORE_RETURN_TYPE | IJavaSearchConstants.IGNORE_DECLARING_TYPE); >+ return getPatternData().getLimitTo() & ~(IJavaSearchConstants.IGNORE_RETURN_TYPE | IJavaSearchConstants.IGNORE_DECLARING_TYPE); > } > > ImageDescriptor getImageDescriptor() { >@@ -281,7 +335,11 @@ > return fResult; > } > >- QuerySpecification getSpecification() { >- return fPatternData; >+ private QuerySpecification getPatternData() { >+ return fPatternDataList.get(0); >+ } >+ >+ List<QuerySpecification> getSpecification() { >+ return fPatternDataList; > } > } >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..06c1613 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,7 @@ > 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..d8082c2 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,10 @@ > package org.eclipse.jdt.ui.actions; > > import java.lang.reflect.InvocationTargetException; >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.Iterator; >+import java.util.List; > > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IStatus; >@@ -98,8 +102,17 @@ > */ > abstract Class<?>[] getValidTypes(); > >- private boolean canOperateOn(IStructuredSelection sel) { >- return sel != null && !sel.isEmpty() && canOperateOn(getJavaElement(sel, true)); >+ boolean canOperateOn(IStructuredSelection sel) { >+ if (sel == null || sel.isEmpty()) { >+ return false; >+ } >+ List<IJavaElement> elementList= getJavaElements(sel, true); >+ for (IJavaElement iJavaElement : elementList) { >+ if (!canOperateOn(iJavaElement)) { >+ return false; >+ } >+ } >+ return true; > } > > boolean canOperateOn(IJavaElement element) { >@@ -139,20 +152,21 @@ > } > } > >- IJavaElement getJavaElement(IStructuredSelection selection, boolean silent) { >- if (selection.size() == 1) { >- Object firstElement= selection.getFirstElement(); >+ private List<IJavaElement> getJavaElements(IStructuredSelection selection, boolean silent) { >+ List<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) { >- return getTypeIfPossible(elem, silent); >+ javaElementList.add(getTypeIfPossible(elem, silent)); > } > > } >- return null; >+ return javaElementList; > } > > private void showOperationUnavailableDialog() { >@@ -201,15 +215,19 @@ > */ > @Override > public void run(IStructuredSelection selection) { >- IJavaElement element= getJavaElement(selection, false); >- if (element == null || !element.exists()) { >- showOperationUnavailableDialog(); >- return; >+ List<IJavaElement> elementList= getJavaElements(selection, false); >+ for (Iterator<IJavaElement> iterator= elementList.iterator(); iterator.hasNext();) { >+ IJavaElement element= iterator.next(); >+ if (element == null || !element.exists()) { >+ showOperationUnavailableDialog(); >+ return; >+ } else if (!ActionUtil.isProcessable(getShell(), element)) { >+ return; >+ } else if (element == RETURN_WITHOUT_BEEP) { >+ return; >+ } > } >- else if (element == RETURN_WITHOUT_BEEP) >- return; >- >- run(element); >+ run(elementList); > } > > /* >@@ -266,9 +284,17 @@ > if (!ActionUtil.isProcessable(getShell(), element)) > return; > >+ run(Arrays.asList(new IJavaElement[] { element })); >+ } >+ >+ private void run(List<IJavaElement> elementList) { > // will return true except for debugging purposes. > try { >- performNewSearch(element); >+ List<QuerySpecification> queryList= new ArrayList<>(elementList.size()); >+ for (IJavaElement element : elementList) { >+ queryList.add(createQuery(element)); >+ } >+ performNewSearch(new JavaSearchQuery(queryList)); > } catch (JavaModelException ex) { > ExceptionHandler.handle(ex, getShell(), SearchMessages.Search_Error_search_notsuccessful_title, SearchMessages.Search_Error_search_notsuccessful_message); > } catch (InterruptedException e) { >@@ -276,8 +302,7 @@ > } > } > >- private void performNewSearch(IJavaElement element) throws JavaModelException, InterruptedException { >- JavaSearchQuery query= new JavaSearchQuery(createQuery(element)); >+ private void performNewSearch(JavaSearchQuery query) { > if (query.canRunInBackground()) { > /* > * This indirection with Object as parameter is needed to prevent the loading >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInHierarchyAction.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInHierarchyAction.java >index 942df16..236dafa 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInHierarchyAction.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInHierarchyAction.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 >@@ -9,6 +9,8 @@ > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.jdt.ui.actions; >+ >+import org.eclipse.jface.viewers.IStructuredSelection; > > import org.eclipse.ui.IWorkbenchSite; > import org.eclipse.ui.PlatformUI; >@@ -93,4 +95,11 @@ > 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); >+ } > }
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