yoshizow / global-pygments-plugin

[DEPRECATED] Pygments Plug-in Parser for GNU GLOBAL
Other
66 stars 16 forks source link

Javascript member functions need the "class" name prepended #5

Closed fakedrake closed 7 years ago

fakedrake commented 9 years ago

I try to use emacs ggtags with javascript. The line I was trying to jump from is this:

   this.conn.writeRaw(buffer, function() {

This is what ggtags runs on the background:

   $ gtags   
   $ global -v --result=grep --color=always --path-style=shorter writeRaw                
   object not found (using '/Users/drninjabatman/Projects/Codebendercc/js-stk500/GTAGS')

Looked into the GTAGS file and made it work like this

   $ global -v --result=grep --color=always --path-style=shorter SerialConnection.writeRaw
   serial.js:150:SerialConnection.prototype.writeRaw = function(msg, callback) {
   serial2.js:191:SerialConnection.prototype.writeRaw = function(msg, callback) {
   2 objects located (using '/Users/drninjabatman/Projects/Codebendercc/js-stk500/GTAGS').

But that's not very useful since ggtags can't know that this.conn is of type SerialConnection. You think there is a way to have pygments register only the method name as a GTAGS entry?

yoshizow commented 9 years ago

Symbols in GTAGS are actually generated by ctags. (global-pygments-plugin internally calls ctags.) By default ctags seems to generate 'SerialConnection' and 'writeRaw' symbols separately, but ctags can change its parsing behavior by configuration files. Could you check if you have any special configuration on your ctags?

fakedrake commented 9 years ago

Never really got into ctags too much. I dont have a ~/.ctags/ if that answers the question...

yoshizow commented 9 years ago

@fakedrake, Could you run ctags on your source code and check what symbol ctags generate?

$ ctags *.js
$ grep writeRaw tags
writeRaw    serial.js   /^  SerialConnection.prototype.writeRaw = function(msg, callback) {$/;" m   class:SerialConnection
writeRaw    serial2.js  /^  SerialConnection.prototype.writeRaw = function(msg, callback) {$/;" m   class:SerialConnection

Maybe depending on some situation ctags generate symbols like 'SerialConnection.writeRaw'.

yoshizow commented 9 years ago

@fakedrake, ctags-5.8 seems to have some problem with JavaScript parser. ctags HEAD will work.

$ ctags-5.8 *.js
$ grep writeRaw tags
SerialConnection.writeRaw   serial.js   /^  SerialConnection.prototype.writeRaw = function(msg, callback) {$/;" m
SerialConnection.writeRaw   serial2.js  /^  SerialConnection.prototype.writeRaw = function(msg, callback) {$/;" m

$ ctags-HEAD *.js
$ grep writeRaw tags
writeRaw    serial.js   /^  SerialConnection.prototype.writeRaw = function(msg, callback) {$/;" m   class:SerialConnection
writeRaw    serial2.js  /^  SerialConnection.prototype.writeRaw = function(msg, callback) {$/;" m   class:SerialConnection