Skip to content

Commit d5c8f16

Browse files
committed
Merge branch 'main' into jabaile/symbol-tweaks
2 parents 8396274 + fd96154 commit d5c8f16

File tree

19,899 files changed

+1367241
-4408
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,899 files changed

+1367241
-4408
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ description: Setup Go
33

44
inputs:
55
go-version:
6+
description: Go version range to set up.
67
default: '>=1.23.0'
78
cache-name:
9+
description: Name of scoped cache for this set up.
810
default: 'cache'
911

1012
runs:
@@ -18,12 +20,12 @@ runs:
1820
cache: false
1921

2022
- name: Go cache
21-
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
23+
uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
2224
with:
2325
# There is more code downloaded and built than is covered by '**/go.sum',
2426
# so give each job its own cache to try and not end up sharing the wrong
2527
# cache between jobs.
26-
key: ts-setup-go-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ github.workflow }}-${{ inputs.cache-name }}-${{ hashFiles('**/go.sum', '**/Herebyfile.mjs') }}
28+
key: ts-setup-go-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ github.workflow }}-${{ inputs.cache-name }}-${{ hashFiles('**/go.sum', '**/Herebyfile.mjs', '**/.custom-gcl.yml') }}
2729
path: |
2830
~/go/pkg/mod
2931
~/.cache/go-build

.github/workflows/ci.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,24 @@ jobs:
3535
strategy:
3636
fail-fast: false
3737
matrix:
38-
os:
39-
- ubuntu-latest
40-
- windows-latest
41-
- macos-latest
42-
no-submodules:
43-
- false
44-
race:
45-
- false
4638
include:
4739
- os: ubuntu-latest
48-
no-submodules: true
40+
- os: windows-latest
41+
- os: macos-latest
4942
- os: ubuntu-latest
43+
name: 'no submodules'
44+
no-submodules: true
45+
- os: ['self-hosted', '1ES.Pool=TypeScript-1ES-GitHub-XL', '1ES.ImageOverride=mariner-2.0']
46+
name: 'race mode'
5047
race: true
5148
- os: ubuntu-latest
49+
name: 'noembed'
5250
noembed: true
51+
- os: ubuntu-latest
52+
name: 'concurrent test programs'
53+
concurrent-test-program: true
5354

54-
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 }})
5556

5657
runs-on: ${{ matrix.os }}
5758

@@ -63,6 +64,8 @@ jobs:
6364
with:
6465
submodules: ${{ !matrix.no-submodules }}
6566
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
67+
with:
68+
node-version: 'lts/*'
6669
- uses: ./.github/actions/setup-go
6770
with:
6871
cache-name: test
@@ -71,14 +74,16 @@ jobs:
7174

7275
- run: go install gotest.tools/gotestsum@latest
7376
# Installing gotestsum is super slow on Windows.
74-
if: ${{ matrix.os != 'windows-latest' }}
77+
# Also, avoid using it in race mode so we get the full output.
78+
if: ${{ matrix.os != 'windows-latest' && !matrix.race }}
7579

7680
- name: Tests
7781
id: test
78-
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"}
7983
env:
8084
RACE_FLAG: ${{ (matrix.race && '--race') || '' }}
8185
NOEMBED_FLAG: ${{ (matrix.noembed && '--noembed') || '' }}
86+
CONCURRENTTESTPROGRAM_FLAG: ${{ (matrix.concurrent-test-program && '--concurrentTestPrograms') || '' }}
8287

8388
- run: git add .
8489
- run: git diff --staged --exit-code --stat
@@ -89,6 +94,11 @@ jobs:
8994
npx hereby baseline-accept
9095
git add testdata/baselines/reference
9196
git diff --staged --exit-code
97+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
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
92102

93103
lint:
94104
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")'

.golangci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json
22

3+
run:
4+
allow-parallel-runners: true
5+
timeout: 180s
6+
37
linters:
48
disable-all: true
59
enable:
@@ -18,7 +22,6 @@ linters:
1822
- errname
1923
- errorlint
2024
- fatcontext
21-
- gci
2225
- gocheckcompilerdirectives
2326
- goprintffuncname
2427
- gosimple

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: 24 additions & 4 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({
@@ -305,7 +313,19 @@ export const lint = task({
305313
name: "lint",
306314
run: async () => {
307315
await buildCustomLinter();
308-
await $`${customLinterPath} run ${options.fix ? ["--fix"] : []} ${isCI ? ["--timeout=5m"] : []}`;
316+
317+
const lintArgs = ["run", "--sort-results"];
318+
if (isCI) {
319+
lintArgs.push("--timeout=5m");
320+
}
321+
if (options.fix) {
322+
lintArgs.push("--fix");
323+
}
324+
325+
const resolvedCustomLinterPath = path.resolve(customLinterPath);
326+
await $`${resolvedCustomLinterPath} ${lintArgs}`;
327+
console.log("Linting _tools");
328+
await $({ cwd: "./_tools" })`${resolvedCustomLinterPath} ${lintArgs}`;
309329
},
310330
});
311331

_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+
}

_tools/customlint/emptycase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func checkCases(pass *analysis.Pass, file *ast.File, clause *ast.BlockStmt) {
6161

6262
func checkCaseStatement(pass *analysis.Pass, file *ast.File, stmt ast.Stmt, nextCasePos token.Pos) {
6363
var body []ast.Stmt
64-
colon := token.NoPos
64+
var colon token.Pos
6565

6666
switch stmt := stmt.(type) {
6767
case *ast.CaseClause:

_tools/customlint/plugin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type plugin struct{}
1616
func (f *plugin) BuildAnalyzers() ([]*analysis.Analyzer, error) {
1717
return []*analysis.Analyzer{
1818
emptyCaseAnalyzer,
19+
shadowAnalyzer,
1920
}, nil
2021
}
2122

0 commit comments

Comments
 (0)