Refactor BlockStructure service and providers#49264
Conversation
This change refactors and moves the BlockStructure service and providers to the shared Workspace utilities layer. The core APIs are now based off SyntaxTree instead of Document to allow the service to be used from an analyzer context, which is required for dotnet#49197.
| namespace Microsoft.CodeAnalysis.Structure | ||
| { | ||
| internal abstract class BlockStructureServiceWithProviders : BlockStructureService | ||
| internal static class BlockStructureHelpers |
There was a problem hiding this comment.
BlockStructureServiceWithProviders was split to move the core structure creation APIs to BlockStructureHelpers helper class. All the code shown as deleted in this file is just in a separate file BlockStructureServiceWithProviders.cs
| Imports Microsoft.CodeAnalysis.Structure | ||
| Imports Microsoft.CodeAnalysis.VisualBasic.Syntax | ||
|
|
||
| Namespace Microsoft.CodeAnalysis.VisualBasic.Structure | ||
| <ExportLanguageServiceFactory(GetType(BlockStructureService), LanguageNames.VisualBasic), [Shared]> |
There was a problem hiding this comment.
All deleted code just moved to a separate file.
|
|
||
| namespace Microsoft.CodeAnalysis.Structure | ||
| { | ||
| internal abstract class BlockStructureServiceWithProviders : BlockStructureService |
There was a problem hiding this comment.
All existing code, except CreateContextAsync at the end of this file.
|
|
||
| Namespace Microsoft.CodeAnalysis.VisualBasic.Structure | ||
| <ExportLanguageServiceFactory(GetType(BlockStructureService), LanguageNames.VisualBasic), [Shared]> | ||
| Friend Class VisualBasicBlockStructureServiceFactory |
There was a problem hiding this comment.
All existing code.
can we move to Features level instead? Does this need to be in workspace layer itself? |
|
|
||
| public bool IsMetadataAsSource { get; } | ||
|
|
||
| public T GetOption<T>(PerLanguageOption2<T> option, string language) |
There was a problem hiding this comment.
i'm curious what other options we need. should we just have a BlockStructureOptions that contains the bools that we need to look at while processing?
|
Just to check, but TS/JS will still work with this right? We still have the same plugin architecture for them there? And only the C#/VB impl now defers to helpers which can now be shared? |
Yes, nothing changes for any languages with this PR. Only thing this PR does is now we can potentially invoke |
Yes, as we discussed offline, I'll do the following:
|
|
@CyrusNajmabadi I will do the refactoring to move the shared functionality into a separate shared project with a follow up PR. It also gives us time to ensure everyone on the team is fine with it (have started an email thread with the IDE team to get consensus). I will like to merge this PR to unblock #49197 |
|
Note that the block structure service is obsolete and we have a long-standing request to change to the new APIs. I forget the name of the new API so I was not able to find the tracking issue in search. |
The block structure stuff is our internal API for ths. It still remains valid (and independent of any host). There is a request to hook this up to the new API on the editor side. However, something blocking that on our side has been a request or us to tie information to view-oriented coordinates. Something which we haven't wanted to do as we want our APIs to be view independent. |
|
@CyrusNajmabadi I have reverted all the file moves to shared layer - all block structure code now lies in the Features layer itself. |
|
Hello @mavasani! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
This change refactors
and movesthe BlockStructure service and providersto the shared Workspace utilities layer. The core APIs are now based off SyntaxTree instead of Document to allow the service to be used from an analyzer context, which is required for #49197.