Skip to content

Commit

Permalink
Add back getSourceFile and mark it as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
mhegazy committed Sep 19, 2016
1 parent 5f1336b commit 3a46371
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/harness/harnessLanguageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ namespace Harness.LanguageService {
getNonBoundSourceFile(fileName: string): ts.SourceFile {
throw new Error("SourceFile can not be marshaled across the shim layer.");
}
getSourceFile(fileName: string): ts.SourceFile {
throw new Error("SourceFile can not be marshaled across the shim layer.");
}
dispose(): void { this.shim.dispose({}); }
}

Expand Down
4 changes: 4 additions & 0 deletions src/server/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ namespace ts.server {
throw new Error("SourceFile objects are not serializable through the server protocol.");
}

getSourceFile(fileName: string): SourceFile {
throw new Error("SourceFile objects are not serializable through the server protocol.");
}

cleanupSemanticCache(): void {
throw new Error("cleanupSemanticCache is not available through the server layer.");
}
Expand Down
11 changes: 11 additions & 0 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,12 @@ namespace ts {

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

/**
* @internal
* @deprecated Use ts.createSourceFile instead.
*/
getSourceFile(fileName: string): SourceFile;

dispose(): void;
}

Expand Down Expand Up @@ -7174,6 +7180,10 @@ namespace ts {
return syntaxTreeCache.getCurrentSourceFile(fileName);
}

function getSourceFile(fileName: string): SourceFile {
return getNonBoundSourceFile(fileName);
}

function getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan {
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);

Expand Down Expand Up @@ -8338,6 +8348,7 @@ namespace ts {
isValidBraceCompletionAtPosition,
getEmitOutput,
getNonBoundSourceFile,
getSourceFile,
getProgram
};
}
Expand Down

0 comments on commit 3a46371

Please sign in to comment.