Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/services/shims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ namespace ts {
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string;

getEmitOutput(fileName: string): string;
getEmitOutputObject(fileName: string): EmitOutput;
}

export interface ClassifierShim extends Shim {
Expand Down Expand Up @@ -518,9 +519,13 @@ namespace ts {
}

function forwardJSONCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): string {
return <string>forwardCall(logger, actionDescription, /*returnJson*/ true, action, logPerformance);
}

function forwardCall<T>(logger: Logger, actionDescription: string, returnJson: boolean, action: () => T, logPerformance: boolean): T | string {
try {
const result = simpleForwardCall(logger, actionDescription, action, logPerformance);
return JSON.stringify({ result });
return returnJson ? JSON.stringify({ result }) : result;
}
catch (err) {
if (err instanceof OperationCanceledException) {
Expand All @@ -532,6 +537,7 @@ namespace ts {
}
}


class ShimBase implements Shim {
constructor(private factory: ShimFactory) {
factory.registerShim(this);
Expand Down Expand Up @@ -918,6 +924,15 @@ namespace ts {
() => this.languageService.getEmitOutput(fileName)
);
}

public getEmitOutputObject(fileName: string): any {
return forwardCall(
this.logger,
`getEmitOutput('${fileName}')`,
/*returnJson*/ false,
() => this.languageService.getEmitOutput(fileName),
this.logPerformance);
}
}

function convertClassifications(classifications: Classifications): { spans: string, endOfLineState: EndOfLineState } {
Expand Down