Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1bd00171
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,发现更多精彩内容 >>
提交
1bd00171
编写于
9月 08, 2015
作者:
B
Balaji Krishnan
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4797 from balajikris/RDT-3645
Get document moniker from IVsProject instead of RDT
上级
11a209fd
8493a37c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
10 addition
and
82 deletion
+10
-82
src/VisualStudio/Core/Def/Implementation/Utilities/VsHierarchyExtensions.cs
...ore/Def/Implementation/Utilities/VsHierarchyExtensions.cs
+0
-65
src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs
...Studio/Core/Def/Implementation/Venus/ContainedDocument.cs
+9
-15
src/VisualStudio/Core/Def/ServicesVisualStudio.csproj
src/VisualStudio/Core/Def/ServicesVisualStudio.csproj
+1
-2
未找到文件。
src/VisualStudio/Core/Def/Implementation/Utilities/VsHierarchyExtensions.cs
已删除
100644 → 0
浏览文件 @
11a209fd
// 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
;
using
System.Runtime.InteropServices
;
using
Microsoft.VisualStudio.Shell.Interop
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.Utilities
{
internal
static
class
VsHierarchyExtensions
{
public
static
string
GetMonikerForHierarchyAndItemId
(
this
IVsRunningDocumentTable
runningDocTable
,
IVsHierarchy
hierarchy
,
uint
itemid
)
{
if
(
runningDocTable
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
runningDocTable
));
}
if
(
hierarchy
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
hierarchy
));
}
// First, get the doc cookie for this
IEnumRunningDocuments
runningDocsEnum
;
Marshal
.
ThrowExceptionForHR
(
runningDocTable
.
GetRunningDocumentsEnum
(
out
runningDocsEnum
));
var
cookies
=
new
uint
[
1
];
uint
cookiesFetched
;
while
(
runningDocsEnum
.
Next
(
1
,
cookies
,
out
cookiesFetched
)
==
VSConstants
.
S_OK
&&
cookiesFetched
==
1
)
{
uint
documentFlags
;
uint
documentReadLocks
;
uint
documentEditLocks
;
string
documentId
;
IVsHierarchy
documentHierarchy
;
uint
documentItemID
;
IntPtr
pDocData
;
Marshal
.
ThrowExceptionForHR
(
runningDocTable
.
GetDocumentInfo
(
cookies
[
0
],
out
documentFlags
,
out
documentReadLocks
,
out
documentEditLocks
,
out
documentId
,
out
documentHierarchy
,
out
documentItemID
,
out
pDocData
));
try
{
if
(
documentHierarchy
==
hierarchy
&&
documentItemID
==
itemid
)
{
return
documentId
;
}
}
finally
{
Marshal
.
Release
(
pDocData
);
}
}
// Uh, OK, that's probably not good that we're supposedly an open file but not in the RDT.
return
null
;
}
// Gets the IVsHierarchy's name property for this item.
public
static
string
GetDocumentNameForHierarchyAndItemId
(
this
IVsHierarchy
hierarchy
,
uint
itemid
)
{
object
property
;
Marshal
.
ThrowExceptionForHR
(
hierarchy
.
GetProperty
(
itemid
,
(
int
)
__VSHPROPID
.
VSHPROPID_Name
,
out
property
));
return
(
string
)
property
;
}
}
}
src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs
浏览文件 @
1bd00171
...
...
@@ -98,22 +98,16 @@ internal sealed class ContainedDocument : ForegroundThreadAffinitizedObject, IVi
_optionService
=
_workspace
.
Services
.
GetService
<
IOptionService
>();
_hostType
=
GetHostType
();
var
rdt
=
(
IVsRunningDocumentTable
)
componentModel
.
GetService
<
SVsServiceProvider
>().
GetService
(
typeof
(
SVsRunningDocumentTable
));
IVsHierarchy
sharedHierarchy
;
uint
itemIdInSharedHierarchy
;
var
isSharedHierarchy
=
LinkedFileUtilities
.
TryGetSharedHierarchyAndItemId
(
hierarchy
,
itemId
,
out
sharedHierarchy
,
out
itemIdInSharedHierarchy
);
var
filePath
=
isSharedHierarchy
?
rdt
.
GetMonikerForHierarchyAndItemId
(
sharedHierarchy
,
itemIdInSharedHierarchy
)
:
rdt
.
GetMonikerForHierarchyAndItemId
(
hierarchy
,
itemId
);
// we couldn't look up the document moniker in RDT for a hierarchy/item pair
// Since we only use this moniker as a key, we could fall back to something else, like the document name.
if
(
filePath
==
null
)
string
filePath
;
if
(!
ErrorHandler
.
Succeeded
(((
IVsProject
)
hierarchy
).
GetMkDocument
(
itemId
,
out
filePath
)))
{
Debug
.
Assert
(
false
,
"Could not get the document moniker for an item in its hierarchy."
);
filePath
=
hierarchy
.
GetDocumentNameForHierarchyAndItemId
(
itemId
);
// we couldn't look up the document moniker from an hierarchy for an itemid.
// Since we only use this moniker as a key, we could fall back to something else, like the document name.
Debug
.
Assert
(
false
,
"Could not get the document moniker for an item from its hierarchy."
);
if
(!
hierarchy
.
TryGetItemName
(
itemId
,
out
filePath
))
{
Environment
.
FailFast
(
"Failed to get document moniker for a contained document"
);
}
}
if
(
Project
.
Hierarchy
!=
null
)
...
...
src/VisualStudio/Core/Def/ServicesVisualStudio.csproj
浏览文件 @
1bd00171
...
...
@@ -649,7 +649,6 @@
<Compile
Include=
"Implementation\Utilities\VsDebugName.cs"
/>
<Compile
Include=
"Implementation\Utilities\VsEnumBSTR.cs"
/>
<Compile
Include=
"Implementation\Utilities\VsEnumDebugName.cs"
/>
<Compile
Include=
"Implementation\Utilities\VsHierarchyExtensions.cs"
/>
<Compile
Include=
"Implementation\Venus\AbstractContainedLanguage.cs"
/>
<Compile
Include=
"Implementation\Venus\CodeBlockEnumerator.cs"
/>
<Compile
Include=
"Implementation\Venus\ContainedDocument.cs"
/>
...
...
@@ -752,4 +751,4 @@
<Import
Project=
"..\..\..\..\build\Targets\VSL.Imports.targets"
/>
<Import
Project=
"$(SolutionDir)\.nuget\NuGet.targets"
Condition=
"Exists('$(SolutionDir)\.nuget\NuGet.targets')"
/>
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录