Skip to content

[Transforms] Extract transformFiles call from printFile #8929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 3, 2016
20 changes: 10 additions & 10 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17160,7 +17160,7 @@ namespace ts {

function isArgumentsLocalBinding(node: Identifier): boolean {
if (!isGeneratedIdentifier(node)) {
node = getSourceTreeNodeOfType(node, isIdentifier);
node = getParseTreeNode(node, isIdentifier);
if (node) {
return getReferencedValueSymbol(node) === argumentsSymbol;
}
Expand Down Expand Up @@ -17206,7 +17206,7 @@ namespace ts {
// When resolved as an expression identifier, if the given node references an exported entity, return the declaration
// node of the exported entity's container. Otherwise, return undefined.
function getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration {
node = getSourceTreeNodeOfType(node, isIdentifier);
node = getParseTreeNode(node, isIdentifier);
if (node) {
// When resolving the export container for the name of a module or enum
// declaration, we need to start resolution at the declaration's container.
Expand Down Expand Up @@ -17244,7 +17244,7 @@ namespace ts {
// When resolved as an expression identifier, if the given node references an import, return the declaration of
// that import. Otherwise, return undefined.
function getReferencedImportDeclaration(node: Identifier): Declaration {
node = getSourceTreeNodeOfType(node, isIdentifier);
node = getParseTreeNode(node, isIdentifier);
if (node) {
const symbol = getReferencedValueSymbol(node);
if (symbol && symbol.flags & SymbolFlags.Alias) {
Expand Down Expand Up @@ -17303,7 +17303,7 @@ namespace ts {
// return the declaration of that entity. Otherwise, return undefined.
function getReferencedDeclarationWithCollidingName(node: Identifier): Declaration {
if (!isGeneratedIdentifier(node)) {
node = getSourceTreeNodeOfType(node, isIdentifier);
node = getParseTreeNode(node, isIdentifier);
if (node) {
const symbol = getReferencedValueSymbol(node);
if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) {
Expand All @@ -17318,7 +17318,7 @@ namespace ts {
// Return true if the given node is a declaration of a nested block scoped entity with a name that either hides an
// existing name or might hide a name when compiled downlevel
function isDeclarationWithCollidingName(node: Declaration): boolean {
node = getSourceTreeNodeOfType(node, isDeclaration);
node = getParseTreeNode(node, isDeclaration);
if (node) {
const symbol = getSymbolOfNode(node);
if (symbol) {
Expand All @@ -17330,7 +17330,7 @@ namespace ts {
}

function isValueAliasDeclaration(node: Node): boolean {
node = getSourceTreeNode(node);
node = getParseTreeNode(node);
if (node === undefined) {
// A synthesized node comes from an emit transformation and is always a value.
return true;
Expand All @@ -17356,7 +17356,7 @@ namespace ts {
}

function isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean {
node = getSourceTreeNodeOfType(node, isImportEqualsDeclaration);
node = getParseTreeNode(node, isImportEqualsDeclaration);
if (node === undefined || node.parent.kind !== SyntaxKind.SourceFile || !isInternalModuleImportEqualsDeclaration(node)) {
// parent is not source file or it is not reference to internal module
return false;
Expand All @@ -17382,7 +17382,7 @@ namespace ts {
}

function isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean {
node = getSourceTreeNode(node);
node = getParseTreeNode(node);
if (isAliasSymbolDeclaration(node)) {
const symbol = getSymbolOfNode(node);
if (symbol && getSymbolLinks(symbol).referenced) {
Expand Down Expand Up @@ -17418,7 +17418,7 @@ namespace ts {
}

function getNodeCheckFlags(node: Node): NodeCheckFlags {
node = getSourceTreeNode(node);
node = getParseTreeNode(node);
return node ? getNodeLinks(node).flags : undefined;
}

Expand Down Expand Up @@ -17549,7 +17549,7 @@ namespace ts {

function getReferencedValueDeclaration(reference: Identifier): Declaration {
if (!isGeneratedIdentifier(reference)) {
reference = getSourceTreeNodeOfType(reference, isIdentifier);
reference = getParseTreeNode(reference, isIdentifier);
if (reference) {
const symbol = getReferencedValueSymbol(reference);
if (symbol) {
Expand Down
21 changes: 20 additions & 1 deletion src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1150,9 +1150,23 @@ namespace ts {
/** Performance measurements for the compiler. */
/*@internal*/
export namespace performance {
declare const onProfilerEvent: { (markName: string): void; profiler: boolean; };
let profilerEvent: (markName: string) => void;
let counters: Map<number>;
let measures: Map<number>;

/**
* Emit a performance event if ts-profiler is connected. This is primarily used
* to generate heap snapshots.
*
* @param eventName A name for the event.
*/
export function emit(eventName: string) {
if (profilerEvent) {
onProfilerEvent(eventName);
}
}

/**
* Increments a counter with the specified name.
*
Expand Down Expand Up @@ -1188,7 +1202,7 @@ namespace ts {
*/
export function measure(measureName: string, marker: number) {
if (measures) {
measures[measureName] = (getProperty(measures, measureName) || 0) + (mark() - marker);
measures[measureName] = (getProperty(measures, measureName) || 0) + (Date.now() - marker);
}
}

Expand All @@ -1215,12 +1229,17 @@ namespace ts {
commentTime: 0,
sourceMapTime: 0
};

profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true
? onProfilerEvent
: undefined;
}

/** Disables (and clears) performance measurements for the compiler. */
export function disable() {
counters = undefined;
measures = undefined;
profilerEvent = undefined;
}
}
}
Loading