Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
48fd60af
F
fsharp
项目概览
dotNET Platform
/
fsharp
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
48fd60af
编写于
4月 29, 2022
作者:
D
dotnet bot
提交者:
GitHub
4月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13074 from dotnet/merges/main-to-release/dev17.3
Merge main to release/dev17.3
上级
f2b0862d
1ddfdc78
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
145 addition
and
41 deletion
+145
-41
eng/Versions.props
eng/Versions.props
+1
-2
src/fsharp/FSharp.Build/FSharp.Build.fsproj
src/fsharp/FSharp.Build/FSharp.Build.fsproj
+2
-0
src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj
...rp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj
+1
-1
src/fsharp/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj
...ndencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj
+1
-0
src/fsharp/NameResolution.fs
src/fsharp/NameResolution.fs
+15
-11
src/fsharp/NameResolution.fsi
src/fsharp/NameResolution.fsi
+3
-1
src/fsharp/fsc/fsc.fsproj
src/fsharp/fsc/fsc.fsproj
+1
-0
src/fsharp/fscAnyCpu/fscAnyCpu.fsproj
src/fsharp/fscAnyCpu/fscAnyCpu.fsproj
+1
-0
src/fsharp/service/FSharpCheckerResults.fs
src/fsharp/service/FSharpCheckerResults.fs
+37
-11
src/fsharp/service/ServiceParsedInputOps.fs
src/fsharp/service/ServiceParsedInputOps.fs
+20
-3
src/fsharp/service/ServiceParsedInputOps.fsi
src/fsharp/service/ServiceParsedInputOps.fsi
+2
-1
tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj
tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj
+1
-0
tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected
...s/FSharp.CompilerService.SurfaceArea.netstandard.expected
+8
-1
tests/service/CompletionTests.fs
tests/service/CompletionTests.fs
+48
-7
vsintegration/Directory.Build.targets
vsintegration/Directory.Build.targets
+1
-0
vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Completion.fs
...LegacyLanguageService/Tests.LanguageService.Completion.fs
+3
-3
未找到文件。
eng/Versions.props
浏览文件 @
48fd60af
...
...
@@ -110,7 +110,7 @@
<SystemThreadingTasksDataflow>4.11.1</SystemThreadingTasksDataflow>
<SystemThreadingThreadVersion>4.3.0</SystemThreadingThreadVersion>
<SystemThreadingThreadPoolVersion>4.3.0</SystemThreadingThreadPoolVersion>
<SystemRuntimeCompilerServicesUnsafeVersion>
5
.0.0</SystemRuntimeCompilerServicesUnsafeVersion>
<SystemRuntimeCompilerServicesUnsafeVersion>
6
.0.0</SystemRuntimeCompilerServicesUnsafeVersion>
<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
<!-- VisualStudio package versions -->
<VisualStudioImplementationPackagesVersion>17.0.487</VisualStudioImplementationPackagesVersion>
...
...
@@ -189,7 +189,6 @@
<MicrosoftVisualStudioUtilitiesVersion>$(VisualStudioContractPackagesVersion)</MicrosoftVisualStudioUtilitiesVersion>
<MicrosoftVisualStudioValidationVersion>17.0.28</MicrosoftVisualStudioValidationVersion>
<MicrosoftVisualStudioWCFReferenceInteropVersion>9.0.30729</MicrosoftVisualStudioWCFReferenceInteropVersion>
<SystemRuntimeCompilerServicesUnsafeVersion>6.0.0</SystemRuntimeCompilerServicesUnsafeVersion>
<VSSDKDebuggerVisualizersVersion>12.0.4</VSSDKDebuggerVisualizersVersion>
<VSSDKVSLangProjVersion>7.0.4</VSSDKVSLangProjVersion>
<VSSDKVSLangProj8Version>8.0.4</VSSDKVSLangProj8Version>
...
...
src/fsharp/FSharp.Build/FSharp.Build.fsproj
浏览文件 @
48fd60af
...
...
@@ -70,6 +70,8 @@
<PackageReference
Include=
"Microsoft.Build.Tasks.Core"
Version=
"$(MicrosoftBuildTasksCoreVersion)"
/>
<PackageReference
Include=
"Microsoft.Build.Utilities.Core"
Version=
"$(MicrosoftBuildUtilitiesCoreVersion)"
/>
<PackageReference
Include=
"Microsoft.Win32.Registry"
Version=
"$(MicrosoftWin32RegistryVersion)"
/>
<PackageReference
Include=
"System.Memory"
Version=
"$(SystemMemoryVersion)"
/>
<PackageReference
Include=
"System.Runtime.CompilerServices.Unsafe"
Version=
"$(SystemRuntimeCompilerServicesUnsafeVersion)"
/>
</ItemGroup>
</Project>
src/fsharp/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj
浏览文件 @
48fd60af
...
...
@@ -1027,10 +1027,10 @@
<PackageReference
Include=
"System.Threading.ThreadPool"
Version=
"$(SystemThreadingThreadPoolVersion)"
/>
<PackageReference
Include=
"System.Buffers"
Version=
"$(SystemBuffersVersion)"
/>
<PackageReference
Include=
"System.Memory"
Version=
"$(SystemMemoryVersion)"
/>
<PackageReference
Include=
"System.Runtime.CompilerServices.Unsafe"
Version=
"$(SystemRuntimeCompilerServicesUnsafeVersion)"
/>
<PackageReference
Include=
"Microsoft.Build.Framework"
Version=
"$(MicrosoftBuildVersion)"
/>
<PackageReference
Include=
"Microsoft.Build.Tasks.Core"
Version=
"$(MicrosoftBuildVersion)"
/>
<PackageReference
Include=
"Microsoft.Build.Utilities.Core"
Version=
"$(MicrosoftBuildVersion)"
/>
<PackageReference
Include=
"System.Runtime.CompilerServices.Unsafe"
Version=
"$(SystemRuntimeCompilerServicesUnsafeVersion)"
/>
</ItemGroup>
</Project>
src/fsharp/FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj
浏览文件 @
48fd60af
...
...
@@ -55,6 +55,7 @@
<PackageReference
Include=
"System.Reflection.TypeExtensions"
Version=
"$(SystemReflectionTypeExtensionsVersion)"
/>
<PackageReference
Include=
"System.Runtime"
Version=
"$(SystemRuntimeVersion)"
/>
<PackageReference
Include=
"System.Runtime.InteropServices"
Version=
"$(SystemRuntimeInteropServicesVersion)"
/>
<PackageReference
Include=
"System.Runtime.CompilerServices.Unsafe"
Version=
"$(SystemRuntimeCompilerServicesUnsafeVersion)"
/>
<PackageReference
Include=
"System.Security.Claims"
Version=
"$(SystemSecurityClaimsVersion)"
/>
<PackageReference
Include=
"System.Security.Cryptography.Algorithms"
Version=
"$(SystemSecurityCryptographyAlgorithmsVersion)"
/>
<PackageReference
Include=
"System.Security.Principal"
Version=
"$(SystemSecurityPrincipalVersion)"
/>
...
...
src/fsharp/NameResolution.fs
浏览文件 @
48fd60af
...
...
@@ -4484,22 +4484,31 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForRecordFields (ncenv: NameRe
|
_
->
[]
)
let
getRecordFieldsInScope
nenv
=
nenv
.
eFieldLabels
|>
Seq
.
collect
(
fun
(
KeyValue
(_,
v
))
->
v
)
|>
Seq
.
map
(
fun
fref
->
let
typeInsts
=
fref
.
TyconRef
.
TyparsNoRange
|>
List
.
map
mkTyparTy
Item
.
RecdField
(
RecdFieldInfo
(
typeInsts
,
fref
)))
|>
List
.
ofSeq
/// allowObsolete - specifies whether we should return obsolete types & modules
/// as (no other obsolete items are returned)
let
rec
ResolvePartialLongIdentToClassOrRecdFields
(
ncenv
:
NameResolver
)
(
nenv
:
NameResolutionEnv
)
m
ad
plid
(
allowObsolete
:
bool
)
=
ResolvePartialLongIdentToClassOrRecdFieldsImpl
ncenv
nenv
OpenQualified
m
ad
plid
allowObsolete
let
rec
ResolvePartialLongIdentToClassOrRecdFields
(
ncenv
:
NameResolver
)
(
nenv
:
NameResolutionEnv
)
m
ad
plid
(
allowObsolete
:
bool
)
(
fieldsOnly
:
bool
)
=
ResolvePartialLongIdentToClassOrRecdFieldsImpl
ncenv
nenv
OpenQualified
m
ad
plid
allowObsolete
fieldsOnly
and
ResolvePartialLongIdentToClassOrRecdFieldsImpl
(
ncenv
:
NameResolver
)
(
nenv
:
NameResolutionEnv
)
fullyQualified
m
ad
plid
allowObsolete
=
and
ResolvePartialLongIdentToClassOrRecdFieldsImpl
(
ncenv
:
NameResolver
)
(
nenv
:
NameResolutionEnv
)
fullyQualified
m
ad
plid
allowObsolete
fieldsOnly
=
let
g
=
ncenv
.
g
match
plid
with
|
id
::
plid
when
id
=
"global"
->
// this is deliberately not the mangled name
// dive deeper
ResolvePartialLongIdentToClassOrRecdFieldsImpl
ncenv
nenv
FullyQualified
m
ad
plid
allowObsolete
ResolvePartialLongIdentToClassOrRecdFieldsImpl
ncenv
nenv
FullyQualified
m
ad
plid
allowObsolete
fieldsOnly
|
[]
->
// empty plid - return namespaces\modules\record types\accessible fields
if
fieldsOnly
then
getRecordFieldsInScope
nenv
else
let
mods
=
let
moduleOrNamespaceRefs
=
...
...
@@ -4528,12 +4537,7 @@ and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv:
|>
Seq
.
toList
let
recdFields
=
nenv
.
eFieldLabels
|>
Seq
.
collect
(
fun
(
KeyValue
(_,
v
))
->
v
)
|>
Seq
.
map
(
fun
fref
->
let
typeInsts
=
fref
.
TyconRef
.
TyparsNoRange
|>
List
.
map
mkTyparTy
Item
.
RecdField
(
RecdFieldInfo
(
typeInsts
,
fref
)))
|>
List
.
ofSeq
getRecordFieldsInScope
nenv
mods
@
recdTyCons
@
recdFields
...
...
@@ -4549,7 +4553,7 @@ and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv:
let
qualifiedFields
=
match
rest
with
|
[]
->
|
[]
when
not
fieldsOnly
->
// get record types accessible in given nenv
let
tycons
=
LookupTypeNameInEnvNoArity
OpenQualified
id
nenv
tycons
...
...
src/fsharp/NameResolution.fsi
浏览文件 @
48fd60af
...
...
@@ -557,8 +557,10 @@ val internal ResolveField : TcResultsSink -> NameResolver -
/// Resolve a long identifier occurring in an expression position
val
internal
ResolveExprLongIdent
:
TcResultsSink
->
NameResolver
->
range
->
AccessorDomain
->
NameResolutionEnv
->
TypeNameResolutionInfo
->
Ident
list
->
ResultOrException
<
EnclosingTypeInst
*
Item
*
Ident
list
>
val
internal
getRecordFieldsInScope
:
NameResolutionEnv
->
Item
list
/// Resolve a (possibly incomplete) long identifier to a loist of possible class or record fields
val
internal
ResolvePartialLongIdentToClassOrRecdFields
:
NameResolver
->
NameResolutionEnv
->
range
->
AccessorDomain
->
string
list
->
bool
->
Item
list
val
internal
ResolvePartialLongIdentToClassOrRecdFields
:
NameResolver
->
NameResolutionEnv
->
range
->
AccessorDomain
->
string
list
->
bool
->
bool
->
Item
list
/// Return the fields for the given class or record
val
internal
ResolveRecordOrClassFieldsOfType
:
NameResolver
->
range
->
AccessorDomain
->
TType
->
bool
->
Item
list
...
...
src/fsharp/fsc/fsc.fsproj
浏览文件 @
48fd60af
...
...
@@ -40,6 +40,7 @@
<PackageReference
Include=
"System.Console"
Version=
"$(SystemConsoleVersion)"
/>
<PackageReference
Include=
"System.Linq.Expressions"
Version=
"$(SystemLinqExpressionsVersion)"
/>
<PackageReference
Include=
"System.Memory"
Version=
"$(SystemMemoryVersion)"
/>
<PackageReference
Include=
"System.Runtime.CompilerServices.Unsafe"
Version=
"$(SystemRuntimeCompilerServicesUnsafeVersion)"
/>
<PackageReference
Include=
"System.Reflection.Metadata"
Version=
"$(SystemReflectionMetadataVersion)"
/>
<PackageReference
Include=
"System.Runtime.Loader"
Version=
"$(SystemRuntimeLoaderVersion)"
/>
<PackageReference
Include=
"System.Security.Principal"
Version=
"$(SystemSecurityPrincipalVersion)"
/>
...
...
src/fsharp/fscAnyCpu/fscAnyCpu.fsproj
浏览文件 @
48fd60af
...
...
@@ -34,6 +34,7 @@
<PackageReference
Include=
"System.Console"
Version=
"$(SystemConsoleVersion)"
/>
<PackageReference
Include=
"System.Linq.Expressions"
Version=
"$(SystemLinqExpressionsVersion)"
/>
<PackageReference
Include=
"System.Memory"
Version=
"$(SystemMemoryVersion)"
/>
<PackageReference
Include=
"System.Runtime.CompilerServices.Unsafe"
Version=
"$(SystemRuntimeCompilerServicesUnsafeVersion)"
/>
<PackageReference
Include=
"System.Reflection.Metadata"
Version=
"$(SystemReflectionMetadataVersion)"
/>
<PackageReference
Include=
"System.Runtime.Loader"
Version=
"$(SystemRuntimeLoaderVersion)"
/>
<PackageReference
Include=
"System.Security.Principal"
Version=
"$(SystemSecurityPrincipalVersion)"
/>
...
...
src/fsharp/service/FSharpCheckerResults.fs
浏览文件 @
48fd60af
...
...
@@ -638,9 +638,9 @@ type internal TypeCheckInfo
GetEnvironmentLookupResolutions
(
nenv
,
ad
,
m
,
plid
,
filterCtors
,
showObsolete
)
/// Find record fields in the best naming environment.
let
GetClassOrRecordFieldsEnvironmentLookupResolutions
(
cursorPos
,
plid
)
=
let
GetClassOrRecordFieldsEnvironmentLookupResolutions
(
cursorPos
,
plid
,
fieldsOnly
)
=
let
(
nenv
,
ad
),
m
=
GetBestEnvForPos
cursorPos
let
items
=
ResolvePartialLongIdentToClassOrRecdFields
ncenv
nenv
m
ad
plid
false
let
items
=
ResolvePartialLongIdentToClassOrRecdFields
ncenv
nenv
m
ad
plid
false
fieldsOnly
let
items
=
items
|>
List
.
map
ItemWithNoInst
let
items
=
items
|>
RemoveDuplicateItems
g
let
items
=
items
|>
RemoveExplicitlySuppressed
g
...
...
@@ -913,6 +913,21 @@ type internal TypeCheckInfo
let
toCompletionItems
(
items
:
ItemWithInst
list
,
denv
:
DisplayEnv
,
m
:
range
)
=
items
|>
List
.
map
DefaultCompletionItem
,
denv
,
m
/// Find record fields in the best naming environment.
let
GetEnvironmentLookupResolutionsIncludingRecordFieldsAtPosition
cursorPos
plid
envItems
=
// An empty record expression may be completed into something like these:
// { XXX = ... }
// { xxx with XXX ... }
// Provide both expression items in scope and available record fields.
let
(
nenv
,
_),
m
=
GetBestEnvForPos
cursorPos
let
fieldItems
,
_,
_
=
GetClassOrRecordFieldsEnvironmentLookupResolutions
(
cursorPos
,
plid
,
true
)
let
fieldCompletionItems
,
_,
_
as
fieldsResult
=
(
fieldItems
,
nenv
.
DisplayEnv
,
m
)
|>
toCompletionItems
match
envItems
with
|
Some
(
items
,
denv
,
m
)
->
Some
(
fieldCompletionItems
@
items
,
denv
,
m
)
|
_
->
Some
(
fieldsResult
)
/// Get the auto-complete items at a particular location.
let
GetDeclItemsForNamesAtPosition
(
parseResultsOpt
:
FSharpParseFileResults
option
,
origLongIdentOpt
:
string
list
option
,
residueOpt
:
string
option
,
lastDotPos
:
int
option
,
line
:
int
,
lineStr
:
string
,
colAtEndOfNamesAndResidue
,
filterCtors
,
resolveOverloads
,
...
...
@@ -963,19 +978,30 @@ type internal TypeCheckInfo
|>
Option
.
map
toCompletionItems
// Completion at ' { XXX = ... } "
|
Some
(
CompletionContext
.
RecordField
(
RecordContext
.
New
(
plid
,
_)))
->
// { x. } can be either record construction or computation expression. Try to get all visible record fields first
match
GetClassOrRecordFieldsEnvironmentLookupResolutions
(
mkPos
line
loc
,
plid
)
|>
toCompletionItems
with
|
[]
,_,_
->
// no record fields found, return completion list as if we were outside any computation expression
GetDeclaredItems
(
parseResultsOpt
,
lineStr
,
origLongIdentOpt
,
colAtEndOfNamesAndResidue
,
residueOpt
,
lastDotPos
,
line
,
loc
,
filterCtors
,
resolveOverloads
,
false
,
fun
()
->
[]
)
|
result
->
Some
(
result
)
|
Some
(
CompletionContext
.
RecordField
(
RecordContext
.
New
((
plid
,
_),
isFirstField
)))
->
if
isFirstField
then
let
cursorPos
=
mkPos
line
loc
let
envItems
=
GetDeclaredItems
(
parseResultsOpt
,
lineStr
,
origLongIdentOpt
,
colAtEndOfNamesAndResidue
,
residueOpt
,
lastDotPos
,
line
,
loc
,
filterCtors
,
resolveOverloads
,
false
,
fun
()
->
[]
)
GetEnvironmentLookupResolutionsIncludingRecordFieldsAtPosition
cursorPos
plid
envItems
else
// { x. } can be either record construction or computation expression. Try to get all visible record fields first
match
GetClassOrRecordFieldsEnvironmentLookupResolutions
(
mkPos
line
loc
,
plid
,
false
)
|>
toCompletionItems
with
|
[]
,_,_
->
// no record fields found, return completion list as if we were outside any computation expression
GetDeclaredItems
(
parseResultsOpt
,
lineStr
,
origLongIdentOpt
,
colAtEndOfNamesAndResidue
,
residueOpt
,
lastDotPos
,
line
,
loc
,
filterCtors
,
resolveOverloads
,
false
,
fun
()
->
[]
)
|
result
->
Some
(
result
)
// Completion at '{ ... }'
|
Some
(
CompletionContext
.
RecordField
RecordContext
.
Empty
)
->
let
cursorPos
=
mkPos
line
loc
let
envItems
=
GetDeclaredItems
(
parseResultsOpt
,
lineStr
,
origLongIdentOpt
,
colAtEndOfNamesAndResidue
,
residueOpt
,
lastDotPos
,
line
,
loc
,
filterCtors
,
resolveOverloads
,
false
,
fun
()
->
[]
)
GetEnvironmentLookupResolutionsIncludingRecordFieldsAtPosition
cursorPos
[]
envItems
// Completion at ' { XXX = ... with ... } "
|
Some
(
CompletionContext
.
RecordField
(
RecordContext
.
CopyOnUpdate
(
r
,
(
plid
,
_))))
->
match
GetRecdFieldsForExpr
(
r
)
with
|
None
->
Some
(
GetClassOrRecordFieldsEnvironmentLookupResolutions
(
mkPos
line
loc
,
plid
))
Some
(
GetClassOrRecordFieldsEnvironmentLookupResolutions
(
mkPos
line
loc
,
plid
,
false
))
|>
Option
.
map
toCompletionItems
|
Some
(
items
,
denv
,
m
)
->
Some
(
List
.
map
ItemWithNoInst
items
,
denv
,
m
)
...
...
@@ -983,7 +1009,7 @@ type internal TypeCheckInfo
// Completion at ' { XXX = ... with ... } "
|
Some
(
CompletionContext
.
RecordField
(
RecordContext
.
Constructor
(
typeName
)))
->
Some
(
GetClassOrRecordFieldsEnvironmentLookupResolutions
(
mkPos
line
loc
,
[
typeName
]))
Some
(
GetClassOrRecordFieldsEnvironmentLookupResolutions
(
mkPos
line
loc
,
[
typeName
]
,
false
))
|>
Option
.
map
toCompletionItems
// No completion at '...: string'
...
...
src/fsharp/service/ServiceParsedInputOps.fs
浏览文件 @
48fd60af
...
...
@@ -43,7 +43,8 @@ type InheritanceContext =
type
RecordContext
=
|
CopyOnUpdate
of
range
:
range
*
path
:
CompletionPath
|
Constructor
of
typeName
:
string
|
New
of
path
:
CompletionPath
|
Empty
|
New
of
path
:
CompletionPath
*
isFirstField
:
bool
|
Declaration
of
isInIdentifier
:
bool
[<
RequireQualifiedAccess
>]
...
...
@@ -956,7 +957,8 @@ module ParsedInput =
Some
(
CompletionContext
.
ParameterList
args
)
|
_
->
defaultTraverse
expr
|
SynExpr
.
Record
(
None
,
None
,
[]
,
_)
->
Some
(
CompletionContext
.
RecordField
RecordContext
.
Empty
)
// Unchecked.defaultof<str$>
|
SynExpr
.
TypeApp
(
typeArgsRange
=
range
)
when
rangeContainsPos
range
pos
->
Some
CompletionContext
.
PatternType
...
...
@@ -968,7 +970,22 @@ module ParsedInput =
match
path
with
|
SyntaxNode
.
SynExpr
_
::
SyntaxNode
.
SynBinding
_
::
SyntaxNode
.
SynMemberDefn
_
::
SyntaxNode
.
SynTypeDefn
(
SynTypeDefn
(
typeInfo
=
SynComponentInfo
(
longId
=[
id
])))
::
_
->
RecordContext
.
Constructor
(
id
.
idText
)
|
_
->
RecordContext
.
New
completionPath
|
SyntaxNode
.
SynExpr
(
SynExpr
.
Record
(
None
,
_,
fields
,
_))
::
_
->
let
isFirstField
=
match
field
,
fields
with
|
Some
contextLid
,
SynExprRecordField
(
fieldName
=
lid
,
_)
::
_
->
contextLid
.
Range
=
lid
.
Range
|
_
->
false
RecordContext
.
New
(
completionPath
,
isFirstField
)
// Unfinished `{ xxx }` expression considered a record field by the tree walker.
|
SyntaxNode
.
SynExpr
(
SynExpr
.
ComputationExpr
_)
::
_
->
RecordContext
.
New
(
completionPath
,
true
)
|
_
->
RecordContext
.
New
(
completionPath
,
false
)
match
field
with
|
Some
field
->
match
parseLid
field
with
...
...
src/fsharp/service/ServiceParsedInputOps.fsi
浏览文件 @
48fd60af
...
...
@@ -18,7 +18,8 @@ type public InheritanceContext =
type
public
RecordContext
=
|
CopyOnUpdate
of
range
:
range
*
path
:
CompletionPath
|
Constructor
of
typeName
:
string
|
New
of
path
:
CompletionPath
|
Empty
|
New
of
path
:
CompletionPath
*
isFirstField
:
bool
|
Declaration
of
isInIdentifier
:
bool
[<
RequireQualifiedAccess
>]
...
...
tests/FSharp.Build.UnitTests/FSharp.Build.UnitTests.fsproj
浏览文件 @
48fd60af
...
...
@@ -21,6 +21,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference
Include=
"System.Runtime.CompilerServices.Unsafe"
Version=
"$(SystemRuntimeCompilerServicesUnsafeVersion)"
/>
<PackageReference
Include=
"Microsoft.Build.Framework"
Version=
"$(MicrosoftBuildFrameworkVersion)"
/>
<PackageReference
Include=
"Microsoft.Build.Tasks.Core"
Version=
"$(MicrosoftBuildTasksCoreVersion)"
/>
<PackageReference
Include=
"Microsoft.Build.Utilities.Core"
Version=
"$(MicrosoftBuildUtilitiesCoreVersion)"
/>
...
...
tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected
浏览文件 @
48fd60af
...
...
@@ -3511,11 +3511,14 @@ FSharp.Compiler.EditorServices.RecordContext+CopyOnUpdate: System.Tuple`2[Micros
FSharp.Compiler.EditorServices.RecordContext+CopyOnUpdate: System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[System.String],Microsoft.FSharp.Core.FSharpOption`1[System.String]] path
FSharp.Compiler.EditorServices.RecordContext+Declaration: Boolean get_isInIdentifier()
FSharp.Compiler.EditorServices.RecordContext+Declaration: Boolean isInIdentifier
FSharp.Compiler.EditorServices.RecordContext+New: Boolean get_isFirstField()
FSharp.Compiler.EditorServices.RecordContext+New: Boolean isFirstField
FSharp.Compiler.EditorServices.RecordContext+New: System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[System.String],Microsoft.FSharp.Core.FSharpOption`1[System.String]] get_path()
FSharp.Compiler.EditorServices.RecordContext+New: System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[System.String],Microsoft.FSharp.Core.FSharpOption`1[System.String]] path
FSharp.Compiler.EditorServices.RecordContext+Tags: Int32 Constructor
FSharp.Compiler.EditorServices.RecordContext+Tags: Int32 CopyOnUpdate
FSharp.Compiler.EditorServices.RecordContext+Tags: Int32 Declaration
FSharp.Compiler.EditorServices.RecordContext+Tags: Int32 Empty
FSharp.Compiler.EditorServices.RecordContext+Tags: Int32 New
FSharp.Compiler.EditorServices.RecordContext: Boolean Equals(FSharp.Compiler.EditorServices.RecordContext)
FSharp.Compiler.EditorServices.RecordContext: Boolean Equals(System.Object)
...
...
@@ -3523,15 +3526,19 @@ FSharp.Compiler.EditorServices.RecordContext: Boolean Equals(System.Object, Syst
FSharp.Compiler.EditorServices.RecordContext: Boolean IsConstructor
FSharp.Compiler.EditorServices.RecordContext: Boolean IsCopyOnUpdate
FSharp.Compiler.EditorServices.RecordContext: Boolean IsDeclaration
FSharp.Compiler.EditorServices.RecordContext: Boolean IsEmpty
FSharp.Compiler.EditorServices.RecordContext: Boolean IsNew
FSharp.Compiler.EditorServices.RecordContext: Boolean get_IsConstructor()
FSharp.Compiler.EditorServices.RecordContext: Boolean get_IsCopyOnUpdate()
FSharp.Compiler.EditorServices.RecordContext: Boolean get_IsDeclaration()
FSharp.Compiler.EditorServices.RecordContext: Boolean get_IsEmpty()
FSharp.Compiler.EditorServices.RecordContext: Boolean get_IsNew()
FSharp.Compiler.EditorServices.RecordContext: FSharp.Compiler.EditorServices.RecordContext Empty
FSharp.Compiler.EditorServices.RecordContext: FSharp.Compiler.EditorServices.RecordContext NewConstructor(System.String)
FSharp.Compiler.EditorServices.RecordContext: FSharp.Compiler.EditorServices.RecordContext NewCopyOnUpdate(FSharp.Compiler.Text.Range, System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[System.String],Microsoft.FSharp.Core.FSharpOption`1[System.String]])
FSharp.Compiler.EditorServices.RecordContext: FSharp.Compiler.EditorServices.RecordContext NewDeclaration(Boolean)
FSharp.Compiler.EditorServices.RecordContext: FSharp.Compiler.EditorServices.RecordContext NewNew(System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[System.String],Microsoft.FSharp.Core.FSharpOption`1[System.String]])
FSharp.Compiler.EditorServices.RecordContext: FSharp.Compiler.EditorServices.RecordContext NewNew(System.Tuple`2[Microsoft.FSharp.Collections.FSharpList`1[System.String],Microsoft.FSharp.Core.FSharpOption`1[System.String]], Boolean)
FSharp.Compiler.EditorServices.RecordContext: FSharp.Compiler.EditorServices.RecordContext get_Empty()
FSharp.Compiler.EditorServices.RecordContext: FSharp.Compiler.EditorServices.RecordContext+Constructor
FSharp.Compiler.EditorServices.RecordContext: FSharp.Compiler.EditorServices.RecordContext+CopyOnUpdate
FSharp.Compiler.EditorServices.RecordContext: FSharp.Compiler.EditorServices.RecordContext+Declaration
...
...
tests/service/CompletionTests.fs
浏览文件 @
48fd60af
module
FSharp
.
Compiler
.
Service
.
Tests
.
CompletionTests
open
FSharp
.
Compiler
.
EditorServices
open
FsUnit
open
NUnit
.
Framework
let
getCompletionInfo
lineText
(
line
,
column
)
source
=
let
parseResults
,
checkResults
=
getParseAndCheckResults
source
let
plid
=
QuickParse
.
GetPartialLongNameEx
(
lineText
,
column
)
checkResults
.
GetDeclarationListInfo
(
Some
parseResults
,
line
,
lineText
,
plid
)
let
getCompletionItemNames
(
completionInfo
:
DeclarationListInfo
)
=
completionInfo
.
Items
|>
Array
.
map
(
fun
item
->
item
.
Name
)
let
assertHasItemWithNames
names
(
completionInfo
:
DeclarationListInfo
)
=
let
itemNames
=
getCompletionItemNames
completionInfo
|>
set
for
name
in
names
do
Assert
.
That
(
Set
.
contains
name
itemNames
,
name
)
[<
Test
>]
let
``Expr - record - field 01 - anon module``
()
=
let
parseResults
,
checkResults
=
getParseAndCheckResults
"""
type Record = { Field: int}
let
info
=
getCompletionInfo
"{ Fi }"
(
4
,
3
)
"""
type Record = { Field: int
}
{ Fi }
"""
let
lineText
=
"{ Fi }"
let
plid
=
QuickParse
.
GetPartialLongNameEx
(
lineText
,
3
)
let
info
=
checkResults
.
GetDeclarationListInfo
(
Some
parseResults
,
4
,
lineText
,
plid
)
assertHasItemWithNames
[
"Field"
]
info
info
.
Items
|>
Array
.
exists
(
fun
item
->
item
.
Name
=
"Field"
)
|>
shouldEqual
true
[<
Test
>]
let
``Expr - record - field 02 - anon module``
()
=
let
info
=
getCompletionInfo
"{ Fi }"
(
6
,
3
)
"""
type Record = { Field: int }
let record = { Field = 1 }
{ Fi }
"""
assertHasItemWithNames
[
"Field"
]
info
[<
Test
>]
let
``Expr - record - empty 01``
()
=
let
info
=
getCompletionInfo
"{ }"
(
4
,
2
)
"""
type Record = { Field: int }
{ }
"""
assertHasItemWithNames
[
"Field"
]
info
[<
Test
>]
let
``Expr - record - empty 02``
()
=
let
info
=
getCompletionInfo
"{ }"
(
6
,
2
)
"""
type Record = { Field: int }
let record = { Field = 1 }
{ }
"""
assertHasItemWithNames
[
"Field"
;
"record"
]
info
vsintegration/Directory.Build.targets
浏览文件 @
48fd60af
...
...
@@ -16,6 +16,7 @@
<PackageReference Include="System.Buffers" Version="$(SystemBuffersVersion)" PrivateAssets="all" ExcludeAssets="contentFiles;analyzers;native" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="$(SystemRuntimeCompilerServicesUnsafeVersion)" PrivateAssets="all" ExcludeAssets="contentFiles;analyzers;native" />
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" PrivateAssets="all" ExcludeAssets="contentFiles;analyzers;native" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="$(SystemRuntimeCompilerServicesUnsafeVersion)" />
</ItemGroup>
<ItemGroup>
...
...
vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Completion.fs
浏览文件 @
48fd60af
...
...
@@ -786,15 +786,15 @@ for i in 0..a."]
]
let
useCases
=
[
"let _ = (* MARKER*){X"
,
"(* MARKER*){X"
,
[]
,
[
"XX"
]
"let _ = (* MARKER*){X
}
"
,
"(* MARKER*){X"
,
[]
,
[
"XX"
]
"let _ = {(* MARKER*)Mod. = 1; O"
,
"(* MARKER*)Mod."
,
[
"XX"
;
"YY"
],
[
"System"
]
"let _ = {(* MARKER*)Mod.Rec. "
,
"(* MARKER*)Mod.Rec."
,
[
"XX"
;
"YY"
],
[
"System"
]
"let _ = (* MARKER*){Mod.XX = 1; }"
,
"(* MARKER*){Mod.XX = 1; "
,
[
"Mod"
],
[
"XX"
;
"abs"
]
]
for
(
code
,
marker
,
should
,
shouldnot
)
in
useCases
do
let
code
=
prologue
@
[
code
]
let
shouldnot
=
shouldnot
@
[
"abs"
]
AssertCtrlSpaceCompleteContains
code
marker
should
[
"abs"
]
AssertCtrlSpaceCompleteContains
code
marker
should
shouldnot
[<
Test
>]
[<
Category
(
"Records"
)>]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录