Skip to content

Commit

Permalink
Make FixAll APIs for refactorings internal for now. dotnet#60703 trac…
Browse files Browse the repository at this point in the history
…ks making them public in future.

Also move some helper types from shared layer to workspaces layer as a result of internalizing these APIs
  • Loading branch information
mavasani committed Apr 12, 2022
1 parent 80dc735 commit 6e86cd6
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities2" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp"/>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Razor"/>
<InternalsVisibleTo Include="IdeCoreBenchmarks"/>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Razor" />
<InternalsVisibleTo Include="IdeCoreBenchmarks" />
<InternalsVisibleTo Include="Roslyn.VisualStudio.Next.UnitTests" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.Completion.Tests" Key="$(IntelliCodeCSharpKey)" WorkItem="https://github.com/dotnet/roslyn/issues/35081" />
<RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.IntelliCode.CSharp" Partner="Pythia" Key="$(IntelliCodeCSharpKey)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ public abstract class CodeRefactoringProvider
/// registered by this code refactoring provider across the supported <see cref="FixAllScope"/>s.
/// Return null if the provider doesn't support fix all operation.
/// </summary>
public virtual FixAllProvider? GetFixAllProvider()
/// <remarks>
/// TODO: Make public, tracked with https://github.com/dotnet/roslyn/issues/60703
/// </remarks>
internal virtual FixAllProvider? GetFixAllProvider()
=> null;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ namespace Microsoft.CodeAnalysis.CodeRefactorings
/// This type provides suitable logic for fixing large solutions in an efficient manner. Projects are serially
/// processed, with all the documents in the project being processed in parallel.
/// <see cref="FixAllAsync(FixAllContext, Document, ImmutableArray{TextSpan})"/> is invoked for each document for implementors to process.
///
/// TODO: Make public, tracked with https://github.com/dotnet/roslyn/issues/60703
/// </remarks>
public abstract class DocumentBasedFixAllProvider : FixAllProvider
internal abstract class DocumentBasedFixAllProvider : FixAllProvider
{
private readonly ImmutableArray<FixAllScope> _supportedFixAllScopes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ namespace Microsoft.CodeAnalysis.CodeRefactorings
/// <summary>
/// Context for "Fix all occurrences" for code refactorings provided by each <see cref="CodeRefactoringProvider"/>.
/// </summary>
public sealed class FixAllContext
/// <remarks>
/// TODO: Make public, tracked with https://github.com/dotnet/roslyn/issues/60703
/// </remarks>
internal sealed class FixAllContext
{
internal FixAllState State { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ namespace Microsoft.CodeAnalysis.CodeRefactorings
/// <summary>
/// Implement this abstract type to provide fix all occurrences support for code refactorings.
/// </summary>
public abstract class FixAllProvider
/// <remarks>
/// TODO: Make public, tracked with https://github.com/dotnet/roslyn/issues/60703
/// </remarks>
internal abstract class FixAllProvider
{
private protected static ImmutableArray<FixAllScope> DefaultSupportedFixAllScopes
= ImmutableArray.Create(FixAllScope.Document, FixAllScope.Project, FixAllScope.Solution);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ namespace Microsoft.CodeAnalysis.CodeRefactorings
/// <summary>
/// Indicates scope for "Fix all occurrences" for code refactorings provided by each <see cref="CodeRefactoringProvider"/>.
/// </summary>
public enum FixAllScope
/// /// <remarks>
/// TODO: Make public, tracked with https://github.com/dotnet/roslyn/issues/60703
/// </remarks>
internal enum FixAllScope
{
Document,
Project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal abstract partial class SyntaxEditorBasedCodeRefactoringProvider : CodeR

protected abstract ImmutableArray<FixAllScope> SupportedFixAllScopes { get; }

public sealed override FixAllProvider? GetFixAllProvider()
internal sealed override FixAllProvider? GetFixAllProvider()
{
if (SupportedFixAllScopes.IsEmpty)
return null;
Expand Down
32 changes: 0 additions & 32 deletions src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,10 @@
abstract Microsoft.CodeAnalysis.CodeRefactorings.DocumentBasedFixAllProvider.FixAllAsync(Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext fixAllContext, Microsoft.CodeAnalysis.Document document, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Text.TextSpan> fixAllSpans) -> System.Threading.Tasks.Task<Microsoft.CodeAnalysis.Document>
Microsoft.CodeAnalysis.CodeFixes.DocumentBasedFixAllProvider.DocumentBasedFixAllProvider(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CodeFixes.FixAllScope> supportedFixAllScopes) -> void
Microsoft.CodeAnalysis.CodeFixes.FixAllContext.FixAllContext(Microsoft.CodeAnalysis.Document document, Microsoft.CodeAnalysis.Text.TextSpan? diagnosticSpan, Microsoft.CodeAnalysis.CodeFixes.CodeFixProvider codeFixProvider, Microsoft.CodeAnalysis.CodeFixes.FixAllScope scope, string codeActionEquivalenceKey, System.Collections.Generic.IEnumerable<string> diagnosticIds, Microsoft.CodeAnalysis.CodeFixes.FixAllContext.DiagnosticProvider fixAllDiagnosticProvider, System.Threading.CancellationToken cancellationToken) -> void
Microsoft.CodeAnalysis.CodeFixes.FixAllScope.ContainingMember = 4 -> Microsoft.CodeAnalysis.CodeFixes.FixAllScope
Microsoft.CodeAnalysis.CodeFixes.FixAllScope.ContainingType = 5 -> Microsoft.CodeAnalysis.CodeFixes.FixAllScope
abstract Microsoft.CodeAnalysis.CodeRefactorings.DocumentBasedFixAllProvider.SupportsFixAllForContainingMember.get -> bool
abstract Microsoft.CodeAnalysis.CodeRefactorings.DocumentBasedFixAllProvider.SupportsFixAllForContainingType.get -> bool
abstract Microsoft.CodeAnalysis.CodeRefactorings.FixAllProvider.GetFixAsync(Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext fixAllContext) -> System.Threading.Tasks.Task<Microsoft.CodeAnalysis.CodeActions.CodeAction>
Microsoft.CodeAnalysis.CodeRefactorings.DocumentBasedFixAllProvider
Microsoft.CodeAnalysis.CodeRefactorings.DocumentBasedFixAllProvider.DocumentBasedFixAllProvider() -> void
Microsoft.CodeAnalysis.CodeRefactorings.DocumentBasedFixAllProvider.DocumentBasedFixAllProvider(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope> supportedFixAllScopes) -> void
Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext
Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext.CancellationToken.get -> System.Threading.CancellationToken
Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext.CodeActionEquivalenceKey.get -> string
Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext.CodeRefactoringProvider.get -> Microsoft.CodeAnalysis.CodeRefactorings.CodeRefactoringProvider
Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext.Document.get -> Microsoft.CodeAnalysis.Document
Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext.GetFixAllSpansAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<System.Collections.Immutable.ImmutableDictionary<Microsoft.CodeAnalysis.Document, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Text.TextSpan>>>
Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext.Scope.get -> Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope
Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext.SelectionSpan.get -> Microsoft.CodeAnalysis.Text.TextSpan
Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext.WithCancellationToken(System.Threading.CancellationToken cancellationToken) -> Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext
Microsoft.CodeAnalysis.CodeRefactorings.FixAllProvider
Microsoft.CodeAnalysis.CodeRefactorings.FixAllProvider.FixAllProvider() -> void
Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope
Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope.ContainingMember = 4 -> Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope
Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope.ContainingType = 5 -> Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope
Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope.Custom = 2147483647 -> Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope
Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope.Document = 0 -> Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope
Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope.Project = 1 -> Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope
Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope.Selection = 3 -> Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope
Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope.Solution = 2 -> Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope
Microsoft.CodeAnalysis.Editing.SyntaxEditor.SyntaxEditor(Microsoft.CodeAnalysis.SyntaxNode root, Microsoft.CodeAnalysis.Host.HostWorkspaceServices services) -> void
*REMOVED*static Microsoft.CodeAnalysis.Editing.SyntaxGenerator.DefaultRemoveOptions -> Microsoft.CodeAnalysis.SyntaxRemoveOptions
static Microsoft.CodeAnalysis.CodeFixes.FixAllProvider.Create(System.Func<Microsoft.CodeAnalysis.CodeFixes.FixAllContext, Microsoft.CodeAnalysis.Document, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Diagnostic>, System.Threading.Tasks.Task<Microsoft.CodeAnalysis.Document>> fixAllAsync, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CodeFixes.FixAllScope> supportedFixAllScopes) -> Microsoft.CodeAnalysis.CodeFixes.FixAllProvider
override sealed Microsoft.CodeAnalysis.CodeRefactorings.DocumentBasedFixAllProvider.GetFixAsync(Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext fixAllContext) -> System.Threading.Tasks.Task<Microsoft.CodeAnalysis.CodeActions.CodeAction>
override sealed Microsoft.CodeAnalysis.CodeRefactorings.DocumentBasedFixAllProvider.GetSupportedFixAllScopes() -> System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope>
static Microsoft.CodeAnalysis.CodeRefactorings.FixAllProvider.Create(System.Func<Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext, Microsoft.CodeAnalysis.Document, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Text.TextSpan>, System.Threading.Tasks.Task<Microsoft.CodeAnalysis.Document>> fixAllAsync) -> Microsoft.CodeAnalysis.CodeRefactorings.FixAllProvider
static Microsoft.CodeAnalysis.CodeRefactorings.FixAllProvider.Create(System.Func<Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext, Microsoft.CodeAnalysis.Document, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Text.TextSpan>, System.Threading.Tasks.Task<Microsoft.CodeAnalysis.Document>> fixAllAsync, System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope> supportedFixAllScopes) -> Microsoft.CodeAnalysis.CodeRefactorings.FixAllProvider
static readonly Microsoft.CodeAnalysis.Editing.SyntaxGenerator.DefaultRemoveOptions -> Microsoft.CodeAnalysis.SyntaxRemoveOptions
Microsoft.CodeAnalysis.Rename.SymbolRenameOptions
Microsoft.CodeAnalysis.Rename.SymbolRenameOptions.SymbolRenameOptions() -> void
Expand All @@ -56,5 +26,3 @@ Microsoft.CodeAnalysis.Rename.DocumentRenameOptions.RenameMatchingTypeInStrings.
Microsoft.CodeAnalysis.Rename.DocumentRenameOptions.RenameMatchingTypeInComments.init -> void
static Microsoft.CodeAnalysis.Rename.Renamer.RenameDocumentAsync(Microsoft.CodeAnalysis.Document document, Microsoft.CodeAnalysis.Rename.DocumentRenameOptions options, string newDocumentName, System.Collections.Generic.IReadOnlyList<string> newDocumentFolders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<Microsoft.CodeAnalysis.Rename.Renamer.RenameDocumentActionSet>
static Microsoft.CodeAnalysis.Rename.Renamer.RenameSymbolAsync(Microsoft.CodeAnalysis.Solution solution, Microsoft.CodeAnalysis.ISymbol symbol, Microsoft.CodeAnalysis.Rename.SymbolRenameOptions options, string newName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<Microsoft.CodeAnalysis.Solution>
virtual Microsoft.CodeAnalysis.CodeRefactorings.DocumentBasedFixAllProvider.GetFixAllTitle(Microsoft.CodeAnalysis.CodeRefactorings.FixAllContext fixAllContext) -> string
virtual Microsoft.CodeAnalysis.CodeRefactorings.FixAllProvider.GetSupportedFixAllScopes() -> System.Collections.Generic.IEnumerable<Microsoft.CodeAnalysis.CodeRefactorings.FixAllScope>
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static short GetScopeIdForTelemetry(this FixAllScope scope)
_ => 7,
};

#if WORKSPACE
public static short GetScopeIdForTelemetry(this CodeRefactorings.FixAllScope scope)
=> scope switch
{
Expand All @@ -60,7 +61,7 @@ public static short GetScopeIdForTelemetry(this CodeRefactorings.FixAllScope sco
CodeRefactorings.FixAllScope.ContainingType => 5,
_ => short.MaxValue,
};

#endif
public static string GetTelemetryDiagnosticID(this Diagnostic diagnostic)
{
// we log diagnostic id as it is if it is from us
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpBlockFactsService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpCommandLineParserService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpFileBannerFactsService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpFixAllSpanMappingService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpHeaderFactsService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpMoveDeclarationNearReferenceService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CSharpSemanticFactsServiceFactory.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
<Compile Include="$(MSBuildThisFileDirectory)CodeFixes\CodeActionOptions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CodeFixes\FixAllContextExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CodeGeneration\CodeGenerationPreferences.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CodeRefactorings\FixAll\FixAllContextExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CodeRefactorings\FixAll\FixAllState.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CodeRefactorings\SyntaxEditorBasedCodeRefactoringProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)EmbeddedLanguages\VirtualChars\IVirtualCharLanguageService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ContextQuery\ISyntaxContextService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ContextQuery\SyntaxContext.cs" />
Expand All @@ -40,8 +37,6 @@
<Compile Include="$(MSBuildThisFileDirectory)CodeFixes\FixAll\FixAllState.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CodeFixes\FixAll\FixAllState.FixMultipleDiagnosticProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\CommandLine\ICommandLineParserService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\FixAllSpanMappingService\AbstractFixAllSpanMappingService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\FixAllSpanMappingService\IFixAllSpanMappingService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\GeneratedCodeRecognition\AbstractGeneratedCodeRecognitionService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\GeneratedCodeRecognition\IGeneratedCodeRecognitionService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\MoveDeclarationNearReference\AbstractMoveDeclarationNearReferenceService.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Indentation\VisualBasicIndentationService.vb" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\VisualBasicBlockFactsService.vb" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\VisualBasicFileBannerFactsService.vb" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\VisualBasicFixAllSpanMappingService.vb" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\VisualBasicHeaderFactsService.vb" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\VisualBasicMoveDeclarationNearReferenceService.vb" />
<Compile Include="$(MSBuildThisFileDirectory)LanguageServices\VisualBasicRemoveUnnecessaryImportsService.Rewriter.vb" />
Expand Down

0 comments on commit 6e86cd6

Please sign in to comment.