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:
parent
da12ba63cf
commit
66af49f629
2 changed files with 13 additions and 7 deletions
|
@ -71,7 +71,8 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
||||||
boolean fileScope = store.getBoolean(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE);
|
boolean fileScope = store.getBoolean(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE);
|
||||||
boolean projectScope = store.getBoolean(ContentAssistPreference.PROJECT_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();
|
IFile file = (IFile)workingCopy.getResource();
|
||||||
if (file != null)
|
if (file != null)
|
||||||
completionNode = CDOM.getInstance().getCompletionNode(
|
completionNode = CDOM.getInstance().getCompletionNode(
|
||||||
|
@ -91,10 +92,11 @@ public class CCompletionProcessor2 implements IContentAssistProcessor {
|
||||||
if (completionNode != null)
|
if (completionNode != null)
|
||||||
prefix = completionNode.getPrefix();
|
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);
|
errorMessage = CUIMessages.getString(noCompletions);
|
||||||
|
|
||||||
List proposals = new ArrayList();
|
List proposals = new ArrayList();
|
||||||
|
|
|
@ -48,8 +48,12 @@ public class SearchCompletionContributor implements ICompletionContributor {
|
||||||
searchEngine.setWaitingPolicy( ICSearchConstants.FORCE_IMMEDIATE_SEARCH );
|
searchEngine.setWaitingPolicy( ICSearchConstants.FORCE_IMMEDIATE_SEARCH );
|
||||||
|
|
||||||
// Create search scope
|
// Create search scope
|
||||||
|
ICSearchScope scope;
|
||||||
|
if (workingCopy != null) {
|
||||||
ICElement[] projects = new ICElement[] { workingCopy.getCProject() };
|
ICElement[] projects = new ICElement[] { workingCopy.getCProject() };
|
||||||
ICSearchScope scope = SearchEngine.createCSearchScope(projects, true);
|
scope = SearchEngine.createCSearchScope(projects, true);
|
||||||
|
} else
|
||||||
|
scope = SearchEngine.createWorkspaceScope();
|
||||||
|
|
||||||
// Create the pattern
|
// Create the pattern
|
||||||
ICSearchPattern pattern = SearchEngine.createSearchPattern(prefix + "*", ICSearchConstants.UNKNOWN_SEARCH_FOR, ICSearchConstants.ALL_OCCURRENCES, true); //$NON-NLS-1$
|
ICSearchPattern pattern = SearchEngine.createSearchPattern(prefix + "*", ICSearchConstants.UNKNOWN_SEARCH_FOR, ICSearchConstants.ALL_OCCURRENCES, true); //$NON-NLS-1$
|
||||||
|
|
Loading…
Add table
Reference in a new issue