1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Bug 427958 - Extension mechanisms for Find References and Call Hierarchy

This change introduces two new extension points - callHierarchyProviders
and externalSearchProviders.

Change-Id: I5e2e5e6c17b596eddfebe97b6be32a7cc62954f6
Reviewed-on: https://git.eclipse.org/r/21862
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
Sergey Prigogin 2014-01-02 17:30:54 -08:00
parent 60068393a1
commit 62ba90a145
20 changed files with 545 additions and 13 deletions

View file

@ -76,6 +76,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
org.eclipse.cdt.ui.actions,
org.eclipse.cdt.ui.browser.typeinfo,
org.eclipse.cdt.ui.dialogs,
org.eclipse.cdt.ui.extensions,
org.eclipse.cdt.ui.internal.templateengine.wizard;x-internal:=true,
org.eclipse.cdt.ui.language.settings.providers,
org.eclipse.cdt.ui.newui,

View file

@ -658,6 +658,8 @@ transfer.CodeStyle.description = C/C++ > Code Style preferences
# Refresh Exclusion Contributors
RefreshExclusionContributor.name = Resources
callHierarchyProviders.name = Call Hierarchy Providers
externalSearchProviders.name = External Search Providers
RefreshExclusionContributorExtensionPoint = Refresh Exclusion Contributor
# New New Project Wizard

View file

@ -18,6 +18,8 @@
<extension-point id="textHovers" name="%textHoversName" schema="schema/textHovers.exsd"/>
<extension-point id="IndexerPage" name="%indexerPage.name" schema="schema/IndexerPage.exsd"/>
<extension-point id="ProposalFilter" name="%proposalFilter.name" schema="schema/ProposalFilter.exsd"/>
<extension-point id="callHierarchyProviders" name="%callHierarchyProviders.name" schema="schema/callHierarchyProviders.exsd"/>
<extension-point id="externalSearchProviders" name="%externalSearchProviders.name" schema="schema/externalSearchProviders.exsd"/>
<extension-point id="completionProposalComputer" name="%completionProposalComputer" schema="schema/completionProposalComputer.exsd"/>
<extension-point id="newCfgDialog" name="%NewCfgDialog.name" schema="schema/newCfgDialog.exsd"/>
<extension-point id="ConfigManager" name="%ConfigManager" schema="schema/ConfigManager.exsd"/>

View file

@ -0,0 +1,73 @@
<?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="callHierarchyProviders" name="Call Hierarchy Providers"/>
</appInfo>
<documentation>
This extension point allows implementers to add external calling points to the call
hierarchy. The additional calling points should belong to the files not indexed by the CDT
indexer.
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="provider"/>
</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>
</annotation>
</attribute>
</complexType>
</element>
<element name="provider">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.extensions.ICallHierarchyProvider"/>
</appInfo>
</annotation>
</attribute>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="identifier"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
</schema>

View file

@ -0,0 +1,73 @@
<?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="externalSearchProviders" name="External Search Providers"/>
</appInfo>
<documentation>
This extension point allows implementers to add external occurrences to the C/C++ search
results. The external occurrences should belong to the files not indexed by the CDT
indexer.
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="provider"/>
</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>
</annotation>
</attribute>
</complexType>
</element>
<element name="provider">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.extensions.IExternalSearchProvider"/>
</appInfo>
</annotation>
</attribute>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="identifier"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
</schema>

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2012 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2014 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
@ -115,6 +115,11 @@ public class CHContentProvider extends AsyncTreeContentProvider {
index.acquireReadLock();
try {
ICElement element= input;
if (CHQueries.isExternal(element)) {
ITranslationUnit tu= CModelUtil.getTranslationUnit(element);
return new Object[] { new CHNode(null, tu, 0, element, -1) };
}
if (!IndexUI.isIndexed(index, input)) {
getDisplay().asyncExec(new Runnable() {
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2011 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2014 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
@ -57,6 +57,7 @@ public class CHMessages extends NLS {
public static String OpenElementInCallHierarchyAction_upperListLabel;
public static String CHPinAction_label;
public static String CHPinAction_tooltip;
public static String CHProviderManager_InvalidCallHierarchyProvider;
static {
// initialize resource bundle

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2006, 2011 Wind River Systems, Inc. and others.
# Copyright (c) 2006, 2014 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
@ -52,3 +52,4 @@ OpenElementInCallHierarchyAction_message=&Choose an element (? = any character,
OpenElementInCallHierarchyAction_errorNoDefinition=Could not locate definition of element ''{0}''
CHPinAction_label=Pi&n Call Hierarchy View
CHPinAction_tooltip=Pin the Call Hierarchy View
CHProviderManager_InvalidCallHierarchyProvider=Ignoring unrecognized implementation of ICallHierarchyProvider contributed by {0}

View file

@ -0,0 +1,66 @@
/*******************************************************************************
* Copyright (c) 2014 Google, 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:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
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.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.util.NLS;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.extensions.ICallHierarchyProvider;
/**
* Maintains a list of extensions implementing the org.eclipse.cdt.ui.callHierarchyProviders
* extension point.
*/
public class CHProviderManager {
private final String CALL_HIERARCHY_PROVIDERS = CUIPlugin.PLUGIN_ID + ".callHierarchyProviders"; //$NON-NLS-1$
private final Object ELEMENT_PROVIDER = "provider"; //$NON-NLS-1$
private final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
private List<ICallHierarchyProvider> callHierarchyProviders;
public static CHProviderManager INSTANCE = new CHProviderManager();
private CHProviderManager() {}
public List<ICallHierarchyProvider> getCallHierarchyProviders() {
if (callHierarchyProviders == null) {
callHierarchyProviders = new ArrayList<ICallHierarchyProvider>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint indexProviderPoint = registry.getExtensionPoint(CALL_HIERARCHY_PROVIDERS);
for (IExtension extension : indexProviderPoint.getExtensions()) {
try {
for (IConfigurationElement element : extension.getConfigurationElements()) {
if (ELEMENT_PROVIDER.equals(element.getName())) {
Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS);
if (provider instanceof ICallHierarchyProvider) {
callHierarchyProviders.add((ICallHierarchyProvider) provider);
} else {
CUIPlugin.logError(NLS.bind(CHMessages.CHProviderManager_InvalidCallHierarchyProvider,
extension.getContributor().getName()));
}
}
}
} catch (CoreException e) {
CUIPlugin.log(e);
}
}
}
return callHierarchyProviders;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2014 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
@ -7,6 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.callhierarchy;
@ -29,6 +30,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.extensions.ICallHierarchyProvider;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
@ -72,9 +74,23 @@ public class CHQueries {
if (!done) {
findCalledBy(callee, linkageID, index, result);
}
for (ICallHierarchyProvider provider : CHProviderManager.INSTANCE.getCallHierarchyProviders()) {
provider.findCalledBy(callee, linkageID, index, result);
}
return cp.createNodes(node, result);
}
/**
* @return {@code true} if the element is owned by an external call hierarchy provider.
*/
public static boolean isExternal(ICElement element) {
for (ICallHierarchyProvider provider : CHProviderManager.INSTANCE.getCallHierarchyProviders()) {
if (provider.ownsElement(element))
return true;
}
return false;
}
private static void findCalledBy(ICElement callee, int linkageID, IIndex index, CalledByResult result)
throws CoreException {
final ICProject project = callee.getCProject();
@ -148,6 +164,9 @@ public class CHQueries {
}
}
}
for (ICallHierarchyProvider provider : CHProviderManager.INSTANCE.getCallHierarchyProviders()) {
provider.findCalls(caller, index, result);
}
return cp.createNodes(node, result);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2014 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
@ -18,8 +18,9 @@ import java.util.Set;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.ui.extensions.ICalledByResult;
public class CalledByResult {
public class CalledByResult implements ICalledByResult {
private Map<ICElement, List<IIndexName>> fElementToReferences= new HashMap<>();
public ICElement[] getElements() {
@ -32,6 +33,7 @@ public class CalledByResult {
return references.toArray(new IIndexName[references.size()]);
}
@Override
public void add(ICElement elem, IIndexName ref) {
List<IIndexName> list= fElementToReferences.get(elem);
if (list == null) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2014 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
@ -18,8 +18,9 @@ import java.util.Set;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.ui.extensions.ICallToResult;
public class CallsToResult {
public class CallsToResult implements ICallToResult {
private Map<CElementSet, List<IIndexName>> fElementSetsToReferences= new HashMap<>();
public CElementSet[] getElementSets() {
@ -32,6 +33,7 @@ public class CallsToResult {
return references.toArray(new IIndexName[references.size()]);
}
@Override
public void add(ICElement[] elems, IIndexName ref) {
CElementSet key= new CElementSet(elems);
List<IIndexName> list= fElementSetsToReferences.get(key);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2011 IBM Corporation and others.
* Copyright (c) 2003, 2014 IBM Corporation 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
@ -93,6 +93,7 @@ public final class CSearchMessages extends NLS {
public static String PDOMSearchTreeContentProvider_IndexerNotEnabledWarning;
public static String PDOMSearchTreeContentProvider_ProjectClosedWarning;
public static String PDOMSearchUnresolvedIncludesQuery_title;
public static String CSearchProviderManager_InvalidSearchProvider;
static {
NLS.initializeMessages(CSearchMessages.class.getName(), CSearchMessages.class);
@ -101,4 +102,4 @@ public final class CSearchMessages extends NLS {
private CSearchMessages() {
// Do not instantiate
}
}
}

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2000, 2011 IBM Corporation and others.
# Copyright (c) 2000, 2014 IBM Corporation 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
@ -109,4 +109,6 @@ OccurrencesFinder_label_singular=''{0}'' - 1 occurrence in ''{1}''
# The first argument will be replaced by the element name, the second by the count and the last by the file name
OccurrencesFinder_label_plural=''{0}'' - {1} occurrences in ''{2}''
OccurrencesFinder_occurrence_description=Occurrence of ''{0}''
OccurrencesFinder_occurrence_write_description=Write occurrence of ''{0}''
OccurrencesFinder_occurrence_write_description=Write occurrence of ''{0}''
CSearchProviderManager_InvalidSearchProvider=Ignoring unrecognized implementation of IExternalSearchProvider contributed by {0}

View file

@ -0,0 +1,66 @@
/*******************************************************************************
* Copyright (c) 2014 Google, 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:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.search;
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.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.util.NLS;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.extensions.IExternalSearchProvider;
/**
* Maintains a list of extensions implementing the org.eclipse.cdt.ui.externalSearchProviders
* extension point.
*/
public class CSearchProviderManager {
private final String SEARCH_PROVIDERS = CUIPlugin.PLUGIN_ID + ".externalSearchProviders"; //$NON-NLS-1$
private final Object ELEMENT_PROVIDER = "provider"; //$NON-NLS-1$
private final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
private List<IExternalSearchProvider> externalSearchProviders;
public static CSearchProviderManager INSTANCE = new CSearchProviderManager();
private CSearchProviderManager() {}
public List<IExternalSearchProvider> getExternalSearchProviders() {
if (externalSearchProviders == null) {
externalSearchProviders = new ArrayList<IExternalSearchProvider>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint indexProviderPoint = registry.getExtensionPoint(SEARCH_PROVIDERS);
for (IExtension extension : indexProviderPoint.getExtensions()) {
try {
for (IConfigurationElement element : extension.getConfigurationElements()) {
if (ELEMENT_PROVIDER.equals(element.getName())) {
Object provider = element.createExecutableExtension(ATTRIBUTE_CLASS);
if (provider instanceof IExternalSearchProvider) {
externalSearchProviders.add((IExternalSearchProvider) provider);
} else {
CUIPlugin.logError(NLS.bind(CSearchMessages.CSearchProviderManager_InvalidSearchProvider,
extension.getContributor().getName()));
}
}
}
} catch (CoreException e) {
CUIPlugin.log(e);
}
}
}
return externalSearchProviders;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2012 QNX Software Systems and others.
* Copyright (c) 2006, 2014 QNX Software Systems 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
@ -64,6 +64,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.extensions.IExternalSearchProvider;
import org.eclipse.cdt.internal.core.browser.ASTTypeInfo;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
@ -245,7 +246,15 @@ public abstract class CSearchQuery implements ISearchQuery {
IIndexName enclosingDefinition = name.getEnclosingDefinition();
if (enclosingDefinition != null) {
enclosingElement = IndexUI.getCElementForName(preferred, index, enclosingDefinition);
} else {
// Get names from the external search providers.
for (IExternalSearchProvider provider : CSearchProviderManager.INSTANCE.getExternalSearchProviders()) {
enclosingElement = provider.getEnclosingElement(name);
if (enclosingElement != null)
break;
}
}
boolean isWriteAccess = name.isWriteAccess();
matches.add(new Match(nodeOffset, nodeLength, isPolymorphicOnly, enclosingElement,
isWriteAccess));
@ -373,6 +382,14 @@ public abstract class CSearchQuery implements ISearchQuery {
}
}
}
// Get names from the external search providers.
for (IExternalSearchProvider provider : CSearchProviderManager.INSTANCE.getExternalSearchProviders()) {
for (IBinding binding : bindings) {
provider.findNames(binding, flags, projects, index, names);
}
}
if (!names.isEmpty()) {
collectNames(index, names, polymorphicNames);
}

View file

@ -0,0 +1,63 @@
/*******************************************************************************
* Copyright (c) 2014 Google, 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:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.extensions;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.ICElement;
/**
* Interface for classes implementing the org.eclipse.cdt.ui.callHierarchyProviders extension
* point.
*
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the CDT team.
*
* @since 5.7
*/
public interface ICallHierarchyProvider {
/**
* Adds the calling functions and the corresponding call points located in files not covered
* by the CDT index to the call hierarchy results.
*
* @param callee the function being called
* @param linkageID the ID of the linkage to search for calling functions or -1 to search
* all linkages.
* @param index the index, for which the caller is holding a read lock
* @param result the accumulator to add the results to
* @throws CoreException may be thrown in case of an error
*/
void findCalledBy(ICElement callee, int linkageID, IIndex index, ICalledByResult result)
throws CoreException;
/**
* Adds the called functions and the corresponding call points for a function defined in a file
* not covered by the CDT index to the call hierarchy results.
*
* @param caller the function to get the called functions for
* @param index the index, for which the caller is holding a read lock
* @param result the accumulator to add the results to
* @throws CoreException may be thrown in case of an error
*/
void findCalls(ICElement caller, IIndex index, ICallToResult result) throws CoreException;
/**
* Checks if an element representing a function is owned by the call hierarchy provider.
*
* @param element the element to check
* @return {@code true} if the element is owned by this provider.
*/
boolean ownsElement(ICElement element);
}

View file

@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2014 Google, 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:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.extensions;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.core.model.ICElement;
/**
* @see ICallHierarchyProvider#findCalls
*
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the CDT team.
*
* @since 5.7
*/
public interface ICallToResult {
/**
* Adds a call point to the list of call hierarchy results.
*
* @param elems the called methods
* @param ref the call site
*/
public void add(ICElement[] elems, IIndexName ref);
}

View file

@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2014 Google, 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:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.extensions;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.core.model.ICElement;
/**
* @see ICallHierarchyProvider#findCalledBy
*
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the CDT team.
*
* @since 5.7
*/
public interface ICalledByResult {
/**
* Adds a call point to the list of call hierarchy results.
*
* @param elem the caller method
* @param ref the call site
*/
public void add(ICElement elem, IIndexName ref);
}

View file

@ -0,0 +1,66 @@
/*******************************************************************************
* Copyright (c) 2014 Google, 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:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.extensions;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexName;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
/**
* Interface for classes implementing the org.eclipse.cdt.ui.externalSearchProviders extension
* point.
*
* <p>
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as
* part of a work in progress. There is no guarantee that this API will work or
* that it will remain the same. Please do not use this API without consulting
* with the CDT team.
*
* @since 5.7
*/
public interface IExternalSearchProvider {
/**
* Searches for all names that resolve to the given binding. The result can be limited to
* references, declarations or definitions, or a combination of those.
* <p>
* When the method is called, the {@code foundNames} list contains the names found in the core
* index. The method may add more names to the {@code foundNames} list, but should not remove
* the names already present there.
*
* @param binding A binding for which names are searched for
* @param flags A combination of {@link IIndex#FIND_DECLARATIONS},
* {@link IIndex#FIND_DEFINITIONS}, {@link IIndex#FIND_REFERENCES} and
* {@link IIndex#SEARCH_ACROSS_LANGUAGE_BOUNDARIES}.
* @param projects The projects in context of which to do search.
* @param foundNames Before the call contains the names found in the core index. After the call
* may contain additional names located in files covered by the index extension.
* @throws CoreException may be thrown in case of an error
*
* @see {@link IIndex#findNames(IBinding, int)}
*/
void findNames(IBinding binding, int flags, ICProject[] projects, IIndex index,
List<IIndexName> foundNames) throws CoreException;
/**
* Finds the function or the class enclosing the given name.
*
* @param name The name to find the enclosing element for.
* @return The function or the class enclosing the given name, or {@code null} if there is
* no enclosing element or the name is not associated with this search provider.
*/
ICElement getEnclosingElement(IIndexName name);
}