Skip to content

Commit 3a46371

Browse files
committed
Add back getSourceFile and mark it as deprecated
1 parent 5f1336b commit 3a46371

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/harness/harnessLanguageService.ts

+3
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,9 @@ namespace Harness.LanguageService {
462462
getNonBoundSourceFile(fileName: string): ts.SourceFile {
463463
throw new Error("SourceFile can not be marshaled across the shim layer.");
464464
}
465+
getSourceFile(fileName: string): ts.SourceFile {
466+
throw new Error("SourceFile can not be marshaled across the shim layer.");
467+
}
465468
dispose(): void { this.shim.dispose({}); }
466469
}
467470

src/server/client.ts

+4
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,10 @@ namespace ts.server {
641641
throw new Error("SourceFile objects are not serializable through the server protocol.");
642642
}
643643

644+
getSourceFile(fileName: string): SourceFile {
645+
throw new Error("SourceFile objects are not serializable through the server protocol.");
646+
}
647+
644648
cleanupSemanticCache(): void {
645649
throw new Error("cleanupSemanticCache is not available through the server layer.");
646650
}

src/services/services.ts

+11
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,12 @@ namespace ts {
12461246

12471247
/* @internal */ getNonBoundSourceFile(fileName: string): SourceFile;
12481248

1249+
/**
1250+
* @internal
1251+
* @deprecated Use ts.createSourceFile instead.
1252+
*/
1253+
getSourceFile(fileName: string): SourceFile;
1254+
12491255
dispose(): void;
12501256
}
12511257

@@ -7174,6 +7180,10 @@ namespace ts {
71747180
return syntaxTreeCache.getCurrentSourceFile(fileName);
71757181
}
71767182

7183+
function getSourceFile(fileName: string): SourceFile {
7184+
return getNonBoundSourceFile(fileName);
7185+
}
7186+
71777187
function getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan {
71787188
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
71797189

@@ -8338,6 +8348,7 @@ namespace ts {
83388348
isValidBraceCompletionAtPosition,
83398349
getEmitOutput,
83408350
getNonBoundSourceFile,
8351+
getSourceFile,
83418352
getProgram
83428353
};
83438354
}

0 commit comments

Comments
 (0)