Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
54062229
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,发现更多精彩内容 >>
未验证
提交
54062229
编写于
11月 22, 2019
作者:
B
Brett V. Forsgren
提交者:
GitHub
11月 22, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change the type of completion item returned for scripts (#7899)
上级
2063694b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
25 deletion
+24
-25
src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs
src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs
+6
-7
tests/FSharp.Compiler.Private.Scripting.UnitTests/CompletionTests.fs
...p.Compiler.Private.Scripting.UnitTests/CompletionTests.fs
+18
-18
未找到文件。
src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs
浏览文件 @
54062229
...
...
@@ -44,6 +44,8 @@ type FSharpScript(?captureInput: bool, ?captureOutput: bool, ?additionalArgs: st
member
__.
ErrorProduced
=
errorProduced
.
Publish
member
__.
Fsi
=
fsi
member
__.
Eval
(
code
:
string
,
?
cancellationToken
:
CancellationToken
)
=
let
cancellationToken
=
defaultArg
cancellationToken
CancellationToken
.
None
let
ch
,
errors
=
fsi
.
EvalInteractionNonThrowing
(
code
,
cancellationToken
)
...
...
@@ -51,21 +53,18 @@ type FSharpScript(?captureInput: bool, ?captureOutput: bool, ?additionalArgs: st
|
Choice1Of2
v
->
Ok
(
v
),
errors
|
Choice2Of2
ex
->
Error
(
ex
),
errors
/// Get the available completion
symbol
s from the code at the specified location.
/// Get the available completion
item
s from the code at the specified location.
///
/// <param name="text">The input text on which completions will be calculated</param>
/// <param name="line">The 1-based line index</param>
/// <param name="column">The 0-based column index</param>
member
__.
GetCompletion
Symbol
s
(
text
:
string
,
line
:
int
,
column
:
int
)
=
member
__.
GetCompletion
Item
s
(
text
:
string
,
line
:
int
,
column
:
int
)
=
async
{
let
!
parseResults
,
checkResults
,
_
projectResults
=
fsi
.
ParseAndCheckInteraction
(
text
)
let
lineText
=
text
.
Split
(
'\n'
).[
line
-
1
]
let
partialName
=
QuickParse
.
GetPartialLongNameEx
(
lineText
,
column
-
1
)
let
!
symbolUses
=
checkResults
.
GetDeclarationListSymbols
(
Some
parseResults
,
line
,
lineText
,
partialName
)
let
symbols
=
symbolUses
|>
List
.
concat
|>
List
.
map
(
fun
s
->
s
.
Symbol
)
return
symbols
let
!
declarationListInfos
=
checkResults
.
GetDeclarationListInfo
(
Some
parseResults
,
line
,
lineText
,
partialName
)
return
declarationListInfos
.
Items
}
interface
IDisposable
with
...
...
tests/FSharp.Compiler.Private.Scripting.UnitTests/CompletionTests.fs
浏览文件 @
54062229
...
...
@@ -16,9 +16,9 @@ type CompletionTests() =
use
script
=
new
FSharpScript
()
let
lines
=
[
"let x = 1"
"x."
]
let
!
completions
=
script
.
GetCompletion
Symbol
s
(
String
.
Join
(
"
\n
"
,
lines
),
2
,
2
)
let
matchingCompletions
=
completions
|>
List
.
filter
(
fun
s
->
s
.
Display
Name
=
"CompareTo"
)
Assert
.
AreEqual
(
1
,
List
.
length
matchingCompletions
)
let
!
completions
=
script
.
GetCompletion
Item
s
(
String
.
Join
(
"
\n
"
,
lines
),
2
,
2
)
let
matchingCompletions
=
completions
|>
Array
.
filter
(
fun
d
->
d
.
Name
=
"CompareTo"
)
Assert
.
AreEqual
(
1
,
matchingCompletions
.
Length
)
}
|>
Async
.
StartAsTask
:>
Task
[<
Test
>]
...
...
@@ -26,36 +26,36 @@ type CompletionTests() =
async
{
use
script
=
new
FSharpScript
()
script
.
Eval
(
"let x = 1"
)
|>
ignoreValue
let
!
completions
=
script
.
GetCompletion
Symbol
s
(
"x."
,
1
,
2
)
let
matchingCompletions
=
completions
|>
List
.
filter
(
fun
s
->
s
.
Display
Name
=
"CompareTo"
)
Assert
.
AreEqual
(
1
,
List
.
length
matchingCompletions
)
let
!
completions
=
script
.
GetCompletion
Item
s
(
"x."
,
1
,
2
)
let
matchingCompletions
=
completions
|>
Array
.
filter
(
fun
d
->
d
.
Name
=
"CompareTo"
)
Assert
.
AreEqual
(
1
,
matchingCompletions
.
Length
)
}
|>
Async
.
StartAsTask
:>
Task
[<
Test
>]
member
_.
``Static member completions``
()
=
async
{
use
script
=
new
FSharpScript
()
let
!
completions
=
script
.
GetCompletion
Symbol
s
(
"System.String."
,
1
,
14
)
let
matchingCompletions
=
completions
|>
List
.
filter
(
fun
s
->
s
.
Display
Name
=
"Join"
)
Assert
.
GreaterOrEqual
(
List
.
length
matchingCompletions
,
1
)
let
!
completions
=
script
.
GetCompletion
Item
s
(
"System.String."
,
1
,
14
)
let
matchingCompletions
=
completions
|>
Array
.
filter
(
fun
d
->
d
.
Name
=
"Join"
)
Assert
.
GreaterOrEqual
(
matchingCompletions
.
Length
,
1
)
}
|>
Async
.
StartAsTask
:>
Task
[<
Test
>]
member
_.
``Type completions from namespace``
()
=
async
{
use
script
=
new
FSharpScript
()
let
!
completions
=
script
.
GetCompletion
Symbol
s
(
"System."
,
1
,
7
)
let
matchingCompletions
=
completions
|>
List
.
filter
(
fun
s
->
s
.
Display
Name
=
"String"
)
Assert
.
GreaterOrEqual
(
List
.
length
matchingCompletions
,
1
)
let
!
completions
=
script
.
GetCompletion
Item
s
(
"System."
,
1
,
7
)
let
matchingCompletions
=
completions
|>
Array
.
filter
(
fun
d
->
d
.
Name
=
"String"
)
Assert
.
GreaterOrEqual
(
matchingCompletions
.
Length
,
1
)
}
|>
Async
.
StartAsTask
:>
Task
[<
Test
>]
member
_.
``Namespace completions``
()
=
async
{
use
script
=
new
FSharpScript
()
let
!
completions
=
script
.
GetCompletion
Symbol
s
(
"System."
,
1
,
7
)
let
matchingCompletions
=
completions
|>
List
.
filter
(
fun
s
->
s
.
Display
Name
=
"Collections"
)
Assert
.
AreEqual
(
1
,
List
.
length
matchingCompletions
)
let
!
completions
=
script
.
GetCompletion
Item
s
(
"System."
,
1
,
7
)
let
matchingCompletions
=
completions
|>
Array
.
filter
(
fun
d
->
d
.
Name
=
"Collections"
)
Assert
.
AreEqual
(
1
,
matchingCompletions
.
Length
)
}
|>
Async
.
StartAsTask
:>
Task
[<
Test
>]
...
...
@@ -65,7 +65,7 @@ type CompletionTests() =
let
lines
=
[
"open System.Linq"
"let list = new System.Collections.Generic.List<int>()"
"list."
]
let
!
completions
=
script
.
GetCompletion
Symbol
s
(
String
.
Join
(
"
\n
"
,
lines
),
3
,
5
)
let
matchingCompletions
=
completions
|>
List
.
filter
(
fun
s
->
s
.
Display
Name
=
"Select"
)
Assert
.
AreEqual
(
1
,
List
.
length
matchingCompletions
)
let
!
completions
=
script
.
GetCompletion
Item
s
(
String
.
Join
(
"
\n
"
,
lines
),
3
,
5
)
let
matchingCompletions
=
completions
|>
Array
.
filter
(
fun
d
->
d
.
Name
=
"Select"
)
Assert
.
AreEqual
(
1
,
matchingCompletions
.
Length
)
}
|>
Async
.
StartAsTask
:>
Task
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录