Open kohlschuetter opened 1 month ago
@kohlschuetter we need a reproducer. According to the stacktrace it is somehow related to a java enum without body declaration. Unclear how to reproduce that.
I'm pretty sure I was editing an enum class around that time.
The code has evolved since then, but I was just able to get another error message while editing such a class, but not reliably.
I believe these messages are not very helpful because they refer to code that's currently being edited, indicating some kind of race condition.
Of course, while editing code, any syntax error can occur. I think editing code in Eclipse IDE should not cause such drastic error messages being logged.
java.lang.IllegalArgumentException
at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:3483)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1875)
at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:428)
at org.eclipse.jdt.core.dom.ASTConverter.convertToEnumDeclaration(ASTConverter.java:3846)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:3482)
at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:213)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:3567)
at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1595)
at org.eclipse.jdt.core.dom.AST.convertCompilationUnit(AST.java:644)
at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:194)
at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:245)
at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:585)
at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent(CompilationUnit.java:1137)
at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:166)
at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:92)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:740)
at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:805)
at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1311)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:132)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:94)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:91)
at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:158)
at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:94)
at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:107)
at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:78)
at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:207)
Exception occurred during compilation unit conversion:
----------------------------------- SOURCE BEGIN -------------------------------------
package com.kohlschutter.jacline.lib.coding;
import java.util.Arrays;
import com.kohlschutter.annotations.compiletime.SuppressFBWarnings;
import jsinterop.annotations.JsType;
/**
* An information message, warning or error that may be occur upon coding or decoding.
*
* @author Christian Kohlschütter
*/
@JsType
public class CodingAdvisory {
private final CodingAdvisoryLevel level;
private final String[] keys;
private final String reason;
private static final String[] NO_KEYS = new String[0];
public CodingAdvisory(CodingAdvisoryLevel level, String reason, String... keys) {
this.level = level;
this.keys = keys.length == 0 ? NO_KEYS : Arrays.copyOf(keys, keys.length);
this.reason = reason;
}
public CodingAdvisoryLevel getLevel() {
return level;
}
@SuppressFBWarnings("EI_EXPOSE_REP")
public String[] getKeys() {
return keys;
}
public String getReason() {
return reason;
}
@JsType
public enum CodingAdvisoryLevel {
INFO("yo"), WARNING, ERROR;
("")
CodingAdvisoryLevel(String string) {
// TODO Auto-generated constructor stub
}
}
}
----------------------------------- SOURCE END -------------------------------------
(Note the stray ("")
line near the end, this was Eclipse's doing; it should actually be after WARNING
).
I just used cmd-1 to create a corresponding constructor after specifying the parameter (yo
).
Maven/m2e project: https://github.com/kohlschutter/jacline/tree/main/jacline-lib-common
Even on code that has syntax errors the parser should be able to clearly state the syntax error instead of throwing internal exception. Can you please boil down the example to a minimal self-contained reproducer?
@jukzi I'm having a hard time doing that, as this doesn't even always reproduce with the code above.
Seen in the Error log
once as "Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui"." another one as "Error in JDT Core during reconcile"