1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 06:45:43 +02:00

Improves the navigation fallback, bug 102643.

This commit is contained in:
Markus Schorn 2008-03-17 16:37:07 +00:00
parent 83c44162bf
commit d82d0c2245
3 changed files with 25 additions and 7 deletions

View file

@ -279,7 +279,7 @@ public interface IIndex {
* *
* This is fully equivalent to * This is fully equivalent to
* <pre> * <pre>
* findBindings(new char[][]{name}, filter, monitor); * findBindings(name, true, filter, monitor);
* </pre> * </pre>
* @param name a name, which has to be matched by the qualified name of the bindings. * @param name a name, which has to be matched by the qualified name of the bindings.
* @param filter a filter that allows for skipping parts of the index * @param filter a filter that allows for skipping parts of the index
@ -289,6 +289,20 @@ public interface IIndex {
*/ */
public IIndexBinding[] findBindings(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException; public IIndexBinding[] findBindings(char[] name, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
/**
* Searches the global scope and optionally all other scopes for bindings with a given name.
* In case a binding exists in multiple projects, no duplicate bindings are returned.
* This method makes use of the BTree and is faster than the methods using patterns.
*
* @param name a name, which has to be matched by the qualified name of the bindings.
* @param fileScopeOnly if true, only bindings at file scope are returned
* @param filter a filter that allows for skipping parts of the index
* @param monitor a monitor to report progress, may be <code>null</code>.
* @return an array of bindings matching the pattern
* @throws CoreException
*/
public IIndexBinding[] findBindings(char[] name, boolean fileScopeOnly, IndexFilter filter, IProgressMonitor monitor) throws CoreException;
/** /**
* Searches for all bindings with names that start with the given prefix. * Searches for all bindings with names that start with the given prefix.
* @param prefix the prefix with which all returned bindings must start * @param prefix the prefix with which all returned bindings must start

View file

@ -134,4 +134,8 @@ final public class EmptyCIndex implements IIndex {
public IIndexFile[] getAllFiles() { public IIndexFile[] getAllFiles() {
return IIndexFile.EMPTY_FILE_ARRAY; return IIndexFile.EMPTY_FILE_ARRAY;
} }
public IIndexBinding[] findBindings(char[] name, boolean fileScopeOnly, IndexFilter filter, IProgressMonitor monitor) {
return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
}
} }

View file

@ -232,7 +232,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
elems.add(elem); elems.add(elem);
} }
} }
IIndexBinding[] bindings = fIndex.findBindings(name, filter, fMonitor); IIndexBinding[] bindings = fIndex.findBindings(name, false, filter, fMonitor);
for (IBinding binding : bindings) { for (IBinding binding : bindings) {
final IName[] names = findNames(fIndex, ast, KIND_OTHER, binding); final IName[] names = findNames(fIndex, ast, KIND_OTHER, binding);
convertToCElements(project, fIndex, names, elems); convertToCElements(project, fIndex, names, elems);
@ -257,7 +257,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
try { try {
open(path, 0, 0); open(path, 0, 0);
} catch (CoreException e) { } catch (CoreException e) {
CUIPlugin.getDefault().log(e); CUIPlugin.log(e);
} }
} }
}); });
@ -280,7 +280,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
try { try {
open(path, offset, length); open(path, offset, length);
} catch (CoreException e) { } catch (CoreException e) {
CUIPlugin.getDefault().log(e); CUIPlugin.log(e);
} }
} }
}); });
@ -305,7 +305,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
elements.add(elem); elements.add(elem);
} }
} catch (CoreException e) { } catch (CoreException e) {
CUIPlugin.getDefault().log(e); CUIPlugin.log(e);
} }
} }
} }
@ -328,7 +328,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
ICElement[] elemArray= elements.toArray(new ICElement[elements.size()]); ICElement[] elemArray= elements.toArray(new ICElement[elements.size()]);
target = (ISourceReference) OpenActionUtil.selectCElement(elemArray, getSite().getShell(), target = (ISourceReference) OpenActionUtil.selectCElement(elemArray, getSite().getShell(),
CEditorMessages.getString("OpenDeclarationsAction.dialog.title"), CEditorMessages.getString("OpenDeclarationsAction.selectMessage"), //$NON-NLS-1$ //$NON-NLS-2$ CEditorMessages.getString("OpenDeclarationsAction.dialog.title"), CEditorMessages.getString("OpenDeclarationsAction.selectMessage"), //$NON-NLS-1$ //$NON-NLS-2$
CElementBaseLabels.ALL_DEFAULT | CElementBaseLabels.MF_POST_FILE_QUALIFIED, 0); CElementBaseLabels.ALL_DEFAULT | CElementBaseLabels.ALL_FULLY_QUALIFIED | CElementBaseLabels.MF_POST_FILE_QUALIFIED, 0);
} }
if (target != null) { if (target != null) {
ITranslationUnit tu= target.getTranslationUnit(); ITranslationUnit tu= target.getTranslationUnit();
@ -339,7 +339,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
open(tu.getLocation(), sourceRange.getIdStartPos(), sourceRange.getIdLength()); open(tu.getLocation(), sourceRange.getIdStartPos(), sourceRange.getIdLength());
} }
} catch (CoreException e) { } catch (CoreException e) {
CUIPlugin.getDefault().log(e); CUIPlugin.log(e);
} }
} }
} }