Skip to content

Commit af5148d

Browse files
committed
Add back getSourceFile and mark it as deprecated
1 parent b7d1d11 commit af5148d

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

Diff for: src/harness/harnessLanguageService.ts

+3
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,9 @@ namespace Harness.LanguageService {
492492
getNonBoundSourceFile(fileName: string): ts.SourceFile {
493493
throw new Error("SourceFile can not be marshaled across the shim layer.");
494494
}
495+
getSourceFile(fileName: string): ts.SourceFile {
496+
throw new Error("SourceFile can not be marshaled across the shim layer.");
497+
}
495498
dispose(): void { this.shim.dispose({}); }
496499
}
497500

Diff for: src/server/client.ts

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

681+
getSourceFile(fileName: string): SourceFile {
682+
throw new Error("SourceFile objects are not serializable through the server protocol.");
683+
}
684+
681685
cleanupSemanticCache(): void {
682686
throw new Error("cleanupSemanticCache is not available through the server layer.");
683687
}

Diff for: src/services/services.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,10 @@ namespace ts {
14011401
return syntaxTreeCache.getCurrentSourceFile(fileName);
14021402
}
14031403

1404+
function getSourceFile(fileName: string): SourceFile {
1405+
return getNonBoundSourceFile(fileName);
1406+
}
1407+
14041408
function getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan {
14051409
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
14061410

@@ -1812,6 +1816,7 @@ namespace ts {
18121816
isValidBraceCompletionAtPosition,
18131817
getEmitOutput,
18141818
getNonBoundSourceFile,
1819+
getSourceFile,
18151820
getProgram
18161821
};
18171822
}

Diff for: src/services/types.ts

+6
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ namespace ts {
240240

241241
/* @internal */ getNonBoundSourceFile(fileName: string): SourceFile;
242242

243+
/**
244+
* @internal
245+
* @deprecated Use ts.createSourceFile instead.
246+
*/
247+
getSourceFile(fileName: string): SourceFile;
248+
243249
dispose(): void;
244250
}
245251

0 commit comments

Comments
 (0)