diff options
author | Mickael Istria | 2017-09-28 12:19:40 +0000 |
---|---|---|
committer | Mickael Istria | 2017-09-28 12:19:40 +0000 |
commit | 87f81040fe12a6a91930ac55a4fb08bd1904cba7 (patch) | |
tree | 04cdd1c3efcec04327953be87b86fbda8f655df5 | |
parent | d9b4c1b5fa395ecc797e2b66c23885ca6e88f31d (diff) | |
download | eclipse.platform.text-87f81040fe12a6a91930ac55a4fb08bd1904cba7.tar.gz eclipse.platform.text-87f81040fe12a6a91930ac55a4fb08bd1904cba7.tar.xz eclipse.platform.text-87f81040fe12a6a91930ac55a4fb08bd1904cba7.zip |
Bug 522255 - Fix NPEs when no content-assist processor is available
Change-Id: I2cc90b1b5de07b11afa5a090d26ef1817606ddb2
Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java index 838eba116f1..db44bf42c84 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java @@ -2224,6 +2224,9 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt } private char[] mergeResults(Collection<IContentAssistProcessor> processors, Function<IContentAssistProcessor, char[]> f) { + if (processors == null) { + return null; + } char[][] arrays = processors.stream() .map(f) .filter(Objects::nonNull) @@ -2490,12 +2493,15 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt */ void fireSessionBeginEvent(boolean isAutoActivated) { if (fContentAssistSubjectControlAdapter != null && !isProposalPopupActive()) { - getProcessors(fContentAssistSubjectControlAdapter, fContentAssistSubjectControlAdapter.getSelectedRange().x).forEach(processor -> { - ContentAssistEvent event= new ContentAssistEvent(this, processor, isAutoActivated); - for (ICompletionListener listener : fCompletionListeners) { - listener.assistSessionStarted(event); - } - }); + Set<IContentAssistProcessor> processors= getProcessors(fContentAssistSubjectControlAdapter, fContentAssistSubjectControlAdapter.getSelectedRange().x); + if (processors != null) { + processors.forEach(processor -> { + ContentAssistEvent event= new ContentAssistEvent(this, processor, isAutoActivated); + for (ICompletionListener listener : fCompletionListeners) { + listener.assistSessionStarted(event); + } + }); + } } } @@ -2506,13 +2512,16 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt */ void fireSessionRestartEvent() { if (fContentAssistSubjectControlAdapter != null) { - getProcessors(fContentAssistSubjectControlAdapter, fContentAssistSubjectControlAdapter.getSelectedRange().x).forEach(processor -> { - ContentAssistEvent event= new ContentAssistEvent(this, processor); - for (ICompletionListener listener : fCompletionListeners) { - if (listener instanceof ICompletionListenerExtension) - ((ICompletionListenerExtension)listener).assistSessionRestarted(event); - } - }); + Set<IContentAssistProcessor> processors= getProcessors(fContentAssistSubjectControlAdapter, fContentAssistSubjectControlAdapter.getSelectedRange().x); + if (processors != null) { + processors.forEach(processor -> { + ContentAssistEvent event= new ContentAssistEvent(this, processor); + for (ICompletionListener listener : fCompletionListeners) { + if (listener instanceof ICompletionListenerExtension) + ((ICompletionListenerExtension)listener).assistSessionRestarted(event); + } + }); + } } } @@ -2523,12 +2532,15 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt */ void fireSessionEndEvent() { if (fContentAssistSubjectControlAdapter != null) { - getProcessors(fContentAssistSubjectControlAdapter, fContentAssistSubjectControlAdapter.getSelectedRange().x).forEach(processor -> { - ContentAssistEvent event= new ContentAssistEvent(this, processor); - for (ICompletionListener listener : fCompletionListeners) { - listener.assistSessionEnded(event); - } - }); + Set<IContentAssistProcessor> processors= getProcessors(fContentAssistSubjectControlAdapter, fContentAssistSubjectControlAdapter.getSelectedRange().x); + if (processors != null) { + processors.forEach(processor -> { + ContentAssistEvent event= new ContentAssistEvent(this, processor); + for (ICompletionListener listener : fCompletionListeners) { + listener.assistSessionEnded(event); + } + }); + } } } |