Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
05f60b77
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
05f60b77
编写于
7月 21, 2020
作者:
J
Joey Robichaud
提交者:
GitHub
7月 21, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #46177 from dotnet/merges/release/dev16.8-preview1-to-master
Merge release/dev16.8-preview1 to master
上级
00e32f96
0c48c30f
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
209 addition
and
104 deletion
+209
-104
src/VisualStudio/Core/Def/Implementation/ProjectSystem/RunningDocumentTableEventTracker.cs
...ntation/ProjectSystem/RunningDocumentTableEventTracker.cs
+13
-30
src/VisualStudio/Core/Def/Implementation/ProjectSystem/RunningDocumentTableExtensions.cs
...mentation/ProjectSystem/RunningDocumentTableExtensions.cs
+59
-0
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.OpenFileTracker.cs
...rojectSystem/VisualStudioWorkspaceImpl.OpenFileTracker.cs
+2
-2
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
...Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
+26
-14
src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioDocumentNavigationService.cs
...tation/Workspace/VisualStudioDocumentNavigationService.cs
+109
-58
未找到文件。
src/VisualStudio/Core/Def/Implementation/ProjectSystem/RunningDocumentTableEventTracker.cs
浏览文件 @
05f60b77
...
...
@@ -2,8 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics.CodeAnalysis
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Microsoft.VisualStudio.Editor
;
...
...
@@ -125,7 +128,11 @@ public int OnAfterDocumentWindowHide(uint docCookie, IVsWindowFrame pFrame)
public
int
OnBeforeSave
(
uint
docCookie
)
=>
VSConstants
.
E_NOTIMPL
;
public
bool
IsFileOpen
(
string
fileName
)
=>
_runningDocumentTable
.
IsMonikerValid
(
fileName
);
public
bool
IsFileOpen
(
string
fileName
)
{
_foregroundAffinitization
.
AssertIsForeground
();
return
_runningDocumentTable
.
IsFileOpen
(
fileName
);
}
/// <summary>
/// Attempts to get a text buffer from the specified moniker.
...
...
@@ -133,26 +140,14 @@ public int OnBeforeSave(uint docCookie)
/// <param name="moniker">the moniker to retrieve the text buffer for.</param>
/// <param name="textBuffer">the output text buffer or null if the moniker is invalid / document is not initialized.</param>
/// <returns>true if the buffer was found with a non null value.</returns>
public
bool
TryGetBufferFromMoniker
(
string
moniker
,
out
ITextBuffer
textBuffer
)
public
bool
TryGetBufferFromMoniker
(
string
moniker
,
[
NotNullWhen
(
true
)]
out
ITextBuffer
?
textBuffer
)
{
_foregroundAffinitization
.
AssertIsForeground
();
textBuffer
=
null
;
if
(!
IsFileOpen
(
moniker
))
{
return
false
;
}
var
cookie
=
_runningDocumentTable
.
GetDocumentCookie
(
moniker
);
if
(!
_runningDocumentTable
.
IsDocumentInitialized
(
cookie
))
{
return
false
;
}
return
TryGetBuffer
(
cookie
,
out
textBuffer
);
return
_runningDocumentTable
.
TryGetBufferFromMoniker
(
_editorAdaptersFactoryService
,
moniker
,
out
textBuffer
);
}
public
IVsHierarchy
GetDocumentHierarchy
(
string
moniker
)
public
IVsHierarchy
?
GetDocumentHierarchy
(
string
moniker
)
{
if
(!
IsFileOpen
(
moniker
))
{
...
...
@@ -213,20 +208,8 @@ private bool TryGetMoniker(uint docCookie, out string moniker)
return
!
string
.
IsNullOrEmpty
(
moniker
);
}
private
bool
TryGetBuffer
(
uint
docCookie
,
out
ITextBuffer
textBuffer
)
{
textBuffer
=
null
;
// The cast from dynamic to object doesn't change semantics, but avoids loading the dynamic binder
// which saves us JIT time in this method and an assembly load.
if
((
object
)
_runningDocumentTable
.
GetDocumentData
(
docCookie
)
is
IVsTextBuffer
bufferAdapter
)
{
textBuffer
=
_editorAdaptersFactoryService
.
GetDocumentBuffer
(
bufferAdapter
);
return
textBuffer
!=
null
;
}
return
false
;
}
private
bool
TryGetBuffer
(
uint
docCookie
,
[
NotNullWhen
(
true
)]
out
ITextBuffer
?
textBuffer
)
=>
_runningDocumentTable
.
TryGetBuffer
(
_editorAdaptersFactoryService
,
docCookie
,
out
textBuffer
);
public
void
Dispose
()
{
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/RunningDocumentTableExtensions.cs
0 → 100644
浏览文件 @
05f60b77
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Diagnostics.CodeAnalysis
;
using
Microsoft.VisualStudio.Editor
;
using
Microsoft.VisualStudio.Shell.Interop
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.TextManager.Interop
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
{
/// <summary>
/// Helper extensions for calling into the RDT.
/// These must all be called from the UI thread.
/// </summary>
internal
static
class
RunningDocumentTableExtensions
{
public
static
bool
TryGetBufferFromMoniker
(
this
IVsRunningDocumentTable4
runningDocumentTable
,
IVsEditorAdaptersFactoryService
editorAdaptersFactoryService
,
string
moniker
,
[
NotNullWhen
(
true
)]
out
ITextBuffer
?
textBuffer
)
{
textBuffer
=
null
;
if
(!
runningDocumentTable
.
IsFileOpen
(
moniker
))
{
return
false
;
}
var
cookie
=
runningDocumentTable
.
GetDocumentCookie
(
moniker
);
if
(!
runningDocumentTable
.
IsDocumentInitialized
(
cookie
))
{
return
false
;
}
return
TryGetBuffer
(
runningDocumentTable
,
editorAdaptersFactoryService
,
cookie
,
out
textBuffer
);
}
public
static
bool
IsFileOpen
(
this
IVsRunningDocumentTable4
runningDocumentTable
,
string
fileName
)
=>
runningDocumentTable
.
IsMonikerValid
(
fileName
);
public
static
bool
TryGetBuffer
(
this
IVsRunningDocumentTable4
runningDocumentTable
,
IVsEditorAdaptersFactoryService
editorAdaptersFactoryService
,
uint
docCookie
,
[
NotNullWhen
(
true
)]
out
ITextBuffer
?
textBuffer
)
{
textBuffer
=
null
;
// The cast from dynamic to object doesn't change semantics, but avoids loading the dynamic binder
// which saves us JIT time in this method and an assembly load.
if
((
object
)
runningDocumentTable
.
GetDocumentData
(
docCookie
)
is
IVsTextBuffer
bufferAdapter
)
{
textBuffer
=
editorAdaptersFactoryService
.
GetDocumentBuffer
(
bufferAdapter
);
return
textBuffer
!=
null
;
}
return
false
;
}
}
}
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.OpenFileTracker.cs
浏览文件 @
05f60b77
...
...
@@ -118,7 +118,7 @@ public static async Task<OpenFileTracker> CreateAsync(VisualStudioWorkspaceImpl
return
new
OpenFileTracker
(
workspace
,
runningDocumentTable
,
componentModel
);
}
private
void
TryOpeningDocumentsForMoniker
(
string
moniker
,
ITextBuffer
textBuffer
,
IVsHierarchy
hierarchy
)
private
void
TryOpeningDocumentsForMoniker
(
string
moniker
,
ITextBuffer
textBuffer
,
IVsHierarchy
?
hierarchy
)
{
_foregroundAffinitization
.
AssertIsForeground
();
...
...
@@ -171,7 +171,7 @@ private void TryOpeningDocumentsForMoniker(string moniker, ITextBuffer textBuffe
});
}
private
ProjectId
GetActiveContextProjectIdAndWatchHierarchies
(
string
moniker
,
IEnumerable
<
ProjectId
>
projectIds
,
IVsHierarchy
hierarchy
)
private
ProjectId
GetActiveContextProjectIdAndWatchHierarchies
(
string
moniker
,
IEnumerable
<
ProjectId
>
projectIds
,
IVsHierarchy
?
hierarchy
)
{
_foregroundAffinitization
.
AssertIsForeground
();
...
...
src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs
浏览文件 @
05f60b77
...
...
@@ -998,7 +998,13 @@ public void OpenDocumentCore(DocumentId documentId, bool activate = true)
var
document
=
this
.
CurrentSolution
.
GetTextDocument
(
documentId
);
if
(
document
!=
null
)
{
if
(
TryGetFrame
(
document
,
out
var
frame
))
OpenDocumentFromPath
(
document
.
FilePath
,
document
.
Project
.
Id
,
activate
);
}
}
internal
void
OpenDocumentFromPath
(
string
?
filePath
,
ProjectId
projectId
,
bool
activate
=
true
)
{
if
(
TryGetFrame
(
filePath
,
projectId
,
out
var
frame
))
{
if
(
activate
)
{
...
...
@@ -1010,19 +1016,25 @@ public void OpenDocumentCore(DocumentId documentId, bool activate = true)
}
}
}
}
private
bool
TryGetFrame
(
CodeAnalysis
.
TextDocument
document
,
[
NotNullWhen
(
returnValue
:
true
)]
out
IVsWindowFrame
?
frame
)
/// <summary>
/// Opens a file and retrieves the window frame.
/// </summary>
/// <param name="filePath">the file path of the file to open.</param>
/// <param name="projectId">used to retrieve the IVsHierarchy to ensure the file is opened in a matching context.</param>
/// <param name="frame">the window frame.</param>
/// <returns></returns>
private
bool
TryGetFrame
(
string
?
filePath
,
ProjectId
projectId
,
[
NotNullWhen
(
returnValue
:
true
)]
out
IVsWindowFrame
?
frame
)
{
frame
=
null
;
if
(
document
.
F
ilePath
==
null
)
if
(
f
ilePath
==
null
)
{
return
false
;
}
var
hierarchy
=
GetHierarchy
(
document
.
Project
.
Id
);
var
itemId
=
hierarchy
?.
TryGetItemId
(
document
.
F
ilePath
)
??
(
uint
)
VSConstants
.
VSITEMID
.
Nil
;
var
hierarchy
=
GetHierarchy
(
project
Id
);
var
itemId
=
hierarchy
?.
TryGetItemId
(
f
ilePath
)
??
(
uint
)
VSConstants
.
VSITEMID
.
Nil
;
if
(
itemId
==
(
uint
)
VSConstants
.
VSITEMID
.
Nil
)
{
// If the ItemId is Nil, then IVsProject would not be able to open the
...
...
@@ -1031,7 +1043,7 @@ private bool TryGetFrame(CodeAnalysis.TextDocument document, [NotNullWhen(return
var
openDocumentService
=
ServiceProvider
.
GlobalProvider
.
GetService
<
SVsUIShellOpenDocument
,
IVsUIShellOpenDocument
>();
return
ErrorHandler
.
Succeeded
(
openDocumentService
.
OpenDocumentViaProject
(
document
.
F
ilePath
,
f
ilePath
,
VSConstants
.
LOGVIEWID
.
TextView_guid
,
out
_
,
out
_
,
...
...
src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioDocumentNavigationService.cs
浏览文件 @
05f60b77
...
...
@@ -3,14 +3,18 @@
// See the LICENSE file in the project root for more information.
using
System
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Threading
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.ErrorReporting
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Internal.Log
;
using
Microsoft.CodeAnalysis.Navigation
;
using
Microsoft.CodeAnalysis.Options
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.VisualStudio.Editor
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.Extensions
;
...
...
@@ -20,6 +24,7 @@
using
Microsoft.VisualStudio.Shell.Interop
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.TextManager.Interop
;
using
Roslyn.Utilities
;
using
TextSpan
=
Microsoft
.
CodeAnalysis
.
Text
.
TextSpan
;
using
VsTextSpan
=
Microsoft
.
VisualStudio
.
TextManager
.
Interop
.
TextSpan
;
...
...
@@ -31,6 +36,7 @@ internal sealed class VisualStudioDocumentNavigationService : ForegroundThreadAf
{
private
readonly
IServiceProvider
_serviceProvider
;
private
readonly
IVsEditorAdaptersFactoryService
_editorAdaptersFactoryService
;
private
readonly
IVsRunningDocumentTable4
_runningDocumentTable
;
public
VisualStudioDocumentNavigationService
(
IThreadingContext
threadingContext
,
...
...
@@ -40,6 +46,7 @@ internal sealed class VisualStudioDocumentNavigationService : ForegroundThreadAf
{
_serviceProvider
=
serviceProvider
;
_editorAdaptersFactoryService
=
editorAdaptersFactoryService
;
_runningDocumentTable
=
(
IVsRunningDocumentTable4
)
serviceProvider
.
GetService
(
typeof
(
SVsRunningDocumentTable
));
}
public
bool
CanNavigateToSpan
(
Workspace
workspace
,
DocumentId
documentId
,
TextSpan
textSpan
)
...
...
@@ -125,27 +132,75 @@ public bool CanNavigateToPosition(Workspace workspace, DocumentId documentId, in
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
);
return
TryNavigateToLocation
(
workspace
,
documentId
,
_
=>
textSpan
,
text
=>
GetVsTextSpan
(
text
,
textSpan
),
options
);
if
(!
IsForeground
()
)
static
VsTextSpan
GetVsTextSpan
(
SourceText
text
,
TextSpan
textSpan
)
{
throw
new
InvalidOperationException
(
ServicesVSResources
.
Navigation_must_be_performed_on_the_foreground_thread
);
var
boundedTextSpan
=
GetSpanWithinDocumentBounds
(
textSpan
,
text
.
Length
);
if
(
boundedTextSpan
!=
textSpan
)
{
try
{
throw
new
ArgumentOutOfRangeException
();
}
catch
(
ArgumentOutOfRangeException
e
)
when
(
FatalError
.
ReportWithoutCrash
(
e
))
{
}
}
using
(
OpenNewDocumentStateScope
(
options
??
workspace
.
Options
))
return
text
.
GetVsTextSpanForSpan
(
boundedTextSpan
);
}
}
public
bool
TryNavigateToLineAndOffset
(
Workspace
workspace
,
DocumentId
documentId
,
int
lineNumber
,
int
offset
,
OptionSet
options
)
{
var
document
=
OpenDocument
(
workspace
,
documentId
);
if
(
document
==
null
)
return
TryNavigateToLocation
(
workspace
,
documentId
,
(
document
)
=>
GetTextSpanFromLineAndOffset
(
document
,
lineNumber
,
offset
),
(
text
)
=>
GetVsTextSpan
(
text
,
lineNumber
,
offset
),
options
);
static
TextSpan
GetTextSpanFromLineAndOffset
(
Document
document
,
int
lineNumber
,
int
offset
)
{
return
false
;
var
text
=
document
.
GetTextSynchronously
(
CancellationToken
.
None
);
var
linePosition
=
new
LinePosition
(
lineNumber
,
offset
);
return
text
.
Lines
.
GetTextSpan
(
new
LinePositionSpan
(
linePosition
,
linePosition
));
}
static
VsTextSpan
GetVsTextSpan
(
SourceText
text
,
int
lineNumber
,
int
offset
)
{
return
text
.
GetVsTextSpanForLineOffset
(
lineNumber
,
offset
);
}
}
public
bool
TryNavigateToPosition
(
Workspace
workspace
,
DocumentId
documentId
,
int
position
,
int
virtualSpace
,
OptionSet
options
)
{
return
TryNavigateToLocation
(
workspace
,
documentId
,
(
document
)
=>
GetTextSpanFromPosition
(
document
,
position
,
virtualSpace
),
(
text
)
=>
GetVsTextSpan
(
text
,
position
,
virtualSpace
),
options
);
static
TextSpan
GetTextSpanFromPosition
(
Document
document
,
int
position
,
int
virtualSpace
)
{
var
text
=
document
.
GetTextSynchronously
(
CancellationToken
.
None
);
var
textBuffer
=
text
.
Container
.
GetTextBuffer
(
);
text
.
GetLineAndOffset
(
position
,
out
var
lineNumber
,
out
var
offset
);
var
boundedTextSpan
=
GetSpanWithinDocumentBounds
(
textSpan
,
text
.
Length
);
if
(
boundedTextSpan
!=
textSpan
)
offset
+=
virtualSpace
;
var
linePosition
=
new
LinePosition
(
lineNumber
,
offset
);
return
text
.
Lines
.
GetTextSpan
(
new
LinePositionSpan
(
linePosition
,
linePosition
));
}
static
VsTextSpan
GetVsTextSpan
(
SourceText
text
,
int
position
,
int
virtualSpace
)
{
var
boundedPosition
=
GetPositionWithinDocumentBounds
(
position
,
text
.
Length
);
if
(
boundedPosition
!=
position
)
{
try
{
...
...
@@ -156,19 +211,11 @@ public bool TryNavigateToSpan(Workspace workspace, DocumentId documentId, TextSp
}
}
var
vsTextSpan
=
text
.
GetVsTextSpanForSpan
(
boundedTextSpan
);
if
(
IsSecondaryBuffer
(
workspace
,
documentId
)
&&
!
vsTextSpan
.
TryMapSpanFromSecondaryBufferToPrimaryBuffer
(
workspace
,
documentId
,
out
vsTextSpan
))
{
return
false
;
}
return
NavigateTo
(
textBuffer
,
vsTextSpan
);
return
text
.
GetVsTextSpanForPosition
(
boundedPosition
,
virtualSpace
);
}
}
p
ublic
bool
TryNavigateToLineAndOffset
(
Workspace
workspace
,
DocumentId
documentId
,
int
lineNumber
,
int
offset
,
OptionSet
options
)
p
rivate
bool
TryNavigateToLocation
(
Workspace
workspace
,
DocumentId
documentId
,
Func
<
Document
,
TextSpan
>
getTextSpanForMapping
,
Func
<
SourceText
,
VsTextSpan
>
getVsTextSpan
,
OptionSet
options
)
{
// Navigation should not change the context of linked files and Shared Projects.
documentId
=
workspace
.
GetDocumentIdInCurrentContext
(
documentId
);
...
...
@@ -180,7 +227,19 @@ public bool TryNavigateToLineAndOffset(Workspace workspace, DocumentId documentI
using
(
OpenNewDocumentStateScope
(
options
??
workspace
.
Options
))
{
var
document
=
OpenDocument
(
workspace
,
documentId
);
// Before attempting to open the document, check if the location maps to a different file that should be opened instead.
var
document
=
workspace
.
CurrentSolution
.
GetDocument
(
documentId
);
var
spanMappingService
=
document
?.
Services
.
GetService
<
ISpanMappingService
>();
if
(
spanMappingService
!=
null
)
{
var
mappedSpan
=
GetMappedSpan
(
spanMappingService
,
document
,
getTextSpanForMapping
(
document
));
if
(
mappedSpan
.
HasValue
)
{
return
TryNavigateToMappedFile
(
workspace
,
document
,
mappedSpan
.
Value
);
}
}
document
=
OpenDocument
(
workspace
,
documentId
);
if
(
document
==
null
)
{
return
false
;
...
...
@@ -189,8 +248,7 @@ public bool TryNavigateToLineAndOffset(Workspace workspace, DocumentId documentI
var
text
=
document
.
GetTextSynchronously
(
CancellationToken
.
None
);
var
textBuffer
=
text
.
Container
.
GetTextBuffer
();
var
vsTextSpan
=
text
.
GetVsTextSpanForLineOffset
(
lineNumber
,
offset
);
var
vsTextSpan
=
getVsTextSpan
(
text
);
if
(
IsSecondaryBuffer
(
workspace
,
documentId
)
&&
!
vsTextSpan
.
TryMapSpanFromSecondaryBufferToPrimaryBuffer
(
workspace
,
documentId
,
out
vsTextSpan
))
{
...
...
@@ -201,49 +259,42 @@ public bool TryNavigateToLineAndOffset(Workspace workspace, DocumentId documentI
}
}
p
ublic
bool
TryNavigateToPosition
(
Workspace
workspace
,
DocumentId
documentId
,
int
position
,
int
virtualSpace
,
OptionSet
options
)
p
rivate
bool
TryNavigateToMappedFile
(
Workspace
workspace
,
Document
generatedDocument
,
MappedSpanResult
mappedSpanResult
)
{
// Navigation should not change the context of linked files and Shared Projects.
documentId
=
workspace
.
GetDocumentIdInCurrentContext
(
documentId
);
if
(!
IsForeground
())
var
vsWorkspace
=
(
VisualStudioWorkspaceImpl
)
workspace
;
// TODO - Move to IOpenDocumentService - https://github.com/dotnet/roslyn/issues/45954
// Pass the original result's project context so that if the mapped file has the same context available, we navigate
// to the mapped file with a consistent project context.
vsWorkspace
.
OpenDocumentFromPath
(
mappedSpanResult
.
FilePath
,
generatedDocument
.
Project
.
Id
);
if
(
_runningDocumentTable
.
TryGetBufferFromMoniker
(
_editorAdaptersFactoryService
,
mappedSpanResult
.
FilePath
,
out
var
textBuffer
))
{
throw
new
InvalidOperationException
(
ServicesVSResources
.
Navigation_must_be_performed_on_the_foreground_thread
);
var
vsTextSpan
=
new
VsTextSpan
{
iStartIndex
=
mappedSpanResult
.
LinePositionSpan
.
Start
.
Character
,
iStartLine
=
mappedSpanResult
.
LinePositionSpan
.
Start
.
Line
,
iEndIndex
=
mappedSpanResult
.
LinePositionSpan
.
End
.
Character
,
iEndLine
=
mappedSpanResult
.
LinePositionSpan
.
End
.
Line
};
return
NavigateTo
(
textBuffer
,
vsTextSpan
);
}
using
(
OpenNewDocumentStateScope
(
options
??
workspace
.
Options
))
{
var
document
=
OpenDocument
(
workspace
,
documentId
);
if
(
document
==
null
)
{
return
false
;
}
var
text
=
document
.
GetTextSynchronously
(
CancellationToken
.
None
);
var
textBuffer
=
text
.
Container
.
GetTextBuffer
();
var
boundedPosition
=
GetPositionWithinDocumentBounds
(
position
,
text
.
Length
);
if
(
boundedPosition
!=
position
)
private
static
MappedSpanResult
?
GetMappedSpan
(
ISpanMappingService
spanMappingService
,
Document
generatedDocument
,
TextSpan
textSpan
)
{
try
{
throw
new
ArgumentOutOfRangeException
();
}
catch
(
ArgumentOutOfRangeException
e
)
when
(
FatalError
.
ReportWithoutCrash
(
e
))
var
results
=
System
.
Threading
.
Tasks
.
Task
.
Run
(
async
()
=>
{
}
}
var
vsTextSpan
=
text
.
GetVsTextSpanForPosition
(
boundedPosition
,
virtualSpace
);
return
await
spanMappingService
.
MapSpansAsync
(
generatedDocument
,
SpecializedCollections
.
SingletonEnumerable
(
textSpan
),
CancellationToken
.
None
).
ConfigureAwait
(
true
);
}).
WaitAndGetResult
(
CancellationToken
.
None
);
if
(
IsSecondaryBuffer
(
workspace
,
documentId
)
&&
!
vsTextSpan
.
TryMapSpanFromSecondaryBufferToPrimaryBuffer
(
workspace
,
documentId
,
out
vsTextSpan
))
if
(!
results
.
IsDefaultOrEmpty
)
{
return
false
;
return
results
.
First
()
;
}
return
NavigateTo
(
textBuffer
,
vsTextSpan
);
}
return
null
;
}
/// <summary>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录