Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
668a1a3c
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,发现更多精彩内容 >>
提交
668a1a3c
编写于
4月 29, 2017
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Store a single checksum for syntax-tree-indices.
上级
d684965b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
38 deletion
+29
-38
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Serialization.cs
...le/FindSymbols/SymbolTree/SymbolTreeInfo_Serialization.cs
+1
-1
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Source.cs
.../Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Source.cs
+1
-1
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex.cs
...s/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex.cs
+2
-4
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex_Create.cs
...Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex_Create.cs
+2
-3
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex_Persistence.cs
...ble/FindSymbols/SyntaxTree/SyntaxTreeIndex_Persistence.cs
+23
-29
未找到文件。
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Serialization.cs
浏览文件 @
668a1a3c
...
...
@@ -17,7 +17,7 @@ namespace Microsoft.CodeAnalysis.FindSymbols
internal
partial
class
SymbolTreeInfo
{
private
const
string
PrefixMetadataSymbolTreeInfo
=
"<SymbolTreeInfo>"
;
private
const
string
SerializationFormat
=
"1
6
"
;
private
const
string
SerializationFormat
=
"1
7
"
;
/// <summary>
/// Loads the SymbolTreeInfo for a given assembly symbol (metadata or project). If the
...
...
src/Workspaces/Core/Portable/FindSymbols/SymbolTree/SymbolTreeInfo_Source.cs
浏览文件 @
668a1a3c
...
...
@@ -31,7 +31,7 @@ private static void FreeSymbolMap(MultiDictionary<string, ISymbol> symbolMap)
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
stateChecksums
=
await
project
.
State
.
GetStateChecksumsAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
checksum
=
Checksum
.
Create
(
"SymbolTree"
,
var
checksum
=
Checksum
.
Create
(
nameof
(
SymbolTreeInfo
)
,
new
Checksum
[]
{
stateChecksums
.
Documents
.
Checksum
,
stateChecksums
.
CompilationOptions
,
stateChecksums
.
ParseOptions
});
return
await
LoadOrCreateSourceSymbolTreeInfoAsync
(
...
...
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex.cs
浏览文件 @
668a1a3c
...
...
@@ -17,15 +17,13 @@ internal sealed partial class SyntaxTreeIndex
private
readonly
DeclarationInfo
_declarationInfo
;
private
SyntaxTreeIndex
(
Checksum
textChecksum
,
Checksum
parseOptionsChecksum
,
Checksum
checksum
,
LiteralInfo
literalInfo
,
IdentifierInfo
identifierInfo
,
ContextInfo
contextInfo
,
DeclarationInfo
declarationInfo
)
{
TextChecksum
=
textChecksum
;
ParseOptionsChecksum
=
parseOptionsChecksum
;
this
.
Checksum
=
checksum
;
_literalInfo
=
literalInfo
;
_identifierInfo
=
identifierInfo
;
_contextInfo
=
contextInfo
;
...
...
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex_Create.cs
浏览文件 @
668a1a3c
...
...
@@ -154,11 +154,10 @@ private static async Task<SyntaxTreeIndex> CreateInfoAsync(Document document, Ca
}
}
var
checksum
s
=
await
GetChecksums
Async
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
var
checksum
=
await
GetChecksum
Async
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
return
new
SyntaxTreeIndex
(
checksums
.
textChecksum
,
checksums
.
parseOptionsChecksum
,
checksum
,
new
LiteralInfo
(
new
BloomFilter
(
FalsePositiveProbability
,
stringLiterals
,
longLiterals
)),
new
IdentifierInfo
(
...
...
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeIndex_Persistence.cs
浏览文件 @
668a1a3c
...
...
@@ -13,42 +13,37 @@ namespace Microsoft.CodeAnalysis.FindSymbols
internal
sealed
partial
class
SyntaxTreeIndex
:
IObjectWritable
{
private
const
string
PersistenceName
=
"<SyntaxTreeIndex>"
;
private
const
string
SerializationFormat
=
"
7
"
;
private
const
string
SerializationFormat
=
"
8
"
;
public
readonly
Checksum
TextChecksum
;
public
readonly
Checksum
ParseOptionsChecksum
;
public
readonly
Checksum
Checksum
;
private
void
WriteFormatAndChecksum
s
(
ObjectWriter
writer
,
string
formatVersion
)
private
void
WriteFormatAndChecksum
(
ObjectWriter
writer
,
string
formatVersion
)
{
writer
.
WriteString
(
formatVersion
);
TextChecksum
.
WriteTo
(
writer
);
ParseOptionsChecksum
.
WriteTo
(
writer
);
Checksum
.
WriteTo
(
writer
);
}
private
static
bool
TryReadFormatAndChecksums
(
ObjectReader
reader
,
string
formatVersion
,
out
Checksum
textChecksum
,
out
Checksum
parseOptionsChecksum
)
private
static
bool
TryReadFormatAndChecksum
(
ObjectReader
reader
,
string
formatVersion
,
out
Checksum
checksum
)
{
textChecksum
=
null
;
parseOptionsChecksum
=
null
;
checksum
=
null
;
if
(
reader
.
ReadString
()
!=
formatVersion
)
{
return
false
;
}
textChecksum
=
Checksum
.
ReadFrom
(
reader
);
parseOptionsChecksum
=
Checksum
.
ReadFrom
(
reader
);
checksum
=
Checksum
.
ReadFrom
(
reader
);
return
true
;
}
private
static
async
Task
<
SyntaxTreeIndex
>
LoadAsync
(
Document
document
,
string
persistenceName
,
string
formatVersion
,
Func
<
ObjectReader
,
Checksum
,
Checksum
,
SyntaxTreeIndex
>
readFrom
,
CancellationToken
cancellationToken
)
Func
<
ObjectReader
,
Checksum
,
SyntaxTreeIndex
>
readFrom
,
CancellationToken
cancellationToken
)
{
var
solution
=
document
.
Project
.
Solution
;
var
persistentStorageService
=
(
IPersistentStorageService2
)
solution
.
Workspace
.
Services
.
GetService
<
IPersistentStorageService
>();
var
(
textChecksum
,
parseOptionsChecksum
)
=
await
GetChecksums
Async
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
var
checksum
=
await
GetChecksum
Async
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
try
{
...
...
@@ -59,9 +54,9 @@ private void WriteFormatAndChecksums(ObjectWriter writer, string formatVersion)
{
if
(
reader
!=
null
)
{
if
(
DataPreambleMatches
(
reader
,
formatVersion
,
textChecksum
,
parseOptionsC
hecksum
))
if
(
DataPreambleMatches
(
reader
,
formatVersion
,
c
hecksum
))
{
return
readFrom
(
reader
,
textChecksum
,
parseOptionsC
hecksum
);
return
readFrom
(
reader
,
c
hecksum
);
}
}
}
...
...
@@ -75,14 +70,13 @@ private void WriteFormatAndChecksums(ObjectWriter writer, string formatVersion)
}
private
static
bool
DataPreambleMatches
(
ObjectReader
reader
,
string
formatVersion
,
Checksum
textChecksum
,
Checksum
parseOptionsC
hecksum
)
ObjectReader
reader
,
string
formatVersion
,
Checksum
c
hecksum
)
{
return
TryReadFormatAndChecksums
(
reader
,
formatVersion
,
out
var
persistTextChecksum
,
out
var
persistParseOptionsChecksum
)
&&
persistTextChecksum
==
textChecksum
&&
persistParseOptionsChecksum
==
parseOptionsChecksum
;
return
TryReadFormatAndChecksum
(
reader
,
formatVersion
,
out
var
persistChecksum
)
&&
persistChecksum
==
checksum
;
}
public
static
async
Task
<
(
Checksum
textChecksum
,
Checksum
parseOptionsChecksum
)>
GetChecksums
Async
(
public
static
async
Task
<
Checksum
>
GetChecksum
Async
(
Document
document
,
CancellationToken
cancellationToken
)
{
var
text
=
await
document
.
GetTextAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
...
...
@@ -94,7 +88,7 @@ private void WriteFormatAndChecksums(ObjectWriter writer, string formatVersion)
var
parseOptionsChecksum
=
ChecksumCache
.
GetOrCreate
(
parseOptions
,
_
=>
serializer
.
CreateChecksum
(
parseOptions
,
cancellationToken
));
return
(
textChecksum
,
parseOptionsChecksum
);
return
Checksum
.
Create
(
nameof
(
SyntaxTreeIndex
),
new
[]
{
textChecksum
,
parseOptionsChecksum
}
);
}
private
static
async
Task
<
bool
>
SaveAsync
(
...
...
@@ -102,7 +96,7 @@ private void WriteFormatAndChecksums(ObjectWriter writer, string formatVersion)
{
var
solution
=
document
.
Project
.
Solution
;
var
persistentStorageService
=
(
IPersistentStorageService2
)
solution
.
Workspace
.
Services
.
GetService
<
IPersistentStorageService
>();
var
(
textChecksum
,
parseOptionsChecksum
)
=
await
GetChecksums
Async
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
var
checksum
=
await
GetChecksum
Async
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
try
{
...
...
@@ -110,7 +104,7 @@ private void WriteFormatAndChecksums(ObjectWriter writer, string formatVersion)
using
(
var
stream
=
SerializableBytes
.
CreateWritableStream
())
using
(
var
writer
=
new
ObjectWriter
(
stream
,
cancellationToken
:
cancellationToken
))
{
data
.
WriteFormatAndChecksum
s
(
writer
,
formatVersion
);
data
.
WriteFormatAndChecksum
(
writer
,
formatVersion
);
data
.
WriteTo
(
writer
);
stream
.
Position
=
0
;
...
...
@@ -130,7 +124,7 @@ private void WriteFormatAndChecksums(ObjectWriter writer, string formatVersion)
{
var
solution
=
document
.
Project
.
Solution
;
var
persistentStorageService
=
(
IPersistentStorageService2
)
solution
.
Workspace
.
Services
.
GetService
<
IPersistentStorageService
>();
var
(
textChecksum
,
parseOptionsChecksum
)
=
await
GetChecksums
Async
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
var
checksum
=
await
GetChecksum
Async
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
// check whether we already have info for this document
try
...
...
@@ -141,7 +135,7 @@ private void WriteFormatAndChecksums(ObjectWriter writer, string formatVersion)
{
if
(
reader
!=
null
)
{
return
DataPreambleMatches
(
reader
,
formatVersion
,
textChecksum
,
parseOptionsC
hecksum
);
return
DataPreambleMatches
(
reader
,
formatVersion
,
c
hecksum
);
}
}
}
...
...
@@ -162,7 +156,7 @@ public void WriteTo(ObjectWriter writer)
}
private
static
SyntaxTreeIndex
ReadFrom
(
ObjectReader
reader
,
Checksum
textChecksum
,
Checksum
parseOptionsC
hecksum
)
ObjectReader
reader
,
Checksum
c
hecksum
)
{
var
literalInfo
=
LiteralInfo
.
TryReadFrom
(
reader
);
var
identifierInfo
=
IdentifierInfo
.
TryReadFrom
(
reader
);
...
...
@@ -175,7 +169,7 @@ public void WriteTo(ObjectWriter writer)
}
return
new
SyntaxTreeIndex
(
textChecksum
,
parseOptionsC
hecksum
,
literalInfo
.
Value
,
identifierInfo
.
Value
,
contextInfo
.
Value
,
declarationInfo
.
Value
);
c
hecksum
,
literalInfo
.
Value
,
identifierInfo
.
Value
,
contextInfo
.
Value
,
declarationInfo
.
Value
);
}
private
Task
<
bool
>
SaveAsync
(
Document
document
,
CancellationToken
cancellationToken
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录