提交 c91055d2 编写于 作者: D David Barbet

Rename TryGetOwningWorkspace to TryGetWorkspace.

上级 8c6c0c1c
......@@ -24,7 +24,7 @@ public VSCommanding.CommandState GetCommandState(RenameCommandArgs args)
return VSCommanding.CommandState.Unspecified;
}
if (!args.SubjectBuffer.TryGetOwningWorkspace(out var workspace) ||
if (!args.SubjectBuffer.TryGetWorkspace(out var workspace) ||
!workspace.CanApplyChange(ApplyChangesKind.ChangeDocument) ||
!args.SubjectBuffer.SupportsRename())
{
......@@ -46,7 +46,7 @@ public bool ExecuteCommand(RenameCommandArgs args, CommandExecutionContext conte
private void ExecuteRenameWorker(RenameCommandArgs args, CommandExecutionContext context)
{
if (!args.SubjectBuffer.TryGetOwningWorkspace(out var workspace))
if (!args.SubjectBuffer.TryGetWorkspace(out var workspace))
{
return;
}
......
......@@ -60,13 +60,14 @@ public bool ExecuteCommand(GoToPreviousMemberCommandArgs args, CommandExecutionC
private VSCommanding.CommandState GetCommandStateImpl(EditorCommandArgs args)
{
var caretPoint = args.TextView.GetCaretPoint(args.SubjectBuffer);
if (!IsAvailable(caretPoint, args.SubjectBuffer))
var subjectBuffer = args.SubjectBuffer;
var caretPoint = args.TextView.GetCaretPoint(subjectBuffer);
if (!caretPoint.HasValue || !subjectBuffer.SupportsNavigationToAnyPosition())
{
return VSCommanding.CommandState.Unspecified;
}
var document = args.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
var document = subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
if (document?.SupportsSyntaxTree != true)
{
return VSCommanding.CommandState.Unspecified;
......@@ -75,19 +76,17 @@ private VSCommanding.CommandState GetCommandStateImpl(EditorCommandArgs args)
return VSCommanding.CommandState.Available;
}
private static bool IsAvailable(SnapshotPoint? caretPoint, ITextBuffer subjectBuffer)
=> caretPoint.HasValue && subjectBuffer.SupportsNavigationToAnyPosition();
private bool ExecuteCommandImpl(EditorCommandArgs args, bool gotoNextMember, CommandExecutionContext context)
{
var caretPoint = args.TextView.GetCaretPoint(args.SubjectBuffer);
if (!IsAvailable(caretPoint, args.SubjectBuffer))
var subjectBuffer = args.SubjectBuffer;
var caretPoint = args.TextView.GetCaretPoint(subjectBuffer);
if (!caretPoint.HasValue || !subjectBuffer.SupportsNavigationToAnyPosition())
{
return false;
}
var document = args.SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
var document = subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
if (document?.SupportsSyntaxTree != true)
{
return false;
......@@ -103,7 +102,7 @@ private bool ExecuteCommandImpl(EditorCommandArgs args, bool gotoNextMember, Com
if (targetPosition != null)
{
args.TextView.TryMoveCaretToAndEnsureVisible(new SnapshotPoint(args.SubjectBuffer.CurrentSnapshot, targetPosition.Value), _outliningManagerService);
args.TextView.TryMoveCaretToAndEnsureVisible(new SnapshotPoint(subjectBuffer.CurrentSnapshot, targetPosition.Value), _outliningManagerService);
}
return true;
......
......@@ -52,7 +52,7 @@ public bool ExecuteCommand(GoToImplementationCommandArgs args, CommandExecutionC
using (context.OperationContext.AddScope(allowCancellation: true, EditorFeaturesResources.Locating_implementations))
{
var subjectBuffer = args.SubjectBuffer;
if (!subjectBuffer.TryGetOwningWorkspace(out var workspace))
if (!subjectBuffer.TryGetWorkspace(out var workspace))
{
return false;
}
......
......@@ -38,9 +38,9 @@ public bool ExecuteCommand(ReorderParametersCommandArgs args, CommandExecutionCo
=> ExecuteCommand(args.TextView, args.SubjectBuffer, context);
private static bool IsAvailable(ITextBuffer subjectBuffer, out Workspace workspace)
=> subjectBuffer.TryGetOwningWorkspace(out workspace) &&
workspace.CanApplyChange(ApplyChangesKind.ChangeDocument) &&
subjectBuffer.SupportsRefactorings();
=> subjectBuffer.TryGetWorkspace(out workspace) &&
workspace.CanApplyChange(ApplyChangesKind.ChangeDocument) &&
subjectBuffer.SupportsRefactorings();
private bool ExecuteCommand(ITextView textView, ITextBuffer subjectBuffer, CommandExecutionContext context)
{
......
......@@ -85,9 +85,9 @@ public bool ExecuteCommand(ExtractInterfaceCommandArgs args, CommandExecutionCon
}
private static bool IsAvailable(ITextBuffer subjectBuffer, out Workspace workspace)
=> subjectBuffer.TryGetOwningWorkspace(out workspace) &&
workspace.CanApplyChange(ApplyChangesKind.AddDocument) &&
workspace.CanApplyChange(ApplyChangesKind.ChangeDocument) &&
subjectBuffer.SupportsRefactorings();
=> subjectBuffer.TryGetWorkspace(out workspace) &&
workspace.CanApplyChange(ApplyChangesKind.AddDocument) &&
workspace.CanApplyChange(ApplyChangesKind.ChangeDocument) &&
subjectBuffer.SupportsRefactorings();
}
}
......@@ -50,7 +50,7 @@ public VSCommanding.CommandState GetCommandState(ExtractMethodCommandArgs args)
return VSCommanding.CommandState.Unspecified;
}
if (!args.SubjectBuffer.TryGetOwningWorkspace(out var workspace) ||
if (!args.SubjectBuffer.TryGetWorkspace(out var workspace) ||
!workspace.CanApplyChange(ApplyChangesKind.ChangeDocument) ||
!args.SubjectBuffer.SupportsRefactorings())
{
......
......@@ -77,7 +77,7 @@ private VSCommanding.CommandState GetCommandState(EditorCommandArgs args, Func<I
private bool IsCommandSupported(EditorCommandArgs args, out Workspace workspace)
{
workspace = null;
if (args.SubjectBuffer.TryGetOwningWorkspace(out var retrievedWorkspace))
if (args.SubjectBuffer.TryGetWorkspace(out var retrievedWorkspace))
{
workspace = retrievedWorkspace;
if (!workspace.CanApplyChange(ApplyChangesKind.ChangeDocument))
......
......@@ -44,7 +44,7 @@ internal static bool GetFeatureOnOffOption(this ITextBuffer buffer, PerLanguageO
}
}
internal static bool TryGetOwningWorkspace(this ITextBuffer buffer, out Workspace workspace)
internal static bool TryGetWorkspace(this ITextBuffer buffer, out Workspace workspace)
=> Workspace.TryGetWorkspace(buffer.AsTextContainer(), out workspace);
/// <summary>
......@@ -74,7 +74,7 @@ internal static bool SupportsNavigationToAnyPosition(this ITextBuffer buffer)
private static bool TryGetSupportsFeatureService(ITextBuffer buffer, out ITextBufferSupportsFeatureService service)
{
service = null;
if (buffer.TryGetOwningWorkspace(out var workspace))
if (buffer.TryGetWorkspace(out var workspace))
{
service = workspace.Services.GetService<ITextBufferSupportsFeatureService>();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册