Skip to content

Commit

Permalink
Remove shims.ts and related infra (#55868)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey authored Sep 28, 2023
1 parent 284cd45 commit 9208239
Show file tree
Hide file tree
Showing 73 changed files with 30 additions and 7,009 deletions.
36 changes: 28 additions & 8 deletions src/harness/fourslashImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import ArrayOrSingle = FourSlashInterface.ArrayOrSingle;

export const enum FourSlashTestType {
Native,
Shims,
ShimsWithPreprocess,
Server,
}

Expand Down Expand Up @@ -202,6 +200,32 @@ const enum CallHierarchyItemDirection {
Outgoing,
}

interface RealizedDiagnostic {
message: string;
start: number;
length: number;
category: string;
code: number;
reportsUnnecessary?: {};
reportsDeprecated?: {};
}

function realizeDiagnostics(diagnostics: readonly ts.Diagnostic[], newLine: string): RealizedDiagnostic[] {
return diagnostics.map(d => realizeDiagnostic(d, newLine));
}

function realizeDiagnostic(diagnostic: ts.Diagnostic, newLine: string): RealizedDiagnostic {
return {
message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine),
start: diagnostic.start!, // TODO: GH#18217
length: diagnostic.length!, // TODO: GH#18217
category: ts.diagnosticCategoryName(diagnostic),
code: diagnostic.code,
reportsUnnecessary: diagnostic.reportsUnnecessary,
reportsDeprecated: diagnostic.reportsDeprecated,
};
}

export class TestState {
// Language service instance
private languageServiceAdapterHost: Harness.LanguageService.LanguageServiceAdapterHost;
Expand Down Expand Up @@ -267,10 +291,6 @@ export class TestState {
switch (testType) {
case FourSlashTestType.Native:
return new Harness.LanguageService.NativeLanguageServiceAdapter(cancellationToken, compilationOptions);
case FourSlashTestType.Shims:
return new Harness.LanguageService.ShimLanguageServiceAdapter(/*preprocessToResolve*/ false, cancellationToken, compilationOptions);
case FourSlashTestType.ShimsWithPreprocess:
return new Harness.LanguageService.ShimLanguageServiceAdapter(/*preprocessToResolve*/ true, cancellationToken, compilationOptions);
case FourSlashTestType.Server:
return new Harness.LanguageService.ServerLanguageServiceAdapter(cancellationToken, compilationOptions);
default:
Expand Down Expand Up @@ -1764,8 +1784,8 @@ export class TestState {

private testDiagnostics(expected: readonly FourSlashInterface.Diagnostic[], diagnostics: readonly ts.Diagnostic[], category: string) {
assert.deepEqual(
ts.realizeDiagnostics(diagnostics, "\n"),
expected.map((e): ts.RealizedDiagnostic => {
realizeDiagnostics(diagnostics, "\n"),
expected.map((e): RealizedDiagnostic => {
const range = e.range || this.getRangesInFile()[0];
if (!range) {
this.raiseError("Must provide a range for each expected diagnostic, or have one range in the fourslash source.");
Expand Down
461 changes: 0 additions & 461 deletions src/harness/harnessLanguageService.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/harness/runnerbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as ts from "./_namespaces/ts";

export type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project";
export type CompilerTestKind = "conformance" | "compiler";
export type FourslashTestKind = "fourslash" | "fourslash-shims" | "fourslash-shims-pp" | "fourslash-server";
export type FourslashTestKind = "fourslash" | "fourslash-server";

export let shards = 1;
export let shardId = 1;
Expand Down
1 change: 0 additions & 1 deletion src/services/_namespaces/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export * from "../suggestionDiagnostics";
export * from "../transpile";
export * from "../services";
export * from "../transform";
export * from "../shims";
import * as BreakpointResolver from "./ts.BreakpointResolver";
export { BreakpointResolver };
import * as CallHierarchy from "./ts.CallHierarchy";
Expand Down
Loading

0 comments on commit 9208239

Please sign in to comment.