Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8441f29

Browse files
committed
fix caching to avoid any duplicates.
Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
1 parenta5f8433 commit8441f29

File tree

1 file changed

+21
-32
lines changed

1 file changed

+21
-32
lines changed

‎vsintegration/src/FSharp.Editor/CodeLens/FSharpCodeLensService.fs‎

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ type internal FSharpCodeLensService
5555

5656
override__.VisitTypeAbbrev(_,range)= Some range
5757

58-
override__.VisitLetOrUse(binding,range)= Some range
58+
override__.VisitLetOrUse(binding,range)=
59+
match binding|> Seq.tryFind(fun b-> b.RangeOfHeadPat.StartLine= pos.Line)with
60+
| Some entry->
61+
Some entry.RangeOfBindingAndRhs
62+
|_-> Some range// This can be invalid and should not happen
5963

6064
override__.VisitBinding(fn,binding)=
6165
Some binding.RangeOfBindingAndRhs
@@ -81,7 +85,6 @@ type internal FSharpCodeLensService
8185
let!res= lens.TaggedText
8286
match reswith
8387
| Some(taggedText, navigation)->
84-
logInfof"Tagged text%A" taggedText
8588
lettextBlock=new TextBlock(Background= Brushes.AliceBlue, Opacity=0.0, TextTrimming= TextTrimming.None)
8689
DependencyObjectExtensions.SetDefaultTextProperties(textBlock, formatMap.Value)
8790

@@ -133,14 +136,11 @@ type internal FSharpCodeLensService
133136
letexecuteCodeLenseAsync()=
134137
asyncMaybe{
135138
do! Async.Sleep800|> liftAsync
136-
logInfof"Rechecking code due to buffer edit!"
137139
let!document= workspace.CurrentSolution.GetDocument(documentId.Value)|> Option.ofObj
138140
let!_,options= projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document)
139141
let!_,parsedInput,checkFileResults= checker.ParseAndCheckDocument(document, options,true,"LineLens")
140-
logInfof"Getting uses of all symbols!"
141142
let!symbolUses= checkFileResults.GetAllUsesOfAllSymbolsInFile()|> liftAsync
142143
lettextSnapshot= buffer.CurrentSnapshot
143-
logInfof"Updating due to buffer edit!"
144144

145145
// Clear existing data and cache flags
146146
// The results which are left.
@@ -159,25 +159,19 @@ type internal FSharpCodeLensService
159159
lettextSnapshot= buffer.CurrentSnapshot
160160
letlineNumber= Line.toZ func.DeclarationLocation.StartLine
161161
if(lineNumber>=0|| lineNumber< textSnapshot.LineCount)then
162-
match func.FullTypeSafewith
163-
| Some_->
164-
let!displayEnv= checkFileResults.GetDisplayEnvForPos func.DeclarationLocation.Start
165-
166-
letdisplayContext=
167-
match displayEnvwith
168-
| Some denv-> FSharpDisplayContext(fun _-> denv)
169-
| None-> displayContext
170-
171-
lettypeLayout= func.FormatLayout displayContext
172-
lettaggedText= ResizeArray()
162+
let!displayEnv= checkFileResults.GetDisplayEnvForPos func.DeclarationLocation.Start
163+
letdisplayContext=
164+
match displayEnvwith
165+
| Some denv-> FSharpDisplayContext(fun _-> denv)
166+
| None-> displayContext
167+
168+
lettypeLayout= func.FormatLayout displayContext
169+
lettaggedText= ResizeArray()
173170

174-
Layout.renderL(Layout.taggedTextListR taggedText.Add) typeLayout|> ignore
175-
letnavigation= QuickInfoNavigation(serviceProvider, checker, projectInfoManager, document, realPosition)
176-
// Because the data is available notify that this line should be updated, displaying the results
177-
return Some(taggedText, navigation)
178-
| None->
179-
logWarningf"Couldn't acquire CodeLens data for function%A" func
180-
return None
171+
Layout.renderL(Layout.taggedTextListR taggedText.Add) typeLayout|> ignore
172+
letnavigation= QuickInfoNavigation(serviceProvider, checker, projectInfoManager, document, realPosition)
173+
// Because the data is available notify that this line should be updated, displaying the results
174+
return Some(taggedText, navigation)
181175
elsereturn None
182176
with e->
183177
logErrorf"Error in lazy line lens computation.%A" e
@@ -188,13 +182,13 @@ type internal FSharpCodeLensService
188182
if newResults.ContainsKey fullDeclarationTextthen
189183
logWarningf"New results already contains:%A" fullDeclarationText
190184
newResults.[fullDeclarationText]<- value
191-
192185
for symbolUsein symbolUsesdo
193186
if symbolUse.IsFromDefinitionthen
194187
match symbolUse.Symbolwith
195188
|:? FSharpMemberOrFunctionOrValueas funcwhen func.IsModuleValueOrMember|| func.IsProperty->
196-
letfuncID= func.FullName
197-
letfullDeclarationText= funcID
189+
letfuncID= func.LogicalName+(func.FullType.ToString()|> hash|> string)
190+
// Use a combination of the the function name + the hashed value of the type signature
191+
letfullDeclarationText= funcID// (textSnapshot.GetText declarationSpan).Replace(func.CompiledName, funcID)
198192
letfullTypeSignature= func.FullType.ToString()
199193
// Try to re-use the last results
200194
if lastResults.ContainsKey fullDeclarationTextthen
@@ -297,7 +291,6 @@ type internal FSharpCodeLensService
297291
let!res= createTextBox codeLens
298292
if resthen
299293
do! Async.SwitchToContext uiContext
300-
logInfof"Adding ui element for%A"(codeLens.TaggedText)
301294
letuiElement= codeLens.UiElement
302295
letanimation=
303296
DoubleAnimation(
@@ -334,7 +327,6 @@ type internal FSharpCodeLensService
334327
for valuein codeLensToAdddo
335328
lettrackingSpan,codeLens= value
336329
letGrid= lineLens.AddCodeLens trackingSpan
337-
logInfof"Trackingspan%A is being added." trackingSpan
338330

339331
Grid.IsVisibleChanged
340332
|> Event.filter(fun eventArgs-> eventArgs.NewValue:?> bool)
@@ -344,8 +336,6 @@ type internal FSharpCodeLensService
344336
lettrackingSpan,_= oldResult.Value
345337
// logInfof "removing trackingSpan %A" trackingSpan
346338
lineLens.RemoveCodeLens trackingSpan|> ignore
347-
348-
logInfof"Finished updating line lens."
349339

350340
ifnot firstTimeCheckedthen
351341
firstTimeChecked<-true
@@ -370,5 +360,4 @@ type internal FSharpCodeLensService
370360
bufferChangedCts.Cancel()// Stop all ongoing async workflow.
371361
bufferChangedCts.Dispose()
372362
bufferChangedCts<-new CancellationTokenSource()
373-
executeCodeLenseAsync()|> Async.Ignore|> RoslynHelpers.StartAsyncSafe bufferChangedCts.Token"Buffer Changed"
374-
363+
executeCodeLenseAsync()|> Async.Ignore|> RoslynHelpers.StartAsyncSafe bufferChangedCts.Token"Buffer Changed"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp