Skip to content

Conversation

@T-Gro
Copy link
Member

@T-Gro T-Gro commented Jul 25, 2023

This adds support for cancellation during lexing+parsing.
This does not affect the code path being taken by standalone compiler (that ones goes via ParseOneInputLexbuf at ParseAndCheckInputs.fs ;; which was not modified).

The cancellation token flows from higher-level operations which were already async{} before, this extracts the let! ct = Async.CancellationToken from it.

(cc @vzarytovskii This does mean that if operations inside Compiler.Service will be redone from async to cancellableTask, the token extraction must be also adjusted)

I tested this in VS, the operation was being cancelled under quick typing (before I adjusted the exception handlers to correctly handle the cancelled exn, it was all going into VS activity log and/or showing up an alert dialog)

@T-Gro T-Gro changed the title Cancellation support for lexing and parsing operationsin language service features Cancellation support for lexing and parsing ops in language service features Jul 25, 2023
@vzarytovskii
Copy link
Member

@vzarytovskii This does mean that if operations inside Compiler.Service will be redone from async to cancellableTask, the token extraction must be also adjusted

Yeah, currently, if you call getDefaultCancellationToken, it will return one which was passed to the topmost cancellableTask. Thinking about it. It should be renamed. To just "cancellationToken".

@T-Gro T-Gro marked this pull request as ready for review July 26, 2023 07:18
@T-Gro T-Gro requested a review from a team as a code owner July 26, 2023 07:18
@T-Gro T-Gro self-assigned this Jul 26, 2023
@T-Gro T-Gro requested review from auduchinok and baronfel July 26, 2023 12:12
Copy link
Member

@auduchinok auduchinok left a comment

Choose a reason for hiding this comment

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

It'd be interesting to see if there's a measurable change when parsing a big file, like CheckExpressions.fs, but otherwise cancellation is good to have in any case, thanks!

…-parsing-operations-esp-in-language-service-features
@T-Gro T-Gro merged commit ba720a8 into dotnet:main Jul 27, 2023
@T-Gro T-Gro deleted the 15026-add-cancellation-support-to-lexing-and-parsing-operations-esp-in-language-service-features branch July 27, 2023 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add cancellation support to lexing and parsing operations, esp. in language service features

6 participants