Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming should not blindly replace occurrences in comments #57

Closed
anthonyvdotbe opened this issue Oct 29, 2023 · 2 comments
Closed

Renaming should not blindly replace occurrences in comments #57

anthonyvdotbe opened this issue Oct 29, 2023 · 2 comments
Labels
Apache-Netbeans enhancement New feature or request
Milestone

Comments

@anthonyvdotbe
Copy link
Contributor

Consider the following code:

import java.io.ByteArrayInputStream;
import java.io.IOException;

/**
 * In is common in English text.
 */
class Test {

    void run() throws IOException {
        try(var in = new ByteArrayInputStream(new byte[0])) {
            in.read();
        }
    }

}

Now if I rename the in variable in the try statement, the in in the class' Javadoc is also renamed. I can see how updating comments as well can be useful, but then the extension should figure out which occurrences refer to the replaced variable and which don't (which, in the general case, would be extremely hard to determine). For example in this case, I'm renaming a local variable, so I'd never refer to it in the class' Javadoc.

@Achal1607 Achal1607 added the enhancement New feature or request label Oct 30, 2023
@jcsahnwaldt
Copy link

I ran into this as well, but only occurrences in the comment on the current method were affected. My workaround: temporarily detach the Javadoc comment from the method by inserting a field declaration, rename the variable, remove the dummy field.

/**
 * Method comment, containing the word "name".
 */
int dummy;

void func() {
  int name = 0;  // now I can rename `name` without affecting the word in the comment.
}

@Achal1607
Copy link
Member

Merged

@Achal1607 Achal1607 added this to the JVSC 23.0.0 milestone Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apache-Netbeans enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants