ternjs / tern

A JavaScript code analyzer for deep, cross-editor language support
https://ternjs.net/
MIT License
4.25k stars 378 forks source link

Is there any way to analyzed code in runtime? #1047

Open easyfrog opened 3 years ago

easyfrog commented 3 years ago

This is much useful to the EventEmitter. to analyzed the event name on fly.

generally the event name is a string. If there are dozens of events. Is difficult to remember the names of these events.

So, my idea is to dynamically bind the event name to a variable. It would be very pleasant if we could dynamically analyze the event name bound by this variable.

var signals = {
     events: {},    // to hold the event's names

     emit: function (name) {
           this.events[name] = name;    // bind to the events property

           ...

     }
}

// event emitter
signals.emit('my-event-name', param);

// register events with auto completions
signals.on(signals.events.[ could show all events binded ], ...