summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLidia Popescu2018-06-28 13:49:56 -0400
committerJonah Graham2018-09-08 03:03:00 -0400
commit0cf1ee7fdece3fd328f69ae69ce9d9396551b975 (patch)
tree3f67c96ab60e05f45800319d60897b64fb23a34c
parent8a73297c10974eb3f502997501f5a2630c973438 (diff)
downloadorg.eclipse.cdt-0cf1ee7fdece3fd328f69ae69ce9d9396551b975.tar.gz
org.eclipse.cdt-0cf1ee7fdece3fd328f69ae69ce9d9396551b975.tar.xz
org.eclipse.cdt-0cf1ee7fdece3fd328f69ae69ce9d9396551b975.zip
Bug 536255 - Extension point for open call hierarchy view
Adding a new extension point that makes possible to extend content from the Open Call Hierarchy View by adding a new node at the top of the tree. Change-Id: I9ac79896a4e8fffc9ed51cdb1be3c70f30d117c4 Signed-off-by: Lidia Popescu <lidia.popescu@windriver.com>
-rw-r--r--core/org.eclipse.cdt.ui.tests/plugin.xml11
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java5
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHContentProvider.java61
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHExtensionTest.java106
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHLabelProvider.java72
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHOpenListener.java92
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/DslNode.java76
-rw-r--r--core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.ui/plugin.xml1
-rw-r--r--core/org.eclipse.cdt.ui/schema/CCallHierarchy.exsd148
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java97
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java45
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java93
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java23
16 files changed, 827 insertions, 47 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/plugin.xml b/core/org.eclipse.cdt.ui.tests/plugin.xml
index d5c5d3bf83..13962eb220 100644
--- a/core/org.eclipse.cdt.ui.tests/plugin.xml
+++ b/core/org.eclipse.cdt.ui.tests/plugin.xml
@@ -283,4 +283,15 @@
</menuContribution>
</extension>
+ <extension
+ point="org.eclipse.cdt.ui.CCallHierarchy">
+ <CallHierarchyLabelProvider
+ class="org.eclipse.cdt.ui.tests.callhierarchy.extension.CHLabelProvider"
+ id="org.eclipse.cdt.ui.tests.callhierarchy.extension.CHLabelProvider">
+ </CallHierarchyLabelProvider>
+ <CallHierarchyContentProvider
+ class="org.eclipse.cdt.ui.tests.callhierarchy.extension.CHContentProvider"
+ id="org.eclipse.cdt.ui.tests.callhierarchy.extension.CHContentProvider">
+ </CallHierarchyContentProvider>
+ </extension>
</plugin>
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java
index de7940509b..b85184476c 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java
@@ -25,6 +25,7 @@ import org.junit.runners.Suite;
org.eclipse.cdt.ui.tests.outline.OutlineTestSuite.class,
org.eclipse.cdt.ui.tests.viewsupport.ViewSupportTestSuite.class,
org.eclipse.cdt.ui.tests.callhierarchy.CallHierarchyTestSuite.class,
+ org.eclipse.cdt.ui.tests.callhierarchy.extension.CHExtensionTest.class,
org.eclipse.cdt.ui.tests.typehierarchy.TypeHierarchyTestSuite.class,
org.eclipse.cdt.ui.tests.includebrowser.IncludeBrowserTestSuite.class,
org.eclipse.cdt.ui.tests.text.contentassist.ContentAssistTestSuite.class,
@@ -33,11 +34,11 @@ import org.junit.runners.Suite;
org.eclipse.cdt.ui.tests.quickfix.AssistQuickFixTest.class,
org.eclipse.cdt.ui.tests.buildconsole.BuildConsoleTests.class,
org.eclipse.cdt.ui.tests.search.SearchTestSuite.class,
- org.eclipse.cdt.ui.tests.refactoring.RefactoringTestSuite.class,
+ org.eclipse.cdt.ui.tests.refactoring.RefactoringTestSuite.class,
org.eclipse.cdt.ui.tests.chelp.CHelpTest.class,
org.eclipse.cdt.ui.tests.wizards.classwizard.ClassWizardTestSuite.class,
org.eclipse.cdt.ui.tests.wizards.settingswizards.SettingsWizardTestSuite.class,
- org.eclipse.cdt.ui.tests.misc.MiscTestSuite.class,
+ org.eclipse.cdt.ui.tests.misc.MiscTestSuite.class,
org.eclipse.cdt.ui.tests.editor.EditorTestSuite.class,
org.eclipse.cdt.ui.tests.templateengine.AllTemplateEngineTests.class,
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHContentProvider.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHContentProvider.java
new file mode 100644
index 0000000000..f04412856a
--- /dev/null
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHContentProvider.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * 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;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHExtensionTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHExtensionTest.java
new file mode 100644
index 0000000000..af8b5c0b3a
--- /dev/null
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHExtensionTest.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lidia Popescu - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.tests.callhierarchy.extension;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.tests.callhierarchy.CallHierarchyBaseTest;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+
+import junit.framework.TestSuite;
+
+/**
+ * @author Lidia Popescu
+ *
+ */
+public class CHExtensionTest extends CallHierarchyBaseTest {
+
+ private static final String FILE_NAME_MAIN_C = "CallHierarchy_main.c";
+ private static final String FILE_NAME_DSL = "CallHierarchy_test.java";
+ private static final String FILE_NAME_C = "CallHierarchy_test.c";
+
+ public CHExtensionTest(String name) {
+ super(name);
+ }
+
+ public static TestSuite suite() {
+ return new TestSuite(CHExtensionTest.class);
+ }
+
+// {CallHierarchy_main.c}
+// extern void function_c(void);
+// extern void function_dsl(void);
+//
+// void main(void)
+// {
+// function_c();
+// function_dsl();
+// }
+
+// {CallHierarchy_test.c}
+// void function_c(void)
+// {
+// printf("Hello, world!\n");
+// }
+
+// {CallHierarchy_test.java}
+// /** Suppose this code is written in a different custom programming language, any DSL, e.g. Java*/
+// class CallHierarchy_test {
+// public static void function_dsl() {
+// System.out.println("Hello, world!");
+// }
+// }
+ public void testCallHierarchy() throws Exception {
+
+ assertNotNull(Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.cdt.ui.CCallHierarchy"));
+
+ ImageDescriptor imageDesc = AbstractUIPlugin.imageDescriptorFromPlugin(CUIPlugin.PLUGIN_ID, CHLabelProvider.ICON_PATH);
+ assertNotNull(imageDesc);
+ Image image = imageDesc.createImage(); //$NON-NLS-1$
+ assertNotNull(image);
+
+ String content = readTaggedComment(FILE_NAME_DSL);
+ assertNotNull(content);
+ IFile file= createFile(getProject(), FILE_NAME_DSL, content);
+
+ content = readTaggedComment(FILE_NAME_C);
+ assertNotNull(content);
+ file= createFile(getProject(), FILE_NAME_C, content);
+ waitUntilFileIsIndexed(fIndex, file);
+
+ content = readTaggedComment(FILE_NAME_MAIN_C);
+ assertNotNull(content);
+ file= createFile(getProject(), FILE_NAME_MAIN_C, content);
+ waitUntilFileIsIndexed(fIndex, file);
+ CEditor editor = openEditor(file);
+
+ String functionName ="function_c";
+ editor.selectAndReveal(content.indexOf(functionName), functionName.length());
+ openCallHierarchy(editor);
+ Tree tree = getCHTreeViewer().getTree();
+ checkTreeNode(tree, 0, "function_c() : void");
+ checkTreeNode(tree, 0, 0 ,"main() : void");
+
+ functionName ="function_dsl";
+ editor.selectAndReveal(content.indexOf(functionName), functionName.length());
+ openCallHierarchy(editor);
+ tree = getCHTreeViewer().getTree();
+ checkTreeNode(tree, 0, "JAVA function function_dsl()");
+ checkTreeNode(tree, 0, 0, "function_dsl() : void");
+ }
+}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHLabelProvider.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHLabelProvider.java
new file mode 100644
index 0000000000..86ae3cfcd3
--- /dev/null
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHLabelProvider.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lidia Popescu - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.tests.callhierarchy.extension;
+
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+public class CHLabelProvider implements IStyledLabelProvider {
+
+ public static String ICON_PATH= "$nl$/icons/obj16/container_obj.gif";
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ @Override
+ public void dispose() {
+ }
+
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return true;
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ @Override
+ public StyledString getStyledText(Object element) {
+ if (element instanceof DslNode) {
+ DslNode node = (DslNode)element;
+ ICElement decl = node.getRepresentedDeclaration();
+
+ if (decl !=null) {
+ StyledString label = new StyledString();
+ label.append(decl.getElementName());
+ if (node.getDslNodeName() != null) {
+ return StyledCellLabelProvider.styleDecoratedString(node.getDslNodeName(), StyledString.DECORATIONS_STYLER, label);
+ }
+ return label;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof DslNode) {
+ Image img = AbstractUIPlugin.imageDescriptorFromPlugin(
+ CUIPlugin.PLUGIN_ID, ICON_PATH).createImage(); //$NON-NLS-1$
+ return img;
+ }
+ return null;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHOpenListener.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHOpenListener.java
new file mode 100644
index 0000000000..4023687829
--- /dev/null
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/CHOpenListener.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lidia Popescu - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.tests.callhierarchy.extension;
+
+import java.util.HashMap;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.progress.UIJob;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.testplugin.CTestPlugin;
+
+
+public class CHOpenListener implements IOpenListener {
+
+ /** On Node click open corresponding file */
+ @Override
+ public void open(OpenEvent event) {
+ if (event !=null ) {
+ ISelection selection = event.getSelection();
+ if (selection instanceof TreeSelection ) {
+ TreeSelection treeSelection = (TreeSelection)selection;
+ Object element = treeSelection.getFirstElement();
+ if (element instanceof DslNode) {
+ DslNode node = (DslNode)element;
+ ICProject project = node.getProject();
+ /**
+ * Based on a custom algorithm the corresponding file and line should be found and open. Suppose that the file
+ * 'CallHierarchy_test.java' has been found, and the line number '3' where the function 'function_dsl' is defined.
+ */
+ IFile file = project.getProject().getFile("CallHierarchy_test.java");
+ IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite().getPage();
+ IEditorInput input = new FileEditorInput(file);
+ IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(input.getName());
+
+ UIJob ui = new UIJob("Open File") {
+
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ try {
+ String editorId = null;
+ if (desc == null || desc.isOpenExternal()) {
+ editorId = "org.eclipse.ui.DefaultTextEditor";
+ } else {
+ editorId = desc.getId();
+ }
+ IEditorPart editor = page.openEditor(input, editorId);
+ IMarker fMarker = file.createMarker(IMarker.TEXT);
+ HashMap<String, Object> map = new HashMap<String, Object>();
+ map.put(IMarker.LINE_NUMBER, 3);
+ fMarker.setAttributes(map);
+ IDE.gotoMarker(editor,fMarker);
+
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return new Status(IStatus.OK, CTestPlugin.PLUGIN_ID, "");
+ }
+ };
+ ui.schedule();
+ }
+ }
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/DslNode.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/DslNode.java
new file mode 100644
index 0000000000..9da5175c15
--- /dev/null
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/extension/DslNode.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lidia Popescu - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.tests.callhierarchy.extension;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.ICHENode;
+
+
+/**
+ * The dsl node sample
+ * */
+public class DslNode implements IAdaptable, ICHENode {
+
+ private ICElement fRepresentedDecl;
+ private ICProject mProject;
+ private String mDslNodeName;
+
+ /**
+ * Constructor used for Open Call Hierarchy command
+ * */
+ public DslNode(ICElement decl) {
+ this.fRepresentedDecl = decl;
+ }
+
+ /**
+ * Constructor used for Open Dsl declaration command
+ * */
+ public DslNode() {
+
+ }
+
+ public ICProject getProject() {
+ return mProject;
+ }
+
+
+ public void setProject(ICProject mProject) {
+ this.mProject = mProject;
+ }
+
+ @Override
+ public ICElement getRepresentedDeclaration() {
+ return fRepresentedDecl;
+ }
+
+
+ @Override
+ public <T> T getAdapter(Class<T> adapterClass) {
+ if (adapterClass == ICElement.class) {
+ return (T)getRepresentedDeclaration();
+ }
+ return null;
+ }
+
+ /**
+ * Should be displayed with an indication that this is the dsl,
+ * e.g. "Java function <function_name>".
+ * */
+ public String getDslNodeName() {
+ if ( mDslNodeName == null ) {
+ mDslNodeName = "JAVA function " + fRepresentedDecl.getElementName()+"()";
+ }
+ return mDslNodeName;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
index 7ceb8554dc..f5fa59b5da 100644
--- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true
-Bundle-Version: 6.3.1.qualifier
+Bundle-Version: 6.4.0.qualifier
Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 904df5b552..5ceb7c9fc7 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -32,6 +32,7 @@
<extension-point id="RefreshExclusionContributor" name="%RefreshExclusionContributorExtensionPoint" schema="schema/RefreshExclusionContributor.exsd"/>
<extension-point id="semanticHighlighting" name="%semanticHighlightingExtensionPoint" schema="schema/semanticHighlighting.exsd"/>
<extension-point id="newToolChainWizards" name="New ToolChain Wizards" schema="schema/newToolChainWizards.exsd"/>
+ <extension-point id="CCallHierarchy" name="The Call Hierarchy Tree Extension" schema="schema/CCallHierarchy.exsd"/>
<extension
point="org.eclipse.core.runtime.adapters">
diff --git a/core/org.eclipse.cdt.ui/schema/CCallHierarchy.exsd b/core/org.eclipse.cdt.ui/schema/CCallHierarchy.exsd
new file mode 100644
index 0000000000..f0a235b9c9
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/schema/CCallHierarchy.exsd
@@ -0,0 +1,148 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.ui" id="CCallHierarchy" name="The Call Hierarchy Tree Extension"/>
+ </appInfo>
+ <documentation>
+ This Call Hierarchy Tree Extension makes possible to extend the CH tree content by adding a new node at the top of the tree, respectivity to customize it&apos;s icon and style text, and to add additional click listeners. This could be usefull for mixed source projects, when original declaration of a CDT node comes from a different programming language.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="CallHierarchyContentProvider"/>
+ <element ref="CallHierarchyLabelProvider"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="CallHierarchyContentProvider">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.ICHEContentProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="CallHierarchyLabelProvider">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider$IStyledLabelProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 6.4
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ A full sample of implementation is provided in org.eclipse.cdt.ui.tests plugin.
+&lt;extension
+ point=&quot;org.eclipse.cdt.ui.CCallHierarchy&quot;&gt;
+ &lt;CallHierarchyLabelProvider
+ class=&quot;org.eclipse.cdt.ui.tests.callhierarchy.extension.CHLabelProvider&quot;
+ id=&quot;org.eclipse.cdt.ui.tests.callhierarchy.extension.CHLabelProvider&quot;&gt;
+ &lt;/CallHierarchyLabelProvider&gt;
+ &lt;CallHierarchyContentProvider
+ class=&quot;org.eclipse.cdt.ui.tests.callhierarchy.extension.CHContentProvider&quot;
+ id=&quot;org.eclipse.cdt.ui.tests.callhierarchy.extension.CHContentProvider&quot;&gt;
+ &lt;/CallHierarchyContentProvider&gt;
+ &lt;/extension&gt;
+
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java
index e94fe13bec..9ccf7a3815 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2014 Wind River Systems, Inc. and others.
+ * Copyright (c) 2018 Wind River Systems, Inc. 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
@@ -8,6 +8,7 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
+ * Lidia Popescu (Wind River) [536255] Extension point for open call hierarchy view
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
@@ -33,6 +34,8 @@ import org.eclipse.cdt.core.model.IMethod;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IVariable;
import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.ICHEContentProvider;
+import org.eclipse.cdt.ui.ICHENode;
import org.eclipse.cdt.internal.corext.util.CModelUtil;
@@ -91,6 +94,19 @@ public class CHContentProvider extends AsyncTreeContentProvider {
@Override
protected Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
try {
+ ICHEContentProvider[] providers = fView.getContentProviders();
+ if (providers != null) {
+ for (ICHEContentProvider provider : providers) {
+ Object[] object = provider.asyncComputeExtendedRoot(parentElement);
+ if (object != null) {
+ return object;
+ }
+ }
+ }
+ if (parentElement instanceof ICHENode) {
+ return asyncComputeRoot(((ICHENode)parentElement).getRepresentedDeclaration());
+ }
+
if (parentElement instanceof ICElement) {
return asyncComputeRoot((ICElement) parentElement);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java
new file mode 100644
index 0000000000..b36fda158d
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHEProviderSettings.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lidia Popescu - [536255] initial API and implementation. Extension point for open call hierarchy view
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.IOpenListener;
+
+import org.eclipse.cdt.ui.ICHEContentProvider;
+
+/**
+ * The Call Hierarchy Extension provider Settings
+ * Responsible to load all available extensions for EXTENSION_POINT_ID
+ * */
+public class CHEProviderSettings {
+
+ private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.CCallHierarchy"; //$NON-NLS-1$
+ private static final String ELEMENT_NAME_CONTENT = "CallHierarchyContentProvider"; //$NON-NLS-1$
+ private static final String ELEMENT_NAME_LABEL = "CallHierarchyLabelProvider"; //$NON-NLS-1$
+ private static final String ATTRIB_CLASS = "class"; //$NON-NLS-1$
+
+ IOpenListener[] openListeners =null;
+
+ static ICHEContentProvider[] chContentProviders = null;
+ static IStyledLabelProvider[] chLabelProviders = null;
+
+ private static void loadExtensions() {
+ List<ICHEContentProvider> chCProviders = new ArrayList<ICHEContentProvider>();
+ List<IStyledLabelProvider> chLProviders = new ArrayList<IStyledLabelProvider>();
+
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
+ if (extensionPoint != null) {
+ IExtension[] extensions = extensionPoint.getExtensions();
+ if (extensions != null) {
+ for (IExtension ex : extensions) {
+ for (IConfigurationElement el : ex.getConfigurationElements()) {
+ if (el.getName().equals(ELEMENT_NAME_CONTENT)) {
+ ICHEContentProvider provider = null;
+ try {
+ provider = (ICHEContentProvider) el.createExecutableExtension(ATTRIB_CLASS);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (provider != null) {
+ chCProviders.add(provider);
+ }
+ }
+ if (el.getName().equals(ELEMENT_NAME_LABEL)) {
+ IStyledLabelProvider provider = null;
+ try {
+ provider = (IStyledLabelProvider) el.createExecutableExtension(ATTRIB_CLASS);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (provider != null) {
+ chLProviders.add(provider);
+ }
+ }
+ }
+ }
+ }
+ }
+ chLabelProviders = chLProviders.toArray(new IStyledLabelProvider[chLProviders.size()]);
+ chContentProviders = chCProviders.toArray(new ICHEContentProvider[chCProviders.size()]);
+ }
+
+
+
+ public static IStyledLabelProvider[] getCCallHierarchyLabelProviders() {
+ if ( chLabelProviders == null) {
+ loadExtensions();
+ }
+ return chLabelProviders;
+ }
+
+ public static ICHEContentProvider[] getCCallHierarchyContentProviders() {
+ if ( chContentProviders == null) {
+ loadExtensions();
+ }
+ return chContentProviders;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java
index 37d33fa642..d5fac53531 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2016 Wind River Systems, Inc. and others.
+ * Copyright (c) 2018 Wind River Systems, Inc. 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
@@ -8,12 +8,14 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Patrick Hofer [bug 325799]
+ * Lidia Popescu (Wind River) [536255] Extension point for open call hierarchy view
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import java.util.HashMap;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.StyledCellLabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.osgi.util.NLS;
@@ -37,19 +39,32 @@ public class CHLabelProvider extends AppearanceAwareLabelProvider {
private final static long LABEL_OPTIONS_SIMPLE = CElementLabels.ALL_FULLY_QUALIFIED
| CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.TEMPLATE_ARGUMENTS;
private final static long LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementLabels.MF_POST_FILE_QUALIFIED;
-
+
private CUILabelProvider fCLabelProvider= new CUILabelProvider(LABEL_OPTIONS_SIMPLE, CElementImageProvider.OVERLAY_ICONS);
private CHContentProvider fContentProvider;
private HashMap<String, Image> fCachedImages= new HashMap<String, Image>();
private Color fColorInactive;
-
- public CHLabelProvider(Display display, CHContentProvider cp) {
+ private IStyledLabelProvider[] fProviders;
+ private CHViewPart fView;
+
+ public CHLabelProvider(CHViewPart view, Display display, CHContentProvider cp) {
fColorInactive= display.getSystemColor(SWT.COLOR_DARK_GRAY);
fContentProvider= cp;
+ fView = view;
}
-
+
@Override
public Image getImage(Object element) {
+ if (fProviders == null ) {
+ fProviders = fView.getLabelProviders();
+ }
+ if ( fProviders != null ) {
+ for (IStyledLabelProvider provider : fProviders) {
+ Image img = provider.getImage(element);
+ if (img != null)
+ return img;
+ }
+ }
if (element instanceof CHNode) {
CHNode node= (CHNode) element;
Image image= null;
@@ -96,9 +111,19 @@ public class CHLabelProvider extends AppearanceAwareLabelProvider {
}
return super.getText(element);
}
-
+
@Override
public StyledString getStyledText(Object element) {
+ if (fProviders == null ) {
+ fProviders = fView.getLabelProviders();
+ }
+ if (fProviders != null) {
+ for (IStyledLabelProvider provider : fProviders) {
+ StyledString styledString = provider.getStyledText(element);
+ if (styledString != null)
+ return styledString;
+ }
+ }
if (element instanceof CHNode) {
CHNode node= (CHNode) element;
ICElement decl= node.getOneRepresentedDeclaration();
@@ -120,7 +145,7 @@ public class CHLabelProvider extends AppearanceAwareLabelProvider {
final int offset= label.length();
label.append(NLS.bind(" ({0} {1})", Integer.valueOf(refCount), CHMessages.CHLabelProvider_matches)); //$NON-NLS-1$
label.setStyle(offset, label.length() - offset, StyledString.COUNTER_STYLER);
-
+
}
String decorated= decorateText(label.getString(), element);
if (decorated != null) {
@@ -131,7 +156,7 @@ public class CHLabelProvider extends AppearanceAwareLabelProvider {
}
return fCLabelProvider.getStyledText(element);
}
-
+
private String addInitializerDecoration(String label) {
int i= 0;
char[] content= label.toCharArray();
@@ -169,7 +194,7 @@ public class CHLabelProvider extends AppearanceAwareLabelProvider {
label2.setStyle(0, i, null);
return label2;
}
-
+
@Override
public void dispose() {
fCLabelProvider.dispose();
@@ -181,7 +206,7 @@ public class CHLabelProvider extends AppearanceAwareLabelProvider {
}
private Image decorateImage(Image image, CHNode node) {
- int flags= 0;
+ int flags= 0;
if (node.isRecursive()) {
flags |= CElementImageDescriptor.RECURSIVE_RELATION;
} else if (fContentProvider.hasChildren(node)) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java
index 492821502a..f69f36f962 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2015 Wind River Systems, Inc. and others.
+ * Copyright (c) 2018 Wind River Systems, Inc. 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
@@ -8,7 +8,8 @@
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
- *******************************************************************************/
+ * Lidia Popescu (Wind River) [536255] Extension point for open call hierarchy view
+ *******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
import java.util.Iterator;
@@ -24,6 +25,7 @@ import org.eclipse.jface.bindings.BindingManagerEvent;
import org.eclipse.jface.bindings.IBindingManagerListener;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -72,6 +74,7 @@ import org.eclipse.cdt.core.model.IFunction;
import org.eclipse.cdt.core.model.IMethod;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.ICHEContentProvider;
import org.eclipse.cdt.ui.actions.CdtActionConstants;
import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
import org.eclipse.cdt.ui.refactoring.actions.CRefactoringActionGroup;
@@ -102,7 +105,7 @@ public class CHViewPart extends ViewPart {
private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
private static final String KEY_FILTER_VARIABLES = "variableFilter"; //$NON-NLS-1$
private static final String KEY_SHOW_FILES= "showFilesInLabels"; //$NON-NLS-1$
-
+
private IMemento fMemento;
private boolean fShowsMessage;
private CHNode fNavigationNode;
@@ -149,6 +152,8 @@ public class CHViewPart extends ViewPart {
private IBindingService bindingService;
private IBindingManagerListener bindingManagerListener;
+ private ICHEContentProvider[] fProviders;
+ private IStyledLabelProvider[] fLabelProviders;
@Override
public void setFocus() {
@@ -162,7 +167,7 @@ public class CHViewPart extends ViewPart {
updateDescription();
updateActionEnablement();
}
-
+
public void setInput(ICElement input) {
if (input == null) {
setMessage(CHMessages.CHViewPart_emptyPageMessage);
@@ -203,7 +208,7 @@ public class CHViewPart extends ViewPart {
if (element instanceof IFunction || element instanceof IMethod) {
return true;
}
-
+
return false;
}
@@ -212,7 +217,7 @@ public class CHViewPart extends ViewPart {
fPagebook = new PageBook(parent, SWT.NULL);
createInfoPage();
createViewerPage();
-
+
getSite().setSelectionProvider(new AdaptingSelectionProvider(ICElement.class, fTreeViewer));
initDragAndDrop();
@@ -236,9 +241,9 @@ public class CHViewPart extends ViewPart {
}
setMessage(CHMessages.CHViewPart_emptyPageMessage);
-
+
initializeActionStates();
-
+
IContextService ctxService = getSite().getService(IContextService.class);
if (ctxService != null) {
fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
@@ -247,7 +252,7 @@ public class CHViewPart extends ViewPart {
PlatformUI.getWorkbench().getHelpSystem().setHelp(fPagebook, ICHelpContextIds.CALL_HIERARCHY_VIEW);
addPartListener();
}
-
+
private void addPartListener() {
fPartListener= new IPartListener2() {
@Override
@@ -316,7 +321,7 @@ public class CHViewPart extends ViewPart {
}
super.dispose();
}
-
+
private void initializeActionStates() {
boolean referencedBy= true;
boolean filterVariables= false;
@@ -391,22 +396,30 @@ public class CHViewPart extends ViewPart {
fViewerPage.setSize(100, 100);
fViewerPage.setLayout(new FillLayout());
- fContentProvider= new CHContentProvider(this, display);
- fLabelProvider= new CHLabelProvider(display, fContentProvider);
+ fProviders = CHEProviderSettings.getCCallHierarchyContentProviders();
+ fLabelProviders = CHEProviderSettings.getCCallHierarchyLabelProviders();
+
+ fContentProvider= new CHContentProvider(this, display);
+ fLabelProvider = new CHLabelProvider(this, display, fContentProvider);
fTreeViewer= new ExtendedTreeViewer(fViewerPage);
fTreeViewer.setContentProvider(fContentProvider);
fTreeViewer.setLabelProvider(new DecoratingCLabelProvider(fLabelProvider));
- fTreeViewer.setAutoExpandLevel(2);
+ fTreeViewer.setAutoExpandLevel(2);
fTreeViewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
onShowSelectedReference(event.getSelection());
}
});
+ if (fProviders !=null) {
+ for (ICHEContentProvider provider : fProviders) {
+ fTreeViewer.addOpenListener(provider.getCCallHierarchyOpenListener());
+ }
+ }
}
-
- private void createInfoPage() {
- fInfoText = new Label(fPagebook, SWT.TOP | SWT.LEFT | SWT.WRAP);
+
+ private void createInfoPage() {
+ fInfoText = new Label(fPagebook, SWT.TOP | SWT.LEFT | SWT.WRAP);
}
private void initDragAndDrop() {
@@ -427,7 +440,7 @@ public class CHViewPart extends ViewPart {
fOpenViewActionGroup.setEnableIncludeBrowser(true);
fSelectionSearchGroup= new SelectionSearchGroup(getSite());
fRefactoringActionGroup= new CRefactoringActionGroup(this);
-
+
fWorkingSetFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
@Override
protected void onWorkingSetChange() {
@@ -439,8 +452,8 @@ public class CHViewPart extends ViewPart {
}
};
- fReferencedByAction=
- new Action(CHMessages.CHViewPart_ShowCallers_label, IAction.AS_RADIO_BUTTON) {
+ fReferencedByAction=
+ new Action(CHMessages.CHViewPart_ShowCallers_label, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
if (isChecked()) {
@@ -449,10 +462,10 @@ public class CHViewPart extends ViewPart {
}
};
fReferencedByAction.setToolTipText(CHMessages.CHViewPart_ShowCallers_tooltip);
- CPluginImages.setImageDescriptors(fReferencedByAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_REF_BY);
+ CPluginImages.setImageDescriptors(fReferencedByAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_REF_BY);
fMakesReferenceToAction=
- new Action(CHMessages.CHViewPart_ShowCallees_label, IAction.AS_RADIO_BUTTON) {
+ new Action(CHMessages.CHViewPart_ShowCallees_label, IAction.AS_RADIO_BUTTON) {
@Override
public void run() {
if (isChecked()) {
@@ -461,7 +474,7 @@ public class CHViewPart extends ViewPart {
}
};
fMakesReferenceToAction.setToolTipText(CHMessages.CHViewPart_ShowCallees_tooltip);
- CPluginImages.setImageDescriptors(fMakesReferenceToAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_RELATES_TO);
+ CPluginImages.setImageDescriptors(fMakesReferenceToAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_RELATES_TO);
fVariableFilter= new ViewerFilter() {
@Override
@@ -484,7 +497,7 @@ public class CHViewPart extends ViewPart {
}
};
fFilterVariablesAction.setToolTipText(CHMessages.CHViewPart_FilterVariables_tooltip);
- CPluginImages.setImageDescriptors(fFilterVariablesAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS);
+ CPluginImages.setImageDescriptors(fFilterVariablesAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS);
fSorterAlphaNumeric= new ViewerComparator();
fSorterReferencePosition= new ViewerComparator() {
@@ -544,8 +557,8 @@ public class CHViewPart extends ViewPart {
onNextOrPrevious(true);
}
};
- fNextAction.setToolTipText(CHMessages.CHViewPart_NextReference_tooltip);
- CPluginImages.setImageDescriptors(fNextAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);
+ fNextAction.setToolTipText(CHMessages.CHViewPart_NextReference_tooltip);
+ CPluginImages.setImageDescriptors(fNextAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);
fPreviousAction = new Action(CHMessages.CHViewPart_PreviousReference_label) {
@Override
@@ -554,7 +567,7 @@ public class CHViewPart extends ViewPart {
}
};
fPreviousAction.setToolTipText(CHMessages.CHViewPart_PreviousReference_tooltip);
- CPluginImages.setImageDescriptors(fPreviousAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);
+ CPluginImages.setImageDescriptors(fPreviousAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);
fRefreshAction = new Action(CHMessages.CHViewPart_Refresh_label) {
@Override
@@ -563,7 +576,7 @@ public class CHViewPart extends ViewPart {
}
};
fRefreshAction.setToolTipText(CHMessages.CHViewPart_Refresh_tooltip);
- CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);
+ CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);
fHistoryAction = new CHHistoryDropDownAction(this);
@@ -611,7 +624,7 @@ public class CHViewPart extends ViewPart {
mm.add(new Separator());
mm.add(fFilterVariablesAction);
}
-
+
private void setNextNode(boolean forward) {
TreeNavigator navigator= new TreeNavigator(fTreeViewer.getTree(), CHNode.class);
TreeItem selectedItem= navigator.getSelectedItemOrFirstOnLevel(1, forward);
@@ -643,7 +656,7 @@ public class CHViewPart extends ViewPart {
fNavigationDetail= 0;
}
}
-
+
protected void onShowSelectedReference(ISelection selection) {
CHNode node= selectionToNode(selection);
if (node != null && node == fNavigationNode && node.getReferenceCount() > 0) {
@@ -699,7 +712,7 @@ public class CHViewPart extends ViewPart {
fTreeViewer.setComparator(fSorterReferencePosition);
}
}
-
+
private void updateDescription() {
String message= ""; //$NON-NLS-1$
if (!fShowsMessage) {
@@ -738,7 +751,7 @@ public class CHViewPart extends ViewPart {
setContentDescription(message);
}
-
+
private void updateActionEnablement() {
fHistoryAction.setEnabled(CallHierarchyUI.getHistoryEntries().length > 0);
fNextAction.setEnabled(!fShowsMessage);
@@ -749,7 +762,7 @@ public class CHViewPart extends ViewPart {
private void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
fContentProvider.setWorkingSetFilter(filterUI);
}
-
+
public void onSetShowReferencedBy(boolean showReferencedBy) {
if (showReferencedBy != fContentProvider.getComputeReferencedBy()) {
Object input= fTreeViewer.getInput();
@@ -832,7 +845,7 @@ public class CHViewPart extends ViewPart {
}
}
}
-
+
private int getReferenceCount(CHNode node) {
if (node != null) {
CHNode parent = node.getParent();
@@ -896,4 +909,18 @@ public class CHViewPart extends ViewPart {
boolean isPinned() {
return fIsPinned;
}
+
+ /**
+ * @return an array of {@link ICHEContentProvider} for Extended Call Hierarchy
+ */
+ public ICHEContentProvider[] getContentProviders() {
+ return fProviders;
+ }
+
+ /**
+ * @return an array of {@link IStyledLabelProvider} for Extended Call Hierarchy
+ */
+ public IStyledLabelProvider[] getLabelProviders() {
+ return fLabelProviders;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java
new file mode 100644
index 0000000000..21a5a5d3e8
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHEContentProvider.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lidia Popescu - [536255] initial API and implementation. Extension point for open call hierarchy view
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+
+import org.eclipse.jface.viewers.IOpenListener;
+/**
+ * The Call Hierarchy Extension Content Provider Interface
+ * @since 6.4
+ * */
+public interface ICHEContentProvider {
+
+ Object[] asyncComputeExtendedRoot(Object parentElement);
+
+ IOpenListener getCCallHierarchyOpenListener();
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java
new file mode 100644
index 0000000000..08e952d5fd
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHENode.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Wind River Systems, Inc. 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lidia Popescu - [536255] initial API and implementation. Extension point for open call hierarchy view
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+
+import org.eclipse.cdt.core.model.ICElement;
+
+/**
+ * The Call Hierarchy Extension Node
+ * @since 6.4
+ */
+public interface ICHENode {
+
+ ICElement getRepresentedDeclaration();
+}