Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
776035bd
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,发现更多精彩内容 >>
未验证
提交
776035bd
编写于
9月 19, 2018
作者:
D
dotnet-automerge-bot
提交者:
GitHub
9月 19, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5671 from Microsoft/merges/master-to-dev16.0
Merge master to dev16.0
上级
11391a56
b6b7ff9d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
127 addition
and
89 deletion
+127
-89
src/fsharp/NameResolution.fs
src/fsharp/NameResolution.fs
+127
-89
未找到文件。
src/fsharp/NameResolution.fs
浏览文件 @
776035bd
...
...
@@ -3403,10 +3403,8 @@ let ItemOfTy g x =
let
nm
=
if
isAppTy
g
x
then
(
tcrefOfAppTy
g
x
).
DisplayName
else
"?"
Item
.
Types
(
nm
,[
x
])
// Filter out 'PrivateImplementationDetail' classes
let
IsInterestingModuleName
nm
=
String
.
length
nm
>=
1
&&
String
.
sub
nm
0
1
<>
"<"
// Filter out 'PrivateImplementationDetail' classes
let
IsInterestingModuleName
nm
=
not
(
System
.
String
.
IsNullOrEmpty
nm
)
&&
nm
.[
0
]
<>
'
<
'
let
rec
PartialResolveLookupInModuleOrNamespaceAsModuleOrNamespaceThen
f
plid
(
modref
:
ModuleOrNamespaceRef
)
=
let
mty
=
modref
.
ModuleOrNamespaceType
...
...
@@ -3657,7 +3655,8 @@ let rec ResolvePartialLongIdentInType (ncenv: NameResolver) nenv isApplicableMet
let
FullTypeOfPinfo
(
pinfo
:
PropInfo
)
=
let
rty
=
pinfo
.
GetPropertyType
(
amap
,
m
)
let
rty
=
if
pinfo
.
IsIndexer
then
mkRefTupledTy
g
(
pinfo
.
GetParamTypes
(
amap
,
m
))
-->
rty
else
rty
rty
rty
(
ty
|>
AllPropInfosOfTypeInScope
ncenv
.
InfoReader
nenv
(
Some
id
,
ad
)
IgnoreOverrides
m
|>
List
.
filter
(
fun
x
->
x
.
IsStatic
=
statics
)
...
...
@@ -3705,9 +3704,23 @@ let InfosForTyconConstructors (ncenv:NameResolver) m ad (tcref:TyconRef) =
|
Exception
_
->
[]
/// import.fs creates somewhat fake modules for nested members of types (so that
/// types never contain other types)
let
notFakeContainerModule
tyconNames
nm
=
not
(
Set
.
contains
nm
tyconNames
)
/// types never contain other types)
let
inline
notFakeContainerModule
(
tyconNames
:
HashSet
<_>)
nm
=
not
(
tyconNames
.
Contains
nm
)
let
getFakeContainerModulesFromTycons
(
tycons
:#
seq
<
Tycon
>)
=
let
hashSet
=
HashSet
()
for
tycon
in
tycons
do
if
tycon
.
IsILTycon
then
hashSet
.
Add
tycon
.
DisplayName
|>
ignore
hashSet
let
getFakeContainerModulesFromTyconRefs
(
tyconRefs
:#
seq
<
TyconRef
>)
=
let
hashSet
=
HashSet
()
for
tyconRef
in
tyconRefs
do
if
tyconRef
.
IsILTycon
then
hashSet
.
Add
tyconRef
.
DisplayName
|>
ignore
hashSet
/// Check is a namespace or module contains something accessible
let
rec
private
EntityRefContainsSomethingAccessible
(
ncenv
:
NameResolver
)
m
ad
(
modref
:
ModuleOrNamespaceRef
)
=
...
...
@@ -3754,11 +3767,24 @@ let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv is
mty
.
TypeDefinitions
|>
List
.
filter
(
fun
tcref
->
not
(
tcref
.
LogicalName
.
Contains
(
","
)))
|>
List
.
filter
(
fun
tycon
->
not
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
(
modref
.
NestedTyconRef
tycon
)))
let
accessibleSubModules
=
let
moduleOrNamespaces
=
mty
.
ModulesAndNamespacesByDemangledName
|>
NameMap
.
range
if
isNil
moduleOrNamespaces
then
[]
else
let
ilTyconNames
=
getFakeContainerModulesFromTycons
mty
.
TypesByAccessNames
.
Values
let
ilTyconNames
=
mty
.
TypesByAccessNames
.
Values
|>
List
.
choose
(
fun
(
tycon
:
Tycon
)
->
if
tycon
.
IsILTycon
then
Some
tycon
.
DisplayName
else
None
)
|>
Set
.
ofList
moduleOrNamespaces
|>
List
.
filter
(
fun
x
->
let
demangledName
=
x
.
DemangledModuleOrNamespaceName
notFakeContainerModule
ilTyconNames
demangledName
&&
IsInterestingModuleName
demangledName
)
|>
List
.
map
modref
.
NestedTyconRef
|>
List
.
filter
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
>>
not
)
|>
List
.
filter
(
EntityRefContainsSomethingAccessible
ncenv
m
ad
)
|>
List
.
map
ItemForModuleOrNamespaceRef
// Collect up the accessible values in the module, excluding the members
(
mty
.
AllValsAndMembers
...
...
@@ -3787,16 +3813,7 @@ let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv is
|>
List
.
filter
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
>>
not
)
|>
List
.
map
Item
.
ExnCase
)
// Collect up the accessible sub-modules
@
(
mty
.
ModulesAndNamespacesByDemangledName
|>
NameMap
.
range
|>
List
.
filter
(
fun
x
->
let
demangledName
=
x
.
DemangledModuleOrNamespaceName
notFakeContainerModule
ilTyconNames
demangledName
&&
IsInterestingModuleName
demangledName
)
|>
List
.
map
modref
.
NestedTyconRef
|>
List
.
filter
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
>>
not
)
|>
List
.
filter
(
EntityRefContainsSomethingAccessible
ncenv
m
ad
)
|>
List
.
map
ItemForModuleOrNamespaceRef
)
@
accessibleSubModules
// Get all the types and .NET constructor groups accessible from here
@
(
tycons
...
...
@@ -3864,10 +3881,6 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE
|
[]
->
let
ilTyconNames
=
nenv
.
TyconsByAccessNames
(
fullyQualified
).
Values
|>
List
.
choose
(
fun
tyconRef
->
if
tyconRef
.
IsILTycon
then
Some
tyconRef
.
DisplayName
else
None
)
|>
Set
.
ofList
/// Include all the entries in the eUnqualifiedItems table.
let
unqualifiedItems
=
...
...
@@ -3889,9 +3902,15 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE
|>
NameMap
.
range
|>
List
.
filter
(
function
Item
.
ActivePatternCase
_
v
->
true
|
_
->
false
)
let
moduleAndNamespaceItems
=
nenv
.
ModulesAndNamespaces
(
fullyQualified
)
|>
NameMultiMap
.
range
let
moduleAndNamespaceItems
=
let
moduleOrNamespaceRefs
=
nenv
.
ModulesAndNamespaces
fullyQualified
|>
NameMultiMap
.
range
if
isNil
moduleOrNamespaceRefs
then
[]
else
let
ilTyconNames
=
getFakeContainerModulesFromTyconRefs
(
nenv
.
TyconsByAccessNames
(
fullyQualified
).
Values
)
moduleOrNamespaceRefs
|>
List
.
filter
(
fun
x
->
let
demangledName
=
x
.
DemangledModuleOrNamespaceName
IsInterestingModuleName
demangledName
&&
notFakeContainerModule
ilTyconNames
demangledName
)
...
...
@@ -3965,21 +3984,26 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForRecordFields (ncenv: NameRe
|>
List
.
filter
(
fun
tycon
->
tycon
.
IsRecordTycon
)
|>
List
.
filter
(
fun
tycon
->
not
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
(
modref
.
NestedTyconRef
tycon
)))
let
ilTyconNames
=
mty
.
TypesByAccessNames
.
Values
|>
List
.
choose
(
fun
(
tycon
:
Tycon
)
->
if
tycon
.
IsILTycon
then
Some
tycon
.
DisplayName
else
None
)
|>
Set
.
ofList
let
accessibleSubModules
=
let
moduleOrNamespaces
=
mty
.
ModulesAndNamespacesByDemangledName
|>
NameMap
.
range
if
isNil
moduleOrNamespaces
then
[]
else
let
ilTyconNames
=
getFakeContainerModulesFromTycons
mty
.
TypesByAccessNames
.
Values
// Collect up the accessible sub-modules
(
mty
.
ModulesAndNamespacesByDemangledName
|>
NameMap
.
range
|>
List
.
filter
(
fun
x
->
let
demangledName
=
x
.
DemangledModuleOrNamespaceName
notFakeContainerModule
ilTyconNames
demangledName
&&
IsInterestingModuleName
demangledName
)
|>
List
.
map
modref
.
NestedTyconRef
|>
List
.
filter
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
>>
not
)
|>
List
.
filter
(
EntityRefContainsSomethingAccessible
ncenv
m
ad
)
|>
List
.
map
ItemForModuleOrNamespaceRef
)
moduleOrNamespaces
|>
List
.
filter
(
fun
x
->
let
demangledName
=
x
.
DemangledModuleOrNamespaceName
notFakeContainerModule
ilTyconNames
demangledName
&&
IsInterestingModuleName
demangledName
)
|>
List
.
map
modref
.
NestedTyconRef
|>
List
.
filter
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
>>
not
)
|>
List
.
filter
(
EntityRefContainsSomethingAccessible
ncenv
m
ad
)
|>
List
.
map
ItemForModuleOrNamespaceRef
accessibleSubModules
// Collect all accessible record types
@
(
tycons
|>
List
.
map
(
modref
.
NestedTyconRef
>>
ItemOfTyconRef
ncenv
m
)
)
...
...
@@ -4029,17 +4053,21 @@ and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv:
|
[]
->
// empty plid - return namespaces\modules\record types\accessible fields
let
iltyconNames
=
nenv
.
TyconsByAccessNames
(
fullyQualified
).
Values
|>
List
.
choose
(
fun
tyconRef
->
if
tyconRef
.
IsILTycon
then
Some
tyconRef
.
DisplayName
else
None
)
|>
Set
.
ofList
let
mods
=
nenv
.
ModulesAndNamespaces
(
fullyQualified
)
|>
NameMultiMap
.
range
let
moduleOrNamespaceRefs
=
nenv
.
ModulesAndNamespaces
fullyQualified
|>
NameMultiMap
.
range
if
isNil
moduleOrNamespaceRefs
then
[]
else
let
ilTyconNames
=
getFakeContainerModulesFromTyconRefs
(
nenv
.
TyconsByAccessNames
(
fullyQualified
).
Values
)
moduleOrNamespaceRefs
|>
List
.
filter
(
fun
x
->
let
demangledName
=
x
.
DemangledModuleOrNamespaceName
IsInterestingModuleName
demangledName
&&
notFakeContainerModule
il
t
yconNames
demangledName
)
IsInterestingModuleName
demangledName
&&
notFakeContainerModule
il
T
yconNames
demangledName
)
|>
List
.
filter
(
EntityRefContainsSomethingAccessible
ncenv
m
ad
)
|>
List
.
filter
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
>>
not
)
|>
List
.
map
ItemForModuleOrNamespaceRef
...
...
@@ -4342,23 +4370,26 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForItem (ncenv: NameResolver)
|>
List
.
filter
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
>>
not
)
|>
List
.
map
Item
.
ExnCase
|
_
->
let
ilTyconNames
=
mty
.
TypesByAccessNames
.
Values
|>
List
.
choose
(
fun
(
tycon
:
Tycon
)
->
if
tycon
.
IsILTycon
then
Some
tycon
.
DisplayName
else
None
)
|>
Set
.
ofList
// Collect up the accessible sub-modules. We must yield them even though `item` is not a module or namespace,
// otherwise we would not resolve long idents which have modules and namespaces in the middle (i.e. all long idents)
yield
!
let
moduleOrNamespaces
=
mty
.
ModulesAndNamespacesByDemangledName
|>
NameMap
.
range
|>
List
.
filter
(
fun
x
->
let
demangledName
=
x
.
DemangledModuleOrNamespaceName
notFakeContainerModule
ilTyconNames
demangledName
&&
IsInterestingModuleName
demangledName
)
|>
List
.
map
modref
.
NestedTyconRef
|>
List
.
filter
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
>>
not
)
|>
List
.
filter
(
EntityRefContainsSomethingAccessible
ncenv
m
ad
)
|>
List
.
map
ItemForModuleOrNamespaceRef
|>
NameMap
.
range
if
not
(
isNil
moduleOrNamespaces
)
then
let
ilTyconNames
=
getFakeContainerModulesFromTycons
mty
.
TypesByAccessNames
.
Values
yield
!
moduleOrNamespaces
|>
List
.
filter
(
fun
x
->
let
demangledName
=
x
.
DemangledModuleOrNamespaceName
notFakeContainerModule
ilTyconNames
demangledName
&&
IsInterestingModuleName
demangledName
)
|>
List
.
map
modref
.
NestedTyconRef
|>
List
.
filter
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
>>
not
)
|>
List
.
filter
(
EntityRefContainsSomethingAccessible
ncenv
m
ad
)
|>
List
.
map
ItemForModuleOrNamespaceRef
let
tycons
=
mty
.
TypeDefinitions
|>
List
.
filter
(
fun
tcref
->
not
(
tcref
.
LogicalName
.
Contains
(
","
)))
...
...
@@ -4425,17 +4456,19 @@ let rec GetCompletionForItem (ncenv: NameResolver) (nenv: NameResolutionEnv) m a
match
item
with
|
Item
.
ModuleOrNamespaces
_
->
let
ilTyconNames
=
nenv
.
TyconsByAccessNames
(
OpenQualified
).
Values
|>
List
.
choose
(
fun
tyconRef
->
if
tyconRef
.
IsILTycon
then
Some
tyconRef
.
DisplayName
else
None
)
|>
Set
.
ofList
let
moduleOrNamespaceRefs
=
nenv
.
ModulesAndNamespaces
OpenQualified
|>
NameMultiMap
.
range
if
not
(
isNil
moduleOrNamespaceRefs
)
then
let
ilTyconNames
=
getFakeContainerModulesFromTyconRefs
(
nenv
.
TyconsByAccessNames
(
OpenQualified
).
Values
)
for
ns
in
NameMultiMap
.
range
(
nenv
.
ModulesAndNamespaces
(
OpenQualified
))
do
let
demangledName
=
ns
.
DemangledModuleOrNamespaceName
if
IsInterestingModuleName
demangledName
&&
notFakeContainerModule
ilTyconNames
demangledName
&&
EntityRefContainsSomethingAccessible
ncenv
m
ad
ns
&&
not
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
ns
)
then
yield
ItemForModuleOrNamespaceRef
ns
for
ns
in
moduleOrNamespaceRefs
do
let
demangledName
=
ns
.
DemangledModuleOrNamespaceName
if
IsInterestingModuleName
demangledName
&&
notFakeContainerModule
ilTyconNames
demangledName
&&
EntityRefContainsSomethingAccessible
ncenv
m
ad
ns
&&
not
(
IsTyconUnseen
ad
g
ncenv
.
amap
m
ns
)
then
yield
ItemForModuleOrNamespaceRef
ns
|
Item
.
Types
_
->
for
tcref
in
nenv
.
TyconsByDemangledNameAndArity
(
OpenQualified
).
Values
do
...
...
@@ -4485,20 +4518,25 @@ let rec GetCompletionForItem (ncenv: NameResolver) (nenv: NameResolutionEnv) m a
}
let
IsItemResolvable
(
ncenv
:
NameResolver
)
(
nenv
:
NameResolutionEnv
)
m
ad
plid
(
item
:
Item
)
:
bool
=
protectAssemblyExploration
false
<|
fun
()
->
GetCompletionForItem
ncenv
nenv
m
ad
plid
item
|>
Seq
.
exists
(
ItemsAreEffectivelyEqual
ncenv
.
g
item
)
protectAssemblyExploration
false
(
fun
()
->
GetCompletionForItem
ncenv
nenv
m
ad
plid
item
|>
Seq
.
exists
(
ItemsAreEffectivelyEqual
ncenv
.
g
item
)
)
let
GetVisibleNamespacesAndModulesAtPoint
(
ncenv
:
NameResolver
)
(
nenv
:
NameResolutionEnv
)
m
ad
=
protectAssemblyExploration
[]
<|
fun
()
->
let
ilTyconNames
=
nenv
.
TyconsByAccessNames
(
FullyQualifiedFlag
.
OpenQualified
).
Values
|>
List
.
choose
(
fun
tyconRef
->
if
tyconRef
.
IsILTycon
then
Some
tyconRef
.
DisplayName
else
None
)
|>
Set
.
ofList
nenv
.
ModulesAndNamespaces
(
FullyQualifiedFlag
.
OpenQualified
)
|>
NameMultiMap
.
range
|>
List
.
filter
(
fun
x
->
let
demangledName
=
x
.
DemangledModuleOrNamespaceName
IsInterestingModuleName
demangledName
&&
notFakeContainerModule
ilTyconNames
demangledName
&&
EntityRefContainsSomethingAccessible
ncenv
m
ad
x
&&
not
(
IsTyconUnseen
ad
ncenv
.
g
ncenv
.
amap
m
x
))
protectAssemblyExploration
[]
(
fun
()
->
let
items
=
nenv
.
ModulesAndNamespaces
FullyQualifiedFlag
.
OpenQualified
|>
NameMultiMap
.
range
if
isNil
items
then
[]
else
let
ilTyconNames
=
getFakeContainerModulesFromTyconRefs
(
nenv
.
TyconsByAccessNames
(
FullyQualifiedFlag
.
OpenQualified
).
Values
)
items
|>
List
.
filter
(
fun
x
->
let
demangledName
=
x
.
DemangledModuleOrNamespaceName
IsInterestingModuleName
demangledName
&&
notFakeContainerModule
ilTyconNames
demangledName
&&
EntityRefContainsSomethingAccessible
ncenv
m
ad
x
&&
not
(
IsTyconUnseen
ad
ncenv
.
g
ncenv
.
amap
m
x
))
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录