Opened 11 years ago

Closed 11 years ago

#1422 closed Bug (fixed)

Rename variables declared in single var statement

Reported by: Frederico Caldeira Knabben Owned by: Frederico Caldeira Knabben
Priority: Normal Milestone:
Component: Project : CKPackager Version:
Keywords: Confirmed Review+ Cc:

Description

Input Code

function Testing()
{
    var test1 = 1, test2 = 2, test3 = 3 ;

    alert( test1 + test2 + test3 ) ;
}

Current Results

function Testing(){var A=1,test2=2,test3=3;alert(A+test2+test3);}

Expected Results

function Testing(){var A=1,B=2,C=3;alert(A+B+C);}

Attachments (2)

1422.patch (1.0 KB) - added by Frederico Caldeira Knabben 11 years ago.
1422_2.patch (1.7 KB) - added by Frederico Caldeira Knabben 11 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 11 years ago by Wojciech Olchawa

Keywords: Confirmed added

Changed 11 years ago by Frederico Caldeira Knabben

Attachment: 1422.patch added

comment:2 Changed 11 years ago by Frederico Caldeira Knabben

Keywords: Review? added
Owner: set to Frederico Caldeira Knabben
Status: newassigned

The proposed patch now do the variable search in two steps. The first identify the var declaration blocks. The second extract all names defined in that block.

comment:3 Changed 11 years ago by Frederico Caldeira Knabben

Keywords: Review- added; Review? removed

Discussion about it with Martin, we found out that variables with the "$" character are not being matched by the proposed patch.

Changed 11 years ago by Frederico Caldeira Knabben

Attachment: 1422_2.patch added

comment:4 Changed 11 years ago by Frederico Caldeira Knabben

Keywords: Review? added; Review- removed

The new patch now matches any kind of character in the variable name. It also fixes a bug with special regex characters (like "$") in the variable name.

comment:5 Changed 11 years ago by Martin Kou

Keywords: Review+ added; Review? removed

comment:6 Changed 11 years ago by Frederico Caldeira Knabben

Resolution: fixed
Status: assignedclosed

Fixed with [2268].

I've tested it over the trunk and I still found some issues that have been addressed in the committed code.

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy