Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-03-06 08:23:15 +0000
committerMarkus Schorn2008-03-06 08:23:15 +0000
commit16d620eaa5b3a4f4bfd5954e3391190a9760a516 (patch)
tree093fd3b30c53ba159f7303772ce37b9c77804279 /core/org.eclipse.cdt.core/parser
parent116aa49ea714f3d4be645f72b064c4e343577165 (diff)
downloadorg.eclipse.cdt-16d620eaa5b3a4f4bfd5954e3391190a9760a516.tar.gz
org.eclipse.cdt-16d620eaa5b3a4f4bfd5954e3391190a9760a516.tar.xz
org.eclipse.cdt-16d620eaa5b3a4f4bfd5954e3391190a9760a516.zip
Navigation from macro definition body, bug 102643.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java31
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java8
4 files changed, 69 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java
index f9784997b44..121c2b8b8b6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java
@@ -146,7 +146,7 @@ public class CIndex implements IIndex {
}
}
// bug 192352, files can reside in multiple fragments, remove duplicates
- if (fragCount > 1) {
+ if (fragCount > 1 || (flags & IIndex.SEARCH_ACCROSS_LANGUAGE_BOUNDARIES) != 0) {
HashMap<String, IIndexFile> fileMap= new HashMap<String, IIndexFile>();
for (Iterator<IIndexFragmentName> iterator = result.iterator(); iterator.hasNext();) {
final IIndexFragmentName name = iterator.next();
@@ -395,7 +395,7 @@ public class CIndex implements IIndex {
}
public IIndexBinding[] findBindings(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
- return findBindings(new char[][]{name}, filter, monitor);
+ return findBindings(name, true, filter, monitor);
}
/*
@@ -499,6 +499,33 @@ public class CIndex implements IIndex {
}
}
+ public IIndexBinding[] findBindings(char[] name, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
+ if(SPECIALCASE_SINGLES && fFragments.length==1) {
+ return fFragments[0].findBindings(name, filescope, filter, monitor);
+ } else {
+ List<IIndexBinding[]> result = new ArrayList<IIndexBinding[]>();
+ ILinkage[] linkages = Linkage.getAllLinkages();
+ for(int j=0; j < linkages.length; j++) {
+ if(filter.acceptLinkage(linkages[j])) {
+ IIndexFragmentBinding[][] fragmentBindings = new IIndexFragmentBinding[fPrimaryFragmentCount][];
+ for (int i = 0; i < fPrimaryFragmentCount; i++) {
+ try {
+ IBinding[] part = fFragments[i].findBindings(name, filescope, retargetFilter(linkages[j], filter), monitor);
+ fragmentBindings[i] = new IIndexFragmentBinding[part.length];
+ System.arraycopy(part, 0, fragmentBindings[i], 0, part.length);
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ fragmentBindings[i] = IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
+ }
+ }
+ ICompositesFactory factory = getCompositesFactory(linkages[j].getLinkageID());
+ result.add(factory.getCompositeBindings(fragmentBindings));
+ }
+ }
+ return flatten(result);
+ }
+ }
+
public IIndexMacro[] findMacros(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
return findMacros(name, false, true, filter, monitor);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java
index e09760934ea..8cf38880770 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IIndexFragment.java
@@ -10,7 +10,6 @@
* Bryan Wilkinson (QNX)
* Andrew Ferguson (Symbian)
*******************************************************************************/
-
package org.eclipse.cdt.internal.core.index;
import java.util.regex.Pattern;
@@ -179,6 +178,12 @@ public interface IIndexFragment {
long getLastWriteAccess();
/**
+ * Returns all bindings with the given name, accepted by the given filter
+ * @param monitor to report progress, may be <code>null</code>
+ */
+ IIndexFragmentBinding[] findBindings(char[] name, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
+
+ /**
* Returns all bindings with the given prefix, accepted by the given filter
* @param monitor to report progress, may be <code>null</code>
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
index e35b0797f71..bd8c67663c0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
@@ -794,6 +794,32 @@ public class PDOM extends PlatformObject implements IPDOM {
return result.toArray(new IIndexFragmentBinding[result.size()]);
}
+ public IIndexFragmentBinding[] findBindings(char[] name, boolean filescope, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
+ ArrayList<IIndexFragmentBinding> result= new ArrayList<IIndexFragmentBinding>();
+ for (Iterator<PDOMLinkage> iter= fLinkageIDCache.values().iterator(); iter.hasNext();) {
+ PDOMLinkage linkage= iter.next();
+ if (filter.acceptLinkage(linkage)) {
+ PDOMBinding[] bindings;
+ BindingCollector visitor = new BindingCollector(linkage, name, filter, false, true);
+ visitor.setMonitor(monitor);
+ try {
+ linkage.accept(visitor);
+ if (!filescope) {
+ linkage.getNestedBindingsIndex().accept(visitor);
+ }
+ }
+ catch (OperationCanceledException e) {
+ }
+ bindings= visitor.getBindings();
+
+ for (int j = 0; j < bindings.length; j++) {
+ result.add(bindings[j]);
+ }
+ }
+ }
+ return result.toArray(new IIndexFragmentBinding[result.size()]);
+ }
+
public IIndexMacro[] findMacros(char[] prefix, boolean isPrefix, boolean isCaseSensitive, IndexFilter filter, IProgressMonitor monitor) throws CoreException {
ArrayList<IIndexMacro> result= new ArrayList<IIndexMacro>();
MacroCollector visitor = new MacroCollector(this, prefix, isPrefix, isCaseSensitive);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java
index 3c33b386b54..387c9274d2c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMProxy.java
@@ -85,6 +85,14 @@ public class PDOMProxy implements IPDOM {
return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
}
+ public synchronized IIndexFragmentBinding[] findBindings(char[] name, boolean filescope,
+ IndexFilter filter, IProgressMonitor monitor) throws CoreException {
+ if (fDelegate != null)
+ return fDelegate.findBindings(name, filescope, filter, monitor);
+
+ return IIndexFragmentBinding.EMPTY_INDEX_BINDING_ARRAY;
+ }
+
public synchronized IIndexFragmentBinding[] findBindingsForPrefix(char[] prefix, boolean filescope,
IndexFilter filter, IProgressMonitor monitor) throws CoreException {
if (fDelegate != null)

Back to the top