Home Download Buy Blog Forum Support

GoTo Anything fails with jQuery js files.

GoTo Anything fails with jQuery js files.

Postby tux. on Wed Mar 06, 2013 12:39 pm

Try the following:

Write some jQuery code with AJAX requests, like this:

Code: Select all
function bild_loeschen(id) {
   var urldaten = {};
   urldaten['action'] = 'bild_loeschen';
   urldaten['id'] = id;
   
   $.post("index.php", urldaten,
      function (data) {
         $("#bild").html(data);
         bilderloader(oe_id);
      });
}


Open the GoTo Anything tool and type "@". It will show you the bild_loeschen() and the function (data) "functions". I am pretty sure this is not wanted.
Image
tux.
 
Posts: 96
Joined: Thu Apr 14, 2011 11:04 am

Re: GoTo Anything fails with jQuery js files.

Postby skuroda on Wed Mar 13, 2013 8:01 am

The symbol list is populated based on the syntax scope rules. By default, as JavaScript may have some additional scopes for symbol list, symbol list are populated with entries with the following scopes - entity.name.function, entity.name.type, meta.toc-list. So, it's more a limitation of the syntax highlighting, rather than of Sublime Text. You can play with the tmLanguage file to add the appropriate scope to that entry (though there isn't a name, which makes it a bit more tricky to "go to").

You can use "ctrl+shift+alt+p" (in windows) to view the scope under the cursor. Alternatively, you can use the ScopeHunter plugin.
skuroda
 
Posts: 674
Joined: Fri Oct 05, 2012 8:11 am

Re: GoTo Anything fails with jQuery js files.

Postby tux. on Wed Mar 13, 2013 8:10 am

skuroda wrote:So, it's more a limitation of the syntax highlighting, rather than of Sublime Text.


The editor is responsible for the highlighting, right?
Image
tux.
 
Posts: 96
Joined: Thu Apr 14, 2011 11:04 am

Re: GoTo Anything fails with jQuery js files.

Postby skuroda on Wed Mar 13, 2013 2:49 pm

I suppose I worded it wrong, this may not have gotten as much attention because it's just a syntax highlighting problem. I also misread the problem (which is why my post in your other thread probably seemed odd :)), I thought you said it wasn't appearing. You can edit the Symbol List Function.tmPreferences, and remove the source.js meta.function.js, but this would cause you to lose the "function" "prefix". So you would have to do a bit more work to get it to only list non anonymous functions.
skuroda
 
Posts: 674
Joined: Fri Oct 05, 2012 8:11 am

Re: GoTo Anything fails with jQuery js files.

Postby skuroda on Wed Mar 13, 2013 2:59 pm

Rather than removing that entry, you can try replacing that symbol list with

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>name</key>
   <string>Symbol List Function</string>
   <key>scope</key>
   <string>source.js meta.function.js, source.js meta.function.json.js</string>
   <key>settings</key>
   <dict>
      <key>showInSymbolList</key>
      <string>1</string>
        <key>symbolTransformation</key>
        <string>s/^function\s*\(.*\)//g</string>
   </dict>
   <key>uuid</key>
   <string>3CEA49B2-A5C5-405C-82E2-B8B668877C38</string>
</dict>
</plist>


Note this is minimally tested, but the regex matches the definition for the anonymous function. All I did was add the "symbolTransformation" entry.
skuroda
 
Posts: 674
Joined: Fri Oct 05, 2012 8:11 am

Re: GoTo Anything fails with jQuery js files.

Postby tux. on Wed Mar 13, 2013 6:23 pm

So it would only match anonymous functions then? Not quite what I wanted to achieve.
Image
tux.
 
Posts: 96
Joined: Thu Apr 14, 2011 11:04 am

Re: GoTo Anything fails with jQuery js files.

Postby skuroda on Wed Mar 13, 2013 11:22 pm

No it removes them,well technically it just replaces "function (foo)" with an empty string, which is subsequently ignored by the symbol list. The symbol transformation, as far as I understand it, modifies what will be displayed in the symbol list. The actual entries are defined by the scope. So in this case, anonymous functions are replaced with empty strings.

Image
skuroda
 
Posts: 674
Joined: Fri Oct 05, 2012 8:11 am

Re: GoTo Anything fails with jQuery js files.

Postby tux. on Wed Mar 13, 2013 11:51 pm

Ah - pretty much what I am looking for, thanks!

Where to store it so an update won't kill it?
Image
tux.
 
Posts: 96
Joined: Thu Apr 14, 2011 11:04 am

Re: GoTo Anything fails with jQuery js files.

Postby skuroda on Thu Mar 14, 2013 12:09 am

Ignore the built in package "JavaScript" and create your own, essentially a copy paste of the folder, with the changes you want to Symbol List Functions. Downside is if there are any updates to the package, you will have to do this again. This will work on (I believe) ST2 and ST3. I was hoping I could override the tmPreferences file in ST3, by creating it in the packages directory, similar to how you can override snippets. Unfortunately, this didn't work for me. Though I could have done something wrong, so you may want to try too. If it doesn't in fact work, perhaps it should be a feature request as that is the behavior I would expect.
skuroda
 
Posts: 674
Joined: Fri Oct 05, 2012 8:11 am

Re: GoTo Anything fails with jQuery js files.

Postby tux. on Thu Mar 14, 2013 12:27 am

I'd just guess as ST3 is still in beta, maybe this is already on the ToDo list.

Thank you, the fix works fine for what it should do. :)
Image
tux.
 
Posts: 96
Joined: Thu Apr 14, 2011 11:04 am


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 20 guests

cron