This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 258664

Summary: Support of destructuring assignment
Product: javascript Reporter: Petr Pisl <ppisl>
Component: EditorAssignee: Petr Pisl <ppisl>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 8.2   
Hardware: PC   
OS: Linux   
Issue Type: TASK Exception Reporter:
Bug Depends on:    
Bug Blocks: 242387    
Attachments: Simple Array Destructuring Assignment
Array Destructuring Assignment with Default Values
Array Destructuring Assignment from a Function
Array Destructuring Assignment - swap values of two variables
Simple Object Destructuring Assignment
Object destructuring assignment without declaration
Object destructuring assignment without declaration
Object destructuring assignment , when a property is not defined
Object destructuring assigning to new variable names
Setting a function parameter's default value

Description Petr Pisl 2016-04-05 15:00:15 UTC
NetBeans should be able to handle destructuring assignment in the right way. 

https://developer.mozilla.org/cs/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

Currently there are false hints and mark occurrences works in wrong way in cases like:

({a, b} = {a:1, b:2});
Comment 1 Petr Pisl 2016-04-13 16:00:26 UTC
Simple array destructuring assignment is handled by NB now.
Comment 2 Petr Pisl 2016-04-19 08:41:51 UTC
Created attachment 159315 [details]
Simple Array Destructuring Assignment

Simple array destructuring assignment. Variables are created, mark occurrences and Go To declaration should work.
Comment 3 Petr Pisl 2016-04-19 08:45:08 UTC
Created attachment 159316 [details]
Array Destructuring Assignment with Default Values

According the default values NB can suggest the tape of object.
Comment 4 Petr Pisl 2016-04-19 08:48:24 UTC
Created attachment 159317 [details]
Array Destructuring Assignment from a Function
Comment 5 Petr Pisl 2016-04-19 08:49:21 UTC
Created attachment 159318 [details]
Array Destructuring Assignment - swap values of two variables

Mark occurrences should work as expected.
Comment 6 Petr Pisl 2016-04-19 08:51:57 UTC
Created attachment 159319 [details]
Simple Object Destructuring Assignment

Creating variables, mark occurrences and Go To navigation should work.
Comment 7 Petr Pisl 2016-04-19 08:54:52 UTC
Created attachment 159320 [details]
Object destructuring assignment without declaration
Comment 8 Petr Pisl 2016-04-19 08:57:41 UTC
Created attachment 159321 [details]
Object destructuring assignment without declaration

Mark occurrences should work on both sides.
Comment 9 Petr Pisl 2016-04-19 09:04:42 UTC
Created attachment 159322 [details]
Object destructuring assignment , when a property is not defined

In this case, the property from the assigned object literal corresponds with the properties on the left site of the assignment. Mark occurrences work for such properties, user can rename them. 

Also the property w is not defined on the right site, so NetBeans doesn't mark such property with green color.
Comment 10 Petr Pisl 2016-04-19 09:11:12 UTC
Created attachment 159323 [details]
Object destructuring assigning to new variable names

NetBeans marks occurrences of the properties assigned from the object literal on the right sight and the properties used on the left site.
Comment 11 Petr Pisl 2016-04-19 09:15:14 UTC
Created attachment 159324 [details]
Setting a function parameter's default value

NetBeans handle parameters defined via destructuring assignment. The mark occurrences, Go To Declaration and code completion should work in such cases.
Comment 12 Petr Pisl 2016-04-19 09:23:29 UTC
The support is done. Implemented in ecma6-truffle branch. There is an issue #258901  with false warnings that will be fixed soon.