diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF index a95dfd88698..598ae262cd8 100644 --- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF @@ -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, diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index b3849de1944..be1b67e5126 100755 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -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 diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 71fd0811149..0e9f068ec5c 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -18,6 +18,8 @@ + + diff --git a/core/org.eclipse.cdt.ui/schema/callHierarchyProviders.exsd b/core/org.eclipse.cdt.ui/schema/callHierarchyProviders.exsd new file mode 100644 index 00000000000..33b4a6db91c --- /dev/null +++ b/core/org.eclipse.cdt.ui/schema/callHierarchyProviders.exsd @@ -0,0 +1,73 @@ + + + + + + + + + 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. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/org.eclipse.cdt.ui/schema/externalSearchProviders.exsd b/core/org.eclipse.cdt.ui/schema/externalSearchProviders.exsd new file mode 100644 index 00000000000..b4a28517ad5 --- /dev/null +++ b/core/org.eclipse.cdt.ui/schema/externalSearchProviders.exsd @@ -0,0 +1,73 @@ + + + + + + + + + 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. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 ec5b4319a8a..e94fe13becd 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, 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 diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java index adca3752d8b..b3ddf2c313e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java @@ -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 diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties index 0d8f98b6daa..b5d0593693c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties @@ -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} \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHProviderManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHProviderManager.java new file mode 100644 index 00000000000..63768897524 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHProviderManager.java @@ -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 callHierarchyProviders; + + public static CHProviderManager INSTANCE = new CHProviderManager(); + + private CHProviderManager() {} + + public List getCallHierarchyProviders() { + if (callHierarchyProviders == null) { + callHierarchyProviders = new ArrayList(); + 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; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java index 36b686ca13a..ef3b20b7278 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java @@ -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); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java index a19868c924d..8e9e14023f3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java @@ -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> 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 list= fElementToReferences.get(elem); if (list == null) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java index 558e259c0bd..a0d46907151 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java @@ -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> 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 list= fElementSetsToReferences.get(key); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java index a8c217ccc1d..d52c3fed8d8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java @@ -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 } -} \ No newline at end of file +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties index cf1c0a9923f..800cf1b0104 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties @@ -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}'' \ No newline at end of file +OccurrencesFinder_occurrence_write_description=Write occurrence of ''{0}'' + +CSearchProviderManager_InvalidSearchProvider=Ignoring unrecognized implementation of IExternalSearchProvider contributed by {0} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchProviderManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchProviderManager.java new file mode 100644 index 00000000000..9563ce95eed --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchProviderManager.java @@ -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 externalSearchProviders; + + public static CSearchProviderManager INSTANCE = new CSearchProviderManager(); + + private CSearchProviderManager() {} + + public List getExternalSearchProviders() { + if (externalSearchProviders == null) { + externalSearchProviders = new ArrayList(); + 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; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java index 62296c39645..45ff1824971 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java @@ -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); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICallHierarchyProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICallHierarchyProvider.java new file mode 100644 index 00000000000..abfb654bf94 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICallHierarchyProvider.java @@ -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. + * + *

+ * EXPERIMENTAL. 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); +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICallToResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICallToResult.java new file mode 100644 index 00000000000..9748b2589d0 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICallToResult.java @@ -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 + * + *

+ * EXPERIMENTAL. 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); +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICalledByResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICalledByResult.java new file mode 100644 index 00000000000..dd7b0d58462 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/ICalledByResult.java @@ -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 + * + *

+ * EXPERIMENTAL. 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); +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/IExternalSearchProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/IExternalSearchProvider.java new file mode 100644 index 00000000000..dd7d7d87542 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/extensions/IExternalSearchProvider.java @@ -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. + * + *

+ * EXPERIMENTAL. 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. + *

+ * 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 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); +}