Skip to content

Commit 5502e2b

Browse files
Comment the new core functions.
1 parent 01deef4 commit 5502e2b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/compiler/emitter.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4818,14 +4818,35 @@ var __param = this.__param || function(index, decorator) { return function (targ
48184818
emitLeadingComments(node.endOfFileToken);
48194819
}
48204820

4821+
/**
4822+
* The standard function to emit on any Node.
4823+
* This will take care of leading/trailing comments, and sourcemaps if applicable.
4824+
*/
48214825
function emit(node: Node, allowGeneratedIdentifiers?: boolean): void {
48224826
emitNodeWorker(node, /*shouldEmitSourceMap*/ true, allowGeneratedIdentifiers);
48234827
}
48244828

4829+
/**
4830+
* A function to be called in the case where sourcemaps should not be tracked for a single node.
4831+
* This will still take care of leading/trailing comments.
4832+
*
4833+
* Note, however, that sourcemap tracking may resume for child nodes within the given
4834+
* node depending on the specifics of how the given node will be emitted.
4835+
*
4836+
* For instance, if this function is called with the node 'a + b', then we will not track
4837+
* the sourcemap for 'a + b' itself, but if 'emit' is called instead for nodes 'a' and 'b',
4838+
* then both 'a' and 'b' will have sourcemaps recorded if appropriate.
4839+
*/
48254840
function emitNodeWithoutSourceMap(node: Node, allowGeneratedIdentifiers?: boolean): void {
48264841
emitNodeWorker(node, /*shouldEmitSourceMap*/ false, allowGeneratedIdentifiers);
48274842
}
48284843

4844+
/**
4845+
* Do not call this function directly.
4846+
*
4847+
* This function acts as a common path to 'emit' and 'emitNodeWithoutSourceMap'
4848+
* that is aware of ordering between comments and sourcemap spans.
4849+
*/
48294850
function emitNodeWorker(node: Node, shouldEmitSourceMap: boolean, allowGeneratedIdentifiers?: boolean): void {
48304851
if (!node) {
48314852
return;

0 commit comments

Comments
 (0)