blob: 4e6dd0b9c88f84d8421410518da7444db74ed6b6 (
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
|
/*******************************************************************************
* Copyright (c) 2018 Wind River Systems, Inc. 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:
* Lidia Popescu - [536255] initial API and implementation. Extension point for open call hierarchy view
*******************************************************************************/
package org.eclipse.cdt.ui.tests.callhierarchy.extension;
import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.ui.ICHEContentProvider;
import org.eclipse.cdt.internal.core.model.ext.FunctionDeclarationHandle;
/**
* This class implements ICHEProvider and provides test information
* */
public class CHContentProvider implements ICHEContentProvider {
@Override
public Object[] asyncComputeExtendedRoot(Object parentElement) {
Object[] object = null;
if (parentElement instanceof ICElement) {
ICElement element = (ICElement) parentElement;
if (isDslFunction(element)) {
// check if this function declaration comes from a DSL file
DslNode node = new DslNode(element);
node.setProject(element.getCProject());
return new Object[] { node };
}
}
return object;
}
@Override
public IOpenListener getCCallHierarchyOpenListener() {
return new CHOpenListener();
}
/**
* E.g. A custom implementation, suppose that functions that ends with
* "_dsl" have been originally declared in a DSL file.
* @param cElement
* @return
*/
private static boolean isDslFunction(ICElement cElement) {
if (cElement instanceof FunctionDeclarationHandle) {
FunctionDeclarationHandle f = (FunctionDeclarationHandle) cElement;
if (f.getElementName() != null & f.getElementName().endsWith("_dsl")) {
return true;
}
}
return false;
}
}
|