jsctags icon indicating copy to clipboard operation
jsctags copied to clipboard

No tags for angular modules

Open algorithmcardboard opened this issue 11 years ago • 6 comments
trafficstars

I have a js file that defines angularjs controllers, directives. When I run jsctags for that file it always outputs empty array.

var app = angular.module('TesetModule', ['LocalStorageModule']);

app.config(["$httpProvider", function(provider) {
  "use strict";
  provider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content');
  provider.responseInterceptors.push('authenticationInterceptor');
}]);

app.run(["$rootScope", "$window", function($rootScope, $window){
  $rootScope.saluteUser = function (){
    if($window.gon.f_n){
      return "Hi "+$window.gon.f_n;
    }
    return "Hi";
  };
}]);

From my terminal:

$ jsctags app.js
[]

Is this expected?

algorithmcardboard avatar Apr 18 '14 07:04 algorithmcardboard

As far as I can tell, that's tern's (the underlying parser) fault.

srathbun avatar Jun 12 '14 19:06 srathbun

Is tern still the culprit?

faceleg avatar Sep 24 '15 05:09 faceleg

I'm having the same issue. Any suggestion to solve it?

lvarayut avatar Oct 11 '15 06:10 lvarayut

Someone needs to determine whether it is tern or this module that is causing this, then submit a PR to solve whatever issue it is.

faceleg avatar Oct 11 '15 19:10 faceleg

Hi, I've added the source code from the first comment to angular-test.js and run tern's condense ([email protected]) command (which outputs code structure in JSON) as node_modules/tern/bin/condense --plugin angular angular-test.js:

{
  "!name": "angular-test.js",
  "!define": {
    "!ng": {
      "TesetModule": "app"
    }
  },
  "app": {
    "!proto": "angular.Module.prototype",
    "!span": "4[0:4]-7[0:7]",
    "!data": {
      "includes": [
        "LocalStorageModule"
      ]
    }
  }
}

So I think tern "understands" angular, but jsctags doesn't use/interpret tern's output.

herrernst avatar Oct 13 '15 08:10 herrernst

Excellent! One step closer - now we wait until someone has time / will to submit a PR

faceleg avatar Oct 13 '15 08:10 faceleg