Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CodeActions in the Language Service #1495

Merged
merged 25 commits into from
May 29, 2024

Conversation

orpuente-MS
Copy link
Contributor

This PR adds support for CodeActions in the Language Service. QuickFixes are one kind of CodeActions available in VS Code.

Below is a demo of QuickFixes for lints:

QuickFixes.mp4

Copy link

github-actions bot commented May 8, 2024

Benchmark for 37f8f15

Click to view benchmark
Test Base PR %
Array append evaluation 356.5±28.74µs 343.8±1.35µs -3.56%
Array literal evaluation 200.5±3.86µs 203.7±4.08µs +1.60%
Array update evaluation 438.7±20.40µs 424.1±2.66µs -3.33%
Core + Standard library compilation 16.8±0.25ms 16.9±0.33ms +0.60%
Deutsch-Jozsa evaluation 5.0±0.05ms 5.1±0.07ms +2.00%
Large file parity evaluation 33.7±0.17ms 33.8±0.10ms +0.30%
Large input file compilation 11.5±0.14ms 11.7±0.20ms +1.74%
Large input file compilation (interpreter) 45.1±1.90ms 45.4±1.30ms +0.67%
Large nested iteration 34.6±2.14ms 33.6±0.15ms -2.89%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1487.9±34.60µs 1482.2±76.61µs -0.38%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.6±0.07ms 7.6±0.07ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1402.8±29.57µs 1398.0±42.93µs -0.34%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 20.3±0.23ms 20.2±0.36ms -0.49%
Teleport evaluation 87.6±5.17µs 88.8±9.52µs +1.37%

vscode/src/codeActions.ts Outdated Show resolved Hide resolved
vscode/src/codeActions.ts Outdated Show resolved Hide resolved
vscode/src/common.ts Outdated Show resolved Hide resolved
Copy link

github-actions bot commented May 8, 2024

Benchmark for cc8ab00

Click to view benchmark
Test Base PR %
Array append evaluation 341.0±5.77µs 344.6±2.81µs +1.06%
Array literal evaluation 181.8±4.16µs 198.5±1.14µs +9.19%
Array update evaluation 422.7±5.86µs 424.6±2.99µs +0.45%
Core + Standard library compilation 16.7±0.05ms 18.4±0.49ms +10.18%
Deutsch-Jozsa evaluation 5.1±0.05ms 5.1±0.05ms 0.00%
Large file parity evaluation 33.7±0.20ms 33.8±0.37ms +0.30%
Large input file compilation 11.3±0.29ms 11.6±0.30ms +2.65%
Large input file compilation (interpreter) 43.4±0.99ms 48.0±1.45ms +10.60%
Large nested iteration 33.5±0.29ms 33.8±0.86ms +0.90%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1503.1±52.17µs 1478.0±43.02µs -1.67%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.6±0.06ms 7.6±0.07ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1424.2±43.74µs 1394.9±36.90µs -2.06%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 20.1±0.07ms 20.3±0.22ms +1.00%
Teleport evaluation 88.2±4.80µs 88.3±3.37µs +0.11%

Copy link

github-actions bot commented May 8, 2024

Benchmark for 6b8cd11

Click to view benchmark
Test Base PR %
Array append evaluation 346.2±4.84µs 341.7±3.05µs -1.30%
Array literal evaluation 201.8±18.56µs 179.4±0.81µs -11.10%
Array update evaluation 423.7±1.03µs 430.5±2.33µs +1.60%
Core + Standard library compilation 16.7±0.15ms 16.9±0.36ms +1.20%
Deutsch-Jozsa evaluation 5.1±0.06ms 5.0±0.04ms -1.96%
Large file parity evaluation 33.7±0.10ms 33.8±1.14ms +0.30%
Large input file compilation 11.2±0.06ms 11.5±0.42ms +2.68%
Large input file compilation (interpreter) 44.0±1.07ms 43.4±0.99ms -1.36%
Large nested iteration 33.5±0.12ms 34.1±0.51ms +1.79%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1534.4±35.43µs 1531.9±34.15µs -0.16%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.6±0.08ms 7.6±0.38ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1401.1±35.33µs 1401.3±29.00µs +0.01%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.0±0.15ms 27.1±0.92ms +0.37%
Teleport evaluation 88.5±3.65µs 87.4±3.54µs -1.24%

Copy link

Benchmark for 94b73f1

Click to view benchmark
Test Base PR %
Array append evaluation 329.4±2.25µs 335.0±2.23µs +1.70%
Array literal evaluation 189.6±2.24µs 188.9±0.77µs -0.37%
Array update evaluation 406.9±2.14µs 410.8±1.54µs +0.96%
Core + Standard library compilation 19.0±0.71ms 19.6±0.87ms +3.16%
Deutsch-Jozsa evaluation 5.0±0.04ms 5.0±0.17ms 0.00%
Large file parity evaluation 34.1±0.08ms 34.2±0.81ms +0.29%
Large input file compilation 12.6±0.31ms 12.7±0.44ms +0.79%
Large input file compilation (interpreter) 48.3±1.44ms 49.7±1.79ms +2.90%
Large nested iteration 32.8±1.07ms 32.9±0.62ms +0.30%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1594.0±32.74µs 1574.9±66.40µs -1.20%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.08ms 7.8±0.12ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1443.2±41.45µs 1422.6±59.06µs -1.43%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.5±0.34ms 28.1±1.12ms +2.18%
Teleport evaluation 87.6±3.70µs 87.5±3.78µs -0.11%

Copy link

Benchmark for f6c5f7d

Click to view benchmark
Test Base PR %
Array append evaluation 330.2±8.35µs 327.8±10.71µs -0.73%
Array literal evaluation 171.4±5.68µs 170.8±0.94µs -0.35%
Array update evaluation 406.3±2.29µs 405.5±6.60µs -0.20%
Core + Standard library compilation 19.1±0.51ms 19.1±0.55ms 0.00%
Deutsch-Jozsa evaluation 5.0±0.05ms 5.0±0.06ms 0.00%
Large file parity evaluation 34.0±0.62ms 33.9±0.17ms -0.29%
Large input file compilation 12.9±0.33ms 12.6±0.25ms -2.33%
Large input file compilation (interpreter) 47.7±1.29ms 48.3±1.34ms +1.26%
Large nested iteration 32.4±0.19ms 32.2±0.59ms -0.62%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1560.7±34.19µs 1562.2±39.21µs +0.10%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.07ms 7.8±0.09ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1416.7±30.02µs 1430.9±124.64µs +1.00%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.6±0.17ms 27.7±0.27ms +0.36%
Teleport evaluation 87.6±3.49µs 87.3±3.73µs -0.34%

Copy link

Benchmark for fe692d0

Click to view benchmark
Test Base PR %
Array append evaluation 325.1±2.02µs 324.5±2.09µs -0.18%
Array literal evaluation 170.9±1.11µs 175.9±4.92µs +2.93%
Array update evaluation 404.5±1.48µs 406.2±5.49µs +0.42%
Core + Standard library compilation 18.5±0.11ms 18.4±0.06ms -0.54%
Deutsch-Jozsa evaluation 5.0±0.05ms 5.0±0.05ms 0.00%
Large file parity evaluation 33.9±0.08ms 33.9±0.51ms 0.00%
Large input file compilation 12.2±0.26ms 12.2±0.18ms 0.00%
Large input file compilation (interpreter) 45.5±1.12ms 45.3±0.81ms -0.44%
Large nested iteration 32.4±0.45ms 32.4±0.40ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1552.1±40.88µs 1539.6±31.12µs -0.81%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.7±0.05ms 7.6±0.05ms -1.30%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1410.2±32.48µs 1407.4±33.69µs -0.20%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.4±0.46ms 27.2±0.14ms -0.73%
Teleport evaluation 88.5±4.53µs 87.6±4.90µs -1.02%

Copy link

Benchmark for 2643890

Click to view benchmark
Test Base PR %
Array append evaluation 327.5±3.13µs 334.3±2.68µs +2.08%
Array literal evaluation 183.9±1.01µs 184.5±2.54µs +0.33%
Array update evaluation 406.9±1.85µs 410.2±1.90µs +0.81%
Core + Standard library compilation 20.8±0.70ms 21.2±0.64ms +1.92%
Deutsch-Jozsa evaluation 5.2±0.06ms 5.1±0.06ms -1.92%
Large file parity evaluation 34.4±0.10ms 34.6±0.34ms +0.58%
Large input file compilation 13.6±0.50ms 13.6±0.39ms 0.00%
Large input file compilation (interpreter) 51.5±2.02ms 52.0±1.59ms +0.97%
Large nested iteration 32.4±0.46ms 32.9±1.25ms +1.54%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1582.1±89.27µs 1598.0±114.63µs +1.00%
Perform Runtime Capabilities Analysis (RCA) on large file sample 8.0±0.21ms 8.0±0.15ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1445.9±97.14µs 1451.3±110.07µs +0.37%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.6±0.27ms 28.8±0.35ms +0.70%
Teleport evaluation 89.7±3.72µs 89.4±3.70µs -0.33%

Copy link
Member

@minestarks minestarks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Few requested changes around range/span handling.

language_service/src/code_action.rs Outdated Show resolved Hide resolved
language_service/src/code_action.rs Outdated Show resolved Hide resolved
language_service/src/code_action.rs Show resolved Hide resolved
compiler/qsc_data_structures/src/line_column.rs Outdated Show resolved Hide resolved
vscode/src/common.ts Show resolved Hide resolved
@minestarks
Copy link
Member

Forgot to mention, you'll want to wire this up in the Playground using the Monaco editor as well. Its APIs are very similar to VS Code's, so hopefully it shouldn't be too complicated.

This is where you'd want to register it, alongside other language feature providers:

function registerMonacoLanguageServiceProviders(

https://microsoft.github.io/monaco-editor/typedoc/interfaces/languages.CodeActionProvider.html

Copy link

Benchmark for b8fd297

Click to view benchmark
Test Base PR %
Array append evaluation 332.7±1.92µs 333.7±2.76µs +0.30%
Array literal evaluation 189.7±1.10µs 198.0±3.51µs +4.38%
Array update evaluation 415.0±2.51µs 416.4±2.74µs +0.34%
Core + Standard library compilation 21.7±1.23ms 21.7±0.76ms 0.00%
Deutsch-Jozsa evaluation 5.2±0.06ms 5.3±0.06ms +1.92%
Large file parity evaluation 34.4±0.11ms 34.5±0.43ms +0.29%
Large input file compilation 15.1±0.50ms 16.0±0.68ms +5.96%
Large input file compilation (interpreter) 52.6±1.74ms 53.8±1.60ms +2.28%
Large nested iteration 32.9±0.28ms 32.7±0.15ms -0.61%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1623.2±167.24µs 1632.7±190.08µs +0.59%
Perform Runtime Capabilities Analysis (RCA) on large file sample 8.4±0.15ms 8.4±0.18ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1478.7±157.01µs 1486.7±154.97µs +0.54%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 29.6±0.23ms 29.8±1.14ms +0.68%
Teleport evaluation 92.8±5.89µs 91.2±5.26µs -1.72%

@orpuente-MS orpuente-MS marked this pull request as ready for review May 28, 2024 21:58
@orpuente-MS orpuente-MS added this pull request to the merge queue May 29, 2024
Merged via the queue into main with commit f20c06a May 29, 2024
16 checks passed
@orpuente-MS orpuente-MS deleted the oscarpuente/quickfix-support branch May 29, 2024 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants