Skip to content

Commit

Permalink
Use auto properties in Microsoft.CodeAnalysis.EditorFeatures
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Aug 2, 2024
1 parent 6e393ce commit 31e51c4
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ internal class CodeActionEditHandlerService(
private readonly IThreadingContext _threadingContext = threadingContext;
private readonly IPreviewFactoryService _previewService = previewService;
private readonly IInlineRenameService _renameService = renameService;
private readonly ITextBufferAssociatedViewService _associatedViewService = associatedViewService;

public ITextBufferAssociatedViewService AssociatedViewService => _associatedViewService;
public ITextBufferAssociatedViewService AssociatedViewService { get; } = associatedViewService;

public async Task<SolutionPreviewResult?> GetPreviewsAsync(
Workspace workspace, ImmutableArray<CodeActionOperation> operations, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,20 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api;
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class VSTypeScriptGlobalOptions(IGlobalOptionService globalOptions)
{
private readonly IGlobalOptionService _globalOptions = globalOptions;

public bool BlockForCompletionItems
{
get => _globalOptions.GetOption(CompletionViewOptionsStorage.BlockForCompletionItems, InternalLanguageNames.TypeScript);
set => _globalOptions.SetGlobalOption(CompletionViewOptionsStorage.BlockForCompletionItems, InternalLanguageNames.TypeScript, value);
get => Service.GetOption(CompletionViewOptionsStorage.BlockForCompletionItems, InternalLanguageNames.TypeScript);
set => Service.SetGlobalOption(CompletionViewOptionsStorage.BlockForCompletionItems, InternalLanguageNames.TypeScript, value);
}

public void SetBackgroundAnalysisScope(bool openFilesOnly)
{
_globalOptions.SetGlobalOption(SolutionCrawlerOptionsStorage.BackgroundAnalysisScopeOption, InternalLanguageNames.TypeScript,
Service.SetGlobalOption(SolutionCrawlerOptionsStorage.BackgroundAnalysisScopeOption, InternalLanguageNames.TypeScript,
openFilesOnly ? BackgroundAnalysisScope.OpenFiles : BackgroundAnalysisScope.FullSolution);
_globalOptions.SetGlobalOption(SolutionCrawlerOptionsStorage.CompilerDiagnosticsScopeOption, InternalLanguageNames.TypeScript,
Service.SetGlobalOption(SolutionCrawlerOptionsStorage.CompilerDiagnosticsScopeOption, InternalLanguageNames.TypeScript,
openFilesOnly ? CompilerDiagnosticsScope.OpenFiles : CompilerDiagnosticsScope.FullSolution);

_globalOptions.SetGlobalOption(SolutionCrawlerOptionsStorage.RemoveDocumentDiagnosticsOnDocumentClose, InternalLanguageNames.TypeScript,
Service.SetGlobalOption(SolutionCrawlerOptionsStorage.RemoveDocumentDiagnosticsOnDocumentClose, InternalLanguageNames.TypeScript,
openFilesOnly);
}

Expand All @@ -41,5 +39,5 @@ public void SetBackgroundAnalysisScope(Workspace workspace, bool openFilesOnly)
=> SetBackgroundAnalysisScope(openFilesOnly);
#pragma warning restore

internal IGlobalOptionService Service => _globalOptions;
internal IGlobalOptionService Service { get; } = globalOptions;
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ internal void SetReferenceSpans(IEnumerable<TextSpan> spans)
foreach (var span in spans)
{
var document = _baseDocuments.First();
var renameableSpan = _session._renameInfo.GetReferenceEditSpan(
var renameableSpan = _session.RenameInfo.GetReferenceEditSpan(
new InlineRenameLocation(document, span), GetTriggerText(document, span), CancellationToken.None);
var trackingSpan = new RenameTrackingSpan(
_subjectBuffer.CurrentSnapshot.CreateTrackingSpan(renameableSpan.ToSpan(), SpanTrackingMode.EdgeInclusive, TrackingFidelityMode.Forward),
Expand Down Expand Up @@ -470,7 +470,7 @@ internal void ApplyConflictResolutionEdits(IInlineRenameReplacementInfo conflict

if (_referenceSpanToLinkedRenameSpanMap.ContainsKey(replacement.OriginalSpan) && kind != RenameSpanKind.Complexified)
{
var linkedRenameSpan = _session._renameInfo.GetConflictEditSpan(
var linkedRenameSpan = _session.RenameInfo.GetConflictEditSpan(
new InlineRenameLocation(newDocument, replacement.NewSpan), GetTriggerText(newDocument, replacement.NewSpan),
GetWithoutAttributeSuffix(_session.ReplacementText,
document.GetLanguageService<LanguageService.ISyntaxFactsService>().IsCaseSensitive), cancellationToken);
Expand Down
Loading

0 comments on commit 31e51c4

Please sign in to comment.