Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
71c47b75
F
fsharp
项目概览
dotNET Platform
/
fsharp
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
71c47b75
编写于
3月 17, 2023
作者:
K
kerams
提交者:
GitHub
3月 17, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor (#14907)
上级
62dfce60
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
87 addition
and
92 deletion
+87
-92
src/Compiler/Checking/NameResolution.fs
src/Compiler/Checking/NameResolution.fs
+87
-92
未找到文件。
src/Compiler/Checking/NameResolution.fs
浏览文件 @
71c47b75
...
...
@@ -4214,57 +4214,56 @@ let FullTypeOfPropInfo g amap m (pinfo: PropInfo) =
ty
let
rec
ResolvePartialLongIdentInType
(
ncenv
:
NameResolver
)
nenv
isApplicableMeth
m
ad
statics
plid
ty
=
[
let
g
=
ncenv
.
g
let
amap
=
ncenv
.
amap
match
plid
with
|
[]
->
yield
!
ResolveCompletionsInType
ncenv
nenv
isApplicableMeth
m
ad
statics
ty
|
[]
->
ResolveCompletionsInType
ncenv
nenv
isApplicableMeth
m
ad
statics
ty
|
id
::
rest
->
[
let
g
=
ncenv
.
g
let
amap
=
ncenv
.
amap
// e.g. <val-id>.<recdfield-id>.<more>
for
fref
in
ncenv
.
InfoReader
.
GetRecordOrClassFieldsOfType
(
None
,
ad
,
m
,
ty
)
do
if
fref
.
LogicalName
=
id
&&
IsRecdFieldAccessible
ncenv
.
amap
m
ad
fref
.
RecdFieldRef
&&
fref
.
RecdField
.
IsStatic
=
statics
then
// e.g. <val-id>.<recdfield-id>.<more>
for
fref
in
ncenv
.
InfoReader
.
GetRecordOrClassFieldsOfType
(
None
,
ad
,
m
,
ty
)
do
if
fref
.
LogicalName
=
id
&&
IsRecdFieldAccessible
ncenv
.
amap
m
ad
fref
.
RecdFieldRef
&&
fref
.
RecdField
.
IsStatic
=
statics
then
yield
!
ResolvePartialLongIdentInType
ncenv
nenv
isApplicableMeth
m
ad
false
rest
fref
.
FieldType
yield
!
ResolvePartialLongIdentInType
ncenv
nenv
isApplicableMeth
m
ad
false
rest
fref
.
FieldType
for
pinfo
in
AllPropInfosOfTypeInScope
ResultCollectionSettings
.
AllResults
ncenv
.
InfoReader
nenv
(
Some
id
)
ad
IgnoreOverrides
m
ty
do
if
pinfo
.
IsStatic
=
statics
&&
IsPropInfoAccessible
g
amap
m
ad
pinfo
then
let
pinfoTy
=
FullTypeOfPropInfo
g
amap
m
pinfo
yield
!
ResolvePartialLongIdentInType
ncenv
nenv
isApplicableMeth
m
ad
false
rest
pinfoTy
for
pinfo
in
AllPropInfosOfTypeInScope
ResultCollectionSettings
.
AllResults
ncenv
.
InfoReader
nenv
(
Some
id
)
ad
IgnoreOverrides
m
ty
do
if
pinfo
.
IsStatic
=
statics
&&
IsPropInfoAccessible
g
amap
m
ad
pinfo
then
let
pinfoTy
=
FullTypeOfPropInfo
g
amap
m
pinfo
yield
!
ResolvePartialLongIdentInType
ncenv
nenv
isApplicableMeth
m
ad
false
rest
pinfoTy
if
not
statics
then
match
TryFindAnonRecdFieldOfType
g
ty
id
with
|
Some
(
Item
.
AnonRecdField
(_,
tys
,
i
,
_))
->
yield
!
ResolvePartialLongIdentInType
ncenv
nenv
isApplicableMeth
m
ad
false
rest
tys
[
i
]
|
_
->
()
if
not
statics
then
match
TryFindAnonRecdFieldOfType
g
ty
id
with
|
Some
(
Item
.
AnonRecdField
(_,
tys
,
i
,
_))
->
yield
!
ResolvePartialLongIdentInType
ncenv
nenv
isApplicableMeth
m
ad
false
rest
tys
[
i
]
|
_
->
()
// e.g. <val-id>.<event-id>.<more>
for
einfo
in
ncenv
.
InfoReader
.
GetEventInfosOfType
(
Some
id
,
ad
,
m
,
ty
)
do
let
einfoTy
=
PropTypeOfEventInfo
ncenv
.
InfoReader
m
ad
einfo
yield
!
ResolvePartialLongIdentInType
ncenv
nenv
isApplicableMeth
m
ad
false
rest
einfoTy
// e.g. <val-id>.<event-id>.<more>
for
einfo
in
ncenv
.
InfoReader
.
GetEventInfosOfType
(
Some
id
,
ad
,
m
,
ty
)
do
let
einfoTy
=
PropTypeOfEventInfo
ncenv
.
InfoReader
m
ad
einfo
yield
!
ResolvePartialLongIdentInType
ncenv
nenv
isApplicableMeth
m
ad
false
rest
einfoTy
// nested types
for
nestedTy
in
GetNestedTypesOfType
(
ad
,
ncenv
,
Some
id
,
TypeNameResolutionStaticArgsInfo
.
Indefinite
,
false
,
m
)
ty
do
yield
!
ResolvePartialLongIdentInType
ncenv
nenv
isApplicableMeth
m
ad
statics
rest
nestedTy
// nested types
for
nestedTy
in
GetNestedTypesOfType
(
ad
,
ncenv
,
Some
id
,
TypeNameResolutionStaticArgsInfo
.
Indefinite
,
false
,
m
)
ty
do
yield
!
ResolvePartialLongIdentInType
ncenv
nenv
isApplicableMeth
m
ad
statics
rest
nestedTy
// e.g. <val-id>.<il-field-id>.<more>
for
finfo
in
ncenv
.
InfoReader
.
GetILFieldInfosOfType
(
Some
id
,
ad
,
m
,
ty
)
do
if
not
finfo
.
IsSpecialName
&&
finfo
.
IsStatic
=
statics
&&
IsILFieldInfoAccessible
g
amap
m
ad
finfo
then
let
finfoTy
=
finfo
.
FieldType
(
amap
,
m
)
yield
!
ResolvePartialLongIdentInType
ncenv
nenv
isApplicableMeth
m
ad
false
rest
finfoTy
]
// e.g. <val-id>.<il-field-id>.<more>
for
finfo
in
ncenv
.
InfoReader
.
GetILFieldInfosOfType
(
Some
id
,
ad
,
m
,
ty
)
do
if
not
finfo
.
IsSpecialName
&&
finfo
.
IsStatic
=
statics
&&
IsILFieldInfoAccessible
g
amap
m
ad
finfo
then
let
finfoTy
=
finfo
.
FieldType
(
amap
,
m
)
yield
!
ResolvePartialLongIdentInType
ncenv
nenv
isApplicableMeth
m
ad
false
rest
finfoTy
]
let
InfosForTyconConstructors
(
ncenv
:
NameResolver
)
m
ad
(
tcref
:
TyconRef
)
=
[
let
g
=
ncenv
.
g
let
amap
=
ncenv
.
amap
// Don't show constructors for type abbreviations. See FSharp 1.0 bug 2881
if
not
tcref
.
IsTypeAbbrev
then
let
ty
=
FreshenTycon
ncenv
m
tcref
match
ResolveObjectConstructor
ncenv
(
DisplayEnv
.
Empty
g
)
m
ad
ty
with
|
Result
item
->
match
item
with
|
Item
.
FakeInterfaceCtor
_
->
()
|
Item
.
FakeInterfaceCtor
_
->
None
|
Item
.
CtorGroup
(
nm
,
ctorInfos
)
->
let
ctors
=
ctorInfos
...
...
@@ -4272,12 +4271,12 @@ let InfosForTyconConstructors (ncenv: NameResolver) m ad (tcref: TyconRef) =
IsMethInfoAccessible
amap
m
ad
minfo
&&
not
(
MethInfoIsUnseen
g
m
ty
minfo
))
match
ctors
with
|
[]
->
()
|
_
->
Item
.
MakeCtorGroup
(
nm
,
ctors
)
|
item
->
item
|
Exception
_
->
()
]
|
[]
->
None
|
_
->
Some
(
Item
.
MakeCtorGroup
(
nm
,
ctors
)
)
|
item
->
Some
item
|
Exception
_
->
None
else
None
/// import.fs creates somewhat fake modules for nested members of types (so that
/// types never contain other types)
...
...
@@ -4411,7 +4410,7 @@ let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv is
|>
List
.
map
(
modref
.
NestedTyconRef
>>
ItemOfTyconRef
ncenv
m
)
)
@
(
tycons
|>
List
.
c
ollect
(
modref
.
NestedTyconRef
>>
InfosForTyconConstructors
ncenv
m
ad
))
|>
List
.
c
hoose
(
modref
.
NestedTyconRef
>>
InfosForTyconConstructors
ncenv
m
ad
))
|
id
::
rest
->
...
...
@@ -4513,7 +4512,7 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE
let
constructors
=
nenv
.
TyconsByDemangledNameAndArity
(
fullyQualified
).
Values
|>
Seq
.
filter
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
>>
not
)
|>
Seq
.
c
ollect
(
InfosForTyconConstructors
ncenv
m
ad
)
|>
Seq
.
c
hoose
(
InfosForTyconConstructors
ncenv
m
ad
)
|>
Seq
.
toList
let
typeVars
=
...
...
@@ -4885,52 +4884,51 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics ty (
// This is "on-demand" reimplementation of completion logic that is only used along one
// pathway - `IsRelativeNameResolvableFromSymbol` - in the editor support for simplifying names
let
rec
ResolvePartialLongIdentInTypeForItem
(
ncenv
:
NameResolver
)
nenv
m
ad
statics
plid
(
item
:
Item
)
ty
=
seq
{
let
g
=
ncenv
.
g
let
amap
=
ncenv
.
amap
match
plid
with
|
[]
->
yield
!
ResolveCompletionsInTypeForItem
ncenv
nenv
m
ad
statics
ty
item
|
id
::
rest
->
match
plid
with
|
[]
->
ResolveCompletionsInTypeForItem
ncenv
nenv
m
ad
statics
ty
item
|
id
::
rest
->
seq
{
let
g
=
ncenv
.
g
let
amap
=
ncenv
.
amap
let
rfinfos
=
ncenv
.
InfoReader
.
GetRecordOrClassFieldsOfType
(
None
,
ad
,
m
,
ty
)
|>
List
.
filter
(
fun
fref
->
fref
.
LogicalName
=
id
&&
IsRecdFieldAccessible
ncenv
.
amap
m
ad
fref
.
RecdFieldRef
&&
fref
.
RecdField
.
IsStatic
=
statics
)
let
rfinfos
=
ncenv
.
InfoReader
.
GetRecordOrClassFieldsOfType
(
None
,
ad
,
m
,
ty
)
|>
List
.
filter
(
fun
fref
->
fref
.
LogicalName
=
id
&&
IsRecdFieldAccessible
ncenv
.
amap
m
ad
fref
.
RecdFieldRef
&&
fref
.
RecdField
.
IsStatic
=
statics
)
let
nestedTypes
=
ty
|>
GetNestedTypesOfType
(
ad
,
ncenv
,
Some
id
,
TypeNameResolutionStaticArgsInfo
.
Indefinite
,
false
,
m
)
let
nestedTypes
=
ty
|>
GetNestedTypesOfType
(
ad
,
ncenv
,
Some
id
,
TypeNameResolutionStaticArgsInfo
.
Indefinite
,
false
,
m
)
// e.g. <val-id>.<recdfield-id>.<more>
for
rfinfo
in
rfinfos
do
yield
!
ResolvePartialLongIdentInTypeForItem
ncenv
nenv
m
ad
false
rest
item
rfinfo
.
FieldType
// e.g. <val-id>.<recdfield-id>.<more>
for
rfinfo
in
rfinfos
do
yield
!
ResolvePartialLongIdentInTypeForItem
ncenv
nenv
m
ad
false
rest
item
rfinfo
.
FieldType
let
pinfos
=
ty
|>
AllPropInfosOfTypeInScope
ResultCollectionSettings
.
AllResults
ncenv
.
InfoReader
nenv
(
Some
id
)
ad
IgnoreOverrides
m
|>
List
.
filter
(
fun
pinfo
->
pinfo
.
IsStatic
=
statics
&&
IsPropInfoAccessible
g
amap
m
ad
pinfo
)
let
pinfos
=
ty
|>
AllPropInfosOfTypeInScope
ResultCollectionSettings
.
AllResults
ncenv
.
InfoReader
nenv
(
Some
id
)
ad
IgnoreOverrides
m
|>
List
.
filter
(
fun
pinfo
->
pinfo
.
IsStatic
=
statics
&&
IsPropInfoAccessible
g
amap
m
ad
pinfo
)
for
pinfo
in
pinfos
do
yield
!
FullTypeOfPropInfo
g
amap
m
pinfo
|>
ResolvePartialLongIdentInTypeForItem
ncenv
nenv
m
ad
false
rest
item
for
pinfo
in
pinfos
do
yield
!
FullTypeOfPropInfo
g
amap
m
pinfo
|>
ResolvePartialLongIdentInTypeForItem
ncenv
nenv
m
ad
false
rest
item
match
TryFindAnonRecdFieldOfType
g
ty
id
with
|
Some
(
Item
.
AnonRecdField
(_
anonInfo
,
tys
,
i
,
_))
->
let
tyinfo
=
tys
[
i
]
yield
!
ResolvePartialLongIdentInTypeForItem
ncenv
nenv
m
ad
false
rest
item
tyinfo
|
_
->
()
match
TryFindAnonRecdFieldOfType
g
ty
id
with
|
Some
(
Item
.
AnonRecdField
(_
anonInfo
,
tys
,
i
,
_))
->
let
tyinfo
=
tys
[
i
]
yield
!
ResolvePartialLongIdentInTypeForItem
ncenv
nenv
m
ad
false
rest
item
tyinfo
|
_
->
()
// e.g. <val-id>.<event-id>.<more>
for
einfo
in
ncenv
.
InfoReader
.
GetEventInfosOfType
(
Some
id
,
ad
,
m
,
ty
)
do
let
tyinfo
=
PropTypeOfEventInfo
ncenv
.
InfoReader
m
ad
einfo
yield
!
ResolvePartialLongIdentInTypeForItem
ncenv
nenv
m
ad
false
rest
item
tyinfo
// e.g. <val-id>.<event-id>.<more>
for
einfo
in
ncenv
.
InfoReader
.
GetEventInfosOfType
(
Some
id
,
ad
,
m
,
ty
)
do
let
tyinfo
=
PropTypeOfEventInfo
ncenv
.
InfoReader
m
ad
einfo
yield
!
ResolvePartialLongIdentInTypeForItem
ncenv
nenv
m
ad
false
rest
item
tyinfo
// nested types!
for
ty
in
nestedTypes
do
yield
!
ResolvePartialLongIdentInTypeForItem
ncenv
nenv
m
ad
statics
rest
item
ty
// nested types!
for
ty
in
nestedTypes
do
yield
!
ResolvePartialLongIdentInTypeForItem
ncenv
nenv
m
ad
statics
rest
item
ty
// e.g. <val-id>.<il-field-id>.<more>
for
finfo
in
ncenv
.
InfoReader
.
GetILFieldInfosOfType
(
Some
id
,
ad
,
m
,
ty
)
do
if
not
finfo
.
IsSpecialName
&&
finfo
.
IsStatic
=
statics
&&
IsILFieldInfoAccessible
g
amap
m
ad
finfo
then
yield
!
finfo
.
FieldType
(
amap
,
m
)
|>
ResolvePartialLongIdentInTypeForItem
ncenv
nenv
m
ad
false
rest
item
}
// e.g. <val-id>.<il-field-id>.<more>
for
finfo
in
ncenv
.
InfoReader
.
GetILFieldInfosOfType
(
Some
id
,
ad
,
m
,
ty
)
do
if
not
finfo
.
IsSpecialName
&&
finfo
.
IsStatic
=
statics
&&
IsILFieldInfoAccessible
g
amap
m
ad
finfo
then
yield
!
finfo
.
FieldType
(
amap
,
m
)
|>
ResolvePartialLongIdentInTypeForItem
ncenv
nenv
m
ad
false
rest
item
}
// This is "on-demand" reimplementation of completion logic that is only used along one
// pathway - `IsRelativeNameResolvableFromSymbol` - in the editor support for simplifying names
...
...
@@ -4990,7 +4988,7 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForItem (ncenv: NameResolver)
// Get all the types and .NET constructor groups accessible from here
let
nestedTycons
=
tycons
|>
List
.
map
modref
.
NestedTyconRef
yield
!
nestedTycons
|>
List
.
map
(
ItemOfTyconRef
ncenv
m
)
yield
!
nestedTycons
|>
List
.
c
ollect
(
InfosForTyconConstructors
ncenv
m
ad
)
yield
!
nestedTycons
|>
List
.
c
hoose
(
InfosForTyconConstructors
ncenv
m
ad
)
|
id
::
rest
->
...
...
@@ -5023,16 +5021,12 @@ let rec PartialResolveLookupInModuleOrNamespaceAsModuleOrNamespaceThenLazy f pli
// This is "on-demand" reimplementation of completion logic that is only used along one
// pathway - `IsRelativeNameResolvableFromSymbol` - in the editor support for simplifying names
let
PartialResolveLongIdentAsModuleOrNamespaceThenLazy
(
nenv
:
NameResolutionEnv
)
plid
f
=
seq
{
match
plid
with
|
id
::
rest
->
match
nenv
.
eModulesAndNamespaces
.
TryGetValue
id
with
|
true
,
modrefs
->
for
modref
in
modrefs
do
yield
!
PartialResolveLookupInModuleOrNamespaceAsModuleOrNamespaceThenLazy
f
rest
modref
|
_
->
()
|
[]
->
()
}
match
plid
with
|
id
::
rest
->
match
nenv
.
eModulesAndNamespaces
.
TryGetValue
id
with
|
true
,
modrefs
->
modrefs
|>
Seq
.
collect
(
fun
modref
->
PartialResolveLookupInModuleOrNamespaceAsModuleOrNamespaceThenLazy
f
rest
modref
)
|
_
->
Seq
.
empty
|
[]
->
Seq
.
empty
// This is "on-demand" reimplementation of completion logic that is only used along one
// pathway - `IsRelativeNameResolvableFromSymbol` - in the editor support for simplifying names
...
...
@@ -5078,9 +5072,10 @@ let rec GetCompletionForItem (ncenv: NameResolver) (nenv: NameResolutionEnv) m a
|
Item
.
CtorGroup
_
|
Item
.
UnqualifiedType
_
->
for
tcref
in
nenv
.
TyconsByDemangledNameAndArity
(
OpenQualified
).
Values
do
if
not
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
tcref
)
then
yield
!
InfosForTyconConstructors
ncenv
m
ad
tcref
if
not
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
tcref
)
then
match
InfosForTyconConstructors
ncenv
m
ad
tcref
with
|
Some
info
->
yield
info
|
_
->
()
|
_
->
()
|
id
::
rest
->
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录