Summary: | [1.8][quick fix] "Remove explicit 'this' parameter" for incorrect locations | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Noopur Gupta <noopur_gupta> |
Component: | UI | Assignee: | JDT-UI-Inbox <jdt-ui-inbox> |
Status: | ASSIGNED --- | QA Contact: | |
Severity: | enhancement | ||
Priority: | P3 | CC: | markus.kell.r |
Version: | 4.4 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: | |||
Bug Depends on: | 427357 | ||
Bug Blocks: |
Description
Noopur Gupta
2014-01-30 07:24:28 EST
The quick fix can also be used as a quick assist to remove the explicit 'this' parameter if required. For the cases where the invalid (to be removed) 'this' parameter is present in a method (not lambda expr), it should be present in either the parameters list of MethodDeclaration or its type should be set in the MethodDeclaration.RECEIVER_TYPE_PROPERTY. Only then it can be removed from the AST. If it is not present anywhere in the AST then how can it be removed (see case #m2 below)? Consider the following example: abstract class Test2 { abstract void m0(Test2 this, int i); void m1(int i, Test2 this) { } static void m2(Test2 this, int i) { } Function<String, String> f1= (String s, Function this) -> s; Function<String, String> f2= (Function this, String s) -> s; } Here, 'this' parameter is present as given below: - In #m0: present in RECEIVER_TYPE_PROPERTY, not present in parameters list. - In #m1: not present in RECEIVER_TYPE_PROPERTY, present in parameters list. - In #m2: not present in RECEIVER_TYPE_PROPERTY, not present in parameters list. - In f1 and f2: present in parameters list of LambdaExpression. For #m2, since it is not a valid receiver parameter, probably it should be present only in parameters list (as in #m1) and not set in RECEIVER_TYPE_PROPERTY. Markus, please share your thoughts on: 1. Is the new quick fix required? 2. AST for 'this' in case of #m2. 3. Where to check the value of IMethodBinding.getDeclaredReceiverType() in AST view? |