Skip to content

Commit 2ca8dec

Browse files
Merge branch 'main' into parsedPatternsOptimization
2 parents c9b3139 + 2d4c0be commit 2ca8dec

File tree

19,817 files changed

+1357095
-2058
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

19,817 files changed

+1357095
-2058
lines changed

.github/actions/setup-go/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ runs:
2020
cache: false
2121

2222
- name: Go cache
23-
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
23+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
2424
with:
2525
# There is more code downloaded and built than is covered by '**/go.sum',
2626
# so give each job its own cache to try and not end up sharing the wrong

.github/workflows/ci.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,19 @@ jobs:
4040
- os: windows-latest
4141
- os: macos-latest
4242
- os: ubuntu-latest
43+
name: 'no submodules'
4344
no-submodules: true
44-
- os: ubuntu-latest
45+
- os: ['self-hosted', '1ES.Pool=TypeScript-1ES-GitHub-XL', '1ES.ImageOverride=mariner-2.0']
46+
name: 'race mode'
4547
race: true
4648
- os: ubuntu-latest
49+
name: 'noembed'
4750
noembed: true
51+
- os: ubuntu-latest
52+
name: 'concurrent test programs'
53+
concurrent-test-program: true
4854

49-
name: test (${{ matrix.os }}${{ (matrix.no-submodules && ' without submodules') || '' }}${{ (matrix.race && ' in race mode') || '' }}${{ (matrix.noembed && ' with noembed') || '' }})
55+
name: test (${{ matrix.name || matrix.os }})
5056

5157
runs-on: ${{ matrix.os }}
5258

@@ -58,6 +64,8 @@ jobs:
5864
with:
5965
submodules: ${{ !matrix.no-submodules }}
6066
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
67+
with:
68+
node-version: 'lts/*'
6169
- uses: ./.github/actions/setup-go
6270
with:
6371
cache-name: test
@@ -71,10 +79,11 @@ jobs:
7179

7280
- name: Tests
7381
id: test
74-
run: npx hereby test:all ${RACE_FLAG:+"$RACE_FLAG"} ${NOEMBED_FLAG:+"$NOEMBED_FLAG"}
82+
run: npx hereby test:all ${RACE_FLAG:+"$RACE_FLAG"} ${NOEMBED_FLAG:+"$NOEMBED_FLAG"} ${CONCURRENTTESTPROGRAM_FLAG:+"$CONCURRENTTESTPROGRAM_FLAG"}
7583
env:
7684
RACE_FLAG: ${{ (matrix.race && '--race') || '' }}
7785
NOEMBED_FLAG: ${{ (matrix.noembed && '--noembed') || '' }}
86+
CONCURRENTTESTPROGRAM_FLAG: ${{ (matrix.concurrent-test-program && '--concurrentTestPrograms') || '' }}
7887

7988
- run: git add .
8089
- run: git diff --staged --exit-code --stat
@@ -85,6 +94,11 @@ jobs:
8594
npx hereby baseline-accept
8695
git add testdata/baselines/reference
8796
git diff --staged --exit-code
97+
- uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
98+
if: ${{ failure() && steps.test.conclusion == 'failure' }}
99+
with:
100+
name: ${{ matrix.os }}-${{ (matrix.race && 'race') || 'norace' }}-new-baselines-artifact
101+
path: testdata/baselines/local
88102

89103
lint:
90104
runs-on: ubuntu-latest

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848

4949
# Initializes the CodeQL tools for scanning.
5050
- name: Initialize CodeQL
51-
uses: github/codeql-action/init@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
51+
uses: github/codeql-action/init@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
5252
with:
5353
config-file: ./.github/codeql/codeql-configuration.yml
5454
# Override language selection by uncommenting this and choosing your languages
@@ -58,7 +58,7 @@ jobs:
5858
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5959
# If this step fails, then you should remove it and run the build manually (see below).
6060
- name: Autobuild
61-
uses: github/codeql-action/autobuild@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
61+
uses: github/codeql-action/autobuild@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
6262

6363
# ℹ️ Command-line programs to run using the OS shell.
6464
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -72,4 +72,4 @@ jobs:
7272
# make release
7373

7474
- name: Perform CodeQL Analysis
75-
uses: github/codeql-action/analyze@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
75+
uses: github/codeql-action/analyze@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10

.github/workflows/merge-queue.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Merge Queue Checks
2+
3+
on:
4+
merge_group:
5+
6+
permissions:
7+
contents: read
8+
9+
# Ensure scripts are run with pipefail. See:
10+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
jobs:
16+
test:
17+
runs-on: ['self-hosted', '1ES.Pool=TypeScript-1ES-GitHub-XL', '1ES.ImageOverride=mariner-2.0']
18+
steps:
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
with:
21+
submodules: true
22+
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
23+
with:
24+
node-version: 'lts/*'
25+
- uses: ./.github/actions/setup-go
26+
with:
27+
cache-name: merge-queue-test
28+
29+
- run: npm ci
30+
- run: npx hereby test:all
31+
32+
required:
33+
runs-on: ubuntu-latest
34+
if: ${{ always() }}
35+
needs:
36+
- test
37+
38+
steps:
39+
- name: Check required jobs
40+
env:
41+
NEEDS: ${{ toJson(needs) }}
42+
run: |
43+
! echo $NEEDS | jq -e 'to_entries[] | { job: .key, result: .value.result } | select(.result != "success")'

CHANGES.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ CHANGES.md lists intentional changes between the Strada (Typescript) and Corsa (
1111
3. Malformed string ImportSpecifiers (`import x as "OOPS" from "y"`) now contain the string's text instead of an empty identifier.
1212
4. Empty binding elements no longer have a separate kind for OmittedExpression. Instead they have Kind=BindingElement with a nil Initialiser, Name and DotDotDotToken.
1313
5. ShorthandPropertyAssignment no longer includes an EqualsToken as a child when it has an ObjectAssignmentInitializer.
14-
6. The parser always parses a JSDocText node for comments in JSDoc. `string` is no longer part of the type of `comment`.
15-
7. In cases where Strada did produce a JSDocText node, Corsa no longer (incorrectly) includes all leading and trailing whitespace/asterisks, as well as initial `/**`.
16-
8. JSDocMemberName is now parsed as QualifiedName. These two nodes previously only differed by type, and now QualifiedName has a much less restrictive type for its left child.
14+
6. JSDoc nodes now include leading whitespace in their location.
15+
7. The parser always parses a JSDocText node for comments in JSDoc. `string` is no longer part of the type of `comment`.
16+
8. In cases where Strada did produce a JSDocText node, Corsa no longer (incorrectly) includes all leading and trailing whitespace/asterisks, as well as initial `/**`.
17+
9. JSDocMemberName is now parsed as QualifiedName. These two nodes previously only differed by type, and now QualifiedName has a much less restrictive type for its left child.
1718

1819
JSDoc types are parsed in normal type annotation position but show a grammar error. Corsa no longer parses the JSDoc types below, giving a parse error instead of a grammar error.
1920

Herebyfile.mjs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ const { values: options } = parseArgs({
2828
fix: { type: "boolean" },
2929
noembed: { type: "boolean" },
3030
debug: { type: "boolean" },
31+
concurrentTestPrograms: { type: "boolean" },
3132
},
3233
strict: false,
3334
allowPositionals: true,
3435
allowNegative: true,
3536
noembed: false,
3637
debug: false,
38+
concurrentTestPrograms: false,
3739
});
3840

3941
const defaultGoBuildTags = [
@@ -203,6 +205,12 @@ const goTestFlags = [
203205
...goBuildTags(),
204206
];
205207

208+
const goTestEnv = {
209+
...(options.concurrentTestPrograms ? { TS_TEST_PROGRAM_SINGLE_THREADED: "false" } : {}),
210+
};
211+
212+
const $test = $({ env: goTestEnv });
213+
206214
const gotestsum = memoize(() => {
207215
const args = isInstalled("gotestsum") ? ["gotestsum", "--format-hide-empty-pkg", "--"] : ["go", "test"];
208216
return args.concat(goTestFlags);
@@ -213,7 +221,7 @@ const goTest = memoize(() => {
213221
});
214222

215223
async function runTests() {
216-
await $`${gotestsum()} ./...`;
224+
await $test`${gotestsum()} ./... ${isCI ? ["--timeout=45m"] : []}`;
217225
}
218226

219227
export const test = task({
@@ -223,7 +231,7 @@ export const test = task({
223231

224232
async function runTestBenchmarks() {
225233
// Run the benchmarks once to ensure they compile and run without errors.
226-
await $`${goTest()} -run=- -bench=. -benchtime=1x ./...`;
234+
await $test`${goTest()} -run=- -bench=. -benchtime=1x ./...`;
227235
}
228236

229237
export const testBenchmarks = task({
@@ -232,7 +240,7 @@ export const testBenchmarks = task({
232240
});
233241

234242
async function runTestTools() {
235-
await $({ cwd: path.join(__dirname, "_tools") })`${gotestsum()} ./...`;
243+
await $test({ cwd: path.join(__dirname, "_tools") })`${gotestsum()} ./...`;
236244
}
237245

238246
export const testTools = task({

_extension/src/extension.ts

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import * as vscode from "vscode";
44
import {
55
LanguageClient,
66
LanguageClientOptions,
7+
NotebookDocumentFilter,
78
ServerOptions,
9+
TextDocumentFilter,
810
TransportKind,
911
} from "vscode-languageclient/node";
1012

@@ -55,11 +57,45 @@ export function activate(context: vscode.ExtensionContext) {
5557
onSave: true,
5658
onTabs: true,
5759
match(documentSelector, resource) {
58-
const document = vscode.workspace.textDocuments.find(doc => doc.uri.toString() === resource.toString());
59-
if (!document) {
60-
return false;
60+
// This function is called when diagnostics are requested but
61+
// only the URI itself is known (e.g. open but not yet focused tabs),
62+
// so will not be present in vscode.workspace.textDocuments.
63+
// See if this file matches without consulting vscode.languages.match
64+
// (which requires a TextDocument).
65+
66+
const language = getLanguageForUri(resource);
67+
68+
for (const selector of documentSelector) {
69+
if (typeof selector === "string") {
70+
if (selector === language) {
71+
return true;
72+
}
73+
continue;
74+
}
75+
if (NotebookDocumentFilter.is(selector)) {
76+
continue;
77+
}
78+
if (TextDocumentFilter.is(selector)) {
79+
if (selector.language !== undefined && selector.language !== language) {
80+
continue;
81+
}
82+
83+
if (selector.scheme !== undefined && selector.scheme !== resource.scheme) {
84+
continue;
85+
}
86+
87+
if (selector.pattern !== undefined) {
88+
// VS Code's glob matcher is not available via the API;
89+
// see: https://github.com/microsoft/vscode/issues/237304
90+
// But, we're only called on selectors passed above, so just ignore this for now.
91+
throw new Error("Not implemented");
92+
}
93+
94+
return true;
95+
}
6196
}
62-
return vscode.languages.match(documentSelector, document) > 0;
97+
98+
return false;
6399
},
64100
},
65101
};
@@ -81,3 +117,23 @@ export function deactivate(): Thenable<void> | undefined {
81117
}
82118
return client.stop();
83119
}
120+
121+
function getLanguageForUri(uri: vscode.Uri): string | undefined {
122+
const ext = path.posix.extname(uri.path);
123+
switch (ext) {
124+
case ".ts":
125+
case ".mts":
126+
case ".cts":
127+
return "typescript";
128+
case ".js":
129+
case ".mjs":
130+
case ".cjs":
131+
return "javascript";
132+
case ".tsx":
133+
return "typescriptreact";
134+
case ".jsx":
135+
return "javascriptreact";
136+
default:
137+
return undefined;
138+
}
139+
}

cmd/tsgo/main.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"runtime"
1111
"runtime/pprof"
1212
"slices"
13+
"strconv"
1314
"strings"
1415
"time"
1516

@@ -141,25 +142,25 @@ func main() {
141142
fs := bundled.WrapFS(osvfs.FS())
142143
defaultLibraryPath := bundled.LibPath()
143144

144-
configFilePath := tspath.ResolvePath(currentDirectory, opts.tsc.project)
145-
if !fs.FileExists(configFilePath) {
146-
configFilePath = tspath.CombinePaths(configFilePath, "tsconfig.json")
147-
if !fs.FileExists(configFilePath) {
148-
fmt.Fprintf(os.Stderr, "Error: The file %v does not exist.\n", configFilePath)
145+
configFileName := tspath.ResolvePath(currentDirectory, opts.tsc.project)
146+
if !fs.FileExists(configFileName) {
147+
configFileName = tspath.CombinePaths(configFileName, "tsconfig.json")
148+
if !fs.FileExists(configFileName) {
149+
fmt.Fprintf(os.Stderr, "Error: The file %v does not exist.\n", configFileName)
149150
os.Exit(1)
150151
}
151152
}
152153

153154
// Set up CLI option overrides
154155
compilerOptions := opts.toCompilerOptions(currentDirectory)
155156

156-
currentDirectory = tspath.GetDirectoryPath(configFilePath)
157+
currentDirectory = tspath.GetDirectoryPath(configFileName)
157158
// !!! is the working directory actually the config path?
158159
host := ts.NewCompilerHost(compilerOptions, currentDirectory, fs, defaultLibraryPath)
159160

160161
parseStart := time.Now()
161162
program := ts.NewProgram(ts.ProgramOptions{
162-
ConfigFilePath: configFilePath,
163+
ConfigFileName: configFileName,
163164
Options: compilerOptions,
164165
SingleThreaded: opts.devel.singleThreaded,
165166
Host: host,
@@ -248,6 +249,7 @@ func main() {
248249
}
249250
stats.add("Total time", totalTime)
250251
stats.add("Memory used", fmt.Sprintf("%vK", memStats.Alloc/1024))
252+
stats.add("Memory allocs", strconv.FormatUint(memStats.Mallocs, 10))
251253

252254
stats.print()
253255
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/dlclark/regexp2 v1.11.4
77
github.com/go-json-experiment/json v0.0.0-20241127185351-9802db03f36a
88
github.com/google/go-cmp v0.6.0
9+
github.com/pkg/diff v0.0.0-20241224192749-4e6772a4315c
910
golang.org/x/sys v0.27.0
1011
golang.org/x/tools v0.27.0
1112
gotest.tools/v3 v3.5.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ github.com/go-json-experiment/json v0.0.0-20241127185351-9802db03f36a h1:W/o3DbE
44
github.com/go-json-experiment/json v0.0.0-20241127185351-9802db03f36a/go.mod h1:BWmvoE1Xia34f3l/ibJweyhrT+aROb/FQ6d+37F0e2s=
55
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
66
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
7+
github.com/pkg/diff v0.0.0-20241224192749-4e6772a4315c h1:8TRxBMS/YsupXoOiGKHr9ZOXo+5DezGWPgBAhBHEHto=
8+
github.com/pkg/diff v0.0.0-20241224192749-4e6772a4315c/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
79
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
810
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
911
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=

0 commit comments

Comments
 (0)