View | Details | Raw Unified | Return to bug 477340 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaMatchFilter.java (-45 / +68 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2016 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-17 Link Here
12
12
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.HashSet;
14
import java.util.HashSet;
15
import java.util.List;
15
import java.util.StringTokenizer;
16
import java.util.StringTokenizer;
16
17
17
import org.eclipse.search.ui.text.Match;
18
import org.eclipse.search.ui.text.Match;
Lines 213-235 Link Here
213
214
214
	@Override
215
	@Override
215
	public boolean isApplicable(JavaSearchQuery query) {
216
	public boolean isApplicable(JavaSearchQuery query) {
216
		QuerySpecification spec= query.getSpecification();
217
		List<QuerySpecification> specList= query.getSpecification();
217
		if (spec instanceof ElementQuerySpecification) {
218
		boolean isApplicable= false;
218
			ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
219
		for (QuerySpecification spec : specList) {
219
			IJavaElement element= elementSpec.getElement();
220
			if (spec instanceof ElementQuerySpecification) {
220
			switch (element.getElementType()) {
221
				ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
221
				case IJavaElement.TYPE:
222
				IJavaElement element= elementSpec.getElement();
222
				case IJavaElement.METHOD:
223
				switch (element.getElementType()) {
223
				case IJavaElement.FIELD:
224
					case IJavaElement.TYPE:
224
				case IJavaElement.PACKAGE_FRAGMENT:
225
					case IJavaElement.METHOD:
225
					return true;
226
					case IJavaElement.FIELD:
226
				default:
227
					case IJavaElement.PACKAGE_FRAGMENT:
227
					return false;
228
						isApplicable= true;
229
						break;
230
					default:
231
						return false;
232
				}
233
			} else if (spec instanceof PatternQuerySpecification) {
234
				return true;
228
			}
235
			}
229
		} else if (spec instanceof PatternQuerySpecification) {
230
			return true;
231
		}
236
		}
232
		return false;
237
		return isApplicable;
233
	}
238
	}
234
239
235
	@Override
240
	@Override
Lines 241-256 Link Here
241
abstract class VariableFilter extends JavaMatchFilter {
246
abstract class VariableFilter extends JavaMatchFilter {
242
	@Override
247
	@Override
243
	public boolean isApplicable(JavaSearchQuery query) {
248
	public boolean isApplicable(JavaSearchQuery query) {
244
		QuerySpecification spec= query.getSpecification();
249
		List<QuerySpecification> speclist= query.getSpecification();
245
		if (spec instanceof ElementQuerySpecification) {
250
		boolean isApplicable= false;
246
			ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
251
		for (QuerySpecification spec : speclist) {
247
			IJavaElement element= elementSpec.getElement();
252
			if (spec instanceof ElementQuerySpecification) {
248
			return element instanceof IField || element instanceof ILocalVariable;
253
				ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
249
		} else if (spec instanceof PatternQuerySpecification) {
254
				IJavaElement element= elementSpec.getElement();
250
			PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
255
				isApplicable= element instanceof IField || element instanceof ILocalVariable;
251
			return patternSpec.getSearchFor() == IJavaSearchConstants.FIELD;
256
				if (!isApplicable)
257
					return false;
258
			} else if (spec instanceof PatternQuerySpecification) {
259
				PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
260
				return patternSpec.getSearchFor() == IJavaSearchConstants.FIELD;
261
			}
252
		}
262
		}
253
		return false;
263
		return isApplicable;
254
	}
264
	}
255
265
256
}
266
}
Lines 351-370 Link Here
351
361
352
    @Override
362
    @Override
353
	public boolean isApplicable(JavaSearchQuery query) {
363
	public boolean isApplicable(JavaSearchQuery query) {
354
        QuerySpecification spec= query.getSpecification();
364
		List<QuerySpecification> speclist= query.getSpecification();
355
        switch (spec.getLimitTo()) {
365
		boolean isApplicable= false;
356
			case IJavaSearchConstants.REFERENCES:
366
		for (QuerySpecification spec : speclist) {
357
			case IJavaSearchConstants.ALL_OCCURRENCES:
367
			switch (spec.getLimitTo()) {
358
                if (spec instanceof ElementQuerySpecification) {
368
				case IJavaSearchConstants.REFERENCES:
359
                    ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
369
				case IJavaSearchConstants.ALL_OCCURRENCES:
360
                    return elementSpec.getElement() instanceof IMethod;
370
					if (spec instanceof ElementQuerySpecification) {
361
                } else if (spec instanceof PatternQuerySpecification) {
371
						ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
362
                    PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
372
						isApplicable= elementSpec.getElement() instanceof IMethod;
363
                    return patternSpec.getSearchFor() == IJavaSearchConstants.METHOD;
373
						if (!isApplicable) {
364
                }
374
							return false;
365
        }
375
						}
366
        return false;
376
					} else if (spec instanceof PatternQuerySpecification) {
367
    }
377
						PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
378
						return patternSpec.getSearchFor() == IJavaSearchConstants.METHOD;
379
					}
380
			}
381
		}
382
		return isApplicable;
383
	}
368
384
369
    @Override
385
    @Override
370
	public String getID() {
386
	public String getID() {
Lines 375-387 Link Here
375
abstract class GenericTypeFilter extends JavaMatchFilter {
391
abstract class GenericTypeFilter extends JavaMatchFilter {
376
	@Override
392
	@Override
377
	public boolean isApplicable(JavaSearchQuery query) {
393
	public boolean isApplicable(JavaSearchQuery query) {
378
		QuerySpecification spec= query.getSpecification();
394
		List<QuerySpecification> specList= query.getSpecification();
379
		if (spec instanceof ElementQuerySpecification) {
395
		boolean isApplicable= false;
380
			ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
396
		for (QuerySpecification spec : specList) {
381
			IJavaElement element= elementSpec.getElement();
397
			if (spec instanceof ElementQuerySpecification) {
382
			return isParameterizedElement(element);
398
				ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
399
				IJavaElement element= elementSpec.getElement();
400
				isApplicable= isParameterizedElement(element);
401
				if (!isApplicable)
402
					return false;
403
			} else {
404
				return false;
405
			}
383
		}
406
		}
384
		return false;
407
		return isApplicable;
385
	}
408
	}
386
409
387
	private static boolean isParameterizedElement(IJavaElement element) {
410
	private static boolean isParameterizedElement(IJavaElement element) {
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchQuery.java (-32 / +90 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2016 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.ui.search;
11
package org.eclipse.jdt.internal.ui.search;
12
13
import java.util.ArrayList;
14
import java.util.List;
12
15
13
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IProgressMonitor;
Lines 55-67 Link Here
55
	private static final String PERF_SEARCH_PARTICIPANT= "org.eclipse.jdt.ui/perf/search/participants"; //$NON-NLS-1$
58
	private static final String PERF_SEARCH_PARTICIPANT= "org.eclipse.jdt.ui/perf/search/participants"; //$NON-NLS-1$
56
59
57
	private ISearchResult fResult;
60
	private ISearchResult fResult;
58
	private final QuerySpecification fPatternData;
61
	private final List<QuerySpecification> fPatternDataList;
59
62
60
	public JavaSearchQuery(QuerySpecification data) {
63
	public JavaSearchQuery(QuerySpecification data) {
61
		if (data == null) {
64
		if (data == null) {
62
			throw new IllegalArgumentException("data must not be null"); //$NON-NLS-1$
65
			throw new IllegalArgumentException("data must not be null"); //$NON-NLS-1$
63
		}
66
		}
64
		fPatternData= data;
67
		fPatternDataList= new ArrayList<>();
68
		fPatternDataList.add(data);
69
	}
70
71
	public JavaSearchQuery(List<QuerySpecification> dataList) {
72
		if (dataList == null) {
73
			throw new IllegalArgumentException("data must not be null"); //$NON-NLS-1$
74
		}
75
		fPatternDataList= dataList;
65
	}
76
	}
66
77
67
	private static class SearchRequestor implements ISearchRequestor {
78
	private static class SearchRequestor implements ISearchRequestor {
Lines 93-99 Link Here
93
		try {
104
		try {
94
105
95
			int totalTicks= 1000;
106
			int totalTicks= 1000;
96
			IProject[] projects= JavaSearchScopeFactory.getInstance().getProjects(fPatternData.getScope());
107
			IProject[] projects= JavaSearchScopeFactory.getInstance().getProjects(getPatternData().getScope());
97
			final SearchParticipantRecord[] participantDescriptors= SearchParticipantsExtensionPoint.getInstance().getSearchParticipants(projects);
108
			final SearchParticipantRecord[] participantDescriptors= SearchParticipantsExtensionPoint.getInstance().getSearchParticipants(projects);
98
			final int[] ticks= new int[participantDescriptors.length];
109
			final int[] ticks= new int[participantDescriptors.length];
99
			for (int i= 0; i < participantDescriptors.length; i++) {
110
			for (int i= 0; i < participantDescriptors.length; i++) {
Lines 108-114 Link Here
108
119
109
					@Override
120
					@Override
110
					public void run() throws Exception {
121
					public void run() throws Exception {
111
						ticks[iPrime]= participantDescriptors[iPrime].getParticipant().estimateTicks(fPatternData);
122
						for (QuerySpecification querySpecification : fPatternDataList) {
123
							ticks[iPrime]+= participantDescriptors[iPrime].getParticipant().estimateTicks(querySpecification);
124
						}
112
					}
125
					}
113
				};
126
				};
114
127
Lines 116-138 Link Here
116
				totalTicks+= ticks[i];
129
				totalTicks+= ticks[i];
117
			}
130
			}
118
131
119
			SearchPattern pattern;
132
			SearchPattern pattern= null;
120
			String stringPattern;
133
			String stringPattern= null;
121
134
			
122
			if (fPatternData instanceof ElementQuerySpecification) {
135
			if (fPatternDataList.size() == 1) {
123
				IJavaElement element= ((ElementQuerySpecification) fPatternData).getElement();
136
				if (getPatternData() instanceof ElementQuerySpecification) {
124
				stringPattern= JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT);
137
					IJavaElement element= ((ElementQuerySpecification) getPatternData()).getElement();
125
				if (!element.exists()) {
138
					stringPattern= JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT);
126
					return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(SearchMessages.JavaSearchQuery_error_element_does_not_exist, stringPattern), null);
139
					if (!element.exists()) {
140
						return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(SearchMessages.JavaSearchQuery_error_element_does_not_exist, stringPattern), null);
141
					}
142
					pattern= SearchPattern.createPattern(element, getPatternData().getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
143
				} else if (getPatternData() instanceof PatternQuerySpecification) {
144
					PatternQuerySpecification patternSpec= (PatternQuerySpecification) getPatternData();
145
					stringPattern= patternSpec.getPattern();
146
					int matchMode= getMatchMode(stringPattern) | SearchPattern.R_ERASURE_MATCH;
147
					if (patternSpec.isCaseSensitive())
148
						matchMode|= SearchPattern.R_CASE_SENSITIVE;
149
					pattern= SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode);
127
				}
150
				}
128
				pattern= SearchPattern.createPattern(element, fPatternData.getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
129
			} else {
151
			} else {
130
				PatternQuerySpecification patternSpec = (PatternQuerySpecification) fPatternData;
152
				for (QuerySpecification querySpecification : fPatternDataList) {
131
				stringPattern= patternSpec.getPattern();
153
					if (!(querySpecification instanceof ElementQuerySpecification))
132
				int matchMode= getMatchMode(stringPattern) | SearchPattern.R_ERASURE_MATCH;
154
						break;
133
				if (patternSpec.isCaseSensitive())
155
					IJavaElement element= ((ElementQuerySpecification) querySpecification).getElement();
134
					matchMode |= SearchPattern.R_CASE_SENSITIVE;
156
					stringPattern= JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT);
135
				pattern= SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode);
157
					if (!element.exists()) {
158
						return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(SearchMessages.JavaSearchQuery_error_element_does_not_exist, stringPattern), null);
159
					}
160
					SearchPattern elementPattern= SearchPattern.createPattern(element, getPatternData().getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
161
					if (pattern == null) {
162
						pattern= elementPattern;
163
					} else {
164
						pattern= SearchPattern.createOrPattern(pattern, elementPattern);
165
					}
166
				}
136
			}
167
			}
137
168
138
			if (pattern == null) {
169
			if (pattern == null) {
Lines 145-151 Link Here
145
			NewSearchResultCollector collector= new NewSearchResultCollector(textResult, ignorePotentials);
176
			NewSearchResultCollector collector= new NewSearchResultCollector(textResult, ignorePotentials);
146
177
147
178
148
			engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, fPatternData.getScope(), collector, mainSearchPM);
179
			engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, getPatternData().getScope(), collector, mainSearchPM);
149
			for (int i= 0; i < participantDescriptors.length; i++) {
180
			for (int i= 0; i < participantDescriptors.length; i++) {
150
				final ISearchRequestor requestor= new SearchRequestor(participantDescriptors[i].getParticipant(), textResult);
181
				final ISearchRequestor requestor= new SearchRequestor(participantDescriptors[i].getParticipant(), textResult);
151
				final IProgressMonitor participantPM= new SubProgressMonitor(monitor, ticks[i]);
182
				final IProgressMonitor participantPM= new SubProgressMonitor(monitor, ticks[i]);
Lines 167-173 Link Here
167
						final PerformanceStats stats= PerformanceStats.getStats(PERF_SEARCH_PARTICIPANT, participant);
198
						final PerformanceStats stats= PerformanceStats.getStats(PERF_SEARCH_PARTICIPANT, participant);
168
						stats.startRun();
199
						stats.startRun();
169
200
170
						participant.search(requestor, fPatternData, participantPM);
201
						for (QuerySpecification querySpecification : fPatternDataList) {
202
							participant.search(requestor, querySpecification, participantPM);
203
						}
171
204
172
						stats.endRun();
205
						stats.endRun();
173
					}
206
					}
Lines 200-206 Link Here
200
	public String getResultLabel(int nMatches) {
233
	public String getResultLabel(int nMatches) {
201
		int limitTo= getMaskedLimitTo();
234
		int limitTo= getMaskedLimitTo();
202
		if (nMatches == 1) {
235
		if (nMatches == 1) {
203
			String[] args= { getSearchPatternDescription(), fPatternData.getScopeDescription() };
236
			String[] args= { getSearchPatternDescription(), getPatternData().getScopeDescription() };
204
			switch (limitTo) {
237
			switch (limitTo) {
205
				case IJavaSearchConstants.IMPLEMENTORS:
238
				case IJavaSearchConstants.IMPLEMENTORS:
206
					return Messages.format(SearchMessages.JavaSearchOperation_singularImplementorsPostfix, args);
239
					return Messages.format(SearchMessages.JavaSearchOperation_singularImplementorsPostfix, args);
Lines 219-225 Link Here
219
					return Messages.format(SearchMessages.JavaSearchQuery_singularReferencesWithMatchLocations, new Object[] { args[0], args[1], matchLocations });
252
					return Messages.format(SearchMessages.JavaSearchQuery_singularReferencesWithMatchLocations, new Object[] { args[0], args[1], matchLocations });
220
			}
253
			}
221
		} else {
254
		} else {
222
			Object[] args= { getSearchPatternDescription(), new Integer(nMatches), fPatternData.getScopeDescription() };
255
			Object[] args= { getSearchPatternDescription(), new Integer(nMatches), getPatternData().getScopeDescription() };
223
			switch (limitTo) {
256
			switch (limitTo) {
224
				case IJavaSearchConstants.IMPLEMENTORS:
257
				case IJavaSearchConstants.IMPLEMENTORS:
225
					return Messages.format(SearchMessages.JavaSearchOperation_pluralImplementorsPostfix, args);
258
					return Messages.format(SearchMessages.JavaSearchOperation_pluralImplementorsPostfix, args);
Lines 241-256 Link Here
241
	}
274
	}
242
275
243
	private String getSearchPatternDescription() {
276
	private String getSearchPatternDescription() {
244
		if (fPatternData instanceof ElementQuerySpecification) {
277
		if (fPatternDataList.size() == 1) {
245
			IJavaElement element= ((ElementQuerySpecification) fPatternData).getElement();
278
			if (getPatternData() instanceof ElementQuerySpecification) {
246
			return JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT
279
				IJavaElement element= ((ElementQuerySpecification) getPatternData()).getElement();
247
					| JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.USE_RESOLVED | JavaElementLabels.P_COMPRESSED);
280
				return JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT
281
						| JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.USE_RESOLVED | JavaElementLabels.P_COMPRESSED);
282
			} else if (getPatternData() instanceof PatternQuerySpecification) {
283
				return BasicElementLabels.getFilePattern(((PatternQuerySpecification) getPatternData()).getPattern());
284
			}
285
		} else {
286
			StringBuilder description= new StringBuilder();
287
			for (int i= 0; i < fPatternDataList.size(); i++) {
288
				QuerySpecification querySpecification= fPatternDataList.get(i);
289
				if (!(querySpecification instanceof ElementQuerySpecification)) {
290
					return new String(""); //$NON-NLS-1$
291
				}
292
				IJavaElement element= ((ElementQuerySpecification) querySpecification).getElement();
293
				if (description.length() != 0 && i < (fPatternDataList.size() - 1)) {
294
					description.append(", "); //$NON-NLS-1$
295
				} else if (description.length() > 0) {
296
					description.append(" " + SearchMessages.JavaSearchQuery_multi_selection_search_and + " "); //$NON-NLS-1$//$NON-NLS-2$
297
				}
298
				description.append(JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT
299
						| JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.USE_RESOLVED | JavaElementLabels.P_COMPRESSED));
300
			}
301
			return description.toString();
248
		}
302
		}
249
		return BasicElementLabels.getFilePattern(((PatternQuerySpecification) fPatternData).getPattern());
303
		return new String(""); //$NON-NLS-1$
250
	}
304
	}
251
305
252
	private int getMaskedLimitTo() {
306
	private int getMaskedLimitTo() {
253
		return fPatternData.getLimitTo() & ~(IJavaSearchConstants.IGNORE_RETURN_TYPE | IJavaSearchConstants.IGNORE_DECLARING_TYPE);
307
		return getPatternData().getLimitTo() & ~(IJavaSearchConstants.IGNORE_RETURN_TYPE | IJavaSearchConstants.IGNORE_DECLARING_TYPE);
254
	}
308
	}
255
309
256
	ImageDescriptor getImageDescriptor() {
310
	ImageDescriptor getImageDescriptor() {
Lines 281-287 Link Here
281
		return fResult;
335
		return fResult;
282
	}
336
	}
283
337
284
	QuerySpecification getSpecification() {
338
	private QuerySpecification getPatternData() {
285
		return fPatternData;
339
		return fPatternDataList.get(0);
340
	}
341
342
	List<QuerySpecification> getSpecification() {
343
		return fPatternDataList;
286
	}
344
	}
287
}
345
}
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchMessages.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2014 IBM Corporation and others.
2
 * Copyright (c) 2000, 2016 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 268-273 Link Here
268
268
269
	public static String JavaSearchQuery_error_element_does_not_exist;
269
	public static String JavaSearchQuery_error_element_does_not_exist;
270
	public static String JavaSearchQuery_pluralReferencesWithMatchLocations;
270
	public static String JavaSearchQuery_pluralReferencesWithMatchLocations;
271
	public static String JavaSearchQuery_multi_selection_search_and;
271
	public static String MatchFilter_PotentialFilter_name;
272
	public static String MatchFilter_PotentialFilter_name;
272
	public static String MatchFilter_PotentialFilter_actionLabel;
273
	public static String MatchFilter_PotentialFilter_actionLabel;
273
	public static String MatchFilter_PotentialFilter_description;
274
	public static String MatchFilter_PotentialFilter_description;
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchMessages.properties (-1 / +2 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2011 IBM Corporation and others.
2
# Copyright (c) 2000, 2016 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 255-260 Link Here
255
JavaSearchQuery_error_participant_search=An error occurred during participant search. The participant has been disabled for the current session.
255
JavaSearchQuery_error_participant_search=An error occurred during participant search. The participant has been disabled for the current session.
256
JavaSearchQuery_pluralReferencesWithMatchLocations=''{0}'' in ''{3}'' - {1} references in {2}
256
JavaSearchQuery_pluralReferencesWithMatchLocations=''{0}'' in ''{3}'' - {1} references in {2}
257
257
258
JavaSearchQuery_multi_selection_search_and=and
258
SearchParticipant_error_noID=Missing id attribute on search participant extension {0}
259
SearchParticipant_error_noID=Missing id attribute on search participant extension {0}
259
SearchParticipant_error_noNature=Missing nature attribute on search participant {0}
260
SearchParticipant_error_noNature=Missing nature attribute on search participant {0}
260
SearchParticipant_error_noClass=Missing class attribute on search participant {0}
261
SearchParticipant_error_noClass=Missing class attribute on search participant {0}
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewer.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2016 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 41-47 Link Here
41
41
42
42
43
	public TypeHierarchyViewer(Composite parent, IContentProvider contentProvider, TypeHierarchyLifeCycle lifeCycle) {
43
	public TypeHierarchyViewer(Composite parent, IContentProvider contentProvider, TypeHierarchyLifeCycle lifeCycle) {
44
		super(new Tree(parent, SWT.SINGLE));
44
		super(new Tree(parent, SWT.MULTI));
45
45
46
		fLabelProvider= new HierarchyLabelProvider(lifeCycle);
46
		fLabelProvider= new HierarchyLabelProvider(lifeCycle);
47
47
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java (-19 / +44 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2016 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-16 Link Here
11
package org.eclipse.jdt.ui.actions;
11
package org.eclipse.jdt.ui.actions;
12
12
13
import java.lang.reflect.InvocationTargetException;
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.ArrayList;
15
import java.util.Arrays;
16
import java.util.Iterator;
17
import java.util.List;
14
18
15
import org.eclipse.core.runtime.IAdaptable;
19
import org.eclipse.core.runtime.IAdaptable;
16
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.IStatus;
Lines 98-105 Link Here
98
	 */
102
	 */
99
	abstract Class<?>[] getValidTypes();
103
	abstract Class<?>[] getValidTypes();
100
104
101
	private boolean canOperateOn(IStructuredSelection sel) {
105
	boolean canOperateOn(IStructuredSelection sel) {
102
		return sel != null && !sel.isEmpty() && canOperateOn(getJavaElement(sel, true));
106
		if (sel == null || sel.isEmpty()) {
107
			return false;
108
		}
109
		List<IJavaElement> elementList= getJavaElements(sel, true);
110
		for (IJavaElement iJavaElement : elementList) {
111
			if (!canOperateOn(iJavaElement)) {
112
				return false;
113
			}
114
		}
115
		return true;
103
	}
116
	}
104
117
105
	boolean canOperateOn(IJavaElement element) {
118
	boolean canOperateOn(IJavaElement element) {
Lines 139-158 Link Here
139
		}
152
		}
140
	}
153
	}
141
154
142
	IJavaElement getJavaElement(IStructuredSelection selection, boolean silent) {
155
	private List<IJavaElement> getJavaElements(IStructuredSelection selection, boolean silent) {
143
		if (selection.size() == 1) {
156
		List<IJavaElement> javaElementList= new ArrayList<>();
144
			Object firstElement= selection.getFirstElement();
157
		for (Iterator<?> iter= selection.iterator(); iter.hasNext();) {
158
			Object firstElement= iter.next();
145
			IJavaElement elem= null;
159
			IJavaElement elem= null;
146
			if (firstElement instanceof IJavaElement)
160
			if (firstElement instanceof IJavaElement)
147
				elem= (IJavaElement) firstElement;
161
				elem= (IJavaElement) firstElement;
148
			else if (firstElement instanceof IAdaptable)
162
			else if (firstElement instanceof IAdaptable)
149
				elem= ((IAdaptable) firstElement).getAdapter(IJavaElement.class);
163
				elem= ((IAdaptable) firstElement).getAdapter(IJavaElement.class);
150
			if (elem != null) {
164
			if (elem != null) {
151
				return getTypeIfPossible(elem, silent);
165
				javaElementList.add(getTypeIfPossible(elem, silent));
152
			}
166
			}
153
167
154
		}
168
		}
155
		return null;
169
		return javaElementList;
156
	}
170
	}
157
171
158
	private void showOperationUnavailableDialog() {
172
	private void showOperationUnavailableDialog() {
Lines 201-215 Link Here
201
	 */
215
	 */
202
	@Override
216
	@Override
203
	public void run(IStructuredSelection selection) {
217
	public void run(IStructuredSelection selection) {
204
		IJavaElement element= getJavaElement(selection, false);
218
		List<IJavaElement> elementList= getJavaElements(selection, false);
205
		if (element == null || !element.exists()) {
219
		for (Iterator<IJavaElement> iterator= elementList.iterator(); iterator.hasNext();) {
206
			showOperationUnavailableDialog();
220
			IJavaElement element= iterator.next();
207
			return;
221
			if (element == null || !element.exists()) {
222
				showOperationUnavailableDialog();
223
				return;
224
			} else if (!ActionUtil.isProcessable(getShell(), element)) {
225
				return;
226
			} else if (element == RETURN_WITHOUT_BEEP) {
227
				return;
228
			}
208
		}
229
		}
209
		else if (element == RETURN_WITHOUT_BEEP)
230
		run(elementList);
210
			return;
211
212
		run(element);
213
	}
231
	}
214
232
215
	/*
233
	/*
Lines 266-274 Link Here
266
		if (!ActionUtil.isProcessable(getShell(), element))
284
		if (!ActionUtil.isProcessable(getShell(), element))
267
			return;
285
			return;
268
286
287
		run(Arrays.asList(new IJavaElement[] { element }));
288
	}
289
290
	private void run(List<IJavaElement> elementList) {
269
		// will return true except for debugging purposes.
291
		// will return true except for debugging purposes.
270
		try {
292
		try {
271
			performNewSearch(element);
293
			List<QuerySpecification> queryList= new ArrayList<>(elementList.size());
294
			for (IJavaElement element : elementList) {
295
				queryList.add(createQuery(element));
296
			}
297
			performNewSearch(new JavaSearchQuery(queryList));
272
		} catch (JavaModelException ex) {
298
		} catch (JavaModelException ex) {
273
			ExceptionHandler.handle(ex, getShell(), SearchMessages.Search_Error_search_notsuccessful_title, SearchMessages.Search_Error_search_notsuccessful_message);
299
			ExceptionHandler.handle(ex, getShell(), SearchMessages.Search_Error_search_notsuccessful_title, SearchMessages.Search_Error_search_notsuccessful_message);
274
		} catch (InterruptedException e) {
300
		} catch (InterruptedException e) {
Lines 276-283 Link Here
276
		}
302
		}
277
	}
303
	}
278
304
279
	private void performNewSearch(IJavaElement element) throws JavaModelException, InterruptedException {
305
	private void performNewSearch(JavaSearchQuery query) {
280
		JavaSearchQuery query= new JavaSearchQuery(createQuery(element));
281
		if (query.canRunInBackground()) {
306
		if (query.canRunInBackground()) {
282
			/*
307
			/*
283
			 * This indirection with Object as parameter is needed to prevent the loading
308
			 * This indirection with Object as parameter is needed to prevent the loading
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInHierarchyAction.java (-1 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2011 IBM Corporation and others.
2
 * Copyright (c) 2000, 2016 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.ui.actions;
11
package org.eclipse.jdt.ui.actions;
12
13
import org.eclipse.jface.viewers.IStructuredSelection;
12
14
13
import org.eclipse.ui.IWorkbenchSite;
15
import org.eclipse.ui.IWorkbenchSite;
14
import org.eclipse.ui.PlatformUI;
16
import org.eclipse.ui.PlatformUI;
Lines 93-96 Link Here
93
		return new ElementQuerySpecification(element, getLimitTo(), scope, description);
95
		return new ElementQuerySpecification(element, getLimitTo(), scope, description);
94
	}
96
	}
95
97
98
	@Override
99
	boolean canOperateOn(IStructuredSelection sel) {
100
		if (sel == null || sel.isEmpty() || sel.size() > 1) {
101
			return false;
102
		}
103
		return super.canOperateOn(sel);
104
	}
96
}
105
}

Return to bug 477340