Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 318122 - NPE in org.eclipse.jface.text.contentassist.CompletionProposalPopup$9.keyTraversed
Summary: NPE in org.eclipse.jface.text.contentassist.CompletionProposalPopup$9.keyTrav...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7 M1   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-27 08:48 EDT by Gary Karasiuk CLA
Modified: 2010-06-28 10:14 EDT (History)
1 user (show)

See Also:


Attachments
Fix (5.91 KB, patch)
2010-06-28 10:12 EDT, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gary Karasiuk CLA 2010-06-27 08:48:57 EDT
I am trying to code my own content assist. When I press the TAB key on one of my content assist entries I get the following NPE:

java.lang.NullPointerException
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup$9.keyTraversed(CompletionProposalPopup.java:728)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:247)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
	at org.eclipse.swt.widgets.Control.traverse(Control.java:3693)
	at org.eclipse.swt.widgets.Control.translateTraversal(Control.java:3675)
	at org.eclipse.swt.widgets.Composite.translateTraversal(Composite.java:1218)
	at org.eclipse.swt.widgets.Display.translateTraversal(Display.java:4691)
	at org.eclipse.swt.widgets.Display.filterMessage(Display.java:1267)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3653)
SNIP 

Here is my code that sets up the content assist proposals:

	private ICompletionProposal[] memorizedCompletions(String token, int offset) {
		List<MemorizedTransactionImmutable> mts = MTCache.instance.getByName(token.substring(2));
		ICompletionProposal[] result= new ICompletionProposal[mts.size()];
		int i = 0;
		for (MemorizedTransactionImmutable mt : mts){
			IContextInformation ci = new ContextInformation(mt.key, mt.transaction);
			result[i++] = new CompletionProposal(mt.transaction, offset-token.length(), token.length(), mt.transaction.length(), null, mt.key, ci, null);
		}
		return result;
	}
Comment 1 Markus Keller CLA 2010-06-28 10:12:32 EDT
Created attachment 172908 [details]
Fix

The NPE happens because you didn't call #setInformationControlCreator(..) on your ContentAssistant. But since that's not required, I've protected our code.
Comment 2 Markus Keller CLA 2010-06-28 10:13:56 EDT
Fixed in HEAD.
Comment 3 Markus Keller CLA 2010-06-28 10:14:04 EDT
.