Bug 172429 - [Content Assist] NPE in CPPTemplateScope.getParent
Summary: [Content Assist] NPE in CPPTemplateScope.getParent
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 4.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 4.0 M5   Edit
Assignee: Bryan Wilkinson CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-02-01 03:06 EST by Anton Leherbauer CLA
Modified: 2008-06-20 10:58 EDT (History)
1 user (show)

See Also:


Attachments
proposed patch (1.08 KB, patch)
2007-02-05 12:14 EST, Bryan Wilkinson CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.