atom / symbols-view

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

Methods called 'save' or starting with 'save' are not been found #130

Closed rogeriotaques closed 3 years ago

rogeriotaques commented 8 years ago

Whenever I have any method/function called save, or which name starts by save, I can't find it using the cmd-r command. I am just able to find it using the default 'search' feature.

mshenfield commented 8 years ago

I'm able to add methods called save or starting with save in a CoffeeScript project and find them using symbols-view:go-to-declaration, symbols-view:toggle-project-symbols, and symbols-view:toggle-file-view. I'm running

MacOS 10.11.1 Atom 1.2.4 symbols-view 0.110.1

Could you provide information about your development environment? Operating system, Atom version, symbols-view version, programming language, and a code snippet to recreate the issue if possible?

rogeriotaques commented 8 years ago

MacOS 10.10.5 Atom 1.2.4 Symbols-view 0.110.0 Language PHP, Javascript

Screenshot:

Screenshot

Code snippet:

public function save (array $data = array(), $id = NULL) {
   // logic goes here ...

   $error = $this->db->error();

   if (is_array($error) && $error['code'] > 0) {
      throw new Exception("Impossible to save.", 1);
   }

   return $id;
} // save
mshenfield commented 8 years ago

It looks like this is actually a duplicate of #103. If you remove the array default function arguments, e.g.

public function save (array $data, $id = NULL) {

symbols-view is able to find it using symbols-view:toggle-file-view.

There are two issues at play. Underneath the covers Atom uses ctags to generate file-level symbols, which ships under symbols-view's vendor folder. It seems like there are several issues with PHP parsing for this version of ctags, but it won't be fixed because the SourceForce ctags is no longer actively maintained. These issues include incorrectly identifying default function parameters as free variables.

The second is that symbols-view only allows 1 symbol definition per line inside of symbols-view:toggle-file-symbols https://github.com/atom/symbols-view/blob/v0.110.1/lib/tag-generator.coffee#L76. In your example, array $data = array() is being parsed first, preventing save from being included in the tags list.

For an immediate fix, you can try installing universal-ctags, an actively developed fork of ctags that fixes many of the PHP issues. The installation instructions for OSX are available here. For the commands involving a user generated tag file (everything but symbols-view:toggle-file-view) this will now allow you to correctly navigate to methods like save. For symbols-view:toggle-file-view, assuming you now have universal-ctags installed at /usr/local/bin/ctags, running the following will symlink the ctags symbols-view uses internally for that function to universal-ctags.

cp /Applications/Atom.app/Contents/Resources/app.asar.unpacked/node_modules/symbols-view/vendor/ctags-darwin /Applications/Atom.app/Contents/Resources/app.asar.unpacked/node_modules/symbols-view/vendor/exuberant-ctags-darwin

ln -s -f /usr/local/bin/ctags /Applications/Atom.app/Contents/Resources/app.asar.unpacked/node_modules/symbols-view/vendor/ctags-darwin

and if you want to go back to normal

mv -f /Applications/Atom.app/Contents/Resources/app.asar.unpacked/node_modules/symbols-view/vendor/exuberant-ctags-darwin /Applications/Atom.app/Contents/Resources/app.asar.unpacked/node_modules/symbols-view/vendor/ctags-darwin