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 showInPreviewTab, bool activateTab, CancellationToken cancellationToken ) { var solution = documentSpan.Document.Project.Solution; var workspace = solution.Workspace; var service = workspace.Services.GetService <IDocumentNavigationService>(); var options = solution.Options.WithChangedOption( NavigationOptions.PreferProvisionalTab, showInPreviewTab ); options = options.WithChangedOption(NavigationOptions.ActivateTab, activateTab); return(service.TryNavigateToSpan( workspace, documentSpan.Document.Id, documentSpan.SourceSpan, options, cancellationToken )); }
public static Task <bool> CanNavigateToAsync(this DocumentSpan documentSpan, CancellationToken cancellationToken) { var workspace = documentSpan.Document.Project.Solution.Workspace; var service = workspace.Services.GetService <IDocumentNavigationService>(); return(service.CanNavigateToSpanAsync(workspace, documentSpan.Document.Id, documentSpan.SourceSpan, cancellationToken)); }
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 bool TryNavigateTo(this DocumentSpan documentSpan, bool showInPreviewTab, bool activateTab, CancellationToken cancellationToken) { var(workspace, service, options) = GetNavigationParts(documentSpan, showInPreviewTab, activateTab); // We're starting with one doc snapshot, but we're navigating to the current version of the doc. As such, // the span we're trying to navigate to may no longer be there. Allow for that and don't crash in that case. return(service.TryNavigateToSpan( workspace, documentSpan.Document.Id, documentSpan.SourceSpan, options, allowInvalidSpan: true, cancellationToken)); }
public static bool TryNavigateTo(this DocumentSpan documentSpan, NavigationBehavior navigationBehavior) { var solution = documentSpan.Document.Project.Solution; var workspace = solution.Workspace; var service = workspace.Services.GetService <IDocumentNavigationService>(); var options = solution.Options.WithChangedOption(NavigationOptions.PreferProvisionalTab, navigationBehavior != NavigationBehavior.Normal); options = options.WithChangedOption(NavigationOptions.ActivateProvisionalTab, navigationBehavior == NavigationBehavior.PreviewWithFocus); return(service.TryNavigateToSpan(workspace, documentSpan.Document.Id, documentSpan.SourceSpan, options)); }
private static (Workspace workspace, IDocumentNavigationService service, OptionSet options) GetNavigationParts( DocumentSpan documentSpan, bool showInPreviewTab, bool activateTab) { var solution = documentSpan.Document.Project.Solution; var workspace = solution.Workspace; var service = workspace.Services.GetService <IDocumentNavigationService>(); var options = solution.Options.WithChangedOption(NavigationOptions.PreferProvisionalTab, showInPreviewTab); options = options.WithChangedOption(NavigationOptions.ActivateTab, activateTab); return(workspace, service, options); }
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); }
public static bool TryNavigateTo(this DocumentSpan documentSpan, bool showInPreviewTab, bool activateTab, CancellationToken cancellationToken) { var solution = documentSpan.Document.Project.Solution; var workspace = solution.Workspace; var service = workspace.Services.GetService <IDocumentNavigationService>(); var options = solution.Options.WithChangedOption(NavigationOptions.PreferProvisionalTab, showInPreviewTab); options = options.WithChangedOption(NavigationOptions.ActivateTab, activateTab); // We're starting with one doc snapshot, but we're navigating to the current version of the doc. As such, // the span we're trying to navigate to may no longer be there. Allow for that and don't crash in that case. return(service.TryNavigateToSpan( workspace, documentSpan.Document.Id, documentSpan.SourceSpan, options, allowInvalidSpan: true, cancellationToken)); }
public static Task <bool> TryNavigateToAsync(this DocumentSpan documentSpan, NavigationOptions options, CancellationToken cancellationToken) { var(workspace, service) = GetNavigationParts(documentSpan); return(service.TryNavigateToSpanAsync(workspace, documentSpan.Document.Id, documentSpan.SourceSpan, options, cancellationToken)); }
private static (Workspace workspace, IDocumentNavigationService service) GetNavigationParts(DocumentSpan documentSpan) { var solution = documentSpan.Document.Project.Solution; var workspace = solution.Workspace; var service = workspace.Services.GetService <IDocumentNavigationService>(); return(workspace, service); }
public static Task <INavigableLocation?> GetNavigableLocationAsync(this DocumentSpan documentSpan, CancellationToken cancellationToken) { var(workspace, service) = GetNavigationParts(documentSpan); return(service.GetLocationForSpanAsync(workspace, documentSpan.Document.Id, documentSpan.SourceSpan, allowInvalidSpan: false, cancellationToken)); }
public static Task <bool> TryNavigateToAsync(this DocumentSpan documentSpan, bool showInPreviewTab, bool activateTab, CancellationToken cancellationToken) { var(workspace, service, options) = GetNavigationParts(documentSpan, showInPreviewTab, activateTab); return(service.TryNavigateToSpanAsync(workspace, documentSpan.Document.Id, documentSpan.SourceSpan, options, cancellationToken)); }
public DocumentIdSpan(DocumentSpan documentSpan) { _workspace = documentSpan.Document.Project.Solution.Workspace; _documentId = documentSpan.Document.Id; SourceSpan = documentSpan.SourceSpan; }