语法错误,插入“EnumBody”完成EnumDeclaration [英] Syntax error , insert "EnumBody" to complete EnumDeclaration

查看:2481
本文介绍了语法错误,插入“EnumBody”完成EnumDeclaration的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编码的中间,并且意外地将以下代码行放在我们声明实例变量的类的部分。但我检查,它给任何地方任何地方,我的意思是在一个静态块,内部构造函数,任何类方法内的相同的错误。除了 private; 被放置为类的第一行
语法错误,插入EnumBody完成ClassBodyDeclarations (由@ chaitanya10在下面的评论中写下,并且在我的工作空间上由我验证)当我们将鼠标悬停在它上面时,eclipse工具提示中的错误。



我明白有错误。

但是当我将光标悬停在错误上时,我不明白错误信息。这个消息的意思是什么?



为什么它期待 EnumBody



以下是截图。



解决方案

为了真正的解释,有人需要做语法检查的详细分析,以及Eclipse Java编译器前端的语法错误恢复和报告组件。但是最有可能的解释是,您的异常语法错误使编译器的语法错误恢复代码混淆。



简而言之,它是一个较小的编译器错误)



开发人员很可能会知道这一点,但是没有修复它,因为:




  • 它不会经常发生,

  • 可能很难做更好的工作,而不会打破其他错误恢复案例,和/或

  • 任何更改将会打破许多编译器错误回归测试。


I was in middle of coding and accidentally put the following line of code at the part of class where we declare instance variables. but i checked and it gives the same error anywhere by anywhere i mean : inside a static block, inside constructor, inside any class method. except when private; is put as the first line of the class it gives Syntax error, insert "EnumBody" to complete ClassBodyDeclarations (as written by @chaitanya10 in comments below and also verified by me on my workspace) error in eclipse tooltip when we hover cursor over it.

I understand there is error.
but I dont understand the error message when i hover cursor over the error. what is the meaning of this message?

why does it expecting EnumBody ?

Below is the screenshot.

解决方案

For a real explanation, someone would need to do a detailed analysis of the syntax checking, and the syntax error recovery and reporting components of the Eclipse Java compiler front end. But the most likely explanation is that your "unusual" syntax error has "confused" the compiler's syntax error recovery code.

In short it is a minor compiler bug (or feature).

It is likely that the developers know about this, but have refrained from fixing it because:

  • it doesn't happen often,
  • it might be hard to do a better job ... without breaking some other error recovery cases, and / or
  • any change would break a number of compiler error regression tests.

这篇关于语法错误,插入“EnumBody”完成EnumDeclaration的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆