Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
ddc4a7d7
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,发现更多精彩内容 >>
未验证
提交
ddc4a7d7
编写于
12月 08, 2022
作者:
D
dotnet bot
提交者:
GitHub
12月 08, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14451 from dotnet/merges/main-to-release/dev17.5
Merge main to release/dev17.5
上级
b85d2db7
2dd6506e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
59 addition
and
13 deletion
+59
-13
vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs
...ation/src/FSharp.Editor/Hints/InlineParameterNameHints.fs
+31
-12
vsintegration/tests/FSharp.Editor.Tests/Hints/HintTestFramework.fs
...tion/tests/FSharp.Editor.Tests/Hints/HintTestFramework.fs
+3
-1
vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs
...FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs
+25
-0
未找到文件。
vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs
浏览文件 @
ddc4a7d7
...
...
@@ -30,6 +30,27 @@ module InlineParameterNameHints =
let
private
doesFieldNameExist
(
field
:
FSharpField
)
=
not
field
.
IsNameGenerated
let
private
getTupleRanges
(
symbolUse
:
FSharpSymbolUse
)
(
parseResults
:
FSharpParseFileResults
)
=
let
position
=
Position
.
mkPos
(
symbolUse
.
Range
.
End
.
Line
)
(
symbolUse
.
Range
.
End
.
Column
+
1
)
parseResults
.
FindParameterLocations
position
|>
Option
.
map
(
fun
locations
->
locations
.
ArgumentLocations
)
|>
Option
.
map
(
Seq
.
map
(
fun
location
->
location
.
ArgumentRange
))
|>
Option
.
defaultValue
[]
|>
Seq
.
toList
let
private
getCurryRanges
(
symbolUse
:
FSharpSymbolUse
)
(
parseResults
:
FSharpParseFileResults
)
=
parseResults
.
GetAllArgumentsForFunctionApplicationAtPosition
symbolUse
.
Range
.
Start
|>
Option
.
defaultValue
[]
let
isMemberOrFunctionOrValueValidForHint
(
symbol
:
FSharpMemberOrFunctionOrValue
)
(
symbolUse
:
FSharpSymbolUse
)
=
if
symbolUse
.
IsFromUse
then
let
isNotBuiltInOperator
=
...
...
@@ -52,18 +73,16 @@ module InlineParameterNameHints =
(
symbolUse
:
FSharpSymbolUse
)
=
let
parameters
=
symbol
.
CurriedParameterGroups
|>
Seq
.
concat
let
ranges
=
parseResults
.
GetAllArgumentsForFunctionApplicationAtPosition
symbolUse
.
Range
.
Start
match
ranges
with
|
Some
ranges
->
parameters
|>
Seq
.
zip
ranges
|>
Seq
.
where
(
snd
>>
doesParameterNameExist
)
|>
Seq
.
map
getParameterHint
|>
Seq
.
toList
// this is the case at least for custom operators
|
None
->
[]
let
tupleRanges
=
parseResults
|>
getTupleRanges
symbolUse
let
curryRanges
=
parseResults
|>
getCurryRanges
symbolUse
let
ranges
=
if
tupleRanges
|>
(
not
<<
Seq
.
isEmpty
)
then
tupleRanges
else
curryRanges
parameters
|>
Seq
.
zip
ranges
// Seq.zip is important as List.zip requires equal lengths
|>
Seq
.
where
(
snd
>>
doesParameterNameExist
)
|>
Seq
.
map
getParameterHint
|>
Seq
.
toList
let
getHintsForUnionCase
(
parseResults
:
FSharpParseFileResults
)
...
...
vsintegration/tests/FSharp.Editor.Tests/Hints/HintTestFramework.fs
浏览文件 @
ddc4a7d7
...
...
@@ -32,7 +32,9 @@ module HintTestFramework =
let
getFsDocument
code
=
use
project
=
SingleFileProject
code
let
fileName
=
fst
project
.
Files
.
Head
let
document
,
_
=
RoslynTestHelpers
.
CreateSingleDocumentSolution
(
fileName
,
code
)
// I don't know, without this lib some symbols are just not loaded
let
options
=
{
project
.
Options
with
OtherOptions
=
[|
"--targetprofile:netcore"
|]
}
let
document
,
_
=
RoslynTestHelpers
.
CreateSingleDocumentSolution
(
fileName
,
code
,
options
)
document
let
getFsiAndFsDocuments
(
fsiCode
:
string
)
(
fsCode
:
string
)
=
...
...
vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs
浏览文件 @
ddc4a7d7
...
...
@@ -381,3 +381,28 @@ type X =
let
actual
=
getParameterNameHints
document
Assert
.
IsEmpty
(
actual
)
[<
Test
>]
let
``Hints are not shown in front of indexes``
()
=
let
code
=
"""
let x = "
test
".Split("").[0].Split("");
"""
let
document
=
getFsDocument
code
let
expected
=
[
{
Content
=
"separator = "
Location
=
(
1
,
22
)
}
{
Content
=
"separator = "
Location
=
(
1
,
36
)
}
]
let
actual
=
getParameterNameHints
document
Assert
.
AreEqual
(
expected
,
actual
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录