Merge branch 'transforms' into transforms-merge

This commit is contained in:
Ron Buckton
2016-05-27 16:38:40 -07:00
31 changed files with 215 additions and 336 deletions
+2 -2
View File
@@ -86,9 +86,9 @@ namespace ts {
const binder = createBinder();
export function bindSourceFile(file: SourceFile, options: CompilerOptions) {
performance.mark("bindStart");
const bindStart = performance.mark();
binder(file, options);
performance.measure("bindTime", "bindStart");
performance.measure("bindTime", bindStart);
}
function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
+2 -2
View File
@@ -16512,11 +16512,11 @@ namespace ts {
}
function checkSourceFile(node: SourceFile) {
performance.mark("checkStart");
const checkStart = performance.mark();
checkSourceFileWorker(node);
performance.measure("checkTime", "checkStart");
performance.measure("checkTime", checkStart);
}
// Fully type check a source file and collect the relevant diagnostics.
+18 -23
View File
@@ -82,12 +82,9 @@ namespace ts {
function getLeadingComments(range: TextRange): CommentRange[];
function getLeadingComments(range: TextRange, contextNode: Node, ignoreNodeCallback: (contextNode: Node) => boolean, getTextRangeCallback: (contextNode: Node) => TextRange): CommentRange[];
function getLeadingComments(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (contextNode: Node) => boolean, getTextRangeCallback?: (contextNode: Node) => TextRange) {
let comments: CommentRange[] = [];
let ignored = false;
if (contextNode) {
range = getTextRangeCallback(contextNode) || range;
if (ignoreNodeCallback(contextNode)) {
ignored = true;
// If the node will not be emitted in JS, remove all the comments (normal,
// pinned and `///`) associated with the node, unless it is a triple slash
// comment at the top of the file.
@@ -101,16 +98,14 @@ namespace ts {
// The first `///` will NOT be removed while the second one will be removed
// even though both nodes will not be emitted.
if (range.pos === 0) {
comments = filter(getLeadingCommentsOfPosition(0), isTripleSlashComment);
return filter(getLeadingCommentsOfPosition(0), isTripleSlashComment);
}
return;
}
}
if (!ignored) {
comments = getLeadingCommentsOfPosition(range.pos);
}
return comments;
return getLeadingCommentsOfPosition(range.pos);
}
/**
@@ -277,42 +272,42 @@ namespace ts {
reset,
setSourceFile,
getLeadingComments(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (contextNode: Node) => boolean, getTextRangeCallback?: (contextNode: Node) => TextRange): CommentRange[] {
performance.mark("commentStart");
const commentStart = performance.mark();
const comments = getLeadingComments(range, contextNode, ignoreNodeCallback, getTextRangeCallback);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
return comments;
},
getTrailingComments(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (contextNode: Node) => boolean, getTextRangeCallback?: (contextNode: Node) => TextRange): CommentRange[] {
performance.mark("commentStart");
const commentStart = performance.mark();
const comments = getTrailingComments(range, contextNode, ignoreNodeCallback, getTextRangeCallback);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
return comments;
},
getTrailingCommentsOfPosition(pos: number): CommentRange[] {
performance.mark("commentStart");
const commentStart = performance.mark();
const comments = getTrailingCommentsOfPosition(pos);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
return comments;
},
emitLeadingComments(range: TextRange, comments: CommentRange[], contextNode?: Node, getTextRangeCallback?: (contextNode: Node) => TextRange): void {
performance.mark("commentStart");
const commentStart = performance.mark();
emitLeadingComments(range, comments, contextNode, getTextRangeCallback);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
},
emitTrailingComments(range: TextRange, comments: CommentRange[]): void {
performance.mark("commentStart");
const commentStart = performance.mark();
emitLeadingComments(range, comments);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
},
emitLeadingDetachedComments(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (contextNode: Node) => boolean): void {
performance.mark("commentStart");
const commentStart = performance.mark();
emitLeadingDetachedComments(range, contextNode, ignoreNodeCallback);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
},
emitTrailingDetachedComments(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (contextNode: Node) => boolean): void {
performance.mark("commentStart");
const commentStart = performance.mark();
emitTrailingDetachedComments(range, contextNode, ignoreNodeCallback);
performance.measure("commentTime", "commentStart");
performance.measure("commentTime", commentStart);
}
};
}
+48 -127
View File
@@ -1120,6 +1120,18 @@ namespace ts {
}
}
export function getEnvironmentVariable(name: string, host?: CompilerHost) {
if (host && host.getEnvironmentVariable) {
return host.getEnvironmentVariable(name);
}
if (sys && sys.getEnvironmentVariable) {
return sys.getEnvironmentVariable(name);
}
return "";
}
export function copyListRemovingItem<T>(item: T, list: T[]) {
const copiedList: T[] = [];
for (const e of list) {
@@ -1139,168 +1151,77 @@ namespace ts {
/** Performance measurements for the compiler. */
/*@internal*/
export namespace performance {
interface MarkData {
markName: string;
timestamp: number;
}
interface MeasureData {
measureName: string;
startMarkName: string;
endMarkName: string;
timestamp: number;
marksOffset: number;
}
export interface Measure {
name: string;
startTime: number;
duration: number;
}
const markTimestamps: Map<number> = {};
const markCounts: Map<number> = {};
const measureDurations: Map<number> = {};
let start = now();
let enabled = false;
/** Gets the current timer for performance measurements. */
export function now() {
return Date.now();
}
let counters: Map<number>;
let measures: Map<number>;
/**
* Adds a performance mark with the specified name.
* Increments a counter with the specified name.
*
* @param markName The name of the performance mark.
* @param counterName The name of the counter.
*/
export function mark(markName: string) {
if (enabled) {
markTimestamps[markName] = now();
markCounts[markName] = getCount(markName) + 1;
export function increment(counterName: string) {
if (counters) {
counters[counterName] = (getProperty(counters, counterName) || 0) + 1;
}
}
/**
* Gets the names of all marks.
* Gets the value of the counter with the specified name.
*
* @param counterName The name of the counter.
*/
export function getMarkNames() {
return getKeys(markCounts);
export function getCount(counterName: string) {
return counters && getProperty(counters, counterName) || 0;
}
/**
* Gets the number of marks with the specified name.
*
* @param markName The name of the marks that should be counted.
* Marks the start of a performance measurement.
*/
export function getCount(markName: string) {
return enabled && getProperty(markCounts, markName) || 0;
}
/**
* Gets the most recent timestamp for the marks with the specified name.
*
* @param markName The name of the mark.
*/
export function getTimestamp(markName: string) {
return enabled && getProperty(markTimestamps, markName) || 0;
}
/**
* Clears performance marks.
*
* @param markName The name of the mark whose time values should be cleared. If not
* specified, all marks will be cleared.
*/
export function clearMarks(markName?: string) {
if (markName === undefined) {
forEachKey(markTimestamps, clearMark);
}
else {
clearMark(markName);
}
}
function clearMark(markName: string) {
if (delete markTimestamps[markName]) {
delete markCounts[markName];
}
export function mark() {
return measures ? Date.now() : 0;
}
/**
* Adds a performance measurement with the specified name.
*
* @param measureName The name of the performance measurement.
* @param startMarkName The name of the starting mark.
* If provided, the most recent time value of the start mark is used.
* If not specified, the value is the time that the performance service was
* initialized or the last time it was reset.
* @param endMarkName The name of the ending mark.
* If provided, the most recent time value of the end mark is used.
* If not specified, the current time is used.
* @param marker The timestamp of the starting mark.
*/
export function measure(measureName: string, startMarkName?: string, endMarkName?: string) {
if (enabled) {
const startTime = startMarkName ? getTimestamp(startMarkName) : start;
const endTime = endMarkName ? getTimestamp(endMarkName) : now();
const duration = endTime - startTime;
measureDurations[measureName] = getDuration(measureName) + duration;
export function measure(measureName: string, marker: number) {
if (measures) {
measures[measureName] = (getProperty(measures, measureName) || 0) + (mark() - marker);
}
}
/**
* Gets the names of all recorded measures.
*/
export function getMeasureNames() {
return getKeys(measureDurations);
}
/**
* Gets the total duration of all measurements with the supplied name.
*
* @param measureName The name of the measure whose durations should be accumulated.
*/
export function getDuration(measureName: string) {
return enabled && getProperty(measureDurations, measureName) || 0;
return measures && getProperty(measures, measureName) || 0;
}
/**
* Clears performance measures.
*
* @param measureName The name of the measure whose durations should be cleared. If not
* specified, all measures will be cleared.
*/
export function clearMeasures(measureName?: string) {
if (measureName === undefined) {
forEachKey(measureDurations, clearMeasure);
}
else {
clearMeasure(measureName);
}
}
function clearMeasure(measureName: string) {
delete measureDurations[measureName];
}
/**
* Resets all marks and measurements in the performance service.
*/
export function reset() {
clearMarks();
clearMeasures();
start = now();
}
/** Enables performance measurements for the compiler. */
/** Enables (and resets) performance measurements for the compiler. */
export function enable() {
enabled = true;
counters = { };
measures = {
programTime: 0,
parseTime: 0,
bindTime: 0,
emitTime: 0,
ioReadTime: 0,
ioWriteTime: 0,
printTime: 0,
commentTime: 0,
sourceMapTime: 0
};
}
/** Disables performance measurements for the compiler. */
/** Disables (and clears) performance measurements for the compiler. */
export function disable() {
enabled = false;
counters = undefined;
measures = undefined;
}
}
}
+3 -12
View File
@@ -91,16 +91,6 @@ namespace ts {
return clone;
}
/**
* Gets a clone of a node with a unique node ID.
*/
export function getUniqueClone<T extends Node>(node: T): T {
const clone = getMutableClone(node);
clone.id = 0;
getNodeId(clone);
return clone;
}
// Literals
export function createLiteral(textSource: StringLiteral | Identifier, location?: TextRange): StringLiteral;
@@ -821,8 +811,9 @@ namespace ts {
}
function createReactNamespace(reactNamespace: string, parent: JsxOpeningLikeElement) {
// Create an identifier and give it a parent. This allows us to resolve the react
// namespace during emit.
// To ensure the emit resolver can properly resolve the namespace, we need to
// treat this identifier as if it were a source tree node by clearing the `Synthesized`
// flag and setting a parent node.
const react = createIdentifier(reactNamespace || "React");
react.flags &= ~NodeFlags.Synthesized;
react.parent = parent;
+2 -2
View File
@@ -281,9 +281,9 @@ const _super = (function (geti, seti) {
}
function printSourceFileWithExtendedDiagnostics(node: SourceFile) {
performance.mark("printStart");
const printStart = performance.mark();
printSourceFile(node);
performance.measure("printTime", "printStart");
performance.measure("printTime", printStart);
return node;
}
+8 -8
View File
@@ -783,9 +783,9 @@ namespace ts {
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile {
let text: string;
try {
performance.mark("ioReadStart");
const ioReadStart = performance.mark();
text = sys.readFile(fileName, options.charset);
performance.measure("ioReadTime", "ioReadStart");
performance.measure("ioReadTime", ioReadStart);
}
catch (e) {
if (onError) {
@@ -852,7 +852,7 @@ namespace ts {
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
try {
performance.mark("ioWriteStart");
const ioWriteStart = performance.mark();
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
if (isWatchSet(options) && sys.createHash && sys.getModifiedTime) {
@@ -862,7 +862,7 @@ namespace ts {
sys.writeFile(fileName, data, writeByteOrderMark);
}
performance.measure("ioWriteTime", "ioWriteStart");
performance.measure("ioWriteTime", ioWriteStart);
}
catch (e) {
if (onError) {
@@ -997,7 +997,7 @@ namespace ts {
let resolvedTypeReferenceDirectives: Map<ResolvedTypeReferenceDirective> = {};
let fileProcessingDiagnostics = createDiagnosticCollection();
performance.mark("programStart");
const programStart = performance.mark();
host = host || createCompilerHost(options);
@@ -1094,7 +1094,7 @@ namespace ts {
verifyCompilerOptions();
performance.measure("programTime", "programStart");
performance.measure("programTime", programStart);
return program;
@@ -1335,7 +1335,7 @@ namespace ts {
// checked is to not pass the file to getEmitResolver.
const emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile);
performance.mark("emitStart");
const emitStart = performance.mark();
// TODO(rbuckton): remove USE_TRANSFORMS condition when we switch to transforms permanently.
let useLegacyEmitter = options.useLegacyEmitter;
@@ -1349,7 +1349,7 @@ namespace ts {
getEmitHost(writeFileCallback),
sourceFile);
performance.measure("emitTime", "emitStart");
performance.measure("emitTime", emitStart);
return emitResult;
}
+10 -10
View File
@@ -782,30 +782,30 @@ namespace ts {
getSourceMapData,
setSourceFile,
emitPos(pos: number): void {
performance.mark("sourcemapStart");
const sourcemapStart = performance.mark();
emitPos(pos);
performance.measure("sourcemapTime", "sourcemapStart");
performance.measure("sourceMapTime", sourcemapStart);
},
emitStart(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (node: Node) => boolean, ignoreChildrenCallback?: (node: Node) => boolean, getTextRangeCallback?: (node: Node) => TextRange): void {
performance.mark("sourcemapStart");
const sourcemapStart = performance.mark();
emitStart(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback);
performance.measure("sourcemapTime", "sourcemapStart");
performance.measure("sourceMapTime", sourcemapStart);
},
emitEnd(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (node: Node) => boolean, ignoreChildrenCallback?: (node: Node) => boolean, getTextRangeCallback?: (node: Node) => TextRange): void {
performance.mark("sourcemapStart");
const sourcemapStart = performance.mark();
emitEnd(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback);
performance.measure("sourcemapTime", "sourcemapStart");
performance.measure("sourceMapTime", sourcemapStart);
},
emitTokenStart(token: SyntaxKind, tokenStartPos: number, contextNode?: Node, ignoreTokenCallback?: (node: Node) => boolean, getTokenTextRangeCallback?: (node: Node, token: SyntaxKind) => TextRange): number {
performance.mark("sourcemapStart");
const sourcemapStart = performance.mark();
tokenStartPos = emitTokenStart(token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback);
performance.measure("sourcemapTime", "sourcemapStart");
performance.measure("sourceMapTime", sourcemapStart);
return tokenStartPos;
},
emitTokenEnd(token: SyntaxKind, tokenEndPos: number, contextNode?: Node, ignoreTokenCallback?: (node: Node) => boolean, getTokenTextRangeCallback?: (node: Node, token: SyntaxKind) => TextRange): number {
performance.mark("sourcemapStart");
const sourcemapStart = performance.mark();
tokenEndPos = emitTokenEnd(token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback);
performance.measure("sourcemapTime", "sourcemapStart");
performance.measure("sourceMapTime", sourcemapStart);
return tokenEndPos;
},
changeEmitSourcePos,
+94
View File
@@ -23,6 +23,100 @@ namespace ts {
EmitNotifications = 1 << 1,
}
/* @internal */
export interface TransformationContext extends LexicalEnvironment {
getCompilerOptions(): CompilerOptions;
getEmitResolver(): EmitResolver;
getEmitHost(): EmitHost;
/**
* Gets flags used to customize later transformations or emit.
*/
getNodeEmitFlags(node: Node): NodeEmitFlags;
/**
* Sets flags used to customize later transformations or emit.
*/
setNodeEmitFlags<T extends Node>(node: T, flags: NodeEmitFlags): T;
/**
* Gets the TextRange to use for source maps for the node.
*/
getSourceMapRange(node: Node): TextRange;
/**
* Sets the TextRange to use for source maps for the node.
*/
setSourceMapRange<T extends Node>(node: T, range: TextRange): T;
/**
* Gets the TextRange to use for source maps for a token of a node.
*/
getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange;
/**
* Sets the TextRange to use for source maps for a token of a node.
*/
setTokenSourceMapRange<T extends Node>(node: T, token: SyntaxKind, range: TextRange): T;
/**
* Gets the TextRange to use for comments for the node.
*/
getCommentRange(node: Node): TextRange;
/**
* Sets the TextRange to use for comments for the node.
*/
setCommentRange<T extends Node>(node: T, range: TextRange): T;
/**
* Hoists a function declaration to the containing scope.
*/
hoistFunctionDeclaration(node: FunctionDeclaration): void;
/**
* Hoists a variable declaration to the containing scope.
*/
hoistVariableDeclaration(node: Identifier): void;
/**
* Enables expression substitutions in the pretty printer for the provided SyntaxKind.
*/
enableSubstitution(kind: SyntaxKind): void;
/**
* Determines whether expression substitutions are enabled for the provided node.
*/
isSubstitutionEnabled(node: Node): boolean;
/**
* Hook used by transformers to substitute expressions just before they
* are emitted by the pretty printer.
*/
onSubstituteNode?: (node: Node, isExpression: boolean) => Node;
/**
* Enables before/after emit notifications in the pretty printer for the provided
* SyntaxKind.
*/
enableEmitNotification(kind: SyntaxKind): void;
/**
* Determines whether before/after emit notifications should be raised in the pretty
* printer when it emits a node.
*/
isEmitNotificationEnabled(node: Node): boolean;
/**
* Hook used to allow transformers to capture state before or after
* the printer emits a node.
*/
onEmitNode?: (node: Node, emit: (node: Node) => void) => void;
}
/* @internal */
export type Transformer = (context: TransformationContext) => (node: SourceFile) => SourceFile;
export function getTransformers(compilerOptions: CompilerOptions) {
const jsx = compilerOptions.jsx;
const languageVersion = getEmitScriptTarget(compilerOptions);
+2 -2
View File
@@ -1003,7 +1003,7 @@ namespace ts {
}
// `declarationName` is the name of the local declaration for the parameter.
const declarationName = getUniqueClone(<Identifier>parameter.name);
const declarationName = getMutableClone(<Identifier>parameter.name);
setNodeEmitFlags(declarationName, NodeEmitFlags.NoSourceMap);
// `expressionName` is the name of the parameter used in expressions.
@@ -2916,7 +2916,7 @@ namespace ts {
*/
function getDeclarationName(node: DeclarationStatement | ClassExpression, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: NodeEmitFlags) {
if (node.name && !isGeneratedIdentifier(node.name)) {
const name = getUniqueClone(node.name);
const name = getMutableClone(node.name);
emitFlags |= getNodeEmitFlags(node.name);
if (!allowSourceMaps) {
emitFlags |= NodeEmitFlags.NoSourceMap;
+3 -3
View File
@@ -929,10 +929,10 @@ namespace ts {
function transformParameterWithPropertyAssignment(node: ParameterDeclaration) {
Debug.assert(isIdentifier(node.name));
const name = node.name as Identifier;
const propertyName = getUniqueClone(name);
const propertyName = getMutableClone(name);
setNodeEmitFlags(propertyName, NodeEmitFlags.NoComments | NodeEmitFlags.NoSourceMap);
const localName = getUniqueClone(name);
const localName = getMutableClone(name);
setNodeEmitFlags(localName, NodeEmitFlags.NoComments);
return startOnNewLine(
@@ -2923,7 +2923,7 @@ namespace ts {
*/
function getDeclarationName(node: DeclarationStatement | ClassExpression, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: NodeEmitFlags) {
if (node.name) {
const name = getUniqueClone(node.name);
const name = getMutableClone(node.name);
emitFlags |= getNodeEmitFlags(node.name);
if (!allowSourceMaps) {
emitFlags |= NodeEmitFlags.NoSourceMap;
+6 -23
View File
@@ -556,7 +556,6 @@ namespace ts {
function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
if (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics) {
performance.enable();
performance.reset();
}
const program = createProgram(fileNames, compilerOptions, compilerHost);
@@ -581,6 +580,12 @@ namespace ts {
reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
}
if (compilerOptions.extendedDiagnostics) {
reportTimeStatistic("Print time", performance.getDuration("printTime"));
reportTimeStatistic("Comment time", performance.getDuration("commentTime"));
reportTimeStatistic("SourceMap time", performance.getDuration("sourceMapTime"));
}
// Individual component times.
// Note: To match the behavior of previous versions of the compiler, the reported parse time includes
// I/O read time and processing time for triple-slash references and module imports, and the reported
@@ -597,29 +602,7 @@ namespace ts {
reportTimeStatistic("Emit time", emitTime);
reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
if (compilerOptions.extendedDiagnostics) {
sys.write("Extended Diagnostics:" + sys.newLine);
sys.write("Marks:" + sys.newLine);
for (const markName of performance.getMarkNames()) {
if (/^(ioReadStart|ioWriteStart|programStart|bindStart|checkStart|emitStart)$/.test(markName)) {
continue;
}
reportCountStatistic(" " + markName, performance.getCount(markName));
}
sys.write("Measures:" + sys.newLine);
for (const measureName of performance.getMeasureNames()) {
if (/^(ioReadTime|ioWriteTime|programTime|bindTime|checkTime|emitTime)$/.test(measureName)) {
continue;
}
reportTimeStatistic(" " + measureName, performance.getDuration(measureName));
}
}
performance.disable();
performance.reset();
}
return { program, exitStatus };
-93
View File
@@ -3019,99 +3019,6 @@ namespace ts {
endLexicalEnvironment(): Statement[];
}
/* @internal */
export interface TransformationContext extends LexicalEnvironment {
getCompilerOptions(): CompilerOptions;
getEmitResolver(): EmitResolver;
getEmitHost(): EmitHost;
/**
* Gets flags used to customize later transformations or emit.
*/
getNodeEmitFlags(node: Node): NodeEmitFlags;
/**
* Sets flags used to customize later transformations or emit.
*/
setNodeEmitFlags<T extends Node>(node: T, flags: NodeEmitFlags): T;
/**
* Gets the TextRange to use for source maps for the node.
*/
getSourceMapRange(node: Node): TextRange;
/**
* Sets the TextRange to use for source maps for the node.
*/
setSourceMapRange<T extends Node>(node: T, range: TextRange): T;
/**
* Gets the TextRange to use for source maps for a token of a node.
*/
getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange;
/**
* Sets the TextRange to use for source maps for a token of a node.
*/
setTokenSourceMapRange<T extends Node>(node: T, token: SyntaxKind, range: TextRange): T;
/**
* Gets the TextRange to use for comments for the node.
*/
getCommentRange(node: Node): TextRange;
/**
* Sets the TextRange to use for comments for the node.
*/
setCommentRange<T extends Node>(node: T, range: TextRange): T;
/**
* Hoists a function declaration to the containing scope.
*/
hoistFunctionDeclaration(node: FunctionDeclaration): void;
/**
* Hoists a variable declaration to the containing scope.
*/
hoistVariableDeclaration(node: Identifier): void;
/**
* Enables expression substitutions in the pretty printer for the provided SyntaxKind.
*/
enableSubstitution(kind: SyntaxKind): void;
/**
* Determines whether expression substitutions are enabled for the provided node.
*/
isSubstitutionEnabled(node: Node): boolean;
/**
* Hook used by transformers to substitute expressions just before they
* are emitted by the pretty printer.
*/
onSubstituteNode?: (node: Node, isExpression: boolean) => Node;
/**
* Enables before/after emit notifications in the pretty printer for the provided
* SyntaxKind.
*/
enableEmitNotification(kind: SyntaxKind): void;
/**
* Determines whether before/after emit notifications should be raised in the pretty
* printer when it emits a node.
*/
isEmitNotificationEnabled(node: Node): boolean;
/**
* Hook used to allow transformers to capture state before or after
* the printer emits a node.
*/
onEmitNode?: (node: Node, emit: (node: Node) => void) => void;
}
/* @internal */
export type Transformer = (context: TransformationContext) => (node: SourceFile) => SourceFile;
export interface TextSpan {
start: number;
-12
View File
@@ -226,18 +226,6 @@ namespace ts {
return `${ file.fileName }(${ loc.line + 1 },${ loc.character + 1 })`;
}
export function getEnvironmentVariable(name: string, host?: CompilerHost) {
if (host && host.getEnvironmentVariable) {
return host.getEnvironmentVariable(name);
}
if (sys && sys.getEnvironmentVariable) {
return sys.getEnvironmentVariable(name);
}
return "";
}
export function getStartPosOfNode(node: Node): number {
return node.pos;
}
+1 -1
View File
@@ -1464,7 +1464,7 @@ namespace Harness {
}
public getSourceMapRecord() {
if (this.sourceMapData.length > 0) {
if (this.sourceMapData && this.sourceMapData.length > 0) {
return Harness.SourceMapRecorder.getSourceMapRecord(this.sourceMapData, this.program, this.files);
}
}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFD,sBAEC;IAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../../outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFD,sBAEC;AAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFD,sBAEC;IAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"","sources":["../../projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFD,sBAEC;AAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFD,sBAEC;IAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"","sources":["file:///tests/cases/projects/outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFD,sBAEC;AAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFD,sBAEC;IAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFD,sBAEC;AAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFD,sBAEC;IAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"/tests/cases/projects/outputdir_module_multifolder/src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFD,sBAEC;AAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFD,sBAEC;IAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"../src/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFD,sBAEC;AAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":[],"mappings":";;IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFD,sBAEC;IAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":[],"mappings":";AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"","sources":["m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFD,sBAEC;AAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,aAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFY,aAAK,QAEjB,CAAA;IAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";;IAAW,QAAA,KAAK,GAAG,EAAE,CAAC;IACtB;QAAA;QAEA,CAAC;QAAD,YAAC;IAAD,CAAC,AAFD,IAEC;IAFD,sBAEC;IAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;IACtC;QACI,MAAM,CAAC,oBAAY,CAAC;IACxB,CAAC;IAFD,sBAEC"}
@@ -1 +1 @@
{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,aAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFY,aAAK,QAEjB,CAAA;AAEU,oBAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFe,aAAK,QAEpB,CAAA"}
{"version":3,"file":"m2.js","sourceRoot":"http://typescript.codeplex.com/","sources":["outputdir_module_multifolder_ref/m2.ts"],"names":[],"mappings":";AAAW,QAAA,KAAK,GAAG,EAAE,CAAC;AACtB;IAAA;IAEA,CAAC;IAAD,YAAC;AAAD,CAAC,AAFD,IAEC;AAFD,sBAEC;AAEU,QAAA,YAAY,GAAG,IAAI,KAAK,EAAE,CAAC;AACtC;IACI,MAAM,CAAC,oBAAY,CAAC;AACxB,CAAC;AAFD,sBAEC"}