Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
30b3a8fa
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,发现更多精彩内容 >>
未验证
提交
30b3a8fa
编写于
10月 04, 2022
作者:
P
Petr
提交者:
GitHub
10月 04, 2022
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
First steps towards reviving CodeLens
上级
a312dc6b
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
41 addition
and
42 deletion
+41
-42
vsintegration/src/FSharp.Editor/CodeLens/CodeLensProvider.fs
vsintegration/src/FSharp.Editor/CodeLens/CodeLensProvider.fs
+39
-40
vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs
...ation/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs
+2
-2
未找到文件。
vsintegration/src/FSharp.Editor/CodeLens/CodeLensProvider.fs
浏览文件 @
30b3a8fa
...
...
@@ -28,51 +28,43 @@ type internal CodeLensProvider
settings
:
EditorOptions
)
=
let
lineLensProvider
=
ResizeArray
()
let
tryGetTextDocument
(
buffer
:
ITextBuffer
)
(
factory
:
ITextDocumentFactoryService
)
=
match
factory
.
TryGetTextDocument
buffer
with
|
true
,
document
->
Some
document
|
_
->
None
let
taggers
=
ResizeArray
()
let
lineLensProviders
=
ResizeArray
()
let
componentModel
=
Package
.
GetGlobalService
(
typeof
<
ComponentModelHost
.
SComponentModel
>)
:?>
ComponentModelHost
.
IComponentModel
let
workspace
=
componentModel
.
GetService
<
VisualStudioWorkspace
>()
/// Returns an provider for the textView if already one has been created. Else create one.
let
addCodeLensProviderOnce
wpfView
buffer
=
let
res
=
taggers
|>
Seq
.
tryFind
(
fun
(
view
,
_)
->
view
=
wpfView
)
match
res
with
|
Some
(_,
(
tagger
,
_))
->
tagger
|
None
->
let
documentId
=
lazy
(
match
textDocumentFactory
.
TryGetTextDocument
(
buffer
)
with
|
true
,
textDocument
->
Seq
.
tryHead
(
workspace
.
CurrentSolution
.
GetDocumentIdsWithFilePath
(
textDocument
.
FilePath
))
|
_
->
None
|>
Option
.
get
)
let
tryGetCodeLensTagger
wpfView
buffer
=
taggers
|>
Seq
.
tryFind
(
fun
(
view
,
_)
->
view
=
wpfView
)
|>
Option
.
map
(
fun
(_,
(
tagger
,
_))
->
tagger
)
|>
Option
.
orElse
(
textDocumentFactory
|>
tryGetTextDocument
buffer
|>
Option
.
map
(
fun
document
->
workspace
.
CurrentSolution
.
GetDocumentIdsWithFilePath
document
.
FilePath
)
|>
Option
.
bind
Seq
.
tryHead
|>
Option
.
map
(
fun
documentId
->
let
tagger
=
CodeLensGeneralTagger
(
wpfView
,
buffer
)
let
service
=
FSharpCodeLensService
(
serviceProvider
,
workspace
,
documentId
,
buffer
,
metadataAsSource
,
componentModel
.
GetService
()
,
typeMap
,
tagger
,
settings
)
let
provider
=
(
wpfView
,
(
tagger
,
service
))
wpfView
.
Closed
.
Add
(
fun
_
->
taggers
.
Remove
provider
|>
ignore
)
taggers
.
Add
((
wpfView
,
(
tagger
,
service
)))
tagger
taggers
.
Add
provider
tagger
))
/// Returns an provider for the textView if already one has been created. Else create one.
let
addLineLensProviderOnce
wpfView
buffer
=
let
res
=
lineLensProvider
|>
Seq
.
tryFind
(
fun
(
view
,
_)
->
view
=
wpfView
)
match
res
with
|
None
->
let
documentId
=
lazy
(
match
textDocumentFactory
.
TryGetTextDocument
(
buffer
)
with
|
true
,
textDocument
->
Seq
.
tryHead
(
workspace
.
CurrentSolution
.
GetDocumentIdsWithFilePath
(
textDocument
.
FilePath
))
|
_
->
None
|>
Option
.
get
)
let
addLineLensProvider
wpfView
buffer
=
textDocumentFactory
|>
tryGetTextDocument
buffer
|>
Option
.
map
(
fun
document
->
workspace
.
CurrentSolution
.
GetDocumentIdsWithFilePath
(
document
.
FilePath
))
|>
Option
.
bind
Seq
.
tryHead
|>
Option
.
map
(
fun
documentId
->
let
service
=
FSharpCodeLensService
(
serviceProvider
,
workspace
,
documentId
,
buffer
,
metadataAsSource
,
componentModel
.
GetService
()
,
typeMap
,
LineLensDisplayService
(
wpfView
,
buffer
),
settings
)
let
provider
=
(
wpfView
,
service
)
wpfView
.
Closed
.
Add
(
fun
_
->
lineLensProvider
.
Remove
provider
|>
ignore
)
lineLensProvider
.
Add
(
provider
)
|
_
->
()
wpfView
.
Closed
.
Add
(
fun
_
->
lineLensProviders
.
Remove
provider
|>
ignore
)
lineLensProviders
.
Add
(
provider
))
[<
Export
(
typeof
<
AdornmentLayerDefinition
>);
Name
(
"CodeLens"
);
Order
(
Before
=
PredefinedAdornmentLayers
.
Text
);
...
...
@@ -92,11 +84,18 @@ type internal CodeLensProvider
|
:?
IWpfTextView
as
view
->
view
|
_
->
failwith
"error"
box
(
addCodeLensProviderOnce
wpfView
buffer
)
:?>
_
match
tryGetCodeLensTagger
wpfView
buffer
with
|
Some
tagger
->
box
tagger
:?>
_
|
None
->
null
else
null
interface
IWpfTextViewCreationListener
with
override
_.
TextViewCreated
view
=
if
settings
.
CodeLens
.
Enabled
&&
settings
.
CodeLens
.
ReplaceWithLineLens
then
addLineLensProviderOnce
view
(
view
.
TextBuffer
)
|>
ignore
\ No newline at end of file
let
provider
=
lineLensProviders
|>
Seq
.
tryFind
(
fun
(
v
,
_)
->
v
=
view
)
if
provider
.
IsNone
then
addLineLensProvider
view
(
view
.
TextBuffer
)
|>
ignore
\ No newline at end of file
vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs
浏览文件 @
30b3a8fa
...
...
@@ -42,7 +42,7 @@ type internal FSharpCodeLensService
(
serviceProvider
:
IServiceProvider
,
workspace
:
Workspace
,
documentId
:
Lazy
<
DocumentId
>
,
documentId
:
DocumentId
,
buffer
:
ITextBuffer
,
metadataAsSource
:
FSharpMetadataAsSourceService
,
classificationFormatMapService
:
IClassificationFormatMapService
,
...
...
@@ -153,7 +153,7 @@ type internal FSharpCodeLensService
#
if
DEBUG
logInfof
"Rechecking code due to buffer edit!"
#
endif
let
!
document
=
workspace
.
CurrentSolution
.
GetDocument
(
documentId
.
Value
)
|>
Option
.
ofObj
let
!
document
=
workspace
.
CurrentSolution
.
GetDocument
documentId
|>
Option
.
ofObj
let
!
parseFileResults
,
checkFileResults
=
document
.
GetFSharpParseAndCheckResultsAsync
(
nameof
(
FSharpUseMutationWhenValueIsMutableFixProvider
))
|>
liftAsync
let
parsedInput
=
parseFileResults
.
ParseTree
#
if
DEBUG
...
...
麦壳饼
@mysticboy
mentioned in commit
b2d14fc2
·
11月 01, 2022
mentioned in commit
b2d14fc2
mentioned in commit b2d14fc27cda7aa1de5c199a440ca1cacf7fab45
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录