Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
c3aacd03
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,发现更多精彩内容 >>
未验证
提交
c3aacd03
编写于
12月 27, 2022
作者:
R
Ross Kuehl
提交者:
GitHub
12月 27, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix: Inline parameter hints for inner bindings (#14506)
Fixes
https://github.com/dotnet/fsharp/issues/14501
上级
0adeca4f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
8 deletion
+49
-8
vsintegration/src/FSharp.Editor/Hints/HintService.fs
vsintegration/src/FSharp.Editor/Hints/HintService.fs
+13
-6
vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs
...ation/src/FSharp.Editor/Hints/InlineParameterNameHints.fs
+5
-2
vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs
...FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs
+31
-0
未找到文件。
vsintegration/src/FSharp.Editor/Hints/HintService.fs
浏览文件 @
c3aacd03
...
...
@@ -6,32 +6,37 @@ open Microsoft.CodeAnalysis
open
Microsoft
.
VisualStudio
.
FSharp
.
Editor
open
FSharp
.
Compiler
.
CodeAnalysis
open
FSharp
.
Compiler
.
Symbols
open
FSharp
.
Compiler
.
Text
open
Hints
module
HintService
=
let
private
getHintsForSymbol
parseResults
hintKinds
(
symbolUse
:
FSharpSymbolUse
)
=
let
private
getHintsForSymbol
parseResults
hintKinds
(
longIdEndLocations
:
Position
list
)
(
symbolUse
:
FSharpSymbolUse
)
=
match
symbolUse
.
Symbol
with
|
:?
FSharpMemberOrFunctionOrValue
as
symbol
when
hintKinds
|>
Set
.
contains
HintKind
.
TypeHint
&&
InlineTypeHints
.
isValidForHint
parseResults
symbol
symbolUse
->
InlineTypeHints
.
getHints
symbol
symbolUse
InlineTypeHints
.
getHints
symbol
symbolUse
,
longIdEndLocations
|
:?
FSharpMemberOrFunctionOrValue
as
symbol
when
hintKinds
|>
Set
.
contains
HintKind
.
ParameterNameHint
&&
InlineParameterNameHints
.
isMemberOrFunctionOrValueValidForHint
symbol
symbolUse
->
InlineParameterNameHints
.
getHintsForMemberOrFunctionOrValue
parseResults
symbol
symbolUse
InlineParameterNameHints
.
getHintsForMemberOrFunctionOrValue
parseResults
symbol
symbolUse
longIdEndLocations
,
symbolUse
.
Range
.
End
::
longIdEndLocations
|
:?
FSharpUnionCase
as
symbol
when
hintKinds
|>
Set
.
contains
HintKind
.
ParameterNameHint
&&
InlineParameterNameHints
.
isUnionCaseValidForHint
symbol
symbolUse
->
InlineParameterNameHints
.
getHintsForUnionCase
parseResults
symbol
symbolUse
InlineParameterNameHints
.
getHintsForUnionCase
parseResults
symbol
symbolUse
,
longIdEndLocations
// we'll be adding other stuff gradually here
|
_
->
[]
[]
,
longIdEndLocations
let
getHintsForDocument
(
document
:
Document
)
hintKinds
userOpName
cancellationToken
=
async
{
...
...
@@ -44,6 +49,8 @@ module HintService =
return
checkResults
.
GetAllUsesOfAllSymbolsInFile
cancellationToken
|>
Seq
.
mapFold
(
getHintsForSymbol
parseResults
hintKinds
)
[]
|>
fst
|>
Seq
.
concat
|>
Seq
.
toList
|>
List
.
collect
(
getHintsForSymbol
parseResults
hintKinds
)
}
vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs
浏览文件 @
c3aacd03
...
...
@@ -33,6 +33,7 @@ module InlineParameterNameHints =
let
private
getArgumentLocations
(
symbolUse
:
FSharpSymbolUse
)
(
longIdEndLocations
:
Position
list
)
(
parseResults
:
FSharpParseFileResults
)
=
let
position
=
Position
.
mkPos
...
...
@@ -40,6 +41,7 @@ module InlineParameterNameHints =
(
symbolUse
.
Range
.
End
.
Column
+
1
)
parseResults
.
FindParameterLocations
position
|>
Option
.
filter
(
fun
locations
->
longIdEndLocations
|>
List
.
contains
locations
.
LongIdEndLocation
|>
not
)
|>
Option
.
map
(
fun
locations
->
locations
.
ArgumentLocations
)
|>
Option
.
defaultValue
[||]
...
...
@@ -81,10 +83,11 @@ module InlineParameterNameHints =
let
getHintsForMemberOrFunctionOrValue
(
parseResults
:
FSharpParseFileResults
)
(
symbol
:
FSharpMemberOrFunctionOrValue
)
(
symbolUse
:
FSharpSymbolUse
)
=
(
symbolUse
:
FSharpSymbolUse
)
(
longIdEndLocations
:
Position
list
)
=
let
parameters
=
symbol
.
CurriedParameterGroups
|>
Seq
.
concat
let
argumentLocations
=
getArgumentLocations
symbolUse
parseResult
s
let
argumentLocations
=
parseResults
|>
getArgumentLocations
symbolUse
longIdEndLocation
s
let
tupleRanges
=
argumentLocations
|>
getTupleRanges
let
curryRanges
=
parseResults
|>
getCurryRanges
symbolUse
...
...
vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs
浏览文件 @
c3aacd03
...
...
@@ -448,3 +448,34 @@ type MyType() =
let
actual
=
getParameterNameHints
document
Assert
.
IsEmpty
(
actual
)
[<
Test
>]
let
``Hints are shown correctly for inner bindings``
()
=
let
code
=
"""
let test sequences =
sequences
|> Seq.map (fun sequence -> sequence |> Seq.map (fun sequence' -> sequence' |> Seq.map (fun item -> item)))
"""
let
document
=
getFsDocument
code
let
expected
=
[
{
Content
=
"mapping = "
Location
=
(
3
,
16
)
}
{
Content
=
"mapping = "
Location
=
(
3
,
53
)
}
{
Content
=
"mapping = "
Location
=
(
3
,
92
)
}
]
let
actual
=
getParameterNameHints
document
Assert
.
AreEqual
(
expected
,
actual
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录