본문 바로가기

개발/Eclipse

[이클립스] javascript 오류 해결법: An internal error occurred during: “Requesting JavaScript AST from selection”

출처:http://stackoverflow.com/questions/13934796/an-internal-error-occurred-during-requesting-javascript-ast-from-selection

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.

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

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

    return fn(x);«error»

    return (fn(x));«error»

    return new fn(x);«ok»

    return xsometimes»

    return ""error» 

    return x+"x"error» 

    return this.xerror»

    return fn(
        x);«error»

    return new fn(
        x);«ok»

    returnerror»  
};
  • «» — 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:

'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?

share|improve this question
 
Interesting phenomenon, but what's your question? –  Bergi Dec 18 '12 at 14:48
 
@Bergi When I'm trying to edit a JS file, my eclipse starts poping up with some error note regularly. I'm unable to write any thing. The moment i place the cursor, at the end of line, it throws the popup. –  Swatantra K Dec 19 '12 at 5:00
 

Simplest solution:

  • Turn off Toggle Mark Occurrences (Alt-Shift-O or 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.

Official solution:

share|improve this answer
 
Just for completeness' sake, with the Mac version (I'm on Eclipse Helios) the shortcut to Toggle Mark Occurrences is <kbd>ALT</kbd>+<kbd>CMD</kbd>+<kbd>O</kbd> (the letter O, not the number zero). – pille May 12 at 7:27 
 
Altough this is the correct answer to eliminate the bug, there is a topic here And the accepted answer worth reading –  azizunsal Jul 8 at 7:21