You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Christian Lenz (Jira)" <ji...@apache.org> on 2021/03/03 14:19:00 UTC

[jira] [Commented] (NETBEANS-5399) JavaScript: rename variable - not all occurrences found

    [ https://issues.apache.org/jira/browse/NETBEANS-5399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17294554#comment-17294554 ] 

Christian Lenz commented on NETBEANS-5399:
------------------------------------------

Reproducable, thx :)

> JavaScript: rename variable - not all occurrences found
> -------------------------------------------------------
>
>                 Key: NETBEANS-5399
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-5399
>             Project: NetBeans
>          Issue Type: Bug
>          Components: javascript - Refactoring
>    Affects Versions: 12.3
>         Environment: Product Version: Apache NetBeans IDE 12.3-beta2
> Java: 14.0.2; Java HotSpot(TM) 64-Bit Server VM 14.0.2+12-46
> Runtime: Java(TM) SE Runtime Environment 14.0.2+12-46
>            Reporter: Czukowski
>            Priority: Minor
>
> Consider a sample project consisting of a single file, {{main.js}}:
> {code}
> 'use strict';
> const registry = {
>     categories: {},
> };
> const f = function (category, event, element = null) {
>     const obj = registry.categories[category]; // [1]
>     if (!obj.hasOwnProperty(event)) { // [2]
>         obj[event] = true; // [3]
>         element.addEventListener(event, function () {
>             // ...
>         });
>     }
> };
> {code}
> The variable in question is {{obj}}, referenced at three places. Try renaming it by placing a cursor at its occurrences and pressing Ctrl+R. Now, depending on where a cursor has been placed, there is a different outcome:
> - If the cursor is at [1] or [3], the occurrence at [2] will not be selected and therefore renamed
> - If the cursor is at [2], all three occurrences will be selected
> Commenting out or removing some other code 'fixes' it, in a way that renaming the variable at any of the three occurrences will rename all three:
> - Removing {{'use strict'}} at the 1st line
> - Removing the default {{null}} value for the {{element}} argument at the function {{f}} declaration
> - Removing the whole call to {{element.addEventListener}}
> The desired behavior is that all occurrences are correctly selected without the need to remove any code.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

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