Bug 172429

Summary: [Content Assist] NPE in CPPTemplateScope.getParent
Product: [Tools] CDT Reporter: Anton Leherbauer <aleherb+eclipse>
Component: cdt-coreAssignee: Bryan Wilkinson <bryan2233>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bryan2233
Version: 4.0Keywords: contributed
Target Milestone: 4.0 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
proposed patch bjorn.freeman-benson: iplog+

Description Anton Leherbauer CLA 2007-02-01 03:06:50 EST
CDT HEAD as of 20070131

Typing the following into a C++ header or source file

template<class T>

a NullPointerException occurs during auto-activation of content assist:

java.lang.NullPointerException
at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateScope.getParent(CPPTemplateScope.java:70)
at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics.getParentScope(CPPSemantics.java:1139)
at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics.lookup(CPPSemantics.java:1119)
at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics.prefixLookup(CPPSemantics.java:3337)
at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics.findBindings(CPPSemantics.java:3288)
at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics.findBindings(CPPSemantics.java:3279)
at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPScope.find(CPPScope.java:212)
at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamedTypeSpecifier.resolvePrefix(CPPASTNamedTypeSpecifier.java:107)
at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName.resolvePrefix(CPPASTName.java:89)
at org.eclipse.cdt.internal.ui.text.contentassist.DOMCompletionContributor.contributeCompletionProposals(DOMCompletionContributor.java:92)
at org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor2.computeCompletionProposals(CCompletionProcessor2.java:117)
Comment 1 Bryan Wilkinson CLA 2007-02-05 12:14:25 EST
Created attachment 58262 [details]
proposed patch

The NullPointerException at CPPTemplateScope.getParent() occurs due to the template's name being null.  However, it is valid for the name to be null for a case such as this, since the template is empty.  Also, the name is only used to handle a special case involving qualification, so simply checking for null and proceeding with the standard execution of the method should suffice.
Comment 2 Anton Leherbauer CLA 2007-02-06 07:18:46 EST
Thanks, patch applied.