1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 102913 - Check for null workingCopy during completions which happens when you open an external file.

This commit is contained in:
Doug Schaefer 2005-07-13 20:06:55 +00:00
parent da12ba63cf
commit 66af49f629
2 changed files with 13 additions and 7 deletions

View file

@ -71,7 +71,8 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
boolean fileScope = store.getBoolean(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE);
boolean projectScope = store.getBoolean(ContentAssistPreference.PROJECT_SEARCH_SCOPE);
if (fileScope) { // do a full parse
if (fileScope && workingCopy != null) { // do a full parse
IFile file = (IFile)workingCopy.getResource();
if (file != null)
completionNode = CDOM.getInstance().getCompletionNode(
@ -90,11 +91,12 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
if (completionNode != null)
prefix = completionNode.getPrefix();
} else if (projectScope) { // find the prefix from the document
prefix = scanPrefix(viewer.getDocument(), offset);
}
if (prefix == null)
prefix = scanPrefix(viewer.getDocument(), offset);
errorMessage = CUIMessages.getString(noCompletions);
List proposals = new ArrayList();

View file

@ -42,14 +42,18 @@ public class SearchCompletionContributor implements ICompletionContributor {
if (prefix == null || prefix.length() == 0)
return;
// Create search engine
SearchEngine searchEngine = new SearchEngine();
searchEngine.setWaitingPolicy( ICSearchConstants.FORCE_IMMEDIATE_SEARCH );
// Create search scope
ICElement[] projects = new ICElement[] { workingCopy.getCProject() };
ICSearchScope scope = SearchEngine.createCSearchScope(projects, true);
ICSearchScope scope;
if (workingCopy != null) {
ICElement[] projects = new ICElement[] { workingCopy.getCProject() };
scope = SearchEngine.createCSearchScope(projects, true);
} else
scope = SearchEngine.createWorkspaceScope();
// Create the pattern
ICSearchPattern pattern = SearchEngine.createSearchPattern(prefix + "*", ICSearchConstants.UNKNOWN_SEARCH_FOR, ICSearchConstants.ALL_OCCURRENCES, true); //$NON-NLS-1$