Skip to content

Renaming a variable leads to entire contents of the file editor being replaced with one word- Error #1974

Open

Description

@iamnotserious

I tried setting up an new project in my workspace and tried editing a JS file by refactoring (renaming) a variable which led to the entire contents of the file being replaced with just one word 'Error'. I would have to close the file and open it again to see its modified contents, which are correct.

What I've observed:

  1. I've observed that this only happens in a nested Gradle project which contains both Java and JavaScript files. I tried the same in a different project (not a Gradle project with sub-projects) and it worked without any issues.
  2. I created a new file in my project with just one small function with two lines and the same thing happened again.
  3. There are no unique errors reported in the 'Error Log' or 'Problems' view when comparing the two projects (one where the issue occurs and the other where it doesn't).
  4. I enabled printing language server logs to the 'Console' view and observed that there was no mention of words 'error' or 'parse' in the Console.
  5. I predicted it would be an issue with JSDT, so I downloaded Spring Tools Eclipse IDE which doesn't contain JSDT and I still get the same issue.

Any help would be appreciated.
Thank you for developing this project.

Activity

  1. changed the title [-]Renaming a variable leads to entire contents of the file being replaced with one word- Error[/-] [+]Renaming a variable leads to entire contents of the file editor being replaced with one word- Error[/+] on Nov 19, 2025
  2. mickaelistria commented on Nov 19, 2025

    @mickaelistria
    Contributor

    Can you please provide detailed minimal steps to reproduce from a fresh Eclipse workspace?

  3. iamnotserious commented on Nov 19, 2025

    @iamnotserious
    Author

    @mickaelistria

    1. Generate a sample Spring Boot project, lets call the directory 'demoAppOne'
    2. Create a copy of the entire project and name the directory 'demoAppTwo'
    3. Place both projects in a parent directory called 'NewGradleProjectSample'
    4. Create a settings.gradle file in the parent directory and remove the same in the two child directories
    5. Import the parent directory as a Gradle project in Eclipse IDE.
    6. Create a sample JS file in one of the two sub-projects (NewGradleProjectSample/demoAppOne/src/main/webapp/js/testFile.js)
    7. Make sure that sub-projects are recognized by right clicking the root directory and selecting Gradle -> Refresh Gradle Project.
    8. Try re-naming a variable in the JS file.
      I normally wouldn't create a Gradle project this way, just did the above steps for the sake of re-creating the issue.
      I've created a sample repo: https://github.com/iamnotserious/NewGradleProjectSample

    Please let me know if you want any more information.

  4. iamnotserious commented on Nov 21, 2025

    @iamnotserious
    Author

    Hi, was any one able to take a look at this? I'm using the latest version of MacOS.

  5. iamnotserious commented on Nov 22, 2025

    @iamnotserious
    Author

    One temporary workaround was to remove the project (delete, including the nested projects) from the workspace. Then delete files generated by Eclipse using the file explorer (.classpath, .settings/, .project and bin/). Now choose to import a new project with the option "Projects from the Folder or Archive" and select only one nested project folder to import. Build the classpath for the new project via Terminal using 'gradle eclipseClasspath'. Refresh the project in Eclipse. Now renaming variables in JS file works. TLDR: I would have to import each nested project as a separate project.

    I still don't know what causes the issue, if its a bug in a component of the IDE or something that I've done wrong.

  6. iamnotserious commented on Nov 27, 2025

    @iamnotserious
    Author

    Update: following this answer also seems to work: https://stackoverflow.com/a/45975110/1668384
    In the parent project's properties, I added a Resource Filter (Exclude All) that excluded each sub-project directory.

    This still appears to be a bug, I'd love for someone to clarify or explain what went wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions