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

Organize imports adding default StringTemplate imports #2159

Closed
danthe1st opened this issue Mar 14, 2024 · 5 comments
Closed

Organize imports adding default StringTemplate imports #2159

danthe1st opened this issue Mar 14, 2024 · 5 comments
Labels
StringTemplate Preview Feature to be removed

Comments

@danthe1st
Copy link

danthe1st commented Mar 14, 2024

If default String template processors (like STR) are used, the Organize imports option creates an unnecessary static import.

Steps to reproduce

package bug;

public class Bug {
	public static void main(String[] args) {
		System.out.println(STR."");
	}
}
  • Save the class
  • Execute the Action Organize Imports

expected behavior

The source file doesn't change

actual behavior

A new line is added before the class:

import static java.lang.StringTemplate.STR;

Full class after Organize Imports:

package bug;

import static java.lang.StringTemplate.STR;
[installationDetails.txt](https://github.com/eclipse-jdt/eclipse.jdt.core/files/14603964/installationDetails.txt)

public class Bug {
	public static void main(String[] args) {
		System.out.println(STR."");
	}
}

System details

I am using Ubuntu 23.10 x86_64
Configuration tab of the Installation Details

@jukzi
Copy link
Contributor

jukzi commented Apr 17, 2024

  • Create a new project with Java 21

did you mean Java 22? STR is a preview feature of 22

@danthe1st
Copy link
Author

danthe1st commented Apr 17, 2024

@jukzi It was there in 21 (JEP here) and for me, it happens with Java 21 (In fact, I don't even have the Java 22 support plugin installed).
However, I don't know how important that is now that String templates will likely be removed in Java 23 (already integrated).

@jukzi
Copy link
Contributor

jukzi commented Apr 18, 2024

note that Stringtemplates will be removed from ecj anyway #2353

@danthe1st
Copy link
Author

danthe1st commented Apr 18, 2024

Yeah when creating this issue, this looked different. I guess this could be closed when string templates are removed from EJC.

@jukzi jukzi added the StringTemplate Preview Feature to be removed label Apr 18, 2024
@danthe1st
Copy link
Author

See the above comment. Closing because string templates are removed from the JDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
StringTemplate Preview Feature to be removed
Projects
None yet
Development

No branches or pull requests

2 participants