blob: 60844e02f8ed858ed82ecfacdd9d7db5a3317ab0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*******************************************************************************
* Copyright (c) 2006, 2014 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* QNX - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.search;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
/**
* @author Doug Schaefer
*/
public class CSearchElementQuery extends CSearchQuery {
private final ISourceReference element;
private String label;
public CSearchElementQuery(ICElement[] scope, ISourceReference element, int flags) {
super(scope, flags | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
this.element = element;
this.label = (element instanceof ICElement) ? ((ICElement) element).getElementName()
: CSearchMessages.PDOMSearchElementQuery_something;
}
@Override
public IStatus runWithIndex(IIndex index, IProgressMonitor monitor) throws OperationCanceledException {
try {
if (element instanceof ICElement) {
IBinding binding = IndexUI.elementToBinding(index, (ICElement) element);
if (binding != null) {
label = labelForBinding(index, binding, label);
// We should call CPPSemantics.pushLookupPoint() here.
// Until we do, instantiation of dependent expressions may not work.
createMatches(index, binding);
}
}
return Status.OK_STATUS;
} catch (CoreException e) {
return e.getStatus();
}
}
@Override
public String getResultLabel(int numMatches) {
return getResultLabel(label, numMatches);
}
}
|