Skip to content

Commit b9edbab

Browse files
committed
allow lsp
1 parent 2f9f6f9 commit b9edbab

15 files changed

Lines changed: 711 additions & 3 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "Compiler-UnionsLSP",
3+
"kind": "lsp",
4+
"args": [],
5+
"tsserverConfig": {
6+
"solution": "Compiler-Unions",
7+
"commands": [
8+
{
9+
"commandName": "updateOpen",
10+
"args": [
11+
{
12+
"file": "checker.ts"
13+
}
14+
]
15+
},
16+
{
17+
"commandName": "geterr",
18+
"args": [
19+
"checker.ts"
20+
]
21+
},
22+
{
23+
"commandName": "references",
24+
"args": {
25+
"file": "checker.ts",
26+
"line": 10960,
27+
"offset": 48
28+
}
29+
},
30+
{
31+
"commandName": "navto",
32+
"args": {
33+
"searchValue": "Type"
34+
}
35+
},
36+
{
37+
"commandName": "completionInfo",
38+
"args": {
39+
"file": "checker.ts",
40+
"line": 25149,
41+
"offset": 6
42+
}
43+
}
44+
]
45+
}
46+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "CompilerLSP",
3+
"kind": "lsp",
4+
"args": [],
5+
"tsserverConfig": {
6+
"solution": "Compiler",
7+
"commands": [
8+
{
9+
"commandName": "updateOpen",
10+
"args": [
11+
{
12+
"file": "checker.ts"
13+
}
14+
]
15+
},
16+
{
17+
"commandName": "geterr",
18+
"args": [
19+
"checker.ts"
20+
]
21+
},
22+
{
23+
"commandName": "references",
24+
"args": {
25+
"file": "checker.ts",
26+
"line": 11696,
27+
"offset": 48
28+
}
29+
},
30+
{
31+
"commandName": "navto",
32+
"args": {
33+
"searchValue": "Type"
34+
}
35+
},
36+
{
37+
"commandName": "completionInfo",
38+
"args": {
39+
"file": "checker.ts",
40+
"line": 26636,
41+
"offset": 6
42+
}
43+
}
44+
]
45+
}
46+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "xstate-main-1-LSP",
3+
"kind": "lsp",
4+
"args": [],
5+
"tsserverConfig": {
6+
"solution": "xstate-main-1",
7+
"commands": [
8+
{
9+
"commandName": "updateOpen",
10+
"args": [
11+
{
12+
"file": "packages/core/src/index.ts"
13+
},
14+
{
15+
"file": "packages/core/src/StateNode.ts"
16+
}
17+
]
18+
},
19+
{
20+
"commandName": "geterr",
21+
"args": [
22+
"packages/core/src/StateNode.ts"
23+
]
24+
},
25+
{
26+
"commandName": "references",
27+
"args": {
28+
"file": "packages/core/src/index.ts",
29+
"line": 14,
30+
"offset": 15
31+
}
32+
},
33+
{
34+
"commandName": "navto",
35+
"args": {
36+
"searchValue": "State"
37+
}
38+
},
39+
{
40+
"commandName": "completionInfo",
41+
"args": {
42+
"file": "packages/core/src/index.ts",
43+
"line": 47,
44+
"offset": 1
45+
}
46+
}
47+
]
48+
}
49+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -exo pipefail
4+
cd "${0%/*}"
5+
6+
source ../../common.sh
7+
8+
clone_scenario https://github.com/statelyai/xstate.git 9118720b2d81cd3cd6b8e4ea8da75d576c47fa8d
9+
10+
run_sandboxed sh -c 'yarn install'

pnpm-lock.yaml

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/src/runTsPerf.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const tsperfExe = checkNonEmpty(process.env.TSPERF_EXE, "Expected TSPERF_EXE env
1717
const commands: Record<string, (() => Promise<void>) | undefined> = {
1818
"install-hosts": installHosts,
1919
"benchmark-tsc": benchmarkTsc,
20+
"benchmark-lsp": benchmarkLsp,
2021
"benchmark-tsserver": benchmarkTsserver,
2122
"benchmark-startup": benchmarkStartup,
2223
};
@@ -141,6 +142,14 @@ async function benchmarkTsserver() {
141142
await $`node ${tsperfExe} benchmark tsserver --builtDir ${builtDir} ${tsperfArgs}`;
142143
}
143144

145+
async function benchmarkLsp() {
146+
const builtDir = checkNonEmpty(args.builtDir, "Expected non-empty --builtDir");
147+
148+
const tsperfArgs = await getCommonBenchmarkArgs();
149+
150+
await $`node ${tsperfExe} benchmark lsp --builtDir ${builtDir} ${tsperfArgs}`;
151+
}
152+
144153
async function benchmarkStartup() {
145154
const builtDir = checkNonEmpty(args.builtDir, "Expected non-empty --builtDir");
146155

scripts/src/setupPipeline.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const hosts = {
5252
native: "native", // Native Go binary; no host runtime needed.
5353
} as const satisfies Record<string, string>;
5454

55-
const allJobKinds = ["tsc", "tsserver", "startup"] as const;
55+
const allJobKinds = ["tsc", "tsserver", "lsp", "startup"] as const;
5656
type JobKind = typeof allJobKinds[number];
5757

5858
const enum RunType {
@@ -411,6 +411,12 @@ function* transformPreset(parameters: Parameters, iter: Iterable<Scenario>, tsgo
411411

412412
function* worker(): Iterable<Scenario> {
413413
for (const scenario of iter) {
414+
if (tsgo && scenario.kind === "tsserver") {
415+
continue;
416+
}
417+
if (!tsgo && scenario.kind === "lsp") {
418+
continue;
419+
}
414420
const scenarioHosts = tsgo ? [hosts.native] : (parameters.hosts ?? [scenario.host]);
415421

416422
for (const host of scenarioHosts) {

ts-perf/packages/api/src/expansion.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export abstract class ExpansionProvider {
1010
config?: {
1111
runner?:
1212
| { kind: "tsserver"; options: TSServerOptions; }
13+
| { kind: "lsp"; options: TSServerOptions; }
1314
| { kind: "tsc"; options: CompilerOptions; }
1415
| { kind: "startup"; options: StartupOptions; };
1516
temp?: TempDirectories;
@@ -28,6 +29,9 @@ export abstract class ExpansionProvider {
2829
case "tsserver":
2930
providers.add(new TSServerOptionsExpansionProvider(config.runner.options));
3031
break;
32+
case "lsp":
33+
providers.add(new TSServerOptionsExpansionProvider(config.runner.options));
34+
break;
3135
}
3236
}
3337
if (config.temp) providers.add(new TempDirectoriesExpansionProvider(config.temp));

ts-perf/packages/api/src/model/scenario.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { TSServerConfig } from "./tsserverconfig";
99

1010
const cachedScenarios = new HashMap<string, Scenario[]>(PathComparer.fileSystem);
1111

12-
export type ScenarioKind = "tsserver" | "tsc" | "startup";
12+
export type ScenarioKind = "tsserver" | "tsc" | "startup" | "lsp";
1313

1414
export interface TscConfig {
1515
usePublicApi?: boolean;
@@ -57,6 +57,9 @@ export class Scenario {
5757
if (kind === "tsserver" && !options?.tsserverConfig) {
5858
throw new Error(`Creating scenario '${name}': expected a tsserver config for tsserver scenario.`);
5959
}
60+
if (kind === "lsp" && !options?.tsserverConfig) {
61+
throw new Error(`Creating scenario '${name}': expected a tsserver config for lsp scenario.`);
62+
}
6063
this.name = name;
6164
this.kind = kind;
6265
this.args = args;

ts-perf/packages/api/src/options.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,20 @@ const tsserver: CommandLineOptionSet = {
110110
},
111111
};
112112

113+
const lsp: CommandLineOptionSet = {
114+
merge: true,
115+
include: ["common"],
116+
options: {
117+
builtDir,
118+
suiteDir,
119+
extended: {
120+
type: "boolean",
121+
description: "If the scenario declares optional (aka extended) requests, run those as well.",
122+
defaultValue: false,
123+
},
124+
},
125+
};
126+
113127
const startup: CommandLineOptionSet = {
114128
merge: true,
115129
include: ["common"],
@@ -151,6 +165,7 @@ export const optionSets: CommandLineOptionSets = {
151165
common,
152166
compiler,
153167
tsserver,
168+
lsp,
154169
startup,
155170
azureStorage,
156171
};

0 commit comments

Comments
 (0)