Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "JDT Core/Plan/4.8/JEP286"
(Created page with "= Planning page for JDT Implementation of Local Variable Type Inference (JEP 286) for Photon (4.8) = Main tracking bug: [https://bugs.eclipse.org/bugs/show_bug.cgi?id=525750...") |
|||
(13 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
Main tracking bug: [https://bugs.eclipse.org/bugs/show_bug.cgi?id=525750 JEP286 Bug] | Main tracking bug: [https://bugs.eclipse.org/bugs/show_bug.cgi?id=525750 JEP286 Bug] | ||
− | == | + | == Compiler changes == |
− | + | Changes regarding the compiler: [https://bugs.eclipse.org/bugs/show_bug.cgi?id=527554 Compiler Bug] | |
=== Grammar changes === | === Grammar changes === | ||
Since var is not a keyword, but a reserved type name AND we need to be backwards compatible anyway, | Since var is not a keyword, but a reserved type name AND we need to be backwards compatible anyway, | ||
Line 17: | Line 17: | ||
=== Error reports === | === Error reports === | ||
* Errors where local variable type cannot be inferred: | * Errors where local variable type cannot be inferred: | ||
− | ** Cannot use ' | + | ** Cannot use 'var' on variable without initializer |
** Lambda expression needs an explicit target-type | ** Lambda expression needs an explicit target-type | ||
** Variable initializer is 'null' | ** Variable initializer is 'null' | ||
− | ** Inferred type is | + | ** Inferred type is 'void' |
** When method reference needs an explicit target-type. | ** When method reference needs an explicit target-type. | ||
** array initializer needs an explicit target-type | ** array initializer needs an explicit target-type | ||
Line 29: | Line 29: | ||
Shouldn't be much work since the stack frame would be filled in with the bound type anyway. | Shouldn't be much work since the stack frame would be filled in with the bound type anyway. | ||
− | == | + | == Java Search support == |
− | + | Changes regarding the Search: [https://bugs.eclipse.org/bugs/show_bug.cgi?id=529434 Search Bug] | |
− | === | + | == DOM support == |
− | + | Changes regarding the DOM: [https://bugs.eclipse.org/bugs/show_bug.cgi?id=527558 DOM Bug] | |
+ | |||
+ | == Content Assist support == | ||
+ | * Top level bug at https://bugs.eclipse.org/bugs/show_bug.cgi?id=529556 | ||
+ | * var to be included in completion - https://bugs.eclipse.org/bugs/show_bug.cgi?id=529552 | ||
+ | * type. completions if the type is var - tracked via https://bugs.eclipse.org/bugs/show_bug.cgi?id=529556 | ||
+ | * name of the variable? Default camel case type to a little alphabet prefixed name will not work here - alternatives (low prio). | ||
+ | * changes to priority of proposals ? | ||
+ | |||
+ | == UI Changes == | ||
+ | |||
+ | * Switch ASTs to JLS10 - [https://bugs.eclipse.org/bugs/show_bug.cgi?id=530298 bug 530298], [https://bugs.eclipse.org/bugs/show_bug.cgi?id=531142 bug 531142]. | ||
=== Code hover === | === Code hover === | ||
− | Show type of variable ( | + | * Show inferred type of variable - [https://bugs.eclipse.org/bugs/show_bug.cgi?id=531041 bug 531041]. |
+ | |||
+ | === Preferences === | ||
+ | * Allow JDT UI to target Java 10 in Compiler Preferences - [https://bugs.eclipse.org/bugs/show_bug.cgi?id=529432 bug 529432] | ||
+ | * Clean up option to prefer 'var' over specific types (to control the irritants generated by the compiler) - [based on need - low prio]. | ||
+ | |||
+ | === Quick assists === | ||
+ | * Convert 'var' into the resolved type - [https://bugs.eclipse.org/bugs/show_bug.cgi?id=531039 bug 531039]. | ||
+ | * Convert explicit typed local variable into 'var', like changing "String coolIde = "Eclipse";" into "var coolIde = "Eclipse";" It should also include: Convert diamond operator to var, like fixing "List<String> names = new LinkedList<>()" into "var names = new LinkedList<String>()" - [https://bugs.eclipse.org/bugs/show_bug.cgi?id=531040 bug 531040]. | ||
+ | |||
+ | === Code templates === | ||
+ | * New templates with 'var' in for loops and introduce new variable - [can be added if useful - need examples - low prio]. | ||
+ | |||
+ | [[Category:JDT]] |
Latest revision as of 09:19, 13 March 2018
Contents
Planning page for JDT Implementation of Local Variable Type Inference (JEP 286) for Photon (4.8)
Main tracking bug: JEP286 Bug
Compiler changes
Changes regarding the compiler: Compiler Bug
Grammar changes
Since var is not a keyword, but a reserved type name AND we need to be backwards compatible anyway, it should be handled in type resolution instead of grammar. Local variable type inference should be denoted by a bit AST node and type binding.
Type checking
- Determine the type of the var declaration
- Determine upwards/downwards type projection for type
- Fallback to "Object" type in case of error
Error reports
- Errors where local variable type cannot be inferred:
- Cannot use 'var' on variable without initializer
- Lambda expression needs an explicit target-type
- Variable initializer is 'null'
- Inferred type is 'void'
- When method reference needs an explicit target-type.
- array initializer needs an explicit target-type
- Error when defining a type called 'var':
This should be a configurable 'warning'/'info' for Java 9 and earlier.
Code generation
Shouldn't be much work since the stack frame would be filled in with the bound type anyway.
Java Search support
Changes regarding the Search: Search Bug
DOM support
Changes regarding the DOM: DOM Bug
Content Assist support
- Top level bug at https://bugs.eclipse.org/bugs/show_bug.cgi?id=529556
- var to be included in completion - https://bugs.eclipse.org/bugs/show_bug.cgi?id=529552
- type. completions if the type is var - tracked via https://bugs.eclipse.org/bugs/show_bug.cgi?id=529556
- name of the variable? Default camel case type to a little alphabet prefixed name will not work here - alternatives (low prio).
- changes to priority of proposals ?
UI Changes
- Switch ASTs to JLS10 - bug 530298, bug 531142.
Code hover
- Show inferred type of variable - bug 531041.
Preferences
- Allow JDT UI to target Java 10 in Compiler Preferences - bug 529432
- Clean up option to prefer 'var' over specific types (to control the irritants generated by the compiler) - [based on need - low prio].
Quick assists
- Convert 'var' into the resolved type - bug 531039.
- Convert explicit typed local variable into 'var', like changing "String coolIde = "Eclipse";" into "var coolIde = "Eclipse";" It should also include: Convert diamond operator to var, like fixing "List<String> names = new LinkedList<>()" into "var names = new LinkedList<String>()" - bug 531040.
Code templates
- New templates with 'var' in for loops and introduce new variable - [can be added if useful - need examples - low prio].