Skip to content

Commit 656fcdd

Browse files
authored
Merge pull request orta#10 from orta/baselines
Showing baselines in a tree view, and clicking going to a diff
2 parents 5378829 + b8856cc commit 656fcdd

20 files changed

+3735
-883
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ out
22
node_modules
33
.vscode-test/
44
*.vsix
5+
*.log

.vscode/extensions.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
22
// See http://go.microsoft.com/fwlink/?LinkId=827846
33
// for the documentation about the extensions.json format
4-
"recommendations": [
5-
"ms-vscode.vscode-typescript-tslint-plugin"
6-
]
4+
"recommendations": []
75
}

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"outFiles": [
1717
"${workspaceFolder}/out/**/*.js"
1818
],
19-
"preLaunchTask": "npm: watch"
19+
"preLaunchTask": "npm: build"
2020
},
2121
{
2222
"name": "Extension Tests",

.vscodeignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ vsc-extension-quickstart.md
1010
**/*.ts
1111
fixtures/**
1212
screenshots/**
13+
node_modules
14+
fixtures

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,25 @@
44

55
## Features
66

7-
It's not too smart yet, but:
7+
### Test File Stuff
88

9-
- It lets you choose a test file and re-run that file easily from anywhere in your editor.
10-
- It adds syntax highlighting for .types and .symbol files in a way which won't fill your screen with errors.
11-
- It adds a command and an optional status bar indicator for the selection’s zero-based position in the current file
9+
- Get the character index of your cursor in a fourslash test
10+
- Get auto-complete for twoslash compiler flags
1211

13-
- Symbol files ![](./screenshots/symbols.png)
12+
### Syntax Highlighting for Test Files
1413

15-
- Type Files ![](./screenshots/types.png)
14+
Adds syntax highlighting for .types and .symbol files in a way which won't fill your screen with errors.
15+
- Symbol files ![](./screenshots/symbols.png)
16+
- Type Files ![](./screenshots/types.png)
1617

17-
### For more information
18+
### Changed Baselines Info
1819

19-
- [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
20-
- [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)
20+
![](./screenshots/baselines.png)
2121

22-
**Enjoy!**
22+
Shows up to 100 changed baselines with:
23+
24+
- Jump to local/reference
25+
- Show diff
26+
- Jump to test (most of the time)
27+
28+
Has a button for `gulp diff`.

jest.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
transform: {
3+
"^.+\\.tsx?$": "esbuild-jest",
4+
},
5+
testEnvironment: "node",
6+
};

package.json

Lines changed: 99 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "vscode-typescript-dev",
33
"displayName": "TSC Dev",
4-
"description": "An extension for working in the TypeScript codebase",
5-
"version": "0.0.5",
4+
"description": "An extension only for working in the TypeScript compiler codebase",
5+
"version": "0.1.0",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/orta/vscode-typescript-dev"
@@ -17,8 +17,16 @@
1717
"activationEvents": [
1818
"workspaceContains:**/*.{ts,js,tsx,jsx}"
1919
],
20-
"main": "./out/extension.js",
20+
"main": "./out/main.js",
2121
"contributes": {
22+
"views": {
23+
"explorer": [
24+
{
25+
"id": "tsDev.baselines",
26+
"name": "Changed Baselines"
27+
}
28+
]
29+
},
2230
"languages": [
2331
{
2432
"id": "ts-symbols",
@@ -45,29 +53,47 @@
4553
"path": "./syntaxes/ts-types.tmLanguage.plist"
4654
}
4755
],
48-
"commands": [
49-
{
50-
"command": "io.orta.typescript-dev.declare-current-test-file",
51-
"title": "Declare current test file",
52-
"category": "TSC"
53-
},
54-
{
55-
"command": "io.orta.typescript-dev.run-current-test-file",
56-
"title": "Run tests",
57-
"category": "TSC"
58-
},
59-
{
60-
"command": "io.orta.typescript-dev.go-to-position",
61-
"title": "Go to position",
62-
"category": "TSC"
63-
},
64-
{
65-
"command": "io.orta.typescript-dev.toggle-position",
66-
"title": "Toggle position indicator in status bar",
67-
"category": "TSC"
68-
}
69-
],
7056
"menus": {
57+
"view/title": [
58+
{
59+
"command": "tsDev.openDiffTool",
60+
"when": "view == tsDev.baselines",
61+
"group": "navigation"
62+
}
63+
],
64+
"view/item/context": [
65+
{
66+
"command": "tsDev.openTestShort",
67+
"when": "view == tsDev.baselines && viewItem == edited",
68+
"group": "inline"
69+
},
70+
{
71+
"command": "tsDev.openReferenceShort",
72+
"when": "view == tsDev.baselines && viewItem == edited",
73+
"group": "inline"
74+
},
75+
{
76+
"command": "tsDev.openDiffShort",
77+
"when": "view == tsDev.baselines && viewItem == edited",
78+
"group": "inline"
79+
},
80+
{
81+
"command": "tsDev.openTestShort",
82+
"when": "view == tsDev.baselines && viewItem == edited"
83+
},
84+
{
85+
"command": "tsDev.openReferenceShort",
86+
"when": "view == tsDev.baselines && viewItem == edited"
87+
},
88+
{
89+
"command": "tsDev.openDiffShort",
90+
"when": "view == tsDev.baselines && viewItem == edited"
91+
},
92+
{
93+
"command": "tsDev.copyPath",
94+
"when": "view == tsDev.baselines && viewItem == edited"
95+
}
96+
],
7197
"commandPalette": [
7298
{
7399
"command": "io.orta.typescript-dev.declare-current-test-file",
@@ -86,24 +112,64 @@
86112
"when": "editorFocus"
87113
}
88114
]
89-
}
115+
},
116+
"commands": [
117+
{
118+
"command": "tsDev.openDiffTool",
119+
"title": "Difftool",
120+
"shortTitle": "Gulp Diff"
121+
},
122+
{
123+
"command": "tsDev.openTestShort",
124+
"title": "Test"
125+
},
126+
{
127+
"command": "tsDev.openReferenceShort",
128+
"title": "Ref"
129+
},
130+
{
131+
"command": "tsDev.openDiffShort",
132+
"title": "Diff"
133+
},
134+
{
135+
"command": "tsDev.copyPath",
136+
"title": "Copy Path"
137+
},
138+
{
139+
"command": "io.orta.typescript-dev.go-to-position",
140+
"title": "Go to position",
141+
"category": "TSC"
142+
},
143+
{
144+
"command": "io.orta.typescript-dev.toggle-position",
145+
"title": "Toggle position indicator in status bar",
146+
"category": "TSC"
147+
}
148+
]
90149
},
91150
"scripts": {
92-
"vscode:prepublish": "yarn run compile",
151+
"vscode:prepublish": "yarn esbuild-base -- --minify",
152+
"esbuild-base": "esbuild ./src/extension.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node",
153+
"build": "yarn esbuild-base --sourcemap",
154+
"watch": "yarn esbuild-base --watch",
93155
"compile": "tsc -p ./",
94-
"watch": "tsc -watch -p ./",
95156
"pretest": "yarn run compile",
96-
"test": "node ./out/test/runTest.js"
157+
"test": "jest"
97158
},
98159
"devDependencies": {
99160
"@types/glob": "^7.1.1",
100-
"@types/mocha": "^5.2.6",
101161
"@types/node": "^10.12.21",
102162
"@types/vscode": "^1.36.0",
103163
"glob": "^7.1.4",
104-
"mocha": "^6.1.4",
105164
"tslint": "^5.12.1",
106-
"typescript": "^4.0.0-dev.20200803",
107-
"vscode-test": "^1.0.0-next.0"
165+
"typescript": "^4.3.2",
166+
"@types/jest": "^26.0.23",
167+
"esbuild": "^0.12.5",
168+
"esbuild-jest": "^0.5.0",
169+
"jest": "^27.0.3"
170+
},
171+
"dependencies": {},
172+
"prettier": {
173+
"printWidth": 140
108174
}
109175
}

screenshots/baselines.png

199 KB
Loading

src/baselineFinder.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as vscode from "vscode";
2+
3+
export const createBaselineFinder = (workspaceRoot: string) => {
4+
const emitter = new vscode.EventEmitter<vscode.Uri[]>();
5+
6+
const run = () => {
7+
const local = new vscode.RelativePattern(workspaceRoot, "tests/baselines/local/**/*");
8+
vscode.workspace.findFiles(local.pattern, null, 100).then((r) => emitter.fire(r));
9+
};
10+
11+
let interval: any | undefined = undefined;
12+
13+
const startTimer = () => {
14+
if (interval) clearInterval(interval);
15+
run();
16+
// Every 30s
17+
setInterval(run, 30 * 1000);
18+
};
19+
20+
const stopTimer = () => {
21+
if (interval) clearInterval(interval);
22+
};
23+
24+
return {
25+
resultsEmitter: emitter,
26+
run,
27+
startTimer,
28+
stopTimer,
29+
};
30+
};
31+
32+
export type Runner = ReturnType<typeof createBaselineFinder>;

src/baselineToTest.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { join } from "path";
2+
import { baselineToTester } from "./baselineToTest";
3+
4+
it("resolves to compiler baselines ", () => {
5+
const root = join(__dirname, "..", "..", "typescript-compiler");
6+
const baseLineToTest = baselineToTester({ tscRoot: root });
7+
8+
const result = root + "/tests/cases/compiler/acceptableAlias1.ts";
9+
expect(baseLineToTest("/tests/baselines/local/acceptableAlias1.js")).toEqual(result);
10+
expect(baseLineToTest("/tests/baselines/local/acceptableAlias1.symbols")).toEqual(result);
11+
expect(baseLineToTest("/tests/baselines/local/acceptableAlias1.types")).toEqual(result);
12+
expect(baseLineToTest("/tests/baselines/local/acceptableAlias1.errors.txt")).toEqual(result);
13+
});
14+
15+
it("resolves to a subfolder ", () => {
16+
const root = join(__dirname, "..", "..", "typescript-compiler");
17+
const baseLineToTest = baselineToTester({ tscRoot: root });
18+
19+
const result = root + "/tests/cases/conformance/classes/propertyMemberDeclarations/abstractPropertyInitializer.ts";
20+
expect(baseLineToTest("/tests/baselines/reference/abstractPropertyInitializer.js")).toEqual(result);
21+
expect(baseLineToTest("/tests/baselines/reference/abstractPropertyInitializer.types")).toEqual(result);
22+
});
23+
24+
it("handles multi-arg files ", () => {
25+
const root = join(__dirname, "..", "..", "typescript-compiler");
26+
const baseLineToTest = baselineToTester({ tscRoot: root });
27+
28+
const result = root + "/tests/cases/conformance/es2020/modules/exportAsNamespace1.ts";
29+
expect(baseLineToTest("/tests/baselines/reference/exportAsNamespace1_amd.js")).toEqual(result);
30+
});
31+
32+
// tests/baselines/reference/exportAndImport-es3-amd.js
33+
// -> tests/cases/conformance/es6/modules/exportAndImport-es3.ts
34+
35+
describe("edge cases", () => {
36+
it("tsbuild", () => {
37+
const root = join(__dirname, "..", "..", "typescript-compiler");
38+
const baseLineToTest = baselineToTester({ tscRoot: root });
39+
40+
const tests = [
41+
[
42+
"/tests/baselines/local/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-prologues-in-all-projects.js",
43+
"/src/testRunner/unittests/tsbuild/amdModulesWithOut.ts:85",
44+
],
45+
];
46+
for (const test of tests) {
47+
expect(baseLineToTest(root + test[0])).toEqual(root + test[1]);
48+
}
49+
});
50+
});

0 commit comments

Comments
 (0)