Skip to content

Read syntax tree, source text and options synchronously in command handlers#62002

Merged
tmat merged 14 commits intodotnet:mainfrom
tmat:SynchHandlers
Jun 27, 2022
Merged

Read syntax tree, source text and options synchronously in command handlers#62002
tmat merged 14 commits intodotnet:mainfrom
tmat:SynchHandlers

Conversation

@tmat
Copy link
Member

@tmat tmat commented Jun 17, 2022

Use ParsedDocument and read options from IEditorOptions.

Use IIndentationManagerService to read line formatting options in all command handlers that use formatting/indentation options. Previously only some handlers did so.

Contributes to #57554
Fixes #61935

@tmat tmat requested a review from a team as a code owner June 17, 2022 21:42
@ghost ghost added the Area-IDE label Jun 17, 2022
@tmat tmat marked this pull request as draft June 17, 2022 21:42
@tmat tmat marked this pull request as ready for review June 22, 2022 04:47
@tmat tmat requested a review from a team June 22, 2022 04:47
@tmat
Copy link
Member Author

tmat commented Jun 22, 2022

@CyrusNajmabadi A few more commits were needed after your review, starting with d18018d, but most significantly this one: b360f4e

@tmat
Copy link
Member Author

tmat commented Jun 22, 2022

@jasonmalinowski Might be interested in reviewing this PR.

@sharwell
Copy link
Contributor

sharwell commented Jun 22, 2022

I'm having a hard time seeing the value on this PR. The summary mentions two issues:

  • Fixes #61935: This change is vastly more complicated than necessary to resolve this issue.
  • Contributes to #57554: The value of this linked issue is debatable, as is a goal to move in that direction. There are open challenges to all points presented in that issue:
    • Executing the LSP server in a separate process introduces overhead that is trivially avoided by simply running the code in-process, so this might not ever happen.
    • Avoiding document realization in devenv is unnecessary if the LSP server is running in process.
    • Avoiding asynchronous operations related to the editor loop may be unnecessary, e.g. Async backfill for completion #61600

I'm concerned that the primary outcome of this change will be someone eventually comes back and manually reverts it (moves everything back to async forms).

@tmat
Copy link
Member Author

tmat commented Jun 22, 2022

@sharwell Forgot to mention in the description/linked issue (updated) that we also have telemetry from the editor team on UI delays occurring during execution of our command handlers. This change is potentially addressing those delays, or at least reducing them to a single cause - which would be that parsing of a source text is slow. GetTextSynchronously was designed to be utilized for these purposes. The issue at the moment is that features have access to Document and any async operation it provides, so it's easy for the implementations to not know that they are being called from a command handler and need to be synchronous. ParsedDocument constraints the implementation since it does not provide any async operations to fetch text/syntax tree.

Avoiding asynchronous operations related to the editor loop may be unnecessary

The async backfill for completion is a great idea and it is gonna be needed when we need to access semantic information. It is not needed for indentation, formatting or brace completion, which is what this PR is addressing.

@tmat
Copy link
Member Author

tmat commented Jun 22, 2022

Added comment on ParsedDocument to explain its purpose.

@tmat tmat merged commit 8606aaa into dotnet:main Jun 27, 2022
@ghost ghost modified the milestones: 17.3, Next Jun 27, 2022
@tmat tmat deleted the SynchHandlers branch June 27, 2022 23:58
@tmat tmat modified the milestones: Next, 17.3 Jun 27, 2022
RikkiGibson added a commit that referenced this pull request Jun 28, 2022
RikkiGibson added a commit that referenced this pull request Jun 28, 2022
tmat added a commit that referenced this pull request Jun 28, 2022
tmat added a commit to tmat/roslyn that referenced this pull request Jun 28, 2022
tmat added a commit that referenced this pull request Jun 30, 2022
* Revert "Revert "Read syntax tree, source text and options synchronously in command handlers (#62002)" (#62189)"

This reverts commit 791de28.

* Read SmartIndent directly from global options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IBraceCompletionService is ILanguageService, but its implementations are not exported via ExportLanguageService

3 participants