atom / symbols-view

Jump to symbols in Atom
MIT License
163 stars 114 forks source link

Cannot find and jump to the JavaScript methods in some cases #215

Open neiloox opened 7 years ago

neiloox commented 7 years ago

Prerequisites

Description

In the cases below, Atom cannot find and jump to the correct JavaScript methods by Command+R:

  1. Cannot find and jump to the methods used "allman" style and defined in a JavaScript class.
  2. Cannot find and jump to the methods defined by arrow function.
  3. Cannot find and jump to the methods defined by "const", but identify the "const" keyword as a method.
  4. Can find and jump to the methods defined by "let", but identify the "let" keyword as a method either.

Steps to Reproduce

Save the code below as a *.js file, and use Command+R.

class Test{
    haha() {
        console.log('haha');
    }

    case1()
    {
        console.log('Case 3: used "allman" style and defined in a class');
    }
}

var fn = function() {
    console.log('fn1');
};

var case2 = () => {
    console.log('Case 2: defined by arrow function');
};

const case3 = function() {
    console.log('Case 3: defined by "const"');
};

let case4 = function() {
    console.log('Case 4: defined by "let"');
};

Expected behavior:

All the cases in description can be found and jumped to the correct methods.

Actual behavior:

Case 1 to 4 are not found or not correct by Command+R. Actual Cases

Reproduces how often: Always.

Versions

Atom    : 1.15.0
Electron: 1.3.13
Chrome  : 52.0.2743.82
Node    : 6.5.0

apm  1.15.3
npm  3.10.5
node 4.4.5 x64
python 2.7.10
git 2.10.1

Additional Information

Nothing.

kevinschaich commented 7 years ago

+1 for me. No arrow functions are being detected at all.

Martinsos commented 6 years ago

Biggest problem for me is arrow functions, since in our project we use const foo = () => {} style to create functions.

I understand this might be harder to recognize since they are not really declared hm, stuff on the right of = could be anything, how hard is this for you to support? At least const there guarantees the value will not change, but still.

Maybe you could just pick all the top-level symbols, meaning all variables? However, I guess that would also become a problem if anonymized function is used to create closure for the whole file. Javascript is tricky hm!