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.
Summary: | Refactoring doesn't work if initiated on function invocation statement | ||
---|---|---|---|
Product: | javascript | Reporter: | Martin Schovanek <mschovanek> |
Component: | Refactoring | Assignee: | Petr Pisl <ppisl> |
Status: | VERIFIED FIXED | ||
Severity: | blocker | CC: | bht, mmirilovic, pjiricka, vriha |
Priority: | P2 | ||
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
Martin Schovanek
2009-05-28 17:12:53 UTC
This is my comment from issue #166032 relevant to this problem: I looked in the JsRenameHandler and it treats the function references as variables, which is of course wrong. This seems to be poorly implemented anyway, just add to your example 'var hello;' and see what happens. The function reference hello(); is colored as a variable (green in the default scheme). When the rename refactoring is initiated either on var hello; it will rename just the variable declaration. If it's initiated on the function declaration it will rename both the function declaration and the function call. If it's initiated on the function call, it will again rename only the variable declaration. This all was tested in Nb6.5 and I assume 6.7 behaves the same. This is not stopper for 6.7. The problem is here from the very beginning as Vita found out. Vita/Marek ... thanks for evaluation, I removed this issue from list of potential FSC stoppers. Petre P, can you please look into this? Thanks. I can confirm what Vita wrote in May that function reference is treated as a variable. The true is that the function name in JavaScript is a variable. So the function declaration function hello() { return "hello from function"; } end var hello = function () { return "hello from function"; } is almost identical. In both cases you can execute the function hello(). In both cases you can also print tha variable hello, which contains the function declaration. The text in such case has only difference that the fist function declaration contains the name of the function, the second one not. After this you can assign to the variable static text and from this time it's not function anymore until you assign into the variable new function. Example: function hello () { // Is exactly same like var hello = function hello() {... return "Hello from function"; // or you can also write var hello =function () {... } // output: alert(hello); // function hello() { // return "Hello from function"; // } alert(hello()); // Hello from function hello = "Hello from field"; alert (hello); // Hello from field alert(hello()); // Runtime error. The hello is not a function The mark occurences find in this example shows all occurences of hello variable, but it's done in the way, tha it marks all nodes, which have text eguel to "hello". Yes the refactoring functionality can do the same, but this approach doesn't take care about scopes. So if there will be function declaration function hello (hello) { return hello; } and you place cursor on a hello variable outside the function, then all hello are marked in the script inluding hello parameter of the function, which is also wrong. The hello parameter is a variable in different scope and shouldn't be marked. So if we will do the fix in the way how the mark occurences done, then the ide can offer many unwanted things. So this is not also solution. I'm not sure how to fix it now, but I'm afraid that there has to be rewritten the variable visitor and add some functionality for scopes. I don't think that this is possible to fix in 6.9 time scope. The release was too short and if there will not be someone, who works on javascript fulltime, then this kind of bug is not possible to fix, because the AST has to be rewritten. Waiver approved for NB 6.9. Waiver request for >48 hours -> switch to waiver http://wiki.netbeans.org/WaiverProcess Also requesting waiver for 7.0.1. Approved. We are preparing rewriting the java script support. It's basically not possible to fix in the current infrastructure, but I don't want to close this issue to keep it for the next version of JS support. So downgrading to P3. Works correctly in the new JS support, that should be available publicly in NB 7.2.next The original report works in the new JS editor that is available as a part of NetBeans 7.3 |