Skip to content

Commit cb578a3

Browse files
committed
Merge branch 'main' into jabaile/symbol-tweaks
2 parents ee7ce24 + 7a99cd9 commit cb578a3

File tree

24,024 files changed

+975324
-28923
lines changed

Some content is hidden

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

24,024 files changed

+975324
-28923
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ubuntu-latest
2323
steps:
2424
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
25+
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
2626
- uses: ./.github/actions/setup-go
2727
with:
2828
cache-name: build
@@ -63,7 +63,7 @@ jobs:
6363
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6464
with:
6565
submodules: ${{ !matrix.no-submodules }}
66-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
66+
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
6767
with:
6868
node-version: 'lts/*'
6969
- uses: ./.github/actions/setup-go
@@ -118,7 +118,7 @@ jobs:
118118

119119
steps:
120120
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
121-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
121+
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
122122
- uses: ./.github/actions/setup-go
123123
with:
124124
cache-name: lint${{ (matrix.noembed && '-noembed') || ''}}
@@ -134,7 +134,7 @@ jobs:
134134
runs-on: ubuntu-latest
135135
steps:
136136
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
137-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
137+
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
138138
- uses: ./.github/actions/setup-go
139139
with:
140140
cache-name: format
@@ -150,7 +150,7 @@ jobs:
150150
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
151151
with:
152152
submodules: true
153-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
153+
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
154154
- uses: ./.github/actions/setup-go
155155
with:
156156
cache-name: generate
@@ -179,7 +179,7 @@ jobs:
179179
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
180180
with:
181181
submodules: true
182-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
182+
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
183183
- uses: ./.github/actions/setup-go
184184
with:
185185
cache-name: smoke

.github/workflows/merge-queue.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2020
with:
2121
submodules: true
22-
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
22+
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
2323
with:
2424
node-version: 'lts/*'
2525
- uses: ./.github/actions/setup-go

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,5 @@ custom-gcl.hash
192192
.DS_Store
193193

194194
.idea
195+
196+
!testdata/submoduleAccepted.txt

.golangci.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,18 @@ linters:
3030
- intrange
3131
- makezero
3232
- mirror
33+
- misspell
3334
- musttag
3435
- nolintlint
3536
- paralleltest
3637
- perfsprint
3738
- predeclared
3839
- reassign
39-
- tenv
4040
- testableexamples
4141
- tparallel
4242
- unconvert
4343
- usestdlibvars
44+
- usetesting
4445
- whitespace
4546

4647
- customlint
@@ -64,10 +65,6 @@ linters-settings:
6465
customlint:
6566
type: module
6667

67-
wrapcheck:
68-
ignorePackageGlobs:
69-
- encoding/*
70-
- github.com/go-json-experiment/*
7168
# revive:
7269
# enable-all-rules: true
7370
# rules:

Herebyfile.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const { values: options } = parseArgs({
2525
args: process.argv.slice(2),
2626
options: {
2727
race: { type: "boolean" },
28+
tests: { type: "string", short: "t" },
2829
fix: { type: "boolean" },
2930
noembed: { type: "boolean" },
3031
debug: { type: "boolean" },
@@ -44,7 +45,7 @@ const defaultGoBuildTags = [
4445

4546
/**
4647
* @param {...string} extra
47-
* @returns
48+
* @returns {string[]}
4849
*/
4950
function goBuildTags(...extra) {
5051
const tags = new Set(defaultGoBuildTags.concat(extra));
@@ -203,6 +204,7 @@ export const generate = task({
203204
const goTestFlags = [
204205
...goBuildFlags,
205206
...goBuildTags(),
207+
...(options.tests ? [`-run=${options.tests}`] : []),
206208
];
207209

208210
const goTestEnv = {

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ This repo uses [Go 1.24 or higher](https://go.dev/dl/), [Node.js with npm](https
1212
For tests and code generation, this repo contains a git submodule to the main TypeScript repo pointing to the commit being ported.
1313
When cloning, you'll want to clone with submodules:
1414

15-
```console
16-
$ git clone --recurse-submodules https://github.com/microsoft/typescript-go.git
15+
```sh
16+
git clone --recurse-submodules https://github.com/microsoft/typescript-go.git
1717
```
1818

1919
If you have already cloned the repo, you can initialize the submodule with:
2020

21-
```console
22-
$ git submodule update --init --recursive
21+
```sh
22+
git submodule update --init --recursive
2323
```
2424

2525
With the submodule in place and `npm ci`, you can run tasks via `hereby`, similar to the TypeScript repo:
2626

27-
```console
28-
$ hereby build # Verify that the project builds
29-
$ hereby test # Run all tests
30-
$ hereby install-tools # Install additional tools such as linters
31-
$ hereby lint # Run all linters
32-
$ hereby format # Format all code
33-
$ hereby generate # Generate all Go code (e.g. diagnostics, committed to repo)
27+
```sh
28+
hereby build # Verify that the project builds
29+
hereby test # Run all tests
30+
hereby install-tools # Install additional tools such as linters
31+
hereby lint # Run all linters
32+
hereby format # Format all code
33+
hereby generate # Generate all Go code (e.g. diagnostics, committed to repo)
3434
```
3535

3636
Additional tasks are a work in progress.

_extension/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
],
3131
"default": "verbose",
3232
"description": "Trace TypeScript Go server communication."
33+
},
34+
"typescript-go.pprofDir": {
35+
"type": "string",
36+
"description": "Directory to write pprof profiles to."
3337
}
3438
}
3539
}

_extension/src/extension.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,21 @@ export function activate(context: vscode.ExtensionContext) {
2626

2727
output.appendLine(`Resolved to ${exe}`);
2828

29+
const config = vscode.workspace.getConfiguration("typescript-go");
30+
31+
// Get pprofDir
32+
const pprofDir = config.get<string>("pprofDir");
33+
const pprofArgs = pprofDir ? ["-pprofDir", pprofDir] : [];
34+
2935
const serverOptions: ServerOptions = {
3036
run: {
3137
command: exe,
32-
args: ["lsp"],
38+
args: ["lsp", ...pprofArgs],
3339
transport: TransportKind.stdio,
3440
},
3541
debug: {
3642
command: exe,
37-
args: ["lsp"],
43+
args: ["lsp", ...pprofArgs],
3844
transport: TransportKind.stdio,
3945
},
4046
};

_tools/customlint/emptycase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var emptyCaseAnalyzer = &analysis.Analyzer{
1919
},
2020
}
2121

22-
func runEmptyCase(pass *analysis.Pass) (interface{}, error) {
22+
func runEmptyCase(pass *analysis.Pass) (any, error) {
2323
inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
2424

2525
nodeFilter := []ast.Node{

cmd/tsgo/lsp.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import (
1010
"github.com/microsoft/typescript-go/internal/bundled"
1111
"github.com/microsoft/typescript-go/internal/core"
1212
"github.com/microsoft/typescript-go/internal/lsp"
13+
"github.com/microsoft/typescript-go/internal/pprof"
1314
"github.com/microsoft/typescript-go/internal/vfs/osvfs"
1415
)
1516

1617
func runLSP(args []string) int {
1718
flag := flag.NewFlagSet("lsp", flag.ContinueOnError)
1819
stdio := flag.Bool("stdio", false, "use stdio for communication")
20+
pprofDir := flag.String("pprofDir", "", "Generate pprof CPU/memory profiles to the given directory.")
1921
pipe := flag.String("pipe", "", "use named pipe for communication")
2022
_ = pipe
2123
socket := flag.String("socket", "", "use socket for communication")
@@ -29,6 +31,12 @@ func runLSP(args []string) int {
2931
return 1
3032
}
3133

34+
if *pprofDir != "" {
35+
fmt.Fprintf(os.Stderr, "pprof profiles will be written to: %v\n", *pprofDir)
36+
profileSession := pprof.BeginProfiling(*pprofDir, os.Stderr)
37+
defer profileSession.Stop()
38+
}
39+
3240
fs := bundled.WrapFS(osvfs.FS())
3341
defaultLibraryPath := bundled.LibPath()
3442

0 commit comments

Comments
 (0)