language-javascript-semantic icon indicating copy to clipboard operation
language-javascript-semantic copied to clipboard

Scope analysis

Open ForbesLindesay opened this issue 11 years ago • 2 comments
trafficstars

It would be great if the same identifier got a different colour if it was declared in a different scope. e.g.

function read(path) {
}
function write(path) {
}

Those two path variables refer to different things.

ForbesLindesay avatar Jul 09 '14 10:07 ForbesLindesay

I agree, but this is unfortunately impossible with Acorn as it does not really support incremental parsing (I just hacked it so it "kind of" does).

p-e-w avatar Jul 11 '14 16:07 p-e-w

What about this case?

function hello() {
  this.state = {
    test: '.text'
  }
  
  this.state.test = 'i am a local variable'
  test = 'i am a global variable'
}

The word 'test' is highlighted in the same color in both cases but I'm guessing its a difficult thing to fix with the current implementation for the same reason stated above.

jessemc98 avatar Mar 02 '17 19:03 jessemc98