本文整理汇总了C#中Microsoft.CodeAnalysis.Workspace.GetDocumentIdInCurrentContext方法的典型用法代码示例。如果您正苦于以下问题:C# Workspace.GetDocumentIdInCurrentContext方法的具体用法?C# Workspace.GetDocumentIdInCurrentContext怎么用?C# Workspace.GetDocumentIdInCurrentContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.Workspace
的用法示例。
在下文中一共展示了Workspace.GetDocumentIdInCurrentContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetTextUndoHistory
public bool TryGetTextUndoHistory(Workspace editorWorkspace, ITextBuffer textBuffer, out ITextUndoHistory undoHistory)
{
undoHistory = null;
if (!(editorWorkspace is VisualStudioWorkspaceImpl) &&
!(editorWorkspace is MiscellaneousFilesWorkspace))
{
return false;
}
// TODO: Handle undo if context changes
var documentId = editorWorkspace.GetDocumentIdInCurrentContext(textBuffer.AsTextContainer());
if (documentId == null)
{
return false;
}
var document = GetDocument(editorWorkspace, documentId);
if (document == null)
{
return false;
}
undoHistory = document.GetTextUndoHistory();
return true;
}
示例2: CanNavigateToPosition
public bool CanNavigateToPosition(Workspace workspace, DocumentId documentId, int position, int virtualSpace = 0)
{
// Navigation should not change the context of linked files and Shared Projects.
documentId = workspace.GetDocumentIdInCurrentContext(documentId);
if (!IsSecondaryBuffer(workspace, documentId))
{
return true;
}
var document = workspace.CurrentSolution.GetDocument(documentId);
var text = document.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None);
var vsTextSpan = text.GetVsTextSpanForPosition(position, virtualSpace);
return CanMapFromSecondaryBufferToPrimaryBuffer(workspace, documentId, vsTextSpan);
}
示例3: TryNavigateToSpan
public bool TryNavigateToSpan(Workspace workspace, DocumentId documentId, TextSpan textSpan, OptionSet options)
{
// Navigation should not change the context of linked files and Shared Projects.
documentId = workspace.GetDocumentIdInCurrentContext(documentId);
if (!IsForeground())
{
throw new InvalidOperationException(ServicesVSResources.Navigation_must_be_performed_on_the_foreground_thread);
}
var document = OpenDocument(workspace, documentId, options);
if (document == null)
{
return false;
}
var text = document.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None);
var textBuffer = text.Container.GetTextBuffer();
var vsTextSpan = text.GetVsTextSpanForSpan(textSpan);
if (IsSecondaryBuffer(workspace, documentId) &&
!vsTextSpan.TryMapSpanFromSecondaryBufferToPrimaryBuffer(workspace, documentId, out vsTextSpan))
{
return false;
}
return NavigateTo(textBuffer, vsTextSpan);
}