Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 395886 - [1.8][DOM/AST] Withdraw annotations property from Name nodes.
Summary: [1.8][DOM/AST] Withdraw annotations property from Name nodes.
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.3   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: BETA J8   Edit
Assignee: Manoj N Palat CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 287648 391847 397421
  Show dependency tree
 
Reported: 2012-12-06 00:24 EST by Srikanth Sankaran CLA
Modified: 2013-10-27 16:51 EDT (History)
4 users (show)

See Also:
srikanth_sankaran: review+


Attachments
Proposed Patch - WIP (64.98 KB, patch)
2013-01-02 01:41 EST, Manoj N Palat CLA
no flags Details | Diff
Proposed Fix (64.37 KB, patch)
2013-01-04 03:43 EST, Manoj N Palat CLA
no flags Details | Diff
Proposed Patch (67.69 KB, patch)
2013-01-07 00:48 EST, Manoj N Palat CLA
no flags Details | Diff
Proposed Patch (80.63 KB, patch)
2013-01-11 09:53 EST, Manoj N Palat CLA
no flags Details | Diff
Proposed Patch (81.58 KB, patch)
2013-01-18 03:56 EST, Manoj N Palat CLA
no flags Details | Diff
Proposed Patch - part 2 (63.23 KB, patch)
2013-01-23 21:43 EST, Manoj N Palat CLA
no flags Details | Diff
Proposed Patch - Part 2 (60.37 KB, patch)
2013-01-24 01:19 EST, Manoj N Palat CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2012-12-06 00:24:18 EST
As part of the fix for bug 391890, ANNOTATIONS_PROPERTY was added to Name nodes.
These need to be removed since the specification has changed to disallow
constructs of the form:

    @Marker java.util.List

The proper way to annotate these is to say:

    java.util. @Marker List

Thus the presence of annotations before a certain segment of a qualified type
signals that what follows is a type and cannot be a name. Very similar to how
the presence of type parameters signals a type.

See also:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391847#c4
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391847#c7
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391847#c33
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391847#c34
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391847#c37
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391847#c39
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391847#c46


When we converty a QualifiedTypeReference or its subtypes, we should
convert everything before the first type annotation seen as a SimpleType of
QualifiedName/SimpleName and convert everything further as types.

Compare how type parameters are handled in conversion of PQTR.
Comment 1 Stephan Herrmann CLA 2012-12-06 09:33:33 EST
Out of curiosity:

(In reply to comment #0)
> These need to be removed since the specification has changed to disallow
> constructs of the form:
> 
>     @Marker java.util.List
> 
> The proper way to annotate these is to say:
> 
>     java.util. @Marker List

Has the compiler been updated for this spec change?
Which bug should I read/follow for that?
Comment 2 Srikanth Sankaran CLA 2012-12-06 23:40:22 EST
(In reply to comment #1)
> Out of curiosity:
> 
> (In reply to comment #0)
> > These need to be removed since the specification has changed to disallow
> > constructs of the form:
> > 
> >     @Marker java.util.List
> > 
> > The proper way to annotate these is to say:
> > 
> >     java.util. @Marker List
> 
> Has the compiler been updated for this spec change?
> Which bug should I read/follow for that?

Please see https://bugs.eclipse.org/bugs/show_bug.cgi?id=394356
Comment 3 Manoj N Palat CLA 2013-01-02 01:41:27 EST
Created attachment 225127 [details]
Proposed Patch - WIP

Non-ASTRewrite Part of the patch - WIP

TODO:
- create another dependent bug for ASTRewrite Part.
- Investigate if more test cases are required.
- Look for more optimized/reduced code additions in terms of tests and implementation.
- Eyeball patch for adherence to code conventions.

Note: 
test0012 of TypeAnnotationsConverterTest (RunDOMTests) is expected to fail until the fix of Bug 392132 is applied as this is a case of intersection of these two bugs.
Comment 4 Manoj N Palat CLA 2013-01-04 03:43:29 EST
Created attachment 225202 [details]
Proposed Fix

- ANNOTATIONS_PROPERTY has been kept for QualifiedName and SimpleName for the sole reason of not breaking the Rewrite part. A separate bug (bug 397421) has been filed for the ASTRewrite part which would take care of the same. Note that all the references of these from the non-ASTRewrite part has been removed in the patch.
Comment 5 Manoj N Palat CLA 2013-01-07 00:48:25 EST
Created attachment 225266 [details]
Proposed Patch

Additional to the code in previous patch, removed the ANNOTATIONS_PROPERTY and associated references in ASTRewrite files as well.
Comment 6 Srikanth Sankaran CLA 2013-01-10 02:09:31 EST
Name.java:

(1) The roll back is very partial and leaves many stale things:
(a) For example the javadoc still says: "For JLS8, the Name may be preceded by optional type annotations. ..." which is incorrect. 
(b) BASE_NAME_NODE_SIZE is not bumped down.

I think the right thing
to do is to restore from commit id bd6803034b95b7e0dd8c0cbcd0aead0a5c726f65

(2) Likewise in QualifiedName: (a) Incorrect statements about JLS8 exist
and QualifiedName has no child list properties anymore so the method
internalGetChildListProperty does not make sense.

The right thing to do is to restore from 34ffedac0864f9670be9b90418a519412edd8a4d

(3) Likewise for SimpleName: There are various stale things still left in.
The right thing to do is to restore from 699cc351076b7c5897a886d674772d111233f0a3

(4) ASTRewriteAnalyzer: org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(SimpleName)
still references ANNOTATIONS_PROPERTY.

(5) ASTRewriteFlattener: org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFlattener.visit(SimpleName)
still references ANNOTATIONS_PROPERTY.

(6) ASTMatcher: org.eclipse.jdt.core.dom.ASTMatcher.match(QualifiedName, Object)
What is the difference between the different case arms of the switch ? 

(7) org.eclipse.jdt.core.dom.ASTMatcher.match(SimpleName, Object) still
references annotations()

(8) ASTConverter: The method org.eclipse.jdt.core.dom.ASTConverter.annotateName(Name, Annotation[]) is
completely redundant now since Names cannot be annotated anymore. All call
sites need to be inspected and removed/modified.

(9) I'll review the tests and ASTConverter changes deeper after these are
addressed and a fresh patch is posted.
Comment 7 Manoj N Palat CLA 2013-01-11 09:53:11 EST
Created attachment 225506 [details]
Proposed Patch

- Reworked as per listed commit diffs.
- References to bug number kept intentionally at a couple of places (only) at ASTCoverter and in test files.
Comment 8 Manoj N Palat CLA 2013-01-18 03:56:51 EST
Created attachment 225804 [details]
Proposed Patch

Made patch current to the latest source and addressed the comments so far.
Comment 9 Srikanth Sankaran CLA 2013-01-21 00:50:27 EST
First batch of changes released via: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=b7bb9d2950572af77f85c2c708c3816367817930
Comment 10 Manoj N Palat CLA 2013-01-23 21:43:04 EST
Created attachment 226013 [details]
Proposed Patch - part 2

Completes the fix.
Comment 11 Srikanth Sankaran CLA 2013-01-24 00:28:20 EST
(1) DBR: the change in getTypeArguments() is not inline with the method
name at all. Fortunately, since this method is called at only one place
it can be readily renamed into getTypeCount() which is a better name even
earlier.

(2) ASTConverter18Test: Has lots of irrelevant changes. Please eliminate
them.
Comment 12 Manoj N Palat CLA 2013-01-24 01:19:42 EST
Created attachment 226019 [details]
Proposed Patch - Part 2
Comment 13 Srikanth Sankaran CLA 2013-01-24 01:24:52 EST
Fix and tests released via http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=c0d8ddbb4b72e166c7dc81eb807bc47fd1beaa74

Thanks Manoj.
Comment 14 Markus Keller CLA 2013-10-27 16:51:59 EDT
(In reply to Srikanth Sankaran from comment #13)
> Fix and tests released via
> http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/
> ?h=BETA_JAVA8&id=c0d8ddbb4b72e166c7dc81eb807bc47fd1beaa74
> 
> Thanks Manoj.

The change in NaiveASTFlattener was wrong. SimpleType doesn't support QualifiedName as name in JLS8, and it shouldn't look like it would be supported. Reverted this change with http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=0d3451e9a7c942ed5f2531f8cbfba408096982ef