Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
43572a1e
F
fsharp
项目概览
dotNET Platform
/
fsharp
12 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
43572a1e
编写于
5月 03, 2020
作者:
S
Steffen Forkmann
提交者:
GitHub
5月 03, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup FSharpCheckerResults (#9111)
上级
22bcd737
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
31 deletion
+36
-31
src/fsharp/service/FSharpCheckerResults.fs
src/fsharp/service/FSharpCheckerResults.fs
+29
-26
src/fsharp/symbols/SymbolHelpers.fs
src/fsharp/symbols/SymbolHelpers.fs
+7
-5
未找到文件。
src/fsharp/service/FSharpCheckerResults.fs
浏览文件 @
43572a1e
...
...
@@ -147,8 +147,8 @@ type internal TypeCheckInfo
let
getToolTipTextCache
=
AgedLookup
<
CompilationThreadToken
,
int
*
int
*
string
,
FSharpToolTipText
<
Layout
>>(
getToolTipTextSize
,
areSimilar
=(
fun
(
x
,
y
)
->
x
=
y
))
let
amap
=
tcImports
.
GetImportMap
()
let
infoReader
=
new
InfoReader
(
g
,
amap
)
let
ncenv
=
new
NameResolver
(
g
,
amap
,
infoReader
,
NameResolution
.
FakeInstantiationGenerator
)
let
infoReader
=
InfoReader
(
g
,
amap
)
let
ncenv
=
NameResolver
(
g
,
amap
,
infoReader
,
NameResolution
.
FakeInstantiationGenerator
)
let
cenv
=
SymbolEnv
(
g
,
thisCcu
,
Some
ccuSigForFile
,
tcImports
,
amap
,
infoReader
)
/// Find the most precise naming environment for the given line and column
...
...
@@ -229,7 +229,8 @@ type internal TypeCheckInfo
NameResResult
.
TypecheckStaleAndTextChanged
// typecheck is stale, wait for second-chance IntelliSense to bring up right result
else
NameResResult
.
Members
(
items
,
denv
,
m
)
else
NameResResult
.
Empty
else
NameResResult
.
Empty
let
GetCapturedNameResolutions
(
endOfNamesPos
:
pos
)
resolveOverloads
=
let
filter
(
endPos
:
pos
)
items
=
...
...
@@ -274,7 +275,7 @@ type internal TypeCheckInfo
// then the expression typings get confused (thinking 'varA:int'), so we use name resolution even for usual values.
|
CNR
(
Item
.
Value
(
vref
),
occurence
,
denv
,
nenv
,
ad
,
m
)::_,
Some
_
->
if
(
occurence
=
ItemOccurence
.
Binding
||
occurence
=
ItemOccurence
.
Pattern
)
then
if
occurence
=
ItemOccurence
.
Binding
||
occurence
=
ItemOccurence
.
Pattern
then
// Return empty list to stop further lookup - for value declarations
NameResResult
.
Cancel
(
denv
,
m
)
else
...
...
@@ -1035,9 +1036,8 @@ type internal TypeCheckInfo
|
None
->
[]
|
Some
(
loadClosure
)
->
loadClosure
.
References
|>
List
.
map
snd
|>
List
.
concat
|>
List
.
filter
(
fun
ar
->
isPosMatch
(
pos
,
ar
.
originalReference
))
|>
List
.
collect
snd
|>
List
.
filter
(
fun
ar
->
isPosMatch
(
pos
,
ar
.
originalReference
))
match
matches
with
|
resolved
::_
// Take the first seen
...
...
@@ -1551,23 +1551,26 @@ module internal ParseAndCheckFile =
// Join the sets and report errors.
// It is by-design that these messages are only present in the language service. A true build would report the errors at their
// spots in the individual source files.
for
(
fileOfHashLoad
,
rangesOfHashLoad
)
in
hashLoadsInFile
do
for
(
file
,
errorGroupedByFileName
)
in
hashLoadBackgroundDiagnosticsGroupedByFileName
do
for
fileOfHashLoad
,
rangesOfHashLoad
in
hashLoadsInFile
do
for
file
,
errorGroupedByFileName
in
hashLoadBackgroundDiagnosticsGroupedByFileName
do
if
sameFile
file
fileOfHashLoad
then
for
rangeOfHashLoad
in
rangesOfHashLoad
do
// Handle the case of two #loads of the same file
let
diagnostics
=
errorGroupedByFileName
|>
Array
.
map
(
fun
(_,(
pe
,
f
))
->
pe
.
Exception
,
f
)
// Strip the build phase here. It will be replaced, in total, with TypeCheck
let
errors
=
[
for
(
err
,
sev
)
in
diagnostics
do
if
sev
=
FSharpErrorSeverity
.
Error
then
yield
err
]
let
warnings
=
[
for
(
err
,
sev
)
in
diagnostics
do
if
sev
=
FSharpErrorSeverity
.
Warning
then
yield
err
]
let
errors
=
[
for
err
,
sev
in
diagnostics
do
if
sev
=
FSharpErrorSeverity
.
Error
then
yield
err
]
let
warnings
=
[
for
err
,
sev
in
diagnostics
do
if
sev
=
FSharpErrorSeverity
.
Warning
then
yield
err
]
let
message
=
HashLoadedSourceHasIssues
(
warnings
,
errors
,
rangeOfHashLoad
)
if
errors
=[]
then
warning
(
message
)
else
errorR
(
message
)
if
isNil
errors
then
warning
message
else
errorR
message
// Replay other background errors.
for
(
phasedError
,
sev
)
in
otherBackgroundDiagnostics
do
for
phasedError
,
sev
in
otherBackgroundDiagnostics
do
if
sev
=
FSharpErrorSeverity
.
Warning
then
warning
phasedError
.
Exception
else
errorR
phasedError
.
Exception
else
errorR
phasedError
.
Exception
|
None
->
// For non-scripts, check for disallow #r and #load.
...
...
@@ -1615,7 +1618,7 @@ module internal ParseAndCheckFile =
errHandler
.
ErrorSeverityOptions
<-
tcConfig
.
errorSeverityOptions
// Play background errors and warnings for this file.
for
(
err
,
sev
)
in
backgroundDiagnostics
do
for
err
,
sev
in
backgroundDiagnostics
do
diagnosticSink
(
err
,
(
sev
=
FSharpErrorSeverity
.
Error
))
// If additional references were brought in by the preprocessor then we need to process them
...
...
@@ -1738,7 +1741,7 @@ type FSharpCheckFileResults
member
__.
HasFullTypeCheckInfo
=
details
.
IsSome
member
info
.
TryGetCurrentTcImports
()
=
member
__
.
TryGetCurrentTcImports
()
=
match
builderX
with
|
Some
builder
->
builder
.
TryGetCurrentTcImports
()
|
_
->
None
...
...
@@ -2065,8 +2068,8 @@ type FSharpCheckProjectResults
tcSymbolUses
|>
Seq
.
collect
(
fun
r
->
r
.
GetUsesOfSymbol
symbol
.
Item
)
|>
Seq
.
distinctBy
(
fun
symbolUse
->
symbolUse
.
ItemOccurence
,
symbolUse
.
Range
)
|>
Seq
.
filter
(
fun
symbolUse
->
symbolUse
.
ItemOccurence
<>
ItemOccurence
.
RelatedText
)
|>
Seq
.
filter
(
fun
symbolUse
->
symbolUse
.
ItemOccurence
<>
ItemOccurence
.
RelatedText
)
|>
Seq
.
distinctBy
(
fun
symbolUse
->
symbolUse
.
ItemOccurence
,
symbolUse
.
Range
)
|>
Seq
.
map
(
fun
symbolUse
->
FSharpSymbolUse
(
tcGlobals
,
symbolUse
.
DisplayEnv
,
symbol
,
symbolUse
.
ItemOccurence
,
symbolUse
.
Range
))
|>
Seq
.
toArray
|>
async
.
Return
...
...
@@ -2077,18 +2080,18 @@ type FSharpCheckProjectResults
let
cenv
=
SymbolEnv
(
tcGlobals
,
thisCcu
,
Some
ccuSig
,
tcImports
)
[|
for
r
in
tcSymbolUses
do
for
symbolUseChunk
in
r
.
AllUsesOfSymbols
do
for
symbolUseChunk
in
r
.
AllUsesOfSymbols
do
for
symbolUse
in
symbolUseChunk
do
if
symbolUse
.
ItemOccurence
<>
ItemOccurence
.
RelatedText
then
let
symbol
=
FSharpSymbol
.
Create
(
cenv
,
symbolUse
.
Item
)
yield
FSharpSymbolUse
(
tcGlobals
,
symbolUse
.
DisplayEnv
,
symbol
,
symbolUse
.
ItemOccurence
,
symbolUse
.
Range
)
|]
if
symbolUse
.
ItemOccurence
<>
ItemOccurence
.
RelatedText
then
let
symbol
=
FSharpSymbol
.
Create
(
cenv
,
symbolUse
.
Item
)
yield
FSharpSymbolUse
(
tcGlobals
,
symbolUse
.
DisplayEnv
,
symbol
,
symbolUse
.
ItemOccurence
,
symbolUse
.
Range
)
|]
|>
async
.
Return
member
__.
ProjectContext
=
let
(
tcGlobals
,
tcImports
,
thisCcu
,
_
ccuSig
,
_
tcSymbolUses
,
_
topAttribs
,
_
tcAssemblyData
,
_
ilAssemRef
,
ad
,
_
tcAssemblyExpr
,
_
dependencyFiles
)
=
getDetails
()
let
assemblies
=
[
for
x
in
tcImports
.
GetImportedAssemblies
()
do
yield
FSharpAssembly
(
tcGlobals
,
tcImports
,
x
.
FSharpViewOfMetadata
)
]
tcImports
.
GetImportedAssemblies
()
|>
List
.
map
(
fun
x
->
FSharpAssembly
(
tcGlobals
,
tcImports
,
x
.
FSharpViewOfMetadata
))
FSharpProjectContext
(
thisCcu
,
assemblies
,
ad
)
member
__.
RawFSharpAssemblyData
=
...
...
@@ -2151,7 +2154,7 @@ type FsiInteractiveChecker(legacyReferenceResolver,
return
match
tcFileInfo
with
|
Result
.
Ok
tcFileInfo
->
let
errors
=
[|
yield
!
parseErrors
;
yield
!
tcErrors
|]
let
errors
=
Array
.
append
parseErrors
tcErrors
let
typeCheckResults
=
FSharpCheckFileResults
(
filename
,
errors
,
Some
tcFileInfo
,
dependencyFiles
,
None
,
reactorOps
,
false
)
let
projectResults
=
FSharpCheckProjectResults
(
filename
,
Some
tcConfig
,
...
...
src/fsharp/symbols/SymbolHelpers.fs
浏览文件 @
43572a1e
...
...
@@ -857,11 +857,13 @@ module internal SymbolHelpers =
member
x
.
GetHashCode
item
=
hash
item
.
Stamp
}
/// Remove all duplicate items
let
RemoveDuplicateItems
g
(
items
:
ItemWithInst
list
)
=
let
RemoveDuplicateItems
g
(
items
:
ItemWithInst
list
)
=
if
isNil
items
then
items
else
items
|>
IPartialEqualityComparer
.
partialDistinctBy
(
IPartialEqualityComparer
.
On
(
fun
item
->
item
.
Item
)
(
ItemDisplayPartialEquality
g
))
/// Remove all duplicate items
let
RemoveDuplicateCompletionItems
g
items
=
let
RemoveDuplicateCompletionItems
g
items
=
if
isNil
items
then
items
else
items
|>
IPartialEqualityComparer
.
partialDistinctBy
(
CompletionItemDisplayPartialEquality
g
)
let
IsExplicitlySuppressed
(
g
:
TcGlobals
)
(
item
:
Item
)
=
...
...
@@ -886,12 +888,12 @@ module internal SymbolHelpers =
|
_
->
false
)
/// Filter types that are explicitly suppressed from the IntelliSense (such as uppercase "FSharpList", "Option", etc.)
let
RemoveExplicitlySuppressed
(
g
:
TcGlobals
)
(
items
:
ItemWithInst
list
)
=
items
|>
List
.
filter
(
fun
item
->
not
(
IsExplicitlySuppressed
g
item
.
Item
))
let
RemoveExplicitlySuppressed
(
g
:
TcGlobals
)
(
items
:
ItemWithInst
list
)
=
items
|>
List
.
filter
(
fun
item
->
not
(
IsExplicitlySuppressed
g
item
.
Item
))
/// Filter types that are explicitly suppressed from the IntelliSense (such as uppercase "FSharpList", "Option", etc.)
let
RemoveExplicitlySuppressedCompletionItems
(
g
:
TcGlobals
)
(
items
:
CompletionItem
list
)
=
items
|>
List
.
filter
(
fun
item
->
not
(
IsExplicitlySuppressed
g
item
.
Item
))
items
|>
List
.
filter
(
fun
item
->
not
(
IsExplicitlySuppressed
g
item
.
Item
))
let
SimplerDisplayEnv
denv
=
{
denv
with
suppressInlineKeyword
=
true
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录