编辑 Javascript 时不断弹出 Eclipse 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11334026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 05:28:25  来源:igfitidea点击:

Eclipse error constantly pops up while editing Javascript

javascripteclipse

提问by BishopZ

I am working on relatively small (100-300 lines) Javascript files in Eclipse and periodically it gets really upset about some piece of code and pops up this error every time I place the cursor on that line. The error is:

我正在 Eclipse 中处理相对较小(100-300 行)的 Javascript 文件,并且每次我将光标放在该行上时,它都会对某些代码感到非常不安,并弹出此错误。错误是:

'Requesting JavaScript AST from Selection' has encountered a problem. 
An internal error occured during "Requesting JavaScript AST from selection". 
java.lang.NullPointerException

While I am converting this:

当我转换这个时:

if(p){
    // enter code here
} else { return false; }

into this:

进入这个:

if(p){
    // enter code here
} return false; 

the error pops up several times. Each time it stops my typing and requires me to click the okay button. I then type two more characters and the error appears again.

错误弹出几次。每次它停止我的打字并要求我单击“确定”按钮时。然后我再输入两个字符,错误再次出现。

Any ideas how to either prevent the error or disable whatever Javascript AST is?

任何想法如何防止错误或禁用任何 Javascript AST?

This is on Eclipse Java EE, Indigo Service Release 2. It is almost a flat install, only two plugins installed and neither are for SVN and have nothing to do with Javascript.

这是在 Eclipse Java EE,Indigo Service Release 2 上。它几乎是一个平面安装,只安装了两个插件,而且都不是针对 SVN 的,也与 Javascript 无关。

采纳答案by BishopZ

At first I thought this was just a trick, but it is working so well, I had to post it as an actual answer.

起初我以为这只是一个技巧,但效果很好,我不得不将其作为实际答案发布。

When the error window pops up, don't close it. Just drag it off to the side, focus back on the main window and keep editing.

当错误窗口弹出时,不要关闭它。只需将其拖到一边,重新关注主窗口并继续编辑。

When the error happens again Eclipse doesn't change the focus back to the error message. Focus stays in the editing window and you can continue to edit the document.

当错误再次发生时,Eclipse 不会将焦点更改回错误消息。焦点停留在编辑窗口中,您可以继续编辑文档。

回答by Bob Kerns

An even better answer (from the bug report linked by Cliff Ribaudo, comment #10 and others):

一个更好的答案(来自 Cliff Ribaudo 链接的错误报告,评论 #10 和其他人):

Turn off Toggle Mark Occurrences (Alt-Shift-O or the paintbrush icon on the toolbar, which handily, will show you your current state).

关闭 Toggle Mark Occurrences(Alt-Shift-O 或工具栏上的画笔图标,可以方便地显示您的当前状态)。

Thanks Cliff!

谢谢悬崖!

Edited:

编辑:

Via Preferences

通过首选项

回答by Cliff Ribaudo

Likely an eclipse bug. See this thread:

可能是日食错误。看到这个线程:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=359005

https://bugs.eclipse.org/bugs/show_bug.cgi?id=359005

There is a patch posted there which you might try.

那里发布了一个补丁,您可以尝试一下。

回答by Towler

Ironically, the solution for me was to install another plugin. After I installed VJET, and set up my JavaScript project to be a VJET-enabled project, the issue went away.

具有讽刺意味的是,我的解决方案是安装另一个插件。在我安装VJET并将我的 JavaScript 项目设置为支持 VJET 的项目后,问题就消失了。

回答by Mayank Raipure

just replace the xml in your .project file (which lies in home directory of your eclipse workspace .

只需替换 .project 文件中的 xml(位于 eclipse 工作区的主目录中。

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>your Project Name</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
    </buildSpec>
    <natures>
    </natures>
</projectDescription>

回答by John P

I've been getting this error lately. I am writing Groovy scripts. The fix for me was to update the Groovy plugin.

我最近一直收到这个错误。我正在编写 Groovy 脚本。我的解决方法是更新 Groovy 插件。

回答by Mr. Noddy

I was getting same error with gc overhead limit exceededdescription in details section of error. To take action on it I have added following in configuration and issue resolved.

我在错误gc overhead limit exceeded详细信息部分的描述中遇到了同样的错误。为了对此采取行动,我在配置中添加了以下内容并解决了问题。

Xms512m
Xmx2048m

Ref: GC overhead limit exceeded problem

参考:GC 开销限制超出问题

In short, for me it was eclipse memory problem.

简而言之,对我来说这是eclipse内存问题。