Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For what it's worth, the following:</p> <pre><code>public class Foo; </code></pre> <p>Error: <code>Syntax error, insert "ClassBody" to complete ClassBodyDeclarations</code></p> <pre><code>public enum Foo; </code></pre> <p>Error: <code>Syntax error, insert "EnumBody" to complete ClassBodyDeclarations</code></p> <pre><code>public interface Foo; </code></pre> <p>Error <code>Syntax error, insert "InterfaceBody" to complete ClassBodyDeclarations</code></p> <p>Anyway, I think what happens is, in this <code> org.eclipse.jdt.internal.compiler.parser.Parser.consumeEnumConstantHeader()</code>, it tries to recover when it gets the parsing error with this code:</p> <pre><code>if(this.currentToken == TokenNameSEMICOLON) { RecoveredType currentType = currentRecoveryType(); if(currentType != null) { currentType.insideEnumConstantPart = false; } } </code></pre> <p>So it correctly figures out that we're not inside an enumeration, so we get an error like above, but it doesn't realize that we don't even know if it is an enumeration. <a href="http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/3.6.1/org.eclipse.jdt/core/3.6.1/org/eclipse/jdt/internal/compiler/parser/Parser.java#Parser.consumeEnumHeader%28%29" rel="noreferrer">You can look at the source here:</a></p> <p>In other words, it's probably a bug that the Eclipse team introduced when they added Enumerations, it's handled slightly differently than some of the other tokens, which causes it to be Recovered in a different way and therefore shows up in the compiler errors.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload