-
Notifications
You must be signed in to change notification settings - Fork 867
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
Refactor "Move Inner to Outer level" on record drops the record details #7044
Comments
Working on tests. Tests first. Then I might be able to resolve the issue, so answer to 'willing to submit a pull request is maybe' |
Further investigation revealed the following. After adding two times RECORD as case label in file My tests now produces
from the following original inner/outer class text:
. As can be seen:
So I am stuck with finding how information from the AST parsetree (classtree) is written out as java code. A simpler test with a record within a record shows that outer record is properly generated, but the inner record
It might have to do with Templates, but I have no idea where I can find them. |
see issue apache#7044 for exact problem. Start with adding tests. Introduced RECORD and RECORD_COMPONENT case labels in multiple places. Deal with method params for the record header in InnerOuterTransformer. The given way of printing the 'method parameters' for the record header include 'private final', producing illegal java code. The solution found might not be the moset elegant, but since the tree modifications will not persist into any real source code, it is acceptable. The solution strips `private` and `final` from the VARIABLE trees. Delete file threw and unnecessary exception where a simple null test suffices.
Dropped earlier pull request and created a new one based on a branch: issue7044. |
Apache NetBeans version
Apache NetBeans 20
What happened
When you have an inner record like so;
and for some reason you want it to be an outer class in its own file, then
refactor Move Inner to Outer level, then the result in the that file is
dropping all record details.
Language / Project Type / NetBeans Component
java editor
How to reproduce
make class as above with inner record and apply refactoring Move Inner to.
The resulting class is no longer a record, the record component parameters including parenthesis are dropped,
but the import (LocalDate) is handed over, but is useless because of the stripping.
Did this work correctly in an earlier version?
No / Don't know
Operating System
ubuntu 24.04, Windows 11
JDK
java 21, Java 17 at least
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
occurs always.
Are you willing to submit a pull request?
Yes, I am at it, but stuck on the steps from parsetree to java code and possibly templates.
The text was updated successfully, but these errors were encountered: