Skip to content

Commit 6237b22

Browse files
committed
Move the builder to compiler directory
1 parent e068475 commit 6237b22

6 files changed

Lines changed: 32 additions & 29 deletions

File tree

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
/// <reference path="..\compiler\commandLineParser.ts" />
2-
/// <reference path="..\services\services.ts" />
3-
/// <reference path="session.ts" />
1+
/// <reference path="program.ts" />
2+
3+
namespace ts {
4+
export interface EmitOutput {
5+
outputFiles: OutputFile[];
6+
emitSkipped: boolean;
7+
}
8+
9+
export interface OutputFile {
10+
name: string;
11+
writeByteOrderMark: boolean;
12+
text: string;
13+
}
414

5-
namespace ts.server {
615
export interface Builder {
716
/**
817
* This is the callback when file infos in the builder are updated
@@ -13,6 +22,20 @@ namespace ts.server {
1322
clear(): void;
1423
}
1524

25+
export function getFileEmitOutput(program: Program, sourceFile: SourceFile, emitOnlyDtsFiles?: boolean,
26+
cancellationToken?: CancellationToken, customTransformers?: CustomTransformers): EmitOutput {
27+
const outputFiles: OutputFile[] = [];
28+
const emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
29+
return {
30+
outputFiles,
31+
emitSkipped: emitOutput.emitSkipped
32+
};
33+
34+
function writeFile(fileName: string, text: string, writeByteOrderMark: boolean) {
35+
outputFiles.push({ name: fileName, writeByteOrderMark, text });
36+
}
37+
}
38+
1639
interface EmitHandler {
1740
addScriptInfo(program: Program, sourceFile: SourceFile): void;
1841
removeScriptInfo(path: Path): void;
@@ -157,7 +180,7 @@ namespace ts.server {
157180
for (const importName of sourceFile.imports) {
158181
const symbol = checker.getSymbolAtLocation(importName);
159182
if (symbol && symbol.declarations && symbol.declarations[0]) {
160-
const declarationSourceFile = symbol.declarations[0].getSourceFile();
183+
const declarationSourceFile = getSourceFileOfNode(symbol.declarations[0]);
161184
if (declarationSourceFile) {
162185
referencedFiles.set(declarationSourceFile.path, true);
163186
}

src/compiler/program.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/// <reference path="sys.ts" />
22
/// <reference path="emitter.ts" />
33
/// <reference path="core.ts" />
4+
/// <reference path="builder.ts" />
45

56
namespace ts {
67
const ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/;

src/compiler/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"declarationEmitter.ts",
3737
"emitter.ts",
3838
"program.ts",
39+
"builder.ts",
3940
"commandLineParser.ts",
4041
"tsc.ts",
4142
"diagnosticInformationMap.generated.ts"

src/server/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <reference path="scriptInfo.ts"/>
44
/// <reference path="lsHost.ts"/>
55
/// <reference path="typingsCache.ts"/>
6-
/// <reference path="builder.ts"/>
6+
/// <reference path="..\compiler\builder.ts"/>
77

88
namespace ts.server {
99

src/services/services.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,19 +1471,8 @@ namespace ts {
14711471
synchronizeHostData();
14721472

14731473
const sourceFile = getValidSourceFile(fileName);
1474-
const outputFiles: OutputFile[] = [];
1475-
1476-
function writeFile(fileName: string, text: string, writeByteOrderMark: boolean) {
1477-
outputFiles.push({ name: fileName, writeByteOrderMark, text });
1478-
}
1479-
14801474
const customTransformers = host.getCustomTransformers && host.getCustomTransformers();
1481-
const emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
1482-
1483-
return {
1484-
outputFiles,
1485-
emitSkipped: emitOutput.emitSkipped
1486-
};
1475+
return getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers);
14871476
}
14881477

14891478
// Signature help

src/services/types.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -693,23 +693,12 @@ namespace ts {
693693
autoCollapse: boolean;
694694
}
695695

696-
export interface EmitOutput {
697-
outputFiles: OutputFile[];
698-
emitSkipped: boolean;
699-
}
700-
701696
export const enum OutputFileType {
702697
JavaScript,
703698
SourceMap,
704699
Declaration
705700
}
706701

707-
export interface OutputFile {
708-
name: string;
709-
writeByteOrderMark: boolean;
710-
text: string;
711-
}
712-
713702
export const enum EndOfLineState {
714703
None,
715704
InMultiLineCommentTrivia,

0 commit comments

Comments
 (0)