Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
25ebdfd2
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,发现更多精彩内容 >>
提交
25ebdfd2
编写于
10月 05, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for null locations and module locations.
上级
90a6a43a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
77 addition
and
33 deletion
+77
-33
src/Workspaces/Core/Portable/SymbolKey/SymbolKey.SymbolKeyReader.cs
...aces/Core/Portable/SymbolKey/SymbolKey.SymbolKeyReader.cs
+57
-29
src/Workspaces/Core/Portable/SymbolKey/SymbolKey.SymbolKeyWriter.cs
...aces/Core/Portable/SymbolKey/SymbolKey.SymbolKeyWriter.cs
+20
-4
未找到文件。
src/Workspaces/Core/Portable/SymbolKey/SymbolKey.SymbolKeyReader.cs
浏览文件 @
25ebdfd2
...
...
@@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis
{
internal
partial
struct
SymbolKey
{
private
abstract
class
Reader
<
TStringResult
,
TLocationResult
>
:
IDisposable
private
abstract
class
Reader
<
TStringResult
>
:
IDisposable
{
protected
const
char
OpenParenChar
=
'('
;
protected
const
char
CloseParenChar
=
')'
;
...
...
@@ -22,7 +22,6 @@ private abstract class Reader<TStringResult, TLocationResult> : IDisposable
private
readonly
Func
<
TStringResult
>
_readString
;
private
readonly
Func
<
bool
>
_readBoolean
;
private
readonly
Func
<
TLocationResult
>
_readLocation
;
private
readonly
Func
<
int
>
_readInteger
;
private
readonly
Func
<
RefKind
>
_readRefKind
;
...
...
@@ -35,7 +34,6 @@ public Reader()
{
_readString
=
ReadString
;
_readBoolean
=
ReadBoolean
;
_readLocation
=
ReadLocation
;
_readInteger
=
ReadInteger
;
_readRefKind
=
()
=>
(
RefKind
)
ReadInteger
();
}
...
...
@@ -115,8 +113,6 @@ public TStringResult ReadString()
return
ReadStringNoSpace
();
}
public
abstract
TLocationResult
ReadLocation
();
protected
TStringResult
ReadStringNoSpace
()
{
if
((
SymbolKeyType
)
Data
[
Position
]
==
SymbolKeyType
.
Null
)
...
...
@@ -176,11 +172,6 @@ public ImmutableArray<bool> ReadBooleanArray()
return
ReadArray
(
_readBoolean
);
}
public
ImmutableArray
<
TLocationResult
>
ReadLocationArray
()
{
return
ReadArray
(
_readLocation
);
}
public
ImmutableArray
<
RefKind
>
ReadRefKindArray
()
{
return
ReadArray
(
_readRefKind
);
...
...
@@ -214,14 +205,16 @@ public ImmutableArray<T> ReadArray<T>(Func<T> readFunction)
}
}
private
abstract
class
Reader
<
TSymbolResult
,
TStringResult
,
TLocationResult
>
:
Reader
<
TStringResult
,
TLocationResult
>
private
abstract
class
Reader
<
TSymbolResult
,
TStringResult
,
TLocationResult
>
:
Reader
<
TStringResult
>
{
private
readonly
Dictionary
<
int
,
TSymbolResult
>
_idToResult
=
new
Dictionary
<
int
,
TSymbolResult
>();
private
readonly
Func
<
TSymbolResult
>
_readSymbolKey
;
private
readonly
Func
<
TLocationResult
>
_readLocation
;
public
Reader
()
{
_readSymbolKey
=
ReadSymbolKey
;
_readLocation
=
ReadLocation
;
}
protected
override
void
Initialize
(
string
data
,
CancellationToken
cancellationToken
)
...
...
@@ -289,6 +282,39 @@ public ImmutableArray<TSymbolResult> ReadSymbolKeyArray()
{
return
ReadArray
(
_readSymbolKey
);
}
public
TLocationResult
ReadLocation
()
{
EatSpace
();
if
((
SymbolKeyType
)
Data
[
Position
]
==
SymbolKeyType
.
Null
)
{
Eat
(
SymbolKeyType
.
Null
);
return
default
(
TLocationResult
);
}
var
isSourceLocation
=
ReadBoolean
();
if
(
isSourceLocation
)
{
var
filePath
=
ReadString
();
var
start
=
ReadInteger
();
var
length
=
ReadInteger
();
return
CreateSourceLocation
(
filePath
,
start
,
length
);
}
else
{
var
assembly
=
ReadSymbolKey
();
var
moduleName
=
ReadString
();
return
CreateModuleLocation
(
assembly
,
moduleName
);
}
}
public
ImmutableArray
<
TLocationResult
>
ReadLocationArray
()
{
return
ReadArray
(
_readLocation
);
}
protected
abstract
TLocationResult
CreateModuleLocation
(
TSymbolResult
assembly
,
TStringResult
moduleName
);
protected
abstract
TLocationResult
CreateSourceLocation
(
TStringResult
filePath
,
int
start
,
int
length
);
}
private
class
GetHashCodeReader
:
Reader
<
int
,
int
,
int
>
...
...
@@ -337,13 +363,14 @@ protected override int CreateNullForString()
return
0
;
}
p
ublic
override
int
ReadLocation
(
)
p
rotected
override
int
CreateSourceLocation
(
int
filePath
,
int
start
,
int
length
)
{
var
filePath
=
ReadString
();
var
start
=
ReadInteger
();
var
length
=
ReadInteger
();
return
Hash
.
Combine
(
filePath
,
Hash
.
Combine
(
start
,
length
));
return
Hash
.
Combine
(
filePath
,
Hash
.
Combine
(
start
,
length
));
}
protected
override
int
CreateModuleLocation
(
int
assembly
,
int
moduleName
)
{
return
Hash
.
Combine
(
assembly
,
moduleName
);
}
public
int
ReadSymbolKeyArrayHashCode
()
...
...
@@ -409,7 +436,7 @@ protected override int ReadWorker(SymbolKeyType type)
}
}
private
class
RemoveAssemblySymbolKeysReader
:
Reader
<
object
,
object
>
private
class
RemoveAssemblySymbolKeysReader
:
Reader
<
object
>
{
private
readonly
StringBuilder
_builder
=
new
StringBuilder
();
...
...
@@ -459,12 +486,6 @@ public string RemoveAssemblySymbolKeys()
return
_builder
.
ToString
();
}
public
override
object
ReadLocation
()
{
// Should never hit this.
throw
new
InvalidOperationException
();
}
protected
override
object
CreateResultForString
(
int
start
,
int
end
,
bool
hasEmbeddedQuote
)
{
// 'start' is right after the open quote, and 'end' is right before the close quote.
...
...
@@ -551,13 +572,20 @@ protected override string CreateNullForString()
return
null
;
}
p
ublic
override
Location
ReadLocation
(
)
p
rotected
override
Location
CreateSourceLocation
(
string
filePath
,
int
start
,
int
length
)
{
var
filePath
=
ReadString
();
var
start
=
ReadInteger
();
var
length
=
ReadInteger
();
var
syntaxTree
=
Compilation
.
SyntaxTrees
.
FirstOrDefault
(
t
=>
t
.
FilePath
==
filePath
);
return
syntaxTree
==
null
?
Location
.
None
:
Location
.
Create
(
syntaxTree
,
new
TextSpan
(
start
,
length
));
Debug
.
Assert
(
syntaxTree
!=
null
);
return
Location
.
Create
(
syntaxTree
,
new
TextSpan
(
start
,
length
));
}
protected
override
Location
CreateModuleLocation
(
SymbolKeyResolution
assembly
,
string
moduleName
)
{
var
symbol
=
assembly
.
GetAnySymbol
()
as
IAssemblySymbol
;
Debug
.
Assert
(
symbol
!=
null
);
var
module
=
symbol
.
Modules
.
FirstOrDefault
(
m
=>
m
.
MetadataName
==
moduleName
);
return
module
.
Locations
.
FirstOrDefault
();
}
protected
override
SymbolKeyResolution
ReadWorker
(
SymbolKeyType
type
)
...
...
src/Workspaces/Core/Portable/SymbolKey/SymbolKey.SymbolKeyWriter.cs
浏览文件 @
25ebdfd2
...
...
@@ -242,11 +242,27 @@ internal void WriteString(string value)
internal
void
WriteLocation
(
Location
location
)
{
location
=
location
??
Location
.
None
;
WriteSpace
();
if
(
location
==
null
)
{
WriteType
(
SymbolKeyType
.
Null
);
return
;
}
Debug
.
Assert
(
location
.
IsInSource
||
location
.
IsInMetadata
);
WriteBoolean
(
location
.
IsInSource
);
WriteString
(
location
.
SourceTree
?.
FilePath
??
""
);
WriteInteger
(
location
.
SourceSpan
.
Start
);
WriteInteger
(
location
.
SourceSpan
.
Length
);
if
(
location
.
IsInSource
)
{
WriteString
(
location
.
SourceTree
.
FilePath
);
WriteInteger
(
location
.
SourceSpan
.
Start
);
WriteInteger
(
location
.
SourceSpan
.
Length
);
}
else
{
WriteSymbolKey
(
location
.
MetadataModule
.
ContainingAssembly
);
WriteString
(
location
.
MetadataModule
.
MetadataName
);
}
}
internal
void
WriteSymbolKeyArray
<
TSymbol
>(
ImmutableArray
<
TSymbol
>
symbols
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录