jsctags
jsctags copied to clipboard
jsctags generating tags incorrectly
I use npm installed jsctags globally.
when I run jsctags in terminal, I got this error:
Array.prototype.push called on null or undefined
/usr/local/lib/node_modules/jsctags/jsctags/ctags/writer.js:89
this.tags = this.tags.sort(sortfunc);
^
TypeError: Cannot read property 'sort' of undefined
at Object.exports.TagWriter.Trait.write (/usr/local/lib/node_modules/jsctags/jsctags/ctags/writer.js:89:30)
at Object.<anonymous> (/usr/local/lib/node_modules/jsctags/bin/jsctags.js:269:10)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
I searched around I find the there's issue already opened for this error: https://github.com/ramitos/jsctags/issues/12
So I make changes to the proper files according to the solution mentioned in the above issue and run jsctags in terminal again, jsctags -f - Players.view.js
, and below is the output:
It's not readable, so I open this file in vim using tagbar to show the tags on the right side:
here's the source code of Players.view.js
file I used for testing jsctags:
sap.ui.jsview("com.sj.redjoker.view.Players", { // this View file is called Address.view.js
getControllerName: function () {
'use strict';
var abc,
def,
ghi;
abc = 1;
def = 2;
ghi = 3;
function ABC(){
var ddd = function(){
}
}
return "com.sj.redjoker.view.Players"; // the Controller lives in Address.controller.js
},
createContent: function (oController) {
'use strict';
new sap.m.Dialog(this.createId('dlgplayermaintenance'), {
title: '{i18n>DT_NEWPLAYER}',
content: [
new sap.m.Input(this.createId('iptplayername'), {
placeholder: '{i18n>PH_ENTERNAME}',
value: '{name}'
})
],
beginButton: new sap.m.Button({
text: '{i18n>BT_OK}',
press: [oController.onOKPressed, oController]
}),
endButton: new sap.m.Button({
text: '{i18n>BT_CANCEL}',
press: [oController.onCancelPressed, oController]
})
});
return new sap.m.Page({
title: '{i18n>PT_PLAYERS}',
showNavButton: true,
navButtonPress: [oController.onNavButtonPressed, oController],
content: [
new sap.m.List(this.createId('listplayers'), {
swipeContent: new sap.m.Button({
text: '{i18n>BT_DELETE}',
type: sap.m.ButtonType.Reject,
press: [oController.onDeletePressed, oController]
}),
items: {
path: '/',
template: new sap.m.StandardListItem({
title: '{name}',
type: sap.m.ListType.Detail
})
},
itemPress: [oController.onItemPressed, oController]
})
],
footer: new sap.m.Toolbar({
content: [
new sap.m.ToolbarSpacer(),
new sap.m.Button({
icon: 'sap-icon://add',
press: [oController.onAddPlayer, oController]
})
]
})
});
}
});
I didn't have all the tags that were supposed to be generated either. Wonder if I was using it wrong.
I have a very similar problem. I have some files with several var fn = function fn() { }
and other things, and jsctags generates about three or four entries only.