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

Eclipse JDT 3.22.0 causes IndexOutOfBoundsException #204

Closed
funfried opened this issue Jun 29, 2020 · 1 comment
Closed

Eclipse JDT 3.22.0 causes IndexOutOfBoundsException #204

funfried opened this issue Jun 29, 2020 · 1 comment

Comments

@funfried
Copy link

funfried commented Jun 29, 2020

Hi,
I'm writing a NetBeans Plugin which adds external code formatters to the IDE (you can find it in externalcodeformatter_for_netbeans in my GitHub repositories). It supports the Eclipse Java Code Formatter (JDT) and the Spring Java Code Formatter amongst others. Since I changed my Eclipse dependencies to the newest versions (3.22.0) of Eclipse JDT, I get this exception when I try to format with the Spring code formatter

java.lang.IndexOutOfBoundsException: Index 13 out of bounds for length 13
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
	at java.base/java.util.Objects.checkIndex(Objects.java:373)
	at java.base/java.util.ArrayList.get(ArrayList.java:425)
	at io.spring.javaformat.formatter.eclipse.TokenManager.get(TokenManager.java:75)
	at io.spring.javaformat.formatter.eclipse.TokenManager.findIndex(TokenManager.java:168)
	at io.spring.javaformat.formatter.eclipse.SpacePreparator.handleToken(SpacePreparator.java:1098)
	at io.spring.javaformat.formatter.eclipse.SpacePreparator.visit(SpacePreparator.java:197)
	at org.eclipse.jdt.core.dom.EnumDeclaration.accept0(EnumDeclaration.java:253)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2971)
	at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:3042)
	at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:258)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2971)
	at io.spring.javaformat.formatter.eclipse.DefaultCodeFormatter.prepareSpaces(DefaultCodeFormatter.java:412)
	at io.spring.javaformat.formatter.eclipse.DefaultCodeFormatter.prepareFormattedCode(DefaultCodeFormatter.java:229)
	at io.spring.javaformat.formatter.eclipse.DefaultCodeFormatter.format(DefaultCodeFormatter.java:186)
	at io.spring.javaformat.formatter.Formatter.lambda$format$1(Formatter.java:129)
	at io.spring.javaformat.formatter.Formatter.nlsSafe(Formatter.java:149)
	at io.spring.javaformat.formatter.Formatter.format(Formatter.java:129)
	at io.spring.javaformat.formatter.Formatter.format(Formatter.java:124)

Maybe you could have a look into this?

Best regards,
Fabian

funfried added a commit to funfried/externalcodeformatter_for_netbeans that referenced this issue Jun 29, 2020
…ich switches to new line sometimes when it shouldn't and 3.22.0 seems to be incompatible with the current version of the Spring Java Code Formatter (0.0.22), see spring-io/spring-javaformat#204
@wilkinsona
Copy link
Contributor

Thanks for the report. This is a duplicate of #195.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants