Bug? B4J Rename To: - possible bug?

Discussion in 'B4J Bugs & Wishlist' started by Computersmith64, Nov 28, 2017.

  1. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    In v6.00 Beta 2, when I do a Find All References (F7) search, then type a new name into the Rename To box & hit Rename, I get a toast message pop up saying "Name already exists".

    In this particular case, I am porting a B4A app to B4J & have copied the Starter service to a code module & renamed it to "Startup". I am trying to rename all the references in my code from Starter to Startup - so I do an F7 search, but then run into this issue when I type "Startup" into the Rename To box & hit Rename. If I type something else (eg: "crap") into the Rename To box, it works fine.

    I thought it might be getting confused because of the code module name ("Startup"), however if I type in "Options" - which is also a code module name - it works fine.

    - Colin.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Can you reproduce it in a small project?
     
  3. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    Hi Erel - I have attached a project that shows the issue. If you highlight the "Starter" reference in the main form & press F7, then type "Startup" in the Rename To box & click the Rename button, you'll get the "Name already exists" error.

    - Colin.
     

    Attached Files:

  4. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    Fyi - as another test, I just added another module called "TestModule" & was able to rename "Starter" to "TestModule" (using the Rename To function) without problems - however then I added the var as Int variable to TestModule & tried again & got the error.

    - Colin.
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    It is expected that you cannot rename the variable to Startup as static code modules implicitly add a global variable with their name.

    I wasn't able to rename it to TestModule. Make sure that you added a static code module and not a class.
     
  6. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    I'm not sure I understand. I'm not trying to change the variables to match the module names, I'm trying to rename an incorrect module name reference

    I have a public variable called "var" in a code module called Startup & another public variable called "var" in a code module called TestModule.

    If I want to reference the variables from my Main code module I can use:
    Code:
    Startup.var
    TeatModule.var
    There is no problem doing this. However if I mis-type my references & make them:
    Code:
    Starter.var
    TestMod.var
    then try to change them to the correct module name references with the Rename To function, I get the "Name already exists" error. I can change them manually & they work fine.

    It's not a big deal, but it seems like a bug in the IDE to me & it's inconvenient because in a case where I have multiple references to variables in a code module that I have since renamed, I have to go through the code & change each one manually.

    - Colin.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    The rename feature doesn't allow you to rename the variable name to an existing name. This is by design.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice