Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 419974 - [1.8][dom ast] MethodDeclaration needs updates for ReceiverParameter
Summary: [1.8][dom ast] MethodDeclaration needs updates for ReceiverParameter
Status: RESOLVED INVALID
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: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-21 09:50 EDT by Markus Keller CLA
Modified: 2013-12-16 11:09 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2013-10-21 09:50:36 EDT
BETA_JAVA8 

MethodDeclaration needs updates for the ReceiverParameter in recent versions of the 308 grammar:

  ReceiverParameter:
    {VariableModifier} UnannType {Identifier .} this

The current DOM API is based on the original grammar, which looked like this:

    Type [Identifier .] this

Given that we now have a separate grammar rule and a third property, I think it's best to get rid of the "receiverType" and "receiverQualifier" properties in MethodDeclaration and instead add a new optional property "receiverParameter" of a new AST node type "ReceiverParameter" with properties

- ChildListPropertyDescriptor(.., "modifiers", IExtendedModifier.class, ..)
- ChildPropertyDescriptor(.., "type", Type.class, MANDATORY, ..)
- ChildPropertyDescriptor(.., "qualifier", Name.class, OPTIONAL, ..)
Comment 1 Srikanth Sankaran CLA 2013-10-22 04:43:25 EDT
org.eclipse.jdt.internal.compiler.ast.Receiver.qualifyingName already
captures the full name, so no grammar changes are required.
Comment 2 Markus Keller CLA 2013-10-23 13:45:00 EDT
Please hold any work on this until the 308 spec is finalized.

The grammar will probably be changed to only allow {Annotation} instead of {VariableModifier}. Then, there are two ways how we could structure the DOM AST:

a) still go the full way suggested in comment 0
b) just add annotations to the appropriate AnnotatableType in the receiverType (ensuring correct source ranges, see below)

The {Identifier .} is also under dispute, so the qualifier property can maybe stay a SimpleName.


(In reply to Markus Keller from bug 419748 comment #1)
> I've added ASTConverter18Test#testParameterizedReceiverType(), but I had to
> release it in an incomplete version since the source range of the outermost
> ParameterizedType doesn't include the annotation. See the commented
> //TODO: bad AST node structure:
> for the remaining work to be done for this bug.

Here's the example. The bug is that there's e.g. a SimpleType "@A X", but the parent of that node is only ParameterizedType "X<T>".

import java.lang.annotation.*;
public class X<T extends Exception> {
    class Y<K, V> {
        class Z {
            public Z(@A X<T>.@B Y<K, V> Y.this){ }
            public void foo(@B Y<K, V>.@C Z this){ }
        }
    }
}
@Target(ElementType.TYPE_USE)
@interface A {}
@Target(ElementType.TYPE_USE)
@interface B {}
@Target(ElementType.TYPE_USE)
@interface C {}
Comment 3 Markus Keller CLA 2013-12-16 11:09:04 EST
The grammar is back to

ReceiverParameter:
  {Annotation} UnannType [Identifier .] this

I've verified that there's nothing left to do. Closing this bug.