[ 
https://issues.apache.org/jira/browse/NETBEANS-479?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ARUNAVA SINHA updated NETBEANS-479:
-----------------------------------
    Description: 
The IDE will include a prompt to replace the explicit types with ‘var’, when 
the type can be inferred from the context.

e.g.., String str = new String("Hello");

can be replaced with var str = new String("hello");

Preconditions for the hint:
 # hint will be enabled only for JDK10 or higher
 # hint willwork only inside local scope
 # hint will be disabled if var type is already present.
 # hint will not support generic array.
 e.g., Arraylist[] arr = new ArrayList[5];

Explicit type of local variable will be converted to var type if type of 
variable is same as assignment type
 Below Scenarios will be covered:
 # Object Initialization:
 Integer i = new Integer("10");
 Fix : var i = new Integer("10");

HashMap<Integer,Integer> map= new HashMap<Integer,Integer>();
 Fix : var map= new HashMap<Integer,Integer>();
 # Array Initialization
 int[][]arr = new int[3][];
 Fix : var arr = new int[3][];

 # Assignment of literal:
 int a = 10;
 Fix: var a = 10;

 # Assignment to a method call
 var list = Collections.unmodifiableList(new ArrayList()) ;

Below Assignment scenarios will be excluded :
 # Anonymous Object
 # Lambda expression
 # Diamond interface

  was:
The IDE will include a prompt to replace the explicit types with ‘var’, when 
the type can be inferred from the context.

e.g.., String str = new String("Hello");

can be replaced with var str = new String("hello");

Preconditions for the hint:
 # hint will be enabled only for JDK10 or higher
 # hint willwork only inside local scope
 # hint will be disabled if var type is already present.
 # hint will not support generic array.
e.g., Arraylist[] arr = new ArrayList[5];

Apache Jira Link:
https://issues.apache.org/jira/browse/NETBEANS-479

Explicit type of local variable will be converted to var type if type of 
variable is same as assignment type
Below Scenarios are covered:
 # Object Initialization:
Integer i = new Integer("10");
Fix : var i = new Integer("10");

HashMap<Integer,Integer> map= new HashMap<Integer,Integer>();
Fix : var map= new HashMap<Integer,Integer>();

 # Array Initialization
int[][]arr = new int[3][];
Fix : var arr = new int[3][];

 # Assignment of literal:
int a = 10;
Fix: var a = 10;

 # Assignment to a method call
var list = Collections.unmodifiableList(new ArrayList()) ;

Below Assignment scenarios are not covered.
 # Anonymous Object
 # Lambda expression
 # Diamond interface


> New Java Hint to replace explicit type of variable with var
> -----------------------------------------------------------
>
>                 Key: NETBEANS-479
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-479
>             Project: NetBeans
>          Issue Type: Improvement
>            Reporter: ARUNAVA SINHA
>            Assignee: ARUNAVA SINHA
>            Priority: Trivial
>              Labels: JDK10-LVTI
>
> The IDE will include a prompt to replace the explicit types with ‘var’, when 
> the type can be inferred from the context.
> e.g.., String str = new String("Hello");
> can be replaced with var str = new String("hello");
> Preconditions for the hint:
>  # hint will be enabled only for JDK10 or higher
>  # hint willwork only inside local scope
>  # hint will be disabled if var type is already present.
>  # hint will not support generic array.
>  e.g., Arraylist[] arr = new ArrayList[5];
> Explicit type of local variable will be converted to var type if type of 
> variable is same as assignment type
>  Below Scenarios will be covered:
>  # Object Initialization:
>  Integer i = new Integer("10");
>  Fix : var i = new Integer("10");
> HashMap<Integer,Integer> map= new HashMap<Integer,Integer>();
>  Fix : var map= new HashMap<Integer,Integer>();
>  # Array Initialization
>  int[][]arr = new int[3][];
>  Fix : var arr = new int[3][];
>  # Assignment of literal:
>  int a = 10;
>  Fix: var a = 10;
>  # Assignment to a method call
>  var list = Collections.unmodifiableList(new ArrayList()) ;
> Below Assignment scenarios will be excluded :
>  # Anonymous Object
>  # Lambda expression
>  # Diamond interface



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to