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 / +67 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 213-235 Link Here
213
213
214
	@Override
214
	@Override
215
	public boolean isApplicable(JavaSearchQuery query) {
215
	public boolean isApplicable(JavaSearchQuery query) {
216
		QuerySpecification spec= query.getSpecification();
216
		ArrayList<QuerySpecification> specList= query.getSpecification();
217
		if (spec instanceof ElementQuerySpecification) {
217
		boolean isApplicable= false;
218
			ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
218
		for (QuerySpecification spec : specList) {
219
			IJavaElement element= elementSpec.getElement();
219
			if (spec instanceof ElementQuerySpecification) {
220
			switch (element.getElementType()) {
220
				ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
221
				case IJavaElement.TYPE:
221
				IJavaElement element= elementSpec.getElement();
222
				case IJavaElement.METHOD:
222
				switch (element.getElementType()) {
223
				case IJavaElement.FIELD:
223
					case IJavaElement.TYPE:
224
				case IJavaElement.PACKAGE_FRAGMENT:
224
					case IJavaElement.METHOD:
225
					return true;
225
					case IJavaElement.FIELD:
226
				default:
226
					case IJavaElement.PACKAGE_FRAGMENT:
227
					return false;
227
						isApplicable= true;
228
					default:
229
						return false;
230
				}
231
			} else if (spec instanceof PatternQuerySpecification) {
232
				return true;
228
			}
233
			}
229
		} else if (spec instanceof PatternQuerySpecification) {
230
			return true;
231
		}
234
		}
232
		return false;
235
		return isApplicable;
233
	}
236
	}
234
237
235
	@Override
238
	@Override
Lines 241-256 Link Here
241
abstract class VariableFilter extends JavaMatchFilter {
244
abstract class VariableFilter extends JavaMatchFilter {
242
	@Override
245
	@Override
243
	public boolean isApplicable(JavaSearchQuery query) {
246
	public boolean isApplicable(JavaSearchQuery query) {
244
		QuerySpecification spec= query.getSpecification();
247
		ArrayList<QuerySpecification> speclist= query.getSpecification();
245
		if (spec instanceof ElementQuerySpecification) {
248
		boolean isApplicable= false;
246
			ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
249
		for (QuerySpecification spec : speclist) {
247
			IJavaElement element= elementSpec.getElement();
250
			if (spec instanceof ElementQuerySpecification) {
248
			return element instanceof IField || element instanceof ILocalVariable;
251
				ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
249
		} else if (spec instanceof PatternQuerySpecification) {
252
				IJavaElement element= elementSpec.getElement();
250
			PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
253
				isApplicable= element instanceof IField || element instanceof ILocalVariable;
251
			return patternSpec.getSearchFor() == IJavaSearchConstants.FIELD;
254
				if (!isApplicable)
255
					return false;
256
			} else if (spec instanceof PatternQuerySpecification) {
257
				PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
258
				return patternSpec.getSearchFor() == IJavaSearchConstants.FIELD;
259
			}
252
		}
260
		}
253
		return false;
261
262
		return isApplicable;
254
	}
263
	}
255
264
256
}
265
}
Lines 351-370 Link Here
351
360
352
    @Override
361
    @Override
353
	public boolean isApplicable(JavaSearchQuery query) {
362
	public boolean isApplicable(JavaSearchQuery query) {
354
        QuerySpecification spec= query.getSpecification();
363
		ArrayList<QuerySpecification> speclist= query.getSpecification();
355
        switch (spec.getLimitTo()) {
364
		boolean isApplicable= false;
356
			case IJavaSearchConstants.REFERENCES:
365
		for (QuerySpecification spec : speclist) {
357
			case IJavaSearchConstants.ALL_OCCURRENCES:
366
			switch (spec.getLimitTo()) {
358
                if (spec instanceof ElementQuerySpecification) {
367
				case IJavaSearchConstants.REFERENCES:
359
                    ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
368
				case IJavaSearchConstants.ALL_OCCURRENCES:
360
                    return elementSpec.getElement() instanceof IMethod;
369
					if (spec instanceof ElementQuerySpecification) {
361
                } else if (spec instanceof PatternQuerySpecification) {
370
						ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
362
                    PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
371
						isApplicable= elementSpec.getElement() instanceof IMethod;
363
                    return patternSpec.getSearchFor() == IJavaSearchConstants.METHOD;
372
						if (!isApplicable) {
364
                }
373
							return false;
365
        }
374
						}
366
        return false;
375
					} else if (spec instanceof PatternQuerySpecification) {
367
    }
376
						PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
377
						return patternSpec.getSearchFor() == IJavaSearchConstants.METHOD;
378
					}
379
			}
380
		}
381
		return isApplicable;
382
	}
368
383
369
    @Override
384
    @Override
370
	public String getID() {
385
	public String getID() {
Lines 375-387 Link Here
375
abstract class GenericTypeFilter extends JavaMatchFilter {
390
abstract class GenericTypeFilter extends JavaMatchFilter {
376
	@Override
391
	@Override
377
	public boolean isApplicable(JavaSearchQuery query) {
392
	public boolean isApplicable(JavaSearchQuery query) {
378
		QuerySpecification spec= query.getSpecification();
393
		ArrayList<QuerySpecification> specList= query.getSpecification();
379
		if (spec instanceof ElementQuerySpecification) {
394
		boolean isApplicable= false;
380
			ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
395
		for (QuerySpecification spec : specList) {
381
			IJavaElement element= elementSpec.getElement();
396
			if (spec instanceof ElementQuerySpecification) {
382
			return isParameterizedElement(element);
397
				ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
398
				IJavaElement element= elementSpec.getElement();
399
				isApplicable= isParameterizedElement(element);
400
				if (!isApplicable)
401
					return false;
402
			} else {
403
				return false;
404
			}
383
		}
405
		}
384
		return false;
406
		return isApplicable;
385
	}
407
	}
386
408
387
	private static boolean isParameterizedElement(IJavaElement element) {
409
	private static boolean isParameterizedElement(IJavaElement element) {
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchQuery.java (-32 / +88 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;
12
14
13
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IProgressMonitor;
16
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$
57
	private static final String PERF_SEARCH_PARTICIPANT= "org.eclipse.jdt.ui/perf/search/participants"; //$NON-NLS-1$
56
58
57
	private ISearchResult fResult;
59
	private ISearchResult fResult;
58
	private final QuerySpecification fPatternData;
60
	private final ArrayList<QuerySpecification> fPatternDataList;
59
61
60
	public JavaSearchQuery(QuerySpecification data) {
62
	public JavaSearchQuery(QuerySpecification data) {
61
		if (data == null) {
63
		if (data == null) {
62
			throw new IllegalArgumentException("data must not be null"); //$NON-NLS-1$
64
			throw new IllegalArgumentException("data must not be null"); //$NON-NLS-1$
63
		}
65
		}
64
		fPatternData= data;
66
		fPatternDataList= new ArrayList<>();
67
		fPatternDataList.add(data);
68
	}
69
70
	public JavaSearchQuery(ArrayList<QuerySpecification> dataList) {
71
		if (dataList == null) {
72
			throw new IllegalArgumentException("data must not be null"); //$NON-NLS-1$
73
		}
74
		fPatternDataList= dataList;
65
	}
75
	}
66
76
67
	private static class SearchRequestor implements ISearchRequestor {
77
	private static class SearchRequestor implements ISearchRequestor {
Lines 93-99 Link Here
93
		try {
103
		try {
94
104
95
			int totalTicks= 1000;
105
			int totalTicks= 1000;
96
			IProject[] projects= JavaSearchScopeFactory.getInstance().getProjects(fPatternData.getScope());
106
			IProject[] projects= JavaSearchScopeFactory.getInstance().getProjects(getPatternData().getScope());
97
			final SearchParticipantRecord[] participantDescriptors= SearchParticipantsExtensionPoint.getInstance().getSearchParticipants(projects);
107
			final SearchParticipantRecord[] participantDescriptors= SearchParticipantsExtensionPoint.getInstance().getSearchParticipants(projects);
98
			final int[] ticks= new int[participantDescriptors.length];
108
			final int[] ticks= new int[participantDescriptors.length];
99
			for (int i= 0; i < participantDescriptors.length; i++) {
109
			for (int i= 0; i < participantDescriptors.length; i++) {
Lines 108-114 Link Here
108
118
109
					@Override
119
					@Override
110
					public void run() throws Exception {
120
					public void run() throws Exception {
111
						ticks[iPrime]= participantDescriptors[iPrime].getParticipant().estimateTicks(fPatternData);
121
						for (QuerySpecification querySpecification : fPatternDataList) {
122
							ticks[iPrime]+= participantDescriptors[iPrime].getParticipant().estimateTicks(querySpecification);
123
						}
112
					}
124
					}
113
				};
125
				};
114
126
Lines 116-138 Link Here
116
				totalTicks+= ticks[i];
128
				totalTicks+= ticks[i];
117
			}
129
			}
118
130
119
			SearchPattern pattern;
131
			SearchPattern pattern= null;
120
			String stringPattern;
132
			String stringPattern= null;
121
133
			
122
			if (fPatternData instanceof ElementQuerySpecification) {
134
			if (fPatternDataList.size() == 1) {
123
				IJavaElement element= ((ElementQuerySpecification) fPatternData).getElement();
135
				if (getPatternData() instanceof ElementQuerySpecification) {
124
				stringPattern= JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT);
136
					IJavaElement element= ((ElementQuerySpecification) getPatternData()).getElement();
125
				if (!element.exists()) {
137
					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);
138
					if (!element.exists()) {
139
						return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(SearchMessages.JavaSearchQuery_error_element_does_not_exist, stringPattern), null);
140
					}
141
					pattern= SearchPattern.createPattern(element, getPatternData().getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
142
				} else if (getPatternData() instanceof PatternQuerySpecification) {
143
					PatternQuerySpecification patternSpec= (PatternQuerySpecification) getPatternData();
144
					stringPattern= patternSpec.getPattern();
145
					int matchMode= getMatchMode(stringPattern) | SearchPattern.R_ERASURE_MATCH;
146
					if (patternSpec.isCaseSensitive())
147
						matchMode|= SearchPattern.R_CASE_SENSITIVE;
148
					pattern= SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode);
127
				}
149
				}
128
				pattern= SearchPattern.createPattern(element, fPatternData.getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
129
			} else {
150
			} else {
130
				PatternQuerySpecification patternSpec = (PatternQuerySpecification) fPatternData;
151
				for (QuerySpecification querySpecification : fPatternDataList) {
131
				stringPattern= patternSpec.getPattern();
152
					if (!(querySpecification instanceof ElementQuerySpecification))
132
				int matchMode= getMatchMode(stringPattern) | SearchPattern.R_ERASURE_MATCH;
153
						break;
133
				if (patternSpec.isCaseSensitive())
154
					IJavaElement element= ((ElementQuerySpecification) querySpecification).getElement();
134
					matchMode |= SearchPattern.R_CASE_SENSITIVE;
155
					stringPattern= JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT);
135
				pattern= SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode);
156
					if (!element.exists()) {
157
						return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, Messages.format(SearchMessages.JavaSearchQuery_error_element_does_not_exist, stringPattern), null);
158
					}
159
					SearchPattern elementPattern= SearchPattern.createPattern(element, getPatternData().getLimitTo(), SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
160
					if (pattern == null)
161
						pattern= elementPattern;
162
					else
163
						pattern= SearchPattern.createOrPattern(pattern, elementPattern);
164
				}
136
			}
165
			}
137
166
138
			if (pattern == null) {
167
			if (pattern == null) {
Lines 145-151 Link Here
145
			NewSearchResultCollector collector= new NewSearchResultCollector(textResult, ignorePotentials);
174
			NewSearchResultCollector collector= new NewSearchResultCollector(textResult, ignorePotentials);
146
175
147
176
148
			engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, fPatternData.getScope(), collector, mainSearchPM);
177
			engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, getPatternData().getScope(), collector, mainSearchPM);
149
			for (int i= 0; i < participantDescriptors.length; i++) {
178
			for (int i= 0; i < participantDescriptors.length; i++) {
150
				final ISearchRequestor requestor= new SearchRequestor(participantDescriptors[i].getParticipant(), textResult);
179
				final ISearchRequestor requestor= new SearchRequestor(participantDescriptors[i].getParticipant(), textResult);
151
				final IProgressMonitor participantPM= new SubProgressMonitor(monitor, ticks[i]);
180
				final IProgressMonitor participantPM= new SubProgressMonitor(monitor, ticks[i]);
Lines 167-173 Link Here
167
						final PerformanceStats stats= PerformanceStats.getStats(PERF_SEARCH_PARTICIPANT, participant);
196
						final PerformanceStats stats= PerformanceStats.getStats(PERF_SEARCH_PARTICIPANT, participant);
168
						stats.startRun();
197
						stats.startRun();
169
198
170
						participant.search(requestor, fPatternData, participantPM);
199
						for (QuerySpecification querySpecification : fPatternDataList) {
200
							participant.search(requestor, querySpecification, participantPM);
201
						}
171
202
172
						stats.endRun();
203
						stats.endRun();
173
					}
204
					}
Lines 200-206 Link Here
200
	public String getResultLabel(int nMatches) {
231
	public String getResultLabel(int nMatches) {
201
		int limitTo= getMaskedLimitTo();
232
		int limitTo= getMaskedLimitTo();
202
		if (nMatches == 1) {
233
		if (nMatches == 1) {
203
			String[] args= { getSearchPatternDescription(), fPatternData.getScopeDescription() };
234
			String[] args= { getSearchPatternDescription(), getPatternData().getScopeDescription() };
204
			switch (limitTo) {
235
			switch (limitTo) {
205
				case IJavaSearchConstants.IMPLEMENTORS:
236
				case IJavaSearchConstants.IMPLEMENTORS:
206
					return Messages.format(SearchMessages.JavaSearchOperation_singularImplementorsPostfix, args);
237
					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 });
250
					return Messages.format(SearchMessages.JavaSearchQuery_singularReferencesWithMatchLocations, new Object[] { args[0], args[1], matchLocations });
220
			}
251
			}
221
		} else {
252
		} else {
222
			Object[] args= { getSearchPatternDescription(), new Integer(nMatches), fPatternData.getScopeDescription() };
253
			Object[] args= { getSearchPatternDescription(), new Integer(nMatches), getPatternData().getScopeDescription() };
223
			switch (limitTo) {
254
			switch (limitTo) {
224
				case IJavaSearchConstants.IMPLEMENTORS:
255
				case IJavaSearchConstants.IMPLEMENTORS:
225
					return Messages.format(SearchMessages.JavaSearchOperation_pluralImplementorsPostfix, args);
256
					return Messages.format(SearchMessages.JavaSearchOperation_pluralImplementorsPostfix, args);
Lines 241-256 Link Here
241
	}
272
	}
242
273
243
	private String getSearchPatternDescription() {
274
	private String getSearchPatternDescription() {
244
		if (fPatternData instanceof ElementQuerySpecification) {
275
		if (fPatternDataList.size() == 1) {
245
			IJavaElement element= ((ElementQuerySpecification) fPatternData).getElement();
276
			if (getPatternData() instanceof ElementQuerySpecification) {
246
			return JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT
277
				IJavaElement element= ((ElementQuerySpecification) getPatternData()).getElement();
247
					| JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.USE_RESOLVED | JavaElementLabels.P_COMPRESSED);
278
				return JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT
279
						| JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.USE_RESOLVED | JavaElementLabels.P_COMPRESSED);
280
			} else if (getPatternData() instanceof PatternQuerySpecification) {
281
				return BasicElementLabels.getFilePattern(((PatternQuerySpecification) getPatternData()).getPattern());
282
			}
283
		} else {
284
			StringBuilder description= new StringBuilder();
285
			for (int i= 0; i < fPatternDataList.size(); i++) {
286
				QuerySpecification querySpecification= fPatternDataList.get(i);
287
				if (!(querySpecification instanceof ElementQuerySpecification))
288
					return new String(""); //$NON-NLS-1$
289
				IJavaElement element= ((ElementQuerySpecification) querySpecification).getElement();
290
				if (description.length() != 0 && i < (fPatternDataList.size() - 1))
291
					description.append(", "); //$NON-NLS-1$
292
				else if (description.length() > 0)
293
					description.append(SearchMessages.JavaSearchQuery_multi_selection_search_and);
294
				description.append(JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT
295
						| JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.USE_RESOLVED | JavaElementLabels.P_COMPRESSED));
296
			}
297
			return description.toString();
248
		}
298
		}
249
		return BasicElementLabels.getFilePattern(((PatternQuerySpecification) fPatternData).getPattern());
299
		return new String(""); //$NON-NLS-1$
250
	}
300
	}
251
301
252
	private int getMaskedLimitTo() {
302
	private int getMaskedLimitTo() {
253
		return fPatternData.getLimitTo() & ~(IJavaSearchConstants.IGNORE_RETURN_TYPE | IJavaSearchConstants.IGNORE_DECLARING_TYPE);
303
		return getPatternData().getLimitTo() & ~(IJavaSearchConstants.IGNORE_RETURN_TYPE | IJavaSearchConstants.IGNORE_DECLARING_TYPE);
254
	}
304
	}
255
305
256
	ImageDescriptor getImageDescriptor() {
306
	ImageDescriptor getImageDescriptor() {
Lines 281-287 Link Here
281
		return fResult;
331
		return fResult;
282
	}
332
	}
283
333
284
	QuerySpecification getSpecification() {
334
	private QuerySpecification getPatternData() {
285
		return fPatternData;
335
		return fPatternDataList.get(0);
286
	}
336
	}
337
	
338
	ArrayList<QuerySpecification> getSpecification() {
339
		return fPatternDataList;
340
	}
341
	
342
	
287
}
343
}
(-)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 / +3 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
259
258
SearchParticipant_error_noID=Missing id attribute on search participant extension {0}
260
SearchParticipant_error_noID=Missing id attribute on search participant extension {0}
259
SearchParticipant_error_noNature=Missing nature attribute on search participant {0}
261
SearchParticipant_error_noNature=Missing nature attribute on search participant {0}
260
SearchParticipant_error_noClass=Missing class attribute on search participant {0}
262
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 (-11 / +113 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.Iterator;
14
16
15
import org.eclipse.core.runtime.IAdaptable;
17
import org.eclipse.core.runtime.IAdaptable;
16
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.IStatus;
Lines 98-105 Link Here
98
	 */
100
	 */
99
	abstract Class<?>[] getValidTypes();
101
	abstract Class<?>[] getValidTypes();
100
102
101
	private boolean canOperateOn(IStructuredSelection sel) {
103
	boolean canOperateOn(IStructuredSelection sel) {
102
		return sel != null && !sel.isEmpty() && canOperateOn(getJavaElement(sel, true));
104
		if (sel == null || sel.isEmpty())
105
			return false;
106
		if (sel.size() == 1)
107
			return canOperateOn(getJavaElement(sel, true));
108
		ArrayList<IJavaElement> elementList= getMultipleJavaElement(sel, true);
109
		boolean canOpearte= true;
110
		for (IJavaElement iJavaElement : elementList) {
111
			canOpearte= canOpearte && canOperateOn(iJavaElement);
112
			if (!canOpearte)
113
				return false;
114
		}
115
		return true;
103
	}
116
	}
104
117
105
	boolean canOperateOn(IJavaElement element) {
118
	boolean canOperateOn(IJavaElement element) {
Lines 139-144 Link Here
139
		}
152
		}
140
	}
153
	}
141
154
155
	IJavaElement getJavaElement(Object firstElement, boolean silent) {
156
		IJavaElement elem= null;
157
		if (firstElement instanceof IJavaElement)
158
			elem= (IJavaElement) firstElement;
159
		else if (firstElement instanceof IAdaptable)
160
			elem= ((IAdaptable) firstElement).getAdapter(IJavaElement.class);
161
		if (elem != null) {
162
			return getTypeIfPossible(elem, silent);
163
		}
164
165
		return null;
166
	}
167
	
142
	IJavaElement getJavaElement(IStructuredSelection selection, boolean silent) {
168
	IJavaElement getJavaElement(IStructuredSelection selection, boolean silent) {
143
		if (selection.size() == 1) {
169
		if (selection.size() == 1) {
144
			Object firstElement= selection.getFirstElement();
170
			Object firstElement= selection.getFirstElement();
Lines 153-158 Link Here
153
179
154
		}
180
		}
155
		return null;
181
		return null;
182
	}
183
	
184
	private ArrayList<IJavaElement> getMultipleJavaElement(IStructuredSelection selection, boolean silent) {
185
		ArrayList<IJavaElement> javaElementList= new ArrayList<>();
186
		for (Iterator<?> iter= selection.iterator(); iter.hasNext();) {
187
			Object firstElement= iter.next();
188
			IJavaElement elem= null;
189
			if (firstElement instanceof IJavaElement)
190
				elem= (IJavaElement) firstElement;
191
			else if (firstElement instanceof IAdaptable)
192
				elem= ((IAdaptable) firstElement).getAdapter(IJavaElement.class);
193
			if (elem != null) {
194
				javaElementList.add(getTypeIfPossible(elem, silent));
195
			}
196
		}
197
		return javaElementList;
156
	}
198
	}
157
199
158
	private void showOperationUnavailableDialog() {
200
	private void showOperationUnavailableDialog() {
Lines 201-215 Link Here
201
	 */
243
	 */
202
	@Override
244
	@Override
203
	public void run(IStructuredSelection selection) {
245
	public void run(IStructuredSelection selection) {
204
		IJavaElement element= getJavaElement(selection, false);
246
		if (selection.size() == 1) {
205
		if (element == null || !element.exists()) {
247
			IJavaElement element= getJavaElement(selection, false);
206
			showOperationUnavailableDialog();
248
			if (element == null || !element.exists()) {
207
			return;
249
				showOperationUnavailableDialog();
208
		}
250
				return;
209
		else if (element == RETURN_WITHOUT_BEEP)
251
			} else if (element == RETURN_WITHOUT_BEEP)
210
			return;
252
				return;
211
253
212
		run(element);
254
			run(element);
255
		} else {
256
			ArrayList<IJavaElement> elementList= getMultipleJavaElement(selection, false);
257
			for (Iterator iterator= elementList.iterator(); iterator.hasNext();) {
258
				IJavaElement element= (IJavaElement) iterator.next();
259
				if (element == null || !element.exists()) {
260
					showOperationUnavailableDialog();
261
					return;
262
				} else if (!ActionUtil.isProcessable(getShell(), element))
263
					return;
264
				else if (element == RETURN_WITHOUT_BEEP)
265
					return;
266
			}
267
			run(elementList);
268
		}
213
	}
269
	}
214
270
215
	/*
271
	/*
Lines 275-280 Link Here
275
			// cancelled
331
			// cancelled
276
		}
332
		}
277
	}
333
	}
334
	
335
	/**
336
	 * Executes this action for the given java element List.
337
	 * 
338
	 * @param element The java element in Lists to be found.
339
	 * @since 3.12
340
	 */
341
	public void run(ArrayList<IJavaElement> element) {
342
		// will return true except for debugging purposes.
343
		try {
344
			performNewSearch(element);
345
		} catch (JavaModelException ex) {
346
			ExceptionHandler.handle(ex, getShell(), SearchMessages.Search_Error_search_notsuccessful_title, SearchMessages.Search_Error_search_notsuccessful_message);
347
		} catch (InterruptedException e) {
348
			// cancelled
349
		}
350
	}
278
351
279
	private void performNewSearch(IJavaElement element) throws JavaModelException, InterruptedException {
352
	private void performNewSearch(IJavaElement element) throws JavaModelException, InterruptedException {
280
		JavaSearchQuery query= new JavaSearchQuery(createQuery(element));
353
		JavaSearchQuery query= new JavaSearchQuery(createQuery(element));
Lines 300-305 Link Here
300
			}
373
			}
301
		}
374
		}
302
	}
375
	}
376
	
377
	private void performNewSearch(ArrayList<IJavaElement> elementList) throws JavaModelException, InterruptedException {
378
		ArrayList<QuerySpecification> queryList= new ArrayList<>(elementList.size());
379
		for (IJavaElement element : elementList) {
380
			queryList.add(createQuery(element));
381
		}
382
		JavaSearchQuery query= new JavaSearchQuery(queryList);
383
		if (query.canRunInBackground()) {
384
			/*
385
			 * This indirection with Object as parameter is needed to prevent the loading
386
			 * of the Search plug-in: the VM verifies the method call and hence loads the
387
			 * types used in the method signature, eventually triggering the loading of
388
			 * a plug-in (in this case ISearchQuery results in Search plug-in being loaded).
389
			 */
390
			SearchUtil.runQueryInBackground(query);
391
		} else {
392
			IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
393
			/*
394
			 * This indirection with Object as parameter is needed to prevent the loading
395
			 * of the Search plug-in: the VM verifies the method call and hence loads the
396
			 * types used in the method signature, eventually triggering the loading of
397
			 * a plug-in (in this case it would be ISearchQuery).
398
			 */
399
			IStatus status= SearchUtil.runQueryInForeground(progressService, query);
400
			if (status.matches(IStatus.ERROR | IStatus.INFO | IStatus.WARNING)) {
401
				ErrorDialog.openError(getShell(), SearchMessages.Search_Error_search_title, SearchMessages.Search_Error_search_message, status);
402
			}
403
		}
404
	}
303
405
304
	/**
406
	/**
305
	 * Creates a query for the given element. Subclasses reimplement this method.
407
	 * Creates a query for the given element. Subclasses reimplement this method.
(-)a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInHierarchyAction.java (-1 / +18 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 java.util.Iterator;
14
15
import org.eclipse.jface.viewers.IStructuredSelection;
12
16
13
import org.eclipse.ui.IWorkbenchSite;
17
import org.eclipse.ui.IWorkbenchSite;
14
import org.eclipse.ui.PlatformUI;
18
import org.eclipse.ui.PlatformUI;
Lines 93-96 Link Here
93
		return new ElementQuerySpecification(element, getLimitTo(), scope, description);
97
		return new ElementQuerySpecification(element, getLimitTo(), scope, description);
94
	}
98
	}
95
99
100
	@Override
101
	boolean canOperateOn(IStructuredSelection sel) {
102
		if (sel == null || sel.isEmpty() || sel.size() > 1) {
103
			return false;
104
		}
105
		for (Iterator<?> iter= sel.iterator(); iter.hasNext();) {
106
			Object element= iter.next();
107
			if (!canOperateOn(getJavaElement(element, true))) {
108
				return false;
109
			}
110
		}
111
		return true;
112
	}
96
}
113
}

Return to bug 477340