-
Notifications
You must be signed in to change notification settings - Fork 0
Src:Parsers
This base class defines the interface for parsers. Subclasses should
implement these methods.
Parse require statements and return a hash of module dependencies of the form:
{
"local.name": "path/to/module"
}
Return an array of class nodes. Be sure to include classes that are
assigned to variables, e.g. exports.MyClass = class MyClass
Return an array of function nodes.
Parses code written according to CommonJS specifications:
require("module")
exports.func = ->
This currently works with the following require
calls:
local_name = require("path/to/module")
or
local_name = require(__dirname + "/path/to/module")
Not yet tested
Parse require([], ->) and define([], ->)
Parse module = require("path/to/module")
Parse require = {}
Match the list of modules to the list of local variable names and add them to the dependencies object given.
Given a node of type 'Code', gathers the names of each of the function arguments and return them in an array.
Given a node of type 'Arr', gathers the module paths represented by each object in the array and returns them in an array.
This currently works with the following require
calls:
local_name = require("path/to/module")
local_name = require(__dirname + "/path/to/module")
The following require
object assignments:
require = {deps: ["path/to/module"]}
require = {deps: ["path/to/module"], callback: (module) ->}
And the following require and
define` calls:
require(["path/to/module"], (module) -> ...)
require({}, ["path/to/module"], (module) -> ...)
define(["path/to/module"], (module) -> ...)
define('', ["path/to/module"], (module) -> ...)