提交 7b40241d 编写于 作者: H HeeJae Chang 提交者: Sam Harwell

Extract DocumentSpanExtensions to its own file

上级 d5e82977
......@@ -2,9 +2,6 @@
using System;
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Navigation;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
......@@ -55,36 +52,4 @@ public override int GetHashCode()
this.Document,
this.SourceSpan.GetHashCode());
}
internal static class DocumentSpanExtensions
{
public static bool CanNavigateTo(this DocumentSpan documentSpan)
{
var workspace = documentSpan.Document.Project.Solution.Workspace;
var service = workspace.Services.GetService<IDocumentNavigationService>();
return service.CanNavigateToSpan(workspace, documentSpan.Document.Id, documentSpan.SourceSpan);
}
public static bool TryNavigateTo(this DocumentSpan documentSpan, bool isPreview)
{
var solution = documentSpan.Document.Project.Solution;
var workspace = solution.Workspace;
var service = workspace.Services.GetService<IDocumentNavigationService>();
return service.TryNavigateToSpan(workspace, documentSpan.Document.Id, documentSpan.SourceSpan,
options: solution.Options.WithChangedOption(NavigationOptions.PreferProvisionalTab, isPreview));
}
public static async Task<bool> IsHiddenAsync(
this DocumentSpan documentSpan, CancellationToken cancellationToken)
{
var document = documentSpan.Document;
if (document.SupportsSyntaxTree)
{
var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
return tree.IsHiddenPosition(documentSpan.SourceSpan.Start, cancellationToken);
}
return false;
}
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Navigation;
namespace Microsoft.CodeAnalysis
{
internal static class DocumentSpanExtensions
{
public static bool CanNavigateTo(this DocumentSpan documentSpan)
{
var workspace = documentSpan.Document.Project.Solution.Workspace;
var service = workspace.Services.GetService<IDocumentNavigationService>();
return service.CanNavigateToSpan(workspace, documentSpan.Document.Id, documentSpan.SourceSpan);
}
public static bool TryNavigateTo(this DocumentSpan documentSpan, bool isPreview)
{
var solution = documentSpan.Document.Project.Solution;
var workspace = solution.Workspace;
var service = workspace.Services.GetService<IDocumentNavigationService>();
return service.TryNavigateToSpan(workspace, documentSpan.Document.Id, documentSpan.SourceSpan,
options: solution.Options.WithChangedOption(NavigationOptions.PreferProvisionalTab, isPreview));
}
public static async Task<bool> IsHiddenAsync(
this DocumentSpan documentSpan, CancellationToken cancellationToken)
{
var document = documentSpan.Document;
if (document.SupportsSyntaxTree)
{
var tree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false);
return tree.IsHiddenPosition(documentSpan.SourceSpan.Start, cancellationToken);
}
return false;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册