Community
Participate
Working Groups
Build Identifier: 20100615235519 Error Code: while (iter.hasNext()) { IContentAssistProcessor legacyProcessor = (IContentAssistProcessor) iter.next(); ICompletionProposal[] legacyComputed = legacyProcessor.computeCompletionProposals(viewer, offset); proposals.addAll(Arrays.asList(legacyComputed)); } around Line 471. Obviously, you can see you never check whether legacyComputed is null or not. I call it a bug because the nullpointException gives my project a real trouble. I have a class which is named AllTagContentAssistProcessor.java in my plugin-project and it extends from the class named AbstractContentAssistProcessor.java. In AllTagContentAssistProcessor.java, I override the method : protected ContentAssistRequest computeCompletionProposals(int documentPosition, String matchString,ITextRegion completionRegion, IDOMNode treeNode,IDOMNode xmlnode), and whenever there is no ICompletionProposal need to show, I makes the method return null. It works well in former versions, but now the nullpointException makes my project a real trouble. To solve the problem in my project, I have to use a very stupid way. I write a method to add a ICompletionProposal contains a comment proposal to the returned ContentAssistRequest like this to avoid the nullpointException: public ContentAssistRequest fixBugs(ContentAssistRequest contentAssistRequest, int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode treeNode, IDOMNode xmlnode) { if( null == contentAssistRequest || null == contentAssistRequest.getCompletionProposals() || contentAssistRequest.getCompletionProposals().length == 0 ){ //contentAssistRequest = new ContentAssistRequest( xmlnode, null, getStructuredDocumentRegion(documentPosition) , completionRegion, documentPosition, 0, matchString); contentAssistRequest = newContentAssistRequest(treeNode, xmlnode,getStructuredDocumentRegion(documentPosition), completionRegion, documentPosition, 0,matchString); String replaceString = "<!-- -->"; String displayString = "comment - xml comment"; String additionalProposalInfo = "comment - xml comment <!-- -->"; ICompletionProposal proposal = new AllTagCompletionProposal(replaceString,documentPosition, 0, replaceString.indexOf(">") + 1,XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_MACRO),displayString, null, additionalProposalInfo, XMLRelevanceConstants.R_TAG_NAME, null); //add a comment to avoid the WTP nullpointException bug contentAssistRequest.addProposal(proposal); } return contentAssistRequest; } Reproducible: Always
StructuredContentAssistProcessor.java Line:471
Created attachment 176557 [details] patch
I think that this bug falls more in line with Major, by the severity definitions.
Requesting review for the maintenance branch.
Approved, surprisingly null is a legal return value.
Code checked in for maintenance and HEAD.