Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
7e4b03f1
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,发现更多精彩内容 >>
未验证
提交
7e4b03f1
编写于
9月 19, 2020
作者:
D
Don Syme
提交者:
GitHub
9月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix script editing perf (#10159)
Co-authored-by:
N
Don Syme
<
donsyme@fastmail.com
>
上级
eb5cf1a6
变更
32
隐藏空白更改
内联
并排
Showing
32 changed file
with
94 addition
and
85 deletion
+94
-85
src/fsharp/Microsoft.DotNet.DependencyManager/DependencyProvider.fs
.../Microsoft.DotNet.DependencyManager/DependencyProvider.fs
+25
-18
vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs
...src/FSharp.Editor/Classification/ClassificationService.fs
+1
-1
vsintegration/src/FSharp.Editor/CodeFix/AddOpenCodeFixProvider.fs
...ation/src/FSharp.Editor/CodeFix/AddOpenCodeFixProvider.fs
+1
-1
vsintegration/src/FSharp.Editor/CodeFix/ImplementInterfaceCodeFixProvider.fs
...Sharp.Editor/CodeFix/ImplementInterfaceCodeFixProvider.fs
+1
-1
vsintegration/src/FSharp.Editor/CodeFix/RemoveUnusedOpens.fs
vsintegration/src/FSharp.Editor/CodeFix/RemoveUnusedOpens.fs
+2
-1
vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs
vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs
+1
-1
vsintegration/src/FSharp.Editor/CodeFix/ReplaceWithSuggestion.fs
...ration/src/FSharp.Editor/CodeFix/ReplaceWithSuggestion.fs
+1
-1
vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs
...ation/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs
+2
-1
vsintegration/src/FSharp.Editor/Commands/HelpContextService.fs
...egration/src/FSharp.Editor/Commands/HelpContextService.fs
+1
-1
vsintegration/src/FSharp.Editor/Commands/XmlDocCommandService.fs
...ration/src/FSharp.Editor/Commands/XmlDocCommandService.fs
+1
-1
vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs
...ration/src/FSharp.Editor/Completion/CompletionProvider.fs
+2
-2
vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs
vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs
+1
-1
vsintegration/src/FSharp.Editor/Debugging/BreakpointResolutionService.fs
...rc/FSharp.Editor/Debugging/BreakpointResolutionService.fs
+1
-1
vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs
...c/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs
+2
-2
vsintegration/src/FSharp.Editor/Diagnostics/SimplifyNameDiagnosticAnalyzer.fs
...harp.Editor/Diagnostics/SimplifyNameDiagnosticAnalyzer.fs
+1
-1
vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs
...c/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs
+1
-1
vsintegration/src/FSharp.Editor/Diagnostics/UnusedOpensDiagnosticAnalyzer.fs
...Sharp.Editor/Diagnostics/UnusedOpensDiagnosticAnalyzer.fs
+1
-1
vsintegration/src/FSharp.Editor/DocumentHighlights/DocumentHighlightsService.fs
...rp.Editor/DocumentHighlights/DocumentHighlightsService.fs
+1
-1
vsintegration/src/FSharp.Editor/Formatting/BraceMatchingService.fs
...tion/src/FSharp.Editor/Formatting/BraceMatchingService.fs
+3
-3
vsintegration/src/FSharp.Editor/Formatting/EditorFormattingService.fs
...n/src/FSharp.Editor/Formatting/EditorFormattingService.fs
+6
-11
vsintegration/src/FSharp.Editor/Formatting/IndentationService.fs
...ration/src/FSharp.Editor/Formatting/IndentationService.fs
+3
-5
vsintegration/src/FSharp.Editor/InlineRename/InlineRenameService.fs
...ion/src/FSharp.Editor/InlineRename/InlineRenameService.fs
+1
-1
vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs
...arp.Editor/LanguageService/FSharpProjectOptionsManager.fs
+20
-14
vsintegration/src/FSharp.Editor/LanguageService/SymbolHelpers.fs
...ration/src/FSharp.Editor/LanguageService/SymbolHelpers.fs
+2
-2
vsintegration/src/FSharp.Editor/Navigation/FindUsagesService.fs
...gration/src/FSharp.Editor/Navigation/FindUsagesService.fs
+1
-1
vsintegration/src/FSharp.Editor/Navigation/GoToDefinition.fs
vsintegration/src/FSharp.Editor/Navigation/GoToDefinition.fs
+4
-4
vsintegration/src/FSharp.Editor/Navigation/NavigateToSearchService.fs
...n/src/FSharp.Editor/Navigation/NavigateToSearchService.fs
+2
-1
vsintegration/src/FSharp.Editor/Navigation/NavigationBarItemService.fs
.../src/FSharp.Editor/Navigation/NavigationBarItemService.fs
+1
-1
vsintegration/src/FSharp.Editor/QuickInfo/QuickInfoProvider.fs
...egration/src/FSharp.Editor/QuickInfo/QuickInfoProvider.fs
+1
-1
vsintegration/src/FSharp.Editor/Structure/BlockStructureService.fs
...tion/src/FSharp.Editor/Structure/BlockStructureService.fs
+1
-1
vsintegration/tests/UnitTests/EditorFormattingServiceTests.fs
...tegration/tests/UnitTests/EditorFormattingServiceTests.fs
+1
-1
vsintegration/tests/UnitTests/IndentationServiceTests.fs
vsintegration/tests/UnitTests/IndentationServiceTests.fs
+2
-2
未找到文件。
src/fsharp/Microsoft.DotNet.DependencyManager/DependencyProvider.fs
浏览文件 @
7e4b03f1
...
...
@@ -8,6 +8,7 @@ open System.Reflection
open
System
.
Runtime
.
InteropServices
open
Internal
.
Utilities
.
FSharpEnvironment
open
Microsoft
.
FSharp
.
Reflection
open
System
.
Collections
.
Concurrent
[<
AutoOpen
>]
module
ReflectionHelper
=
...
...
@@ -88,19 +89,19 @@ type IResolveDependenciesResult =
abstract
Success
:
bool
/// The resolution output log
abstract
StdOut
:
string
array
abstract
StdOut
:
string
[]
/// The resolution error log (* process stderror *)
abstract
StdError
:
string
array
abstract
StdError
:
string
[]
/// The resolution paths
abstract
Resolutions
:
s
tring
seq
abstract
Resolutions
:
s
eq
<
string
>
/// The source code file paths
abstract
SourceFiles
:
s
tring
seq
abstract
SourceFiles
:
s
eq
<
string
>
/// The roots to package directories
abstract
Roots
:
s
tring
seq
abstract
Roots
:
s
eq
<
string
>
[<
AllowNullLiteralAttribute
>]
...
...
@@ -326,6 +327,8 @@ type DependencyProvider (assemblyProbingPaths: AssemblyResolutionProbe, nativePr
None
managers
let
cache
=
ConcurrentDictionary
<_,
IResolveDependenciesResult
>(
HashIdentity
.
Structural
)
/// Returns a formatted error message for the host to presentconstruct with just nativeProbing handler
new
(
nativeProbingRoots
:
NativeResolutionProbe
)
=
new
DependencyProvider
(
Unchecked
.
defaultof
<
AssemblyResolutionProbe
>,
nativeProbingRoots
)
...
...
@@ -390,20 +393,24 @@ type DependencyProvider (assemblyProbingPaths: AssemblyResolutionProbe, nativePr
[<
Optional
;
DefaultParameterValue
(
""
)>]
implicitIncludeDir
:
string
,
[<
Optional
;
DefaultParameterValue
(
""
)>]
mainScriptName
:
string
,
[<
Optional
;
DefaultParameterValue
(
""
)>]
fileName
:
string
):
IResolveDependenciesResult
=
let
key
=
(
packageManager
.
Key
,
scriptExt
,
Seq
.
toArray
packageManagerTextLines
,
executionTfm
,
executionRid
,
implicitIncludeDir
,
mainScriptName
,
fileName
)
try
let
executionRid
=
if
isNull
executionRid
then
RidHelpers
.
platformRid
else
executionRid
packageManager
.
ResolveDependencies
(
implicitIncludeDir
,
mainScriptName
,
fileName
,
scriptExt
,
packageManagerTextLines
,
executionTfm
,
executionRid
)
with
e
->
let
e
=
stripTieWrapper
e
let
err
,
msg
=
(
DependencyManager
.
SR
.
packageManagerError
(
e
.
Message
))
reportError
.
Invoke
(
ErrorReportType
.
Error
,
err
,
msg
)
ReflectionDependencyManagerProvider
.
MakeResultFromFields
(
false
,
arrEmpty
,
arrEmpty
,
seqEmpty
,
seqEmpty
,
seqEmpty
)
cache
.
GetOrAdd
(
key
,
System
.
Func
<_,_>(
fun
_
->
try
let
executionRid
=
if
isNull
executionRid
then
RidHelpers
.
platformRid
else
executionRid
packageManager
.
ResolveDependencies
(
implicitIncludeDir
,
mainScriptName
,
fileName
,
scriptExt
,
packageManagerTextLines
,
executionTfm
,
executionRid
)
with
e
->
let
e
=
stripTieWrapper
e
let
err
,
msg
=
(
DependencyManager
.
SR
.
packageManagerError
(
e
.
Message
))
reportError
.
Invoke
(
ErrorReportType
.
Error
,
err
,
msg
)
ReflectionDependencyManagerProvider
.
MakeResultFromFields
(
false
,
arrEmpty
,
arrEmpty
,
seqEmpty
,
seqEmpty
,
seqEmpty
)
))
interface
IDisposable
with
...
...
vsintegration/src/FSharp.Editor/Classification/ClassificationService.fs
浏览文件 @
7e4b03f1
...
...
@@ -158,7 +158,7 @@ type internal FSharpClassificationService
asyncMaybe
{
use
_
logBlock
=
Logger
.
LogBlock
(
LogEditorFunctionId
.
Classification_Semantic
)
let
!
_,
_,
projectOptions
=
projectInfoManager
.
TryGetOptionsForDocumentOrProject
(
document
,
cancellationToken
)
let
!
_,
_,
projectOptions
=
projectInfoManager
.
TryGetOptionsForDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
// If we are trying to get semantic classification for a document that is not open, get the results from the background and cache it.
...
...
vsintegration/src/FSharp.Editor/CodeFix/AddOpenCodeFixProvider.fs
浏览文件 @
7e4b03f1
...
...
@@ -96,7 +96,7 @@ type internal FSharpAddOpenCodeFixProvider
override
__.
RegisterCodeFixesAsync
context
:
Task
=
asyncMaybe
{
let
document
=
context
.
Document
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
context
.
CancellationToken
)
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
context
.
CancellationToken
,
userOpName
)
let
!
sourceText
=
context
.
Document
.
GetTextAsync
(
context
.
CancellationToken
)
let
!
_,
parsedInput
,
checkResults
=
checker
.
ParseAndCheckDocument
(
document
,
projectOptions
,
sourceText
=
sourceText
,
userOpName
=
userOpName
)
let
line
=
sourceText
.
Lines
.
GetLineFromPosition
(
context
.
Span
.
End
)
...
...
vsintegration/src/FSharp.Editor/CodeFix/ImplementInterfaceCodeFixProvider.fs
浏览文件 @
7e4b03f1
...
...
@@ -138,7 +138,7 @@ type internal FSharpImplementInterfaceCodeFixProvider
override
__.
RegisterCodeFixesAsync
context
:
Task
=
asyncMaybe
{
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
context
.
Document
,
context
.
CancellationToken
)
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
context
.
Document
,
context
.
CancellationToken
,
userOpName
)
let
cancellationToken
=
context
.
CancellationToken
let
!
sourceText
=
context
.
Document
.
GetTextAsync
(
cancellationToken
)
let
!
_,
parsedInput
,
checkFileResults
=
checker
.
ParseAndCheckDocument
(
context
.
Document
,
projectOptions
,
sourceText
=
sourceText
,
userOpName
=
userOpName
)
...
...
vsintegration/src/FSharp.Editor/CodeFix/RemoveUnusedOpens.fs
浏览文件 @
7e4b03f1
...
...
@@ -22,6 +22,7 @@ type internal FSharpRemoveUnusedOpensCodeFixProvider
projectInfoManager
:
FSharpProjectOptionsManager
)
=
inherit
CodeFixProvider
()
let
userOpName
=
"FSharpRemoveUnusedOpensCodeFixProvider"
let
fixableDiagnosticIds
=
[
FSharpIDEDiagnosticIds
.
RemoveUnnecessaryImportsDiagnosticId
]
let
createCodeFix
(
title
:
string
,
context
:
CodeFixContext
)
=
...
...
@@ -32,7 +33,7 @@ type internal FSharpRemoveUnusedOpensCodeFixProvider
let
document
=
context
.
Document
let
!
sourceText
=
document
.
GetTextAsync
()
let
checker
=
checkerProvider
.
Checker
let
!
_
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
context
.
CancellationToken
)
let
!
_
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
context
.
CancellationToken
,
userOpName
)
let
!
unusedOpens
=
UnusedOpensDiagnosticAnalyzer
.
GetUnusedOpenRanges
(
document
,
projectOptions
,
checker
)
let
changes
=
unusedOpens
...
...
vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs
浏览文件 @
7e4b03f1
...
...
@@ -57,7 +57,7 @@ type internal FSharpRenameUnusedValueCodeFixProvider
// We have to use the additional check for backtickes because `IsOperatorOrBacktickedName` operates on display names
// where backtickes are replaced with parens.
if
not
(
PrettyNaming
.
IsOperatorOrBacktickedName
ident
)
&&
not
(
ident
.
StartsWith
"``"
)
then
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
context
.
CancellationToken
)
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
context
.
CancellationToken
,
userOpName
)
let
!
_,
_,
checkResults
=
checker
.
ParseAndCheckDocument
(
document
,
projectOptions
,
sourceText
=
sourceText
,
userOpName
=
userOpName
)
let
m
=
RoslynHelpers
.
TextSpanToFSharpRange
(
document
.
FilePath
,
context
.
Span
,
sourceText
)
let
defines
=
CompilerEnvironment
.
GetCompilationDefinesForEditing
parsingOptions
...
...
vsintegration/src/FSharp.Editor/CodeFix/ReplaceWithSuggestion.fs
浏览文件 @
7e4b03f1
...
...
@@ -33,7 +33,7 @@ type internal FSharpReplaceWithSuggestionCodeFixProvider
do
!
Option
.
guard
settings
.
CodeFixes
.
SuggestNamesForErrors
let
document
=
context
.
Document
let
!
_,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
context
.
CancellationToken
)
let
!
_,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
context
.
CancellationToken
,
userOpName
)
let
!
parseFileResults
,
_,
checkFileResults
=
checker
.
ParseAndCheckDocument
(
document
,
projectOptions
,
userOpName
=
userOpName
)
// This is all needed to get a declaration list
...
...
vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs
浏览文件 @
7e4b03f1
...
...
@@ -52,6 +52,7 @@ type internal FSharpCodeLensService
)
as
self
=
let
lineLens
=
codeLens
let
userOpName
=
"FSharpCodeLensService"
let
visit
pos
parseTree
=
AstTraversal
.
Traverse
(
pos
,
parseTree
,
{
new
AstTraversal
.
AstVisitorBase
<_>()
with
...
...
@@ -154,7 +155,7 @@ type internal FSharpCodeLensService
logInfof
"Rechecking code due to buffer edit!"
#
endif
let
!
document
=
workspace
.
CurrentSolution
.
GetDocument
(
documentId
.
Value
)
|>
Option
.
ofObj
let
!
_,
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
bufferChangedCts
.
Token
)
let
!
_,
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
bufferChangedCts
.
Token
,
userOpName
)
let
!
_,
parsedInput
,
checkFileResults
=
checker
.
ParseAndCheckDocument
(
document
,
options
,
"LineLens"
,
allowStaleResults
=
true
)
#
if
DEBUG
logInfof
"Getting uses of all symbols!"
...
...
vsintegration/src/FSharp.Editor/Commands/HelpContextService.fs
浏览文件 @
7e4b03f1
...
...
@@ -98,7 +98,7 @@ type internal FSharpHelpContextService
member
this
.
GetHelpTermAsync
(
document
,
textSpan
,
cancellationToken
)
=
asyncMaybe
{
let
!
_
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
_
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
let
!
textVersion
=
document
.
GetTextVersionAsync
(
cancellationToken
)
let
defines
=
projectInfoManager
.
GetCompilationDefinesForEditingDocument
(
document
)
...
...
vsintegration/src/FSharp.Editor/Commands/XmlDocCommandService.fs
浏览文件 @
7e4b03f1
...
...
@@ -67,7 +67,7 @@ type internal XmlDocCommandFilter
// XmlDocable line #1 are 1-based, editor is 0-based
let
curLineNum
=
wpfTextView
.
Caret
.
Position
.
BufferPosition
.
GetContainingLine
()
.
LineNumber
+
1
let
!
document
=
document
.
Value
let
!
parsingOptions
,
_
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
CancellationToken
.
None
)
let
!
parsingOptions
,
_
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
CancellationToken
.
None
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
(
CancellationToken
.
None
)
let
!
parsedInput
=
checker
.
ParseDocument
(
document
,
parsingOptions
,
sourceText
,
userOpName
)
let
xmlDocables
=
XmlDocParser
.
getXmlDocables
(
sourceText
.
ToFSharpSourceText
()
,
Some
parsedInput
)
...
...
vsintegration/src/FSharp.Editor/Completion/CompletionProvider.fs
浏览文件 @
7e4b03f1
...
...
@@ -228,7 +228,7 @@ type internal FSharpCompletionProvider
let
!
sourceText
=
context
.
Document
.
GetTextAsync
(
context
.
CancellationToken
)
let
defines
=
projectInfoManager
.
GetCompilationDefinesForEditingDocument
(
document
)
do
!
Option
.
guard
(
CompletionUtils
.
shouldProvideCompletion
(
document
.
Id
,
document
.
FilePath
,
defines
,
sourceText
,
context
.
Position
))
let
!
_
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
context
.
CancellationToken
)
let
!
_
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
context
.
CancellationToken
,
userOpName
)
let
!
textVersion
=
context
.
Document
.
GetTextVersionAsync
(
context
.
CancellationToken
)
let
getAllSymbols
(
fileCheckResults
:
FSharpCheckFileResults
)
=
if
settings
.
IntelliSense
.
IncludeSymbolsFromUnopenedNamespacesOrModules
...
...
@@ -298,7 +298,7 @@ type internal FSharpCompletionProvider
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
let
textWithItemCommitted
=
sourceText
.
WithChanges
(
TextChange
(
item
.
Span
,
nameInCode
))
let
line
=
sourceText
.
Lines
.
GetLineFromPosition
(
item
.
Span
.
Start
)
let
!
parsingOptions
,
_
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
_
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
parsedInput
=
checker
.
ParseDocument
(
document
,
parsingOptions
,
sourceText
,
userOpName
)
let
fullNameIdents
=
fullName
|>
Option
.
map
(
fun
x
->
x
.
Split
'.'
)
|>
Option
.
defaultValue
[||]
...
...
vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs
浏览文件 @
7e4b03f1
...
...
@@ -197,7 +197,7 @@ type internal FSharpSignatureHelpProvider
member
this
.
GetItemsAsync
(
document
,
position
,
triggerInfo
,
cancellationToken
)
=
asyncMaybe
{
try
let
!
_
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
_
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
let
!
textVersion
=
document
.
GetTextVersionAsync
(
cancellationToken
)
...
...
vsintegration/src/FSharp.Editor/Debugging/BreakpointResolutionService.fs
浏览文件 @
7e4b03f1
...
...
@@ -44,7 +44,7 @@ type internal FSharpBreakpointResolutionService
interface
IFSharpBreakpointResolutionService
with
member
this
.
ResolveBreakpointAsync
(
document
:
Document
,
textSpan
:
TextSpan
,
cancellationToken
:
CancellationToken
):
Task
<
FSharpBreakpointResolutionResult
>
=
asyncMaybe
{
let
!
parsingOptions
,
_
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
_
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
let
!
range
=
FSharpBreakpointResolutionService
.
GetBreakpointLocation
(
checkerProvider
.
Checker
,
sourceText
,
document
.
Name
,
textSpan
,
parsingOptions
)
let
!
span
=
RoslynHelpers
.
TryFSharpRangeToTextSpan
(
sourceText
,
range
)
...
...
vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs
浏览文件 @
7e4b03f1
...
...
@@ -112,7 +112,7 @@ type internal FSharpDocumentDiagnosticAnalyzer [<ImportingConstructor>] () =
member
this
.
AnalyzeSyntaxAsync
(
document
:
Document
,
cancellationToken
:
CancellationToken
):
Task
<
ImmutableArray
<
Diagnostic
>>
=
let
projectInfoManager
=
getProjectInfoManager
document
asyncMaybe
{
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
let
!
textVersion
=
document
.
GetTextVersionAsync
(
cancellationToken
)
return
!
...
...
@@ -125,7 +125,7 @@ type internal FSharpDocumentDiagnosticAnalyzer [<ImportingConstructor>] () =
member
this
.
AnalyzeSemanticsAsync
(
document
:
Document
,
cancellationToken
:
CancellationToken
):
Task
<
ImmutableArray
<
Diagnostic
>>
=
let
projectInfoManager
=
getProjectInfoManager
document
asyncMaybe
{
let
!
parsingOptions
,
_,
projectOptions
=
projectInfoManager
.
TryGetOptionsForDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
_,
projectOptions
=
projectInfoManager
.
TryGetOptionsForDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
let
!
textVersion
=
document
.
GetTextVersionAsync
(
cancellationToken
)
if
document
.
Project
.
Name
<>
FSharpConstants
.
FSharpMiscellaneousFilesName
||
isScriptFile
document
.
FilePath
then
...
...
vsintegration/src/FSharp.Editor/Diagnostics/SimplifyNameDiagnosticAnalyzer.fs
浏览文件 @
7e4b03f1
...
...
@@ -41,7 +41,7 @@ type internal SimplifyNameDiagnosticAnalyzer [<ImportingConstructor>] () =
do
!
Option
.
guard
document
.
FSharpOptions
.
CodeFixes
.
SimplifyName
do
Trace
.
TraceInformation
(
"{0:n3} (start) SimplifyName"
,
DateTime
.
Now
.
TimeOfDay
.
TotalSeconds
)
do
!
Async
.
Sleep
DefaultTuning
.
SimplifyNameInitialDelay
|>
liftAsync
let
!
_
parsingOptions
,
projectOptions
=
getProjectInfoManager
(
document
).
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
_
parsingOptions
,
projectOptions
=
getProjectInfoManager
(
document
).
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
textVersion
=
document
.
GetTextVersionAsync
(
cancellationToken
)
let
textVersionHash
=
textVersion
.
GetHashCode
()
let
!
_
=
guard
.
WaitAsync
(
cancellationToken
)
|>
Async
.
AwaitTask
|>
liftAsync
...
...
vsintegration/src/FSharp.Editor/Diagnostics/UnusedDeclarationsAnalyzer.fs
浏览文件 @
7e4b03f1
...
...
@@ -31,7 +31,7 @@ type internal UnusedDeclarationsAnalyzer [<ImportingConstructor>] () =
do
Trace
.
TraceInformation
(
"{0:n3} (start) UnusedDeclarationsAnalyzer"
,
DateTime
.
Now
.
TimeOfDay
.
TotalSeconds
)
do
!
Async
.
Sleep
DefaultTuning
.
UnusedDeclarationsAnalyzerInitialDelay
|>
liftAsync
// be less intrusive, give other work priority most of the time
match
!
getProjectInfoManager
(
document
).
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
with
match
!
getProjectInfoManager
(
document
).
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
with
|
(_
parsingOptions
,
projectOptions
)
->
let
!
sourceText
=
document
.
GetTextAsync
()
let
checker
=
getChecker
document
...
...
vsintegration/src/FSharp.Editor/Diagnostics/UnusedOpensDiagnosticAnalyzer.fs
浏览文件 @
7e4b03f1
...
...
@@ -51,7 +51,7 @@ type internal UnusedOpensDiagnosticAnalyzer [<ImportingConstructor>] () =
asyncMaybe
{
do
Trace
.
TraceInformation
(
"{0:n3} (start) UnusedOpensAnalyzer"
,
DateTime
.
Now
.
TimeOfDay
.
TotalSeconds
)
do
!
Async
.
Sleep
DefaultTuning
.
UnusedOpensAnalyzerInitialDelay
|>
liftAsync
// be less intrusive, give other work priority most of the time
let
!
_
parsingOptions
,
projectOptions
=
getProjectInfoManager
(
document
).
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
_
parsingOptions
,
projectOptions
=
getProjectInfoManager
(
document
).
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
()
let
checker
=
getChecker
document
let
!
unusedOpens
=
UnusedOpensDiagnosticAnalyzer
.
GetUnusedOpenRanges
(
document
,
projectOptions
,
checker
)
...
...
vsintegration/src/FSharp.Editor/DocumentHighlights/DocumentHighlightsService.fs
浏览文件 @
7e4b03f1
...
...
@@ -75,7 +75,7 @@ type internal FSharpDocumentHighlightsService [<ImportingConstructor>] (checkerP
interface
IFSharpDocumentHighlightsService
with
member
__.
GetDocumentHighlightsAsync
(
document
,
position
,
_
documentsToSearch
,
cancellationToken
)
:
Task
<
ImmutableArray
<
FSharpDocumentHighlights
>>
=
asyncMaybe
{
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
let
!
textVersion
=
document
.
GetTextVersionAsync
(
cancellationToken
)
let
defines
=
CompilerEnvironment
.
GetCompilationDefinesForEditing
parsingOptions
...
...
vsintegration/src/FSharp.Editor/Formatting/BraceMatchingService.fs
浏览文件 @
7e4b03f1
...
...
@@ -17,7 +17,7 @@ type internal FSharpBraceMatchingService
projectInfoManager
:
FSharpProjectOptionsManager
)
=
static
let
defaultU
serOpName
=
"BraceMatching"
static
let
u
serOpName
=
"BraceMatching"
static
member
GetBraceMatchingResult
(
checker
:
FSharpChecker
,
sourceText
:
SourceText
,
fileName
,
parsingOptions
:
FSharpParsingOptions
,
position
:
int
,
userOpName
:
string
,
[<
Optional
;
DefaultParameterValue
(
false
)>]
forFormatting
:
bool
)
=
async
{
...
...
@@ -37,9 +37,9 @@ type internal FSharpBraceMatchingService
interface
IFSharpBraceMatcher
with
member
this
.
FindBracesAsync
(
document
,
position
,
cancellationToken
)
=
asyncMaybe
{
let
!
parsingOptions
,
_
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
_
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
let
!
(
left
,
right
)
=
FSharpBraceMatchingService
.
GetBraceMatchingResult
(
checkerProvider
.
Checker
,
sourceText
,
document
.
Name
,
parsingOptions
,
position
,
defaultU
serOpName
)
let
!
(
left
,
right
)
=
FSharpBraceMatchingService
.
GetBraceMatchingResult
(
checkerProvider
.
Checker
,
sourceText
,
document
.
Name
,
parsingOptions
,
position
,
u
serOpName
)
let
!
leftSpan
=
RoslynHelpers
.
TryFSharpRangeToTextSpan
(
sourceText
,
left
)
let
!
rightSpan
=
RoslynHelpers
.
TryFSharpRangeToTextSpan
(
sourceText
,
right
)
return
FSharpBraceMatchingResult
(
leftSpan
,
rightSpan
)
...
...
vsintegration/src/FSharp.Editor/Formatting/EditorFormattingService.fs
浏览文件 @
7e4b03f1
...
...
@@ -29,7 +29,7 @@ type internal FSharpEditorFormattingService
static
let
getIndentation
(
line
:
string
)
=
line
|>
Seq
.
takeWhile
((=)
'
'
)
|>
Seq
.
length
static
member
GetFormattingChanges
(
documentId
:
DocumentId
,
sourceText
:
SourceText
,
filePath
:
string
,
checker
:
FSharpChecker
,
indentStyle
:
FormattingOptions
.
IndentStyle
,
options
:
(
FSharpParsingOptions
*
FSharpProjectOptions
)
option
,
position
:
int
)
=
static
member
GetFormattingChanges
(
documentId
:
DocumentId
,
sourceText
:
SourceText
,
filePath
:
string
,
checker
:
FSharpChecker
,
indentStyle
:
FormattingOptions
.
IndentStyle
,
parsingOptions
:
FSharpParsingOptions
,
position
:
int
)
=
// Logic for determining formatting changes:
// If first token on the current line is a closing brace,
// match the indent with the indent on the line that opened it
...
...
@@ -40,8 +40,6 @@ type internal FSharpEditorFormattingService
// (this is what C# does)
do
!
Option
.
guard
(
indentStyle
=
FormattingOptions
.
IndentStyle
.
Smart
)
let
!
parsingOptions
,
_
projectOptions
=
options
let
line
=
sourceText
.
Lines
.[
sourceText
.
Lines
.
IndexOf
position
]
let
defines
=
CompilerEnvironment
.
GetCompilationDefinesForEditing
parsingOptions
...
...
@@ -151,8 +149,8 @@ type internal FSharpEditorFormattingService
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
|>
Async
.
AwaitTask
let
!
options
=
document
.
GetOptionsAsync
(
cancellationToken
)
|>
Async
.
AwaitTask
let
indentStyle
=
options
.
GetOption
(
FormattingOptions
.
SmartIndent
,
FSharpConstants
.
FSharpLanguageName
)
let
!
projectOptionsOpt
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
textChange
=
FSharpEditorFormattingService
.
GetFormattingChanges
(
document
.
Id
,
sourceText
,
document
.
FilePath
,
checkerProvider
.
Checker
,
indentStyle
,
p
rojectOptionsOpt
,
position
)
let
parsingOptions
=
projectInfoManager
.
TryGetQuickParsingOptionsForEditingDocumentOrProject
(
document
)
let
!
textChange
=
FSharpEditorFormattingService
.
GetFormattingChanges
(
document
.
Id
,
sourceText
,
document
.
FilePath
,
checkerProvider
.
Checker
,
indentStyle
,
p
arsingOptions
,
position
)
return
textChange
|>
Option
.
toList
|>
toIList
}
...
...
@@ -162,12 +160,9 @@ type internal FSharpEditorFormattingService
let
!
options
=
document
.
GetOptionsAsync
(
cancellationToken
)
|>
Async
.
AwaitTask
let
tabSize
=
options
.
GetOption
<
int
>(
FormattingOptions
.
TabSize
,
FSharpConstants
.
FSharpLanguageName
)
match
!
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
with
|
Some
(
parsingOptions
,
_)
->
let
!
textChanges
=
FSharpEditorFormattingService
.
GetPasteChanges
(
document
.
Id
,
sourceText
,
document
.
FilePath
,
settings
.
Formatting
,
tabSize
,
parsingOptions
,
currentClipboard
,
span
)
return
textChanges
|>
Option
.
defaultValue
Seq
.
empty
|>
toIList
|
None
->
return
toIList
Seq
.
empty
let
parsingOptions
=
projectInfoManager
.
TryGetQuickParsingOptionsForEditingDocumentOrProject
(
document
)
let
!
textChanges
=
FSharpEditorFormattingService
.
GetPasteChanges
(
document
.
Id
,
sourceText
,
document
.
FilePath
,
settings
.
Formatting
,
tabSize
,
parsingOptions
,
currentClipboard
,
span
)
return
textChanges
|>
Option
.
defaultValue
Seq
.
empty
|>
toIList
}
interface
IFSharpEditorFormattingService
with
...
...
vsintegration/src/FSharp.Editor/Formatting/IndentationService.fs
浏览文件 @
7e4b03f1
...
...
@@ -61,7 +61,7 @@ type internal FSharpIndentationService
true
|
_
->
false
static
member
GetDesiredIndentation
(
documentId
:
DocumentId
,
sourceText
:
SourceText
,
filePath
:
string
,
lineNumber
:
int
,
tabSize
:
int
,
indentStyle
:
FormattingOptions
.
IndentStyle
,
options
:
(
FSharpParsingOptions
*
FSharpProjectOptions
)
option
):
Option
<
int
>
=
static
member
GetDesiredIndentation
(
documentId
:
DocumentId
,
sourceText
:
SourceText
,
filePath
:
string
,
lineNumber
:
int
,
tabSize
:
int
,
indentStyle
:
FormattingOptions
.
IndentStyle
,
parsingOptions
:
FSharpParsingOptions
):
Option
<
int
>
=
// Match indentation with previous line
let
rec
tryFindPreviousNonEmptyLine
l
=
...
...
@@ -81,8 +81,6 @@ type internal FSharpIndentationService
|>
Seq
.
takeWhile
((=)
'
'
)
|>
Seq
.
length
let
!
parsingOptions
,
_
=
options
// Only use smart indentation after tokens that need indentation
// if the option is enabled
return
...
...
@@ -100,8 +98,8 @@ type internal FSharpIndentationService
let
!
options
=
document
.
GetOptionsAsync
(
cancellationToken
)
|>
Async
.
AwaitTask
let
tabSize
=
options
.
GetOption
<
int
>(
FormattingOptions
.
TabSize
,
FSharpConstants
.
FSharpLanguageName
)
let
indentStyle
=
options
.
GetOption
(
FormattingOptions
.
SmartIndent
,
FSharpConstants
.
FSharpLanguageName
)
let
!
projectOptionsOpt
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
indent
=
FSharpIndentationService
.
GetDesiredIndentation
(
document
.
Id
,
sourceText
,
document
.
FilePath
,
lineNumber
,
tabSize
,
indentStyle
,
p
rojectOptionsOpt
)
let
parsingOptions
=
projectInfoManager
.
TryGetQuickParsingOptionsForEditingDocumentOrProject
(
document
)
let
indent
=
FSharpIndentationService
.
GetDesiredIndentation
(
document
.
Id
,
sourceText
,
document
.
FilePath
,
lineNumber
,
tabSize
,
indentStyle
,
p
arsingOptions
)
return
match
indent
with
|
None
->
Nullable
()
...
...
vsintegration/src/FSharp.Editor/InlineRename/InlineRenameService.fs
浏览文件 @
7e4b03f1
...
...
@@ -169,7 +169,7 @@ type internal InlineRenameService
interface
IFSharpEditorInlineRenameService
with
member
__.
GetRenameInfoAsync
(
document
:
Document
,
position
:
int
,
cancellationToken
:
CancellationToken
)
:
Task
<
IFSharpInlineRenameInfo
>
=
asyncMaybe
{
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
let
defines
=
CompilerEnvironment
.
GetCompilationDefinesForEditing
parsingOptions
return
!
InlineRenameService
.
GetInlineRenameInfo
(
checkerProvider
.
Checker
,
projectInfoManager
,
document
,
sourceText
,
position
,
defines
,
projectOptions
)
...
...
vsintegration/src/FSharp.Editor/LanguageService/FSharpProjectOptionsManager.fs
浏览文件 @
7e4b03f1
...
...
@@ -75,7 +75,7 @@ module private FSharpProjectOptionsHelpers =
[<
RequireQualifiedAccess
>]
type
private
FSharpProjectOptionsMessage
=
|
TryGetOptionsByDocument
of
Document
*
AsyncReplyChannel
<(
FSharpParsingOptions
*
FSharpProjectOptions
)
option
>
*
CancellationToken
|
TryGetOptionsByDocument
of
Document
*
AsyncReplyChannel
<(
FSharpParsingOptions
*
FSharpProjectOptions
)
option
>
*
CancellationToken
*
userOpName
:
string
|
TryGetOptionsByProject
of
Project
*
AsyncReplyChannel
<(
FSharpParsingOptions
*
FSharpProjectOptions
)
option
>
*
CancellationToken
|
ClearOptions
of
ProjectId
|
ClearSingleFileOptionsCache
of
DocumentId
...
...
@@ -92,13 +92,13 @@ type private FSharpProjectOptionsReactor (workspace: Workspace, settings: Editor
let
cache
=
ConcurrentDictionary
<
ProjectId
,
Project
*
FSharpParsingOptions
*
FSharpProjectOptions
>()
let
singleFileCache
=
ConcurrentDictionary
<
DocumentId
,
VersionStamp
*
FSharpParsingOptions
*
FSharpProjectOptions
>()
let
rec
tryComputeOptionsByFile
(
document
:
Document
)
(
ct
:
CancellationToken
)
=
let
rec
tryComputeOptionsByFile
(
document
:
Document
)
(
ct
:
CancellationToken
)
userOpName
=
async
{
let
!
fileStamp
=
document
.
GetTextVersionAsync
(
ct
)
|>
Async
.
AwaitTask
match
singleFileCache
.
TryGetValue
(
document
.
Id
)
with
|
false
,
_
->
let
!
sourceText
=
document
.
GetTextAsync
(
ct
)
|>
Async
.
AwaitTask
let
!
scriptProjectOptions
,
_
=
checkerProvider
.
Checker
.
GetProjectOptionsFromScript
(
document
.
FilePath
,
sourceText
.
ToFSharpSourceText
()
,
SessionsProperties
.
fsiPreview
)
let
!
scriptProjectOptions
,
_
=
checkerProvider
.
Checker
.
GetProjectOptionsFromScript
(
document
.
FilePath
,
sourceText
.
ToFSharpSourceText
()
,
SessionsProperties
.
fsiPreview
,
userOpName
=
userOpName
)
let
projectOptions
=
if
isScriptFile
document
.
FilePath
then
scriptProjectOptions
...
...
@@ -129,7 +129,7 @@ type private FSharpProjectOptionsReactor (workspace: Workspace, settings: Editor
|
true
,
(
fileStamp2
,
parsingOptions
,
projectOptions
)
->
if
fileStamp
<>
fileStamp2
then
singleFileCache
.
TryRemove
(
document
.
Id
)
|>
ignore
return
!
tryComputeOptionsByFile
document
ct
return
!
tryComputeOptionsByFile
document
ct
userOpName
else
return
Some
(
parsingOptions
,
projectOptions
)
}
...
...
@@ -244,7 +244,7 @@ type private FSharpProjectOptionsReactor (workspace: Workspace, settings: Editor
async
{
while
true
do
match
!
agent
.
Receive
()
with
|
FSharpProjectOptionsMessage
.
TryGetOptionsByDocument
(
document
,
reply
,
ct
)
->
|
FSharpProjectOptionsMessage
.
TryGetOptionsByDocument
(
document
,
reply
,
ct
,
userOpName
)
->
if
ct
.
IsCancellationRequested
then
reply
.
Reply
None
else
...
...
@@ -253,7 +253,7 @@ type private FSharpProjectOptionsReactor (workspace: Workspace, settings: Editor
if
document
.
Project
.
Solution
.
Workspace
.
Kind
=
WorkspaceKind
.
MiscellaneousFiles
then
reply
.
Reply
None
elif
document
.
Project
.
Name
=
FSharpConstants
.
FSharpMiscellaneousFilesName
then
let
!
options
=
tryComputeOptionsByFile
document
ct
let
!
options
=
tryComputeOptionsByFile
document
ct
userOpName
reply
.
Reply
options
else
// We only care about the latest project in the workspace's solution.
...
...
@@ -300,8 +300,8 @@ type private FSharpProjectOptionsReactor (workspace: Workspace, settings: Editor
member
__.
TryGetOptionsByProjectAsync
(
project
,
ct
)
=
agent
.
PostAndAsyncReply
(
fun
reply
->
FSharpProjectOptionsMessage
.
TryGetOptionsByProject
(
project
,
reply
,
ct
))
member
__.
TryGetOptionsByDocumentAsync
(
document
,
ct
)
=
agent
.
PostAndAsyncReply
(
fun
reply
->
FSharpProjectOptionsMessage
.
TryGetOptionsByDocument
(
document
,
reply
,
ct
))
member
__.
TryGetOptionsByDocumentAsync
(
document
,
ct
,
userOpName
)
=
agent
.
PostAndAsyncReply
(
fun
reply
->
FSharpProjectOptionsMessage
.
TryGetOptionsByDocument
(
document
,
reply
,
ct
,
userOpName
))
member
__.
ClearOptionsByProjectId
(
projectId
)
=
agent
.
Post
(
FSharpProjectOptionsMessage
.
ClearOptions
(
projectId
))
...
...
@@ -379,23 +379,29 @@ type internal FSharpProjectOptionsManager
reactor
.
TryGetOptionsByProjectAsync
(
project
)
/// Get the exact options for a document or project
member
this
.
TryGetOptionsForDocumentOrProject
(
document
:
Document
,
cancellationToken
)
=
member
this
.
TryGetOptionsForDocumentOrProject
(
document
:
Document
,
cancellationToken
,
userOpName
)
=
async
{
match
!
reactor
.
TryGetOptionsByDocumentAsync
(
document
,
cancellationToken
)
with
match
!
reactor
.
TryGetOptionsByDocumentAsync
(
document
,
cancellationToken
,
userOpName
)
with
|
Some
(
parsingOptions
,
projectOptions
)
->
return
Some
(
parsingOptions
,
None
,
projectOptions
)
|
_
->
return
None
}
/// Get the options for a document or project relevant for syntax processing.
/// Quicker then TryGetOptionsForDocumentOrProject as it doesn't need to recompute the exact project options for a script.
member
this
.
TryGetOptionsForEditingDocumentOrProject
(
document
:
Document
,
cancellationToken
)
=
/// Get the exact options for a document or project relevant for syntax processing.
member
this
.
TryGetOptionsForEditingDocumentOrProject
(
document
:
Document
,
cancellationToken
,
userOpName
)
=
async
{
let
!
result
=
this
.
TryGetOptionsForDocumentOrProject
(
document
,
cancellationToken
)
let
!
result
=
this
.
TryGetOptionsForDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
return
result
|>
Option
.
map
(
fun
(
parsingOptions
,
_,
projectOptions
)
->
parsingOptions
,
projectOptions
)
}
/// Get the options for a document or project relevant for syntax processing.
/// Quicker it doesn't need to recompute the exact project options for a script.
member
this
.
TryGetQuickParsingOptionsForEditingDocumentOrProject
(
document
:
Document
)
=
match
reactor
.
TryGetCachedOptionsByProjectId
(
document
.
Project
.
Id
)
with
|
Some
(_,
parsingOptions
,
_)
->
parsingOptions
|
_
->
{
FSharpParsingOptions
.
Default
with
IsInteractive
=
FSharpFileUtilities
.
isScriptFile
document
.
Name
}
[<
Export
>]
/// This handles commandline change notifications from the Dotnet Project-system
/// Prior to VS 15.7 path contained path to project file, post 15.7 contains target binpath
...
...
vsintegration/src/FSharp.Editor/LanguageService/SymbolHelpers.fs
浏览文件 @
7e4b03f1
...
...
@@ -25,7 +25,7 @@ module internal SymbolHelpers =
let
textLine
=
sourceText
.
Lines
.
GetLineFromPosition
(
position
)
let
textLinePos
=
sourceText
.
Lines
.
GetLinePosition
(
position
)
let
fcsTextLineNumber
=
Line
.
fromZ
textLinePos
.
Line
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
defines
=
CompilerEnvironment
.
GetCompilationDefinesForEditing
parsingOptions
let
!
symbol
=
Tokenizer
.
getSymbolAtPosition
(
document
.
Id
,
sourceText
,
position
,
document
.
FilePath
,
defines
,
SymbolLookupKind
.
Greedy
,
false
)
let
settings
=
document
.
FSharpOptions
...
...
@@ -118,7 +118,7 @@ module internal SymbolHelpers =
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
let
originalText
=
sourceText
.
ToString
(
symbolSpan
)
do
!
Option
.
guard
(
originalText
.
Length
>
0
)
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
defines
=
CompilerEnvironment
.
GetCompilationDefinesForEditing
parsingOptions
let
!
symbol
=
Tokenizer
.
getSymbolAtPosition
(
document
.
Id
,
sourceText
,
symbolSpan
.
Start
,
document
.
FilePath
,
defines
,
SymbolLookupKind
.
Greedy
,
false
)
let
!
_,
_,
checkFileResults
=
checker
.
ParseAndCheckDocument
(
document
,
projectOptions
,
userOpName
=
userOpName
)
...
...
vsintegration/src/FSharp.Editor/Navigation/FindUsagesService.fs
浏览文件 @
7e4b03f1
...
...
@@ -51,7 +51,7 @@ type internal FSharpFindUsagesService
asyncMaybe
{
let
!
sourceText
=
document
.
GetTextAsync
(
context
.
CancellationToken
)
|>
Async
.
AwaitTask
|>
liftAsync
let
checker
=
checkerProvider
.
Checker
let
!
parsingOptions
,
_,
projectOptions
=
projectInfoManager
.
TryGetOptionsForDocumentOrProject
(
document
,
context
.
CancellationToken
)
let
!
parsingOptions
,
_,
projectOptions
=
projectInfoManager
.
TryGetOptionsForDocumentOrProject
(
document
,
context
.
CancellationToken
,
userOpName
)
let
!
_,
_,
checkFileResults
=
checker
.
ParseAndCheckDocument
(
document
,
projectOptions
,
sourceText
=
sourceText
,
userOpName
=
userOpName
)
let
textLine
=
sourceText
.
Lines
.
GetLineFromPosition
(
position
).
ToString
()
let
lineNumber
=
sourceText
.
Lines
.
GetLinePosition
(
position
).
Line
+
1
...
...
vsintegration/src/FSharp.Editor/Navigation/GoToDefinition.fs
浏览文件 @
7e4b03f1
...
...
@@ -168,7 +168,7 @@ type internal GoToDefinition(checker: FSharpChecker, projectInfoManager: FSharpP
/// Helper function that is used to determine the navigation strategy to apply, can be tuned towards signatures or implementation files.
member
private
__.
FindSymbolHelper
(
originDocument
:
Document
,
originRange
:
range
,
sourceText
:
SourceText
,
preferSignature
:
bool
)
=
asyncMaybe
{
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
originDocument
,
CancellationToken
.
None
)
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
originDocument
,
CancellationToken
.
None
,
userOpName
)
let
defines
=
CompilerEnvironment
.
GetCompilationDefinesForEditing
parsingOptions
let
!
originTextSpan
=
RoslynHelpers
.
TryFSharpRangeToTextSpan
(
sourceText
,
originRange
)
let
position
=
originTextSpan
.
Start
...
...
@@ -190,7 +190,7 @@ type internal GoToDefinition(checker: FSharpChecker, projectInfoManager: FSharpP
if
not
(
File
.
Exists
fsfilePath
)
then
return
!
None
else
let
!
implDoc
=
originDocument
.
Project
.
Solution
.
TryGetDocumentFromPath
fsfilePath
let
!
implSourceText
=
implDoc
.
GetTextAsync
()
let
!
_
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
implDoc
,
CancellationToken
.
None
)
let
!
_
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
implDoc
,
CancellationToken
.
None
,
userOpName
)
let
!
_,
_,
checkFileResults
=
checker
.
ParseAndCheckDocument
(
implDoc
,
projectOptions
,
sourceText
=
implSourceText
,
userOpName
=
userOpName
)
let
!
symbolUses
=
checkFileResults
.
GetUsesOfSymbolInFile
symbol
|>
liftAsync
let
!
implSymbol
=
symbolUses
|>
Array
.
tryHead
...
...
@@ -220,7 +220,7 @@ type internal GoToDefinition(checker: FSharpChecker, projectInfoManager: FSharpP
member
private
this
.
FindDefinitionAtPosition
(
originDocument
:
Document
,
position
:
int
)
=
asyncMaybe
{
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
originDocument
,
CancellationToken
.
None
)
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
originDocument
,
CancellationToken
.
None
,
userOpName
)
let
!
sourceText
=
originDocument
.
GetTextAsync
()
|>
liftTaskAsync
let
defines
=
CompilerEnvironment
.
GetCompilationDefinesForEditing
parsingOptions
let
textLine
=
sourceText
.
Lines
.
GetLineFromPosition
position
...
...
@@ -307,7 +307,7 @@ type internal GoToDefinition(checker: FSharpChecker, projectInfoManager: FSharpP
let
!
implDocument
=
originDocument
.
Project
.
Solution
.
TryGetDocumentFromPath
implFilePath
let
!
implVersion
=
implDocument
.
GetTextVersionAsync
()
|>
liftTaskAsync
let
!
implSourceText
=
implDocument
.
GetTextAsync
()
|>
liftTaskAsync
let
!
_
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
implDocument
,
CancellationToken
.
None
)
let
!
_
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
implDocument
,
CancellationToken
.
None
,
userOpName
)
let
!
targetRange
=
this
.
FindSymbolDeclarationInFile
(
targetSymbolUse
,
implFilePath
,
implSourceText
,
projectOptions
,
implVersion
.
GetHashCode
()
)
...
...
vsintegration/src/FSharp.Editor/Navigation/NavigateToSearchService.fs
浏览文件 @
7e4b03f1
...
...
@@ -172,6 +172,7 @@ type internal FSharpNavigateToSearchService
projectInfoManager
:
FSharpProjectOptionsManager
)
=
let
userOpName
=
"FSharpNavigateToSearchService"
let
kindsProvided
=
ImmutableHashSet
.
Create
(
FSharpNavigateToItemKind
.
Module
,
FSharpNavigateToItemKind
.
Class
,
FSharpNavigateToItemKind
.
Field
,
FSharpNavigateToItemKind
.
Property
,
FSharpNavigateToItemKind
.
Method
,
FSharpNavigateToItemKind
.
Enum
,
FSharpNavigateToItemKind
.
EnumItem
)
:>
IImmutableSet
<
string
>
// Save the backing navigation data in a memory cache held in a sliding window
...
...
@@ -261,7 +262,7 @@ type internal FSharpNavigateToSearchService
member
__.
SearchDocumentAsync
(
document
,
searchPattern
,
kinds
,
cancellationToken
)
:
Task
<
ImmutableArray
<
FSharpNavigateToSearchResult
>>
=
asyncMaybe
{
let
!
parsingOptions
,
_,
_
=
projectInfoManager
.
TryGetOptionsForDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
_,
_
=
projectInfoManager
.
TryGetOptionsForDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
items
=
getCachedIndexedNavigableItems
(
document
,
parsingOptions
,
kinds
)
|>
liftAsync
return
items
.
Find
(
searchPattern
)
}
...
...
vsintegration/src/FSharp.Editor/Navigation/NavigationBarItemService.fs
浏览文件 @
7e4b03f1
...
...
@@ -32,7 +32,7 @@ type internal FSharpNavigationBarItemService
interface
IFSharpNavigationBarItemService
with
member
__.
GetItemsAsync
(
document
,
cancellationToken
)
:
Task
<
IList
<
FSharpNavigationBarItem
>>
=
asyncMaybe
{
let
!
parsingOptions
,
_
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
_
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
let
!
parsedInput
=
checkerProvider
.
Checker
.
ParseDocument
(
document
,
parsingOptions
,
sourceText
=
sourceText
,
userOpName
=
userOpName
)
let
navItems
=
FSharpNavigation
.
getNavigation
parsedInput
...
...
vsintegration/src/FSharp.Editor/QuickInfo/QuickInfoProvider.fs
浏览文件 @
7e4b03f1
...
...
@@ -92,7 +92,7 @@ module internal FSharpQuickInfo =
asyncMaybe
{
let
!
sourceText
=
document
.
GetTextAsync
cancellationToken
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
projectOptions
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
defines
=
CompilerEnvironment
.
GetCompilationDefinesForEditing
parsingOptions
let
!
lexerSymbol
=
Tokenizer
.
getSymbolAtPosition
(
document
.
Id
,
sourceText
,
position
,
document
.
FilePath
,
defines
,
SymbolLookupKind
.
Greedy
,
true
)
let
idRange
=
lexerSymbol
.
Ident
.
idRange
...
...
vsintegration/src/FSharp.Editor/Structure/BlockStructureService.fs
浏览文件 @
7e4b03f1
...
...
@@ -152,7 +152,7 @@ type internal FSharpBlockStructureService [<ImportingConstructor>] (checkerProvi
member
__.
GetBlockStructureAsync
(
document
,
cancellationToken
)
:
Task
<
FSharpBlockStructure
>
=
asyncMaybe
{
let
!
parsingOptions
,
_
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
)
let
!
parsingOptions
,
_
options
=
projectInfoManager
.
TryGetOptionsForEditingDocumentOrProject
(
document
,
cancellationToken
,
userOpName
)
let
!
sourceText
=
document
.
GetTextAsync
(
cancellationToken
)
let
!
parsedInput
=
checkerProvider
.
Checker
.
ParseDocument
(
document
,
parsingOptions
,
sourceText
,
userOpName
)
return
createBlockSpans
document
.
FSharpOptions
.
Advanced
.
IsBlockStructureEnabled
sourceText
parsedInput
|>
Seq
.
toImmutableArray
...
...
vsintegration/tests/UnitTests/EditorFormattingServiceTests.fs
浏览文件 @
7e4b03f1
...
...
@@ -78,7 +78,7 @@ marker4"""
let
lineNumber
=
sourceText
.
Lines
|>
Seq
.
findIndex
(
fun
line
->
line
.
Span
.
Contains
position
)
let
parsingOptions
,
_
=
checker
.
GetParsingOptionsFromProjectOptions
projectOptions
let
changesOpt
=
FSharpEditorFormattingService
.
GetFormattingChanges
(
documentId
,
sourceText
,
filePath
,
checker
,
indentStyle
,
Some
(
parsingOptions
,
projectOptions
)
,
position
)
|>
Async
.
RunSynchronously
let
changesOpt
=
FSharpEditorFormattingService
.
GetFormattingChanges
(
documentId
,
sourceText
,
filePath
,
checker
,
indentStyle
,
parsingOptions
,
position
)
|>
Async
.
RunSynchronously
match
changesOpt
with
|
None
->
Assert
.
Fail
(
"Expected a text change, but got None"
)
|
Some
changes
->
...
...
vsintegration/tests/UnitTests/IndentationServiceTests.fs
浏览文件 @
7e4b03f1
...
...
@@ -176,7 +176,7 @@ while true do
let
sourceText
=
SourceText
.
From
(
template
)
let
parsingOptions
,
_
=
checker
.
GetParsingOptionsFromProjectOptions
projectOptions
let
actualIndentation
=
FSharpIndentationService
.
GetDesiredIndentation
(
documentId
,
sourceText
,
filePath
,
lineNumber
,
tabSize
,
indentStyle
,
Some
(
parsingOptions
,
projectOptions
)
)
let
actualIndentation
=
FSharpIndentationService
.
GetDesiredIndentation
(
documentId
,
sourceText
,
filePath
,
lineNumber
,
tabSize
,
indentStyle
,
parsingOptions
)
match
expectedIndentation
with
|
None
->
Assert
.
IsTrue
(
actualIndentation
.
IsNone
,
"No indentation was expected at line {0}"
,
lineNumber
)
|
Some
indentation
->
Assert
.
AreEqual
(
expectedIndentation
.
Value
,
actualIndentation
.
Value
,
"Indentation on line {0} doesn't match"
,
lineNumber
)
...
...
@@ -189,7 +189,7 @@ while true do
let
sourceText
=
SourceText
.
From
(
template
)
let
parsingOptions
,
_
=
checker
.
GetParsingOptionsFromProjectOptions
projectOptions
let
actualIndentation
=
FSharpIndentationService
.
GetDesiredIndentation
(
documentId
,
sourceText
,
filePath
,
lineNumber
,
tabSize
,
indentStyle
,
Some
(
parsingOptions
,
projectOptions
)
)
let
actualIndentation
=
FSharpIndentationService
.
GetDesiredIndentation
(
documentId
,
sourceText
,
filePath
,
lineNumber
,
tabSize
,
indentStyle
,
parsingOptions
)
match
expectedIndentation
with
|
None
->
Assert
.
IsTrue
(
actualIndentation
.
IsNone
,
"No indentation was expected at line {0}"
,
lineNumber
)
|
Some
indentation
->
Assert
.
AreEqual
(
expectedIndentation
.
Value
,
actualIndentation
.
Value
,
"Indentation on line {0} doesn't match"
,
lineNumber
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录