-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
How could I disable static imports in the v55 output? #1152
Comments
We introduced static imports in Spoon 5.5 when you use the |
Can I have this behavior?
|
Not sure to understand. Without auto-import (
On the contrary, in auto-import mode, Spoon try to import types and static types if there is no name conflicts:
Do you spot an incorrect behaviour here? Could you create a unit test showing it? |
Thx for the explanation. I think you mean
while enabling auto imports. What I want is auto imports w/o static import w/ fully qualified class names on conflict. Here is a related discussion on stackoverflow: http://stackoverflow.com/a/2644534 One way is to produce all the fully qualified class names and press ctrl+shift+M to produce all the non-static imports, but it is kind of inefficient. Maybe I should stick with v52 --with-import at the moment. |
Reading again the produced output: package com.company;
import com.company.framework.Constants;
import static com.company.framework.Constants.READY;
import static java.lang.System.out;
public class Main {
public static void main(String[] args) throws Exception {
out.println(READY);
}
} shows that we need indeed improve the pretty print of Spoon with static imports. The constant
Is it for readability reason or is there another reason behind? |
Yes, it is for readability reason. The code base here was developed during the jdk1.4-1.6 era w/o static imports and should be kept that way. The transpiled code has to work on jdk1.6. There are a lot of constants like the following. com.company.framework.Module1Constants.READY = 0x1; // need fqcn on conflict
com.company.framework.Module1Constants.RUNNING = 0x2; // need fqcn on conflict
com.company.framework.Module2Constants.READY = 0x3; // short name ok
com.company.framework.Module2Constants.RUNNING = 0x4; // short name ok
com.company.framework.dept3.Module1Constants.READY = 0x5; // need fqcn on conflict
com.company.framework.dept3.Module1Constants.RUNNING = 0x6; // need fqcn on conflict When there are no conflicts, short names like I normally pick a handful of java files, put them in a temp directory, and run Spoon with jdk1.8 on the java files. I turn on But #774 mentioned that
|
Meanwhile, eclipse Ctrl+shift+M requires a human to pick from a list of candidates. I came to Spoon for automation. |
I found v53+ are producing static imports.
The text was updated successfully, but these errors were encountered: