期间发生内部错误:“从选择中请求 JavaScript AST”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13934796/
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 15:10:10  来源:igfitidea点击:

An internal error occurred during: "Requesting JavaScript AST from selection"

javascripteclipseide

提问by Swatantra Kumar

I'm facing unique error/alert-popup while editing JavaScript files in Eclipse and it pops up this error every time I place the cursor on that line.

在 Eclipse 中编辑 JavaScript 文件时,我遇到了独特的错误/警报弹出窗口,每次我将光标放在该行上时,它都会弹出此错误。

JS: NullPointerException when cursor is placed at the end of the line containing return statement.

JS: NullPointerException 当光标放在包含 return 语句的行的末尾时。

foo.bar = function(x) {
    if (xyz) {
      return fn(x);?error?
    }

    return fn(x);?error?

    return (fn(x));?error?

    return new fn(x);?ok?

    return x;?sometimes?

    return "";?error? 

    return x+"x";?error? 

    return this.x;?error?

    return fn(
        x);?error?

    return new fn(
        x);?ok?

    return;?error?  
};
  • ?? — cursor position
  • ?ok? — no error
  • ?error? — triggers error
  • ?sometimes? — I have code that never triggers an exception in that case, but I don't see a pattern.
  • ?? — 光标位置
  • ?好的?— 没有错误
  • ?错误?— 触发错误
  • ?有时?— 在这种情况下,我的代码永远不会触发异常,但我没有看到模式。

If cursor is at the end of the line of a return, this exception happens:

如果光标位于返回行的末尾,则会发生此异常:

An internal error occurred during: "Requesting JavaScript AST from selection".
java.lang.NullPointerException

The Eclipse error is:

Eclipse 错误是:

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

Is there a solution or workaround available to fix the problem?

是否有解决方案或解决方法可以解决该问题?

回答by Swatantra Kumar

Simplest solution:

最简单的解决方案:

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

    • It's just disabling the feature of highlighting other occurrences of whatever variable, etc you have your cursor on.
  • 关闭 Toggle Mark Occurrences(Alt- Shift-O或工具栏上的画笔图标,它会方便地显示您的当前状态)。

    • 它只是禁用突出显示任何变量的其他出现的功能,等等你有你的光标。

Official solution:

官方解决方案:

  • You can track the official bug here.

  • There is a patch posted herewhich you might try.

  • 您可以在此处跟踪官方错误。

  • 有发布补丁在这里,你可以尝试。

回答by Jyo Banerjee

Opening JavaScript files in text editor helps. You may like to change the default default file association for js files to Text Editor.

在文本编辑器中打开 JavaScript 文件会有所帮助。您可能希望将 js 文件的默认默认文件关联更改为文本编辑器。