Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 102257 - [content assist] CompletionProposalLabelProvider assumes proposal signature not null
Summary: [content assist] CompletionProposalLabelProvider assumes proposal signature n...
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Tom Hofmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-29 23:18 EDT by Phillip Avery CLA
Modified: 2005-07-05 10:50 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Phillip Avery CLA 2005-06-29 23:18:10 EDT
see related bug 102206

in revision 1.9 of CompletionProposalLabelProvider, this logic was added:

case CompletionProposal.TYPE_REF:
  switch (Signature.getTypeSignatureKind(proposal.getSignature())) {


but according to the doc, the signature for a proposal can be null.
This is especially true if the proposal is created through this API:

 CompletionProposal.create(CompletionProposal.TYPE_REF, offset);


CompletionProposalLabelProvider should probably default to some generic image
for a TYPE_REF that has a null signature.
Comment 1 Tom Hofmann CLA 2005-06-30 07:16:43 EDT
Hm, CompletionProposal.getSignature says:

> For kinds of completion proposals, this method returns null

But also states that the signature is available for proposals of kind TYPE_REF:

> This field is available for the following kinds of completion proposals:
>    * TYPE_REF - type signature of the type that is referenced

I would expect that the signature is always non-null for proposals of the kinds
listed.

However, we could probably add a guard for this situation.

David (Audel), what is your view on this as the maintainer of this API?
Comment 2 David Audel CLA 2005-07-04 05:34:20 EDT
The spec of CompletionProposal#create(int, int) says:
> Creates a basic completion proposal. All instance
> field have plausible default values unless otherwise noted
Currently all default values are 'null' or 0.

But the spec of CompletionProposal#getSignature() says:
> This field is available for the following kinds of completion proposals:
> TYPE_REF - type signature of the type that is referenced

My understanding of the spec is that the caller of CompletionProposal#create()
must also add all the required values to the proposal. So the signature of a
TYPE_REF is always non-null for clients. But i am not totally convinced that my
understanding is the correct one.

Jim, could you comment this as designer of this API?




By reading the spec i also found that my implementation of the spec is not safe.
If a CompletionProposal is not created by CompletionEngine then a call to
'findParameterNames' or 'getCompletion' could throw an NPE (see bug 102346).
Comment 3 Jim des Rivieres CLA 2005-07-05 10:39:47 EDT
David,  You're correct in your reading. The (internal) party that creates 
CompletionProposal instances must fill in all the required values.
Comment 4 Tom Hofmann CLA 2005-07-05 10:50:03 EDT
Then I close this PR - the creator of the proposal must provide a non-null
signature for TYPE_REF proposals.