-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove InferredIndentationDocumentOptionsProviderFactory
- Loading branch information
Showing
6 changed files
with
137 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 0 additions & 109 deletions
109
src/EditorFeatures/Core/Formatting/InferredIndentationDocumentOptionsProviderFactory.cs
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
src/EditorFeatures/Core/Formatting/LegacyIndentationManagerWorkspaceService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Composition; | ||
using Microsoft.CodeAnalysis.ErrorReporting; | ||
using Microsoft.CodeAnalysis.Formatting; | ||
using Microsoft.CodeAnalysis.Host.Mef; | ||
using Microsoft.CodeAnalysis.Text; | ||
using Microsoft.VisualStudio.Text; | ||
using Microsoft.VisualStudio.Text.Editor; | ||
|
||
namespace Microsoft.CodeAnalysis.Formatting; | ||
|
||
[ExportWorkspaceService(typeof(ILegacyIndentationManagerWorkspaceService)), Shared] | ||
internal sealed class LegacyIndentationManagerWorkspaceService : ILegacyIndentationManagerWorkspaceService | ||
{ | ||
private readonly IIndentationManagerService _indentationManagerService; | ||
|
||
[ImportingConstructor] | ||
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] | ||
public LegacyIndentationManagerWorkspaceService(IIndentationManagerService indentationManagerService) | ||
{ | ||
_indentationManagerService = indentationManagerService; | ||
} | ||
|
||
private static ITextBuffer GetRequiredTextBuffer(SourceText text) | ||
=> text.Container.TryGetTextBuffer() ?? throw new InvalidOperationException( | ||
"We had an open document but it wasn't associated with a buffer. That meant we couldn't apply formatting settings."); | ||
|
||
public bool UseSpacesForWhitespace(SourceText text) | ||
=> _indentationManagerService.UseSpacesForWhitespace(GetRequiredTextBuffer(text), explicitFormat: false); | ||
|
||
public int GetTabSize(SourceText text) | ||
=> _indentationManagerService.GetTabSize(GetRequiredTextBuffer(text), explicitFormat: false); | ||
|
||
public int GetIndentSize(SourceText text) | ||
=> _indentationManagerService.GetIndentSize(GetRequiredTextBuffer(text), explicitFormat: false); | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Workspaces/Core/Portable/Options/ILegacyIndentationManagerWorkspaceService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.CodeAnalysis.Host; | ||
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace Microsoft.CodeAnalysis.Formatting; | ||
|
||
/// <summary> | ||
/// Enables legacy APIs to access indentation inference editor APIs from workspace. | ||
/// https://github.com/dotnet/roslyn/issues/61109 | ||
/// </summary> | ||
internal interface ILegacyIndentationManagerWorkspaceService : IWorkspaceService | ||
{ | ||
bool UseSpacesForWhitespace(SourceText text); | ||
int GetTabSize(SourceText text); | ||
int GetIndentSize(SourceText text); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters