Skip to content

Refactor BlockStructure service and providers#49264

Merged
6 commits merged intodotnet:masterfrom
mavasani:RefactorBlockStructureService
Nov 13, 2020
Merged

Refactor BlockStructure service and providers#49264
6 commits merged intodotnet:masterfrom
mavasani:RefactorBlockStructureService

Conversation

@mavasani
Copy link
Contributor

@mavasani mavasani commented Nov 10, 2020

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 #49197.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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]>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All deleted code just moved to a separate file.


namespace Microsoft.CodeAnalysis.Structure
{
internal abstract class BlockStructureServiceWithProviders : BlockStructureService
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All existing code.

@CyrusNajmabadi
Copy link
Contributor

This change refactors and moves the BlockStructure service and providers to the shared Workspace utilities layer

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

@CyrusNajmabadi
Copy link
Contributor

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?

@mavasani
Copy link
Contributor Author

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 BlockStructureHelpers.GetStructure from analyzer layer (whenever we convert LSIF generator to an analyzer) for C# and VB.

@mavasani
Copy link
Contributor Author

can we move to Features level instead? Does this need to be in workspace layer its

Yes, as we discussed offline, I'll do the following:

  1. Add a new shared Features layer that gets included in Features projects and CodeStyle projects
  2. Open a follow-up design issue to convert all the IDE shared projects into separate utility projects with public APIs with weak public API support. These projects will have no IVTs and will be used by Workspaces/Features and CodeStyle Analyzers/Fixes respectively. This would likely need RPS approval upfront as we will be loading bunch of additional assemblies on VS startup (WorkspaceUtilities, FeaturesUtilities, CSharpWorkspaceUtilities (and/or BasicWorkspaceUtilities) and CSharpFeaturesUtilities (and/or BasicFeaturesUtilities).

@mavasani
Copy link
Contributor Author

@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

@mavasani mavasani marked this pull request as ready for review November 11, 2020 16:47
@mavasani mavasani requested a review from a team as a code owner November 11, 2020 16:47
@sharwell
Copy link
Contributor

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.

@CyrusNajmabadi
Copy link
Contributor

Note that the block structure service is obsolete and we have a long-standing request to change to the new APIs

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.

@mavasani
Copy link
Contributor Author

@CyrusNajmabadi I have reverted all the file moves to shared layer - all block structure code now lies in the Features layer itself.

@mavasani mavasani added this to the 16.9 milestone Nov 13, 2020
@ghost
Copy link

ghost commented Nov 13, 2020

Hello @mavasani!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

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 (@msftbot) and give me an instruction to get started! Learn more here.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

@ghost ghost merged commit 75b0f7b into dotnet:master Nov 13, 2020
@ghost ghost modified the milestones: 16.9, Next Nov 13, 2020
@mavasani mavasani deleted the RefactorBlockStructureService branch November 13, 2020 17:41
@allisonchou allisonchou modified the milestones: Next, 16.9.P2 Nov 24, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants