-
Notifications
You must be signed in to change notification settings - Fork 917
[GITHUB-9056] Using sharp(er) classpath when rename refactoring. #9069
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
base: master
Are you sure you want to change the base?
Conversation
|
can confirm that this fixes the issue, I could rename the (heavily used) utility method with all projects open. |
| switch (p) { | ||
| case PRECHECK: | ||
| case FASTCHECKPARAMETERS: | ||
| return JavaSource.forFileObject(docTreePathHandle != null? docTreePathHandle.getTreePathHandle().getFileObject() | ||
| : treePathHandle.getFileObject()); | ||
| case PREPARE: | ||
| case CHECKPARAMETERS: | ||
| if(treePathHandle != null && treePathHandle.getKind() == Tree.Kind.LABELED_STATEMENT) { | ||
| return JavaSource.forFileObject(treePathHandle.getFileObject()); | ||
| } | ||
| ClasspathInfo cpInfo = getClasspathInfo(refactoring); | ||
| JavaSource source = JavaSource.create(cpInfo, docTreePathHandle != null? docTreePathHandle.getTreePathHandle().getFileObject() | ||
| : treePathHandle.getFileObject()); | ||
| return source; | ||
|
|
||
| } | ||
| throw new IllegalStateException(); | ||
| return JavaSource.forFileObject(docTreePathHandle != null? docTreePathHandle.getTreePathHandle().getFileObject() | ||
| : treePathHandle.getFileObject()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i suppose this used to be an optimization to create a smaller CP for inline rename?
i tried to look through history and the switch slowly grew over time
emilianbold/netbeans-releases@0a558e4
emilianbold/netbeans-releases@f2d147e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I am not sure what was the idea. I see the label rename refactoring probably does not have tests, I'll see if there's a meaningful way to add some.
The Java refactoring is sometimes using class path (
ClasspathInfo) that is, to me, extremely weird. In the specific case of #9056, theClasspathInfoused to processGspIndenterdoes not in some cases contain thelexermodule, while thegroovy/groovy.gspdefinitely lists it as a dependency.The consequence of that is that there are compile-time errors in the file(s) with this broken class path. Sometimes, it may lead to "catastrophic" failures like:
https://bugs.openjdk.org/browse/JDK-8373094
but even if it does not, wrong class path is likely to lead to weird effects. Like, in the test for the PR,
testComplexRename1, insidemain.Main, not onlytest(Side)will be renamed, but alsotest(String)will be renamed with the current state, as the classpath when analyzingmain.maindoes not containside.The goal of this PR is to use class path that is more sensible for the rename refactoring.
^Add meaningful description above
Click to collapse/expand PR instructions
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
Please make sure (eg.
git log) that all commits have a valid name and email address for you in the Author field.If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.
PR approval and merge checklist:
If this PR targets the delivery branch: don't merge. (full wiki article)