Bug 353474 - type converters should include more annotations
Summary: type converters should include more annotations
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: 3.8 M3   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 186342 353472
  Show dependency tree
 
Reported: 2011-07-31 16:17 EDT by Stephan Herrmann CLA
Modified: 2011-10-25 02:12 EDT (History)
3 users (show)

See Also:


Attachments
proposed change to SourceTypeConverter (1.66 KB, patch)
2011-07-31 16:25 EDT, Stephan Herrmann CLA
no flags Details | Diff
test & fix (9.14 KB, patch)
2011-10-06 15:00 EDT, Stephan Herrmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2011-07-31 16:17:19 EDT
When converting a method the SourceTypeConverter converts annotations
of the method itself but skips any parameter annotations.
The BinaryTypeConverter does not convert any annotations of methods.

Are there any hidden reasons why this is so, or should we just add the
missing cases?

Given that the model already contains all this information it looks
strange that it is not converted.
Comment 1 Stephan Herrmann CLA 2011-07-31 16:19:14 EDT
At least the source type version would be required by bug 353472.
Comment 2 Stephan Herrmann CLA 2011-07-31 16:25:02 EDT
Created attachment 200637 [details]
proposed change to SourceTypeConverter

Here's a trivial change that would solve the issue for SourceTypeConverter.

A change for BinaryTypeConverter would be slightly more involved, if needed.
Comment 3 Ayushman Jain CLA 2011-08-01 10:17:38 EDT
Jay, can you please take a look? Thanks!
Comment 4 Olivier Thomann CLA 2011-08-23 10:15:20 EDT
I think this needs to be updated. I don't think there is a particular reason for not doing it. If we do it, we should be consistent and do it for both converters.
Comment 5 Stephan Herrmann CLA 2011-09-06 17:02:51 EDT
I've seen bogus warnings from the reconciler when the support for
null-annotations was installed. These warnings happened when a type
with annotations entered compilation via the SourceTypeConverter.
The patch from comment 2 indeed fixed the issue.

However, I couldn't easily think of a test to challenge the
BinaryTypeConverter in a similar way.
What tests do we have to specifically test the BinaryTypeConverter?
Comment 6 Jay Arthanareeswaran CLA 2011-09-07 00:58:53 EDT
(In reply to comment #5)
> However, I couldn't easily think of a test to challenge the
> BinaryTypeConverter in a similar way.
> What tests do we have to specifically test the BinaryTypeConverter?

We have a bunch of tests in TypeResolveTests that were added for bug 334783.
Comment 7 Stephan Herrmann CLA 2011-10-06 11:59:13 EDT
I'll prepare a more complete patch as this essentially blocks bug 186342.
Comment 8 Stephan Herrmann CLA 2011-10-06 15:00:59 EDT
Created attachment 204708 [details]
test & fix

I spent time on trying to find suitable tests.

The SourceTypeConverter can be tested from ASTConverter15Test, e.g.
I included corresponding tests on this behalf.

However, for the BinaryTypeConverter I'm now convinced this issue cannot
be triggered:
Only two clients ever create BinaryTypeConverters:
+ CompletionEngine.complete(IType ...)
+ SelectionEngine.selectType(char[],IType)
For neither scenario would we ever come close to asking for annotations
in a method signature.
I set a breakpoint to the constructor of BinaryTypeConverter and in all of
AllJavaModelTests only two groups of tests triggered this breakpoint:
SnippetCompletionTests (and _1_5) for complete and TypeResolveTests for
selectType. Also these tests give no hint at how we could ever be interested
in the missing annotations.

I don't think we should implement behavior that can never be triggered.
Besides, in the BinaryTypeConverter the implementation would be more
involved because we don't have the infra structure in place as we have in
SourceTypeConverter.

Jay, can we release the patch as is? I think this is the best we can do
here and bug 186342 will indeed benefit from this.
Comment 9 Stephan Herrmann CLA 2011-10-08 16:55:24 EDT
I'm going to release this, since it is needed for the scheduled review for 
bug 186342. Please reopen should you find reasons why BinaryTypeConverter
should also be updated (cf. comment 8).
Comment 10 Stephan Herrmann CLA 2011-10-08 16:59:49 EDT
Released as commit de0226254a405a86138be24d23fd7ea72c01b855 for 3.8 M3.
Comment 11 Srikanth Sankaran CLA 2011-10-25 02:12:02 EDT
(In reply to comment #8)

> I don't think we should implement behavior that can never be triggered.

That is not unreasonable.

Patch looks good. Verified for 3.8 M3.