Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit c70ec41

Browse files
dsymeDon Syme
authored andcommitted
fix script editing perf (dotnet#10159)
Co-authored-by: Don Syme <[email protected]>
1 parent df72efe commit c70ec41

29 files changed

+66
-64
lines changed

Classification/ClassificationService.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ type internal FSharpClassificationService
158158
asyncMaybe {
159159
use _logBlock = Logger.LogBlock(LogEditorFunctionId.Classification_Semantic)
160160

161-
let! _, _, projectOptions = projectInfoManager.TryGetOptionsForDocumentOrProject(document, cancellationToken)
161+
let! _, _, projectOptions = projectInfoManager.TryGetOptionsForDocumentOrProject(document, cancellationToken, userOpName)
162162
let! sourceText = document.GetTextAsync(cancellationToken)
163163

164164
// If we are trying to get semantic classification for a document that is not open, get the results from the background and cache it.

CodeFix/AddOpenCodeFixProvider.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ type internal FSharpAddOpenCodeFixProvider
9696
override __.RegisterCodeFixesAsync context : Task =
9797
asyncMaybe {
9898
let document = context.Document
99-
let! parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, context.CancellationToken)
99+
let! parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, context.CancellationToken, userOpName)
100100
let! sourceText = context.Document.GetTextAsync(context.CancellationToken)
101101
let! _, parsedInput, checkResults = checker.ParseAndCheckDocument(document, projectOptions, sourceText = sourceText, userOpName = userOpName)
102102
let line = sourceText.Lines.GetLineFromPosition(context.Span.End)

CodeFix/ImplementInterfaceCodeFixProvider.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ type internal FSharpImplementInterfaceCodeFixProvider
138138

139139
override __.RegisterCodeFixesAsync context : Task =
140140
asyncMaybe {
141-
let! parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(context.Document, context.CancellationToken)
141+
let! parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(context.Document, context.CancellationToken, userOpName)
142142
let cancellationToken = context.CancellationToken
143143
let! sourceText = context.Document.GetTextAsync(cancellationToken)
144144
let! _, parsedInput, checkFileResults = checker.ParseAndCheckDocument(context.Document, projectOptions, sourceText = sourceText, userOpName = userOpName)

CodeFix/RemoveUnusedOpens.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type internal FSharpRemoveUnusedOpensCodeFixProvider
2222
projectInfoManager: FSharpProjectOptionsManager
2323
) =
2424
inherit CodeFixProvider()
25+
let userOpName = "FSharpRemoveUnusedOpensCodeFixProvider"
2526
let fixableDiagnosticIds = [FSharpIDEDiagnosticIds.RemoveUnnecessaryImportsDiagnosticId]
2627

2728
let createCodeFix (title: string, context: CodeFixContext) =
@@ -32,7 +33,7 @@ type internal FSharpRemoveUnusedOpensCodeFixProvider
3233
let document = context.Document
3334
let! sourceText = document.GetTextAsync()
3435
let checker = checkerProvider.Checker
35-
let! _parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, context.CancellationToken)
36+
let! _parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, context.CancellationToken, userOpName)
3637
let! unusedOpens = UnusedOpensDiagnosticAnalyzer.GetUnusedOpenRanges(document, projectOptions, checker)
3738
let changes =
3839
unusedOpens

CodeFix/RenameUnusedValue.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type internal FSharpRenameUnusedValueCodeFixProvider
5757
// We have to use the additional check for backtickes because `IsOperatorOrBacktickedName` operates on display names
5858
// where backtickes are replaced with parens.
5959
if not (PrettyNaming.IsOperatorOrBacktickedName ident) && not (ident.StartsWith "``") then
60-
let! parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, context.CancellationToken)
60+
let! parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, context.CancellationToken, userOpName)
6161
let! _, _, checkResults = checker.ParseAndCheckDocument(document, projectOptions, sourceText = sourceText, userOpName=userOpName)
6262
let m = RoslynHelpers.TextSpanToFSharpRange(document.FilePath, context.Span, sourceText)
6363
let defines = CompilerEnvironment.GetCompilationDefinesForEditing parsingOptions

CodeFix/ReplaceWithSuggestion.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type internal FSharpReplaceWithSuggestionCodeFixProvider
3333
do! Option.guard settings.CodeFixes.SuggestNamesForErrors
3434

3535
let document = context.Document
36-
let! _, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, context.CancellationToken)
36+
let! _, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, context.CancellationToken, userOpName)
3737
let! parseFileResults, _, checkFileResults = checker.ParseAndCheckDocument(document, projectOptions, userOpName=userOpName)
3838

3939
// This is all needed to get a declaration list

CodeLens/FSharpCodeLensService.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type internal FSharpCodeLensService
5252
) as self =
5353

5454
let lineLens = codeLens
55+
let userOpName = "FSharpCodeLensService"
5556

5657
let visit pos parseTree =
5758
AstTraversal.Traverse(pos, parseTree, { new AstTraversal.AstVisitorBase<_>() with
@@ -154,7 +155,7 @@ type internal FSharpCodeLensService
154155
logInfof "Rechecking code due to buffer edit!"
155156
#endif
156157
let! document = workspace.CurrentSolution.GetDocument(documentId.Value) |> Option.ofObj
157-
let! _, options = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, bufferChangedCts.Token)
158+
let! _, options = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, bufferChangedCts.Token, userOpName)
158159
let! _, parsedInput, checkFileResults = checker.ParseAndCheckDocument(document, options, "LineLens", allowStaleResults=true)
159160
#if DEBUG
160161
logInfof "Getting uses of all symbols!"

Commands/HelpContextService.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ type internal FSharpHelpContextService
9898

9999
member this.GetHelpTermAsync(document, textSpan, cancellationToken) =
100100
asyncMaybe {
101-
let! _parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, cancellationToken)
101+
let! _parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, cancellationToken, userOpName)
102102
let! sourceText = document.GetTextAsync(cancellationToken)
103103
let! textVersion = document.GetTextVersionAsync(cancellationToken)
104104
let defines = projectInfoManager.GetCompilationDefinesForEditingDocument(document)

Commands/XmlDocCommandService.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type internal XmlDocCommandFilter
6767
// XmlDocable line #1 are 1-based, editor is 0-based
6868
let curLineNum = wpfTextView.Caret.Position.BufferPosition.GetContainingLine().LineNumber + 1
6969
let! document = document.Value
70-
let! parsingOptions, _options = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, CancellationToken.None)
70+
let! parsingOptions, _options = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, CancellationToken.None, userOpName)
7171
let! sourceText = document.GetTextAsync(CancellationToken.None)
7272
let! parsedInput = checker.ParseDocument(document, parsingOptions, sourceText, userOpName)
7373
let xmlDocables = XmlDocParser.getXmlDocables (sourceText.ToFSharpSourceText(), Some parsedInput)

Completion/CompletionProvider.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ type internal FSharpCompletionProvider
228228
let! sourceText = context.Document.GetTextAsync(context.CancellationToken)
229229
let defines = projectInfoManager.GetCompilationDefinesForEditingDocument(document)
230230
do! Option.guard (CompletionUtils.shouldProvideCompletion(document.Id, document.FilePath, defines, sourceText, context.Position))
231-
let! _parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, context.CancellationToken)
231+
let! _parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, context.CancellationToken, userOpName)
232232
let! textVersion = context.Document.GetTextVersionAsync(context.CancellationToken)
233233
let getAllSymbols(fileCheckResults: FSharpCheckFileResults) =
234234
if settings.IntelliSense.IncludeSymbolsFromUnopenedNamespacesOrModules
@@ -298,7 +298,7 @@ type internal FSharpCompletionProvider
298298
let! sourceText = document.GetTextAsync(cancellationToken)
299299
let textWithItemCommitted = sourceText.WithChanges(TextChange(item.Span, nameInCode))
300300
let line = sourceText.Lines.GetLineFromPosition(item.Span.Start)
301-
let! parsingOptions, _options = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, cancellationToken)
301+
let! parsingOptions, _options = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, cancellationToken, userOpName)
302302
let! parsedInput = checker.ParseDocument(document, parsingOptions, sourceText, userOpName)
303303
let fullNameIdents = fullName |> Option.map (fun x -> x.Split '.') |> Option.defaultValue [||]
304304

0 commit comments

Comments
 (0)