bindSourceFile
Basically checks if the file.locals
is defined, if not it hands over to (a local function) bind
.
TIP: local functions are used heavily within the TypeScript compiler. A local function very likely uses variables from the parent function (captured by closure). In the case of (a local function within bindSourceFile
) it (or function it calls) will setup the symbolCount
and classifiableNames
among others, that are then stored on the returned SourceFile
.
bind
bindWorker
This function switches on node.kind
(of type SyntaxKind
) and delegates work to the appropriate bindFoo
function (also defined within binder.ts
). For example if the node
is a SourceFile
it calls (eventually and only if its an external file module) bindAnonymousDeclaration
bindFoo
functions
As you can see it is simply keeping the symbolCount
(a local to ) up to date and creating the symbol with the specified parameters.