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

Commit6c4867d

Browse files
committed
Wrapping all warning logging messages with #if Debug
Signed-off-by: realvictorprm <mueller.vpr@gmail.com>
1 parent5db861c commit6c4867d

File tree

4 files changed

+105
-23
lines changed

4 files changed

+105
-23
lines changed

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

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type CodeLensDisplayService (view : IWpfTextView, buffer : ITextBuffer, layerNam
2121
buffer.Changed.Add self.HandleBufferChanged
2222
view.LayoutChanged.Add self.HandleLayoutChanged
2323
)
24-
24+
2525
/// <summary>
2626
/// Enqueing an unit signals to the tagger that all visible line lens must be layouted again,
2727
/// to respect single line changes.
@@ -123,7 +123,9 @@ type CodeLensDisplayService (view : IWpfTextView, buffer : ITextBuffer, layerNam
123123
letstartLineNumber= snapshot.GetLineNumberFromPosition(trackingSpan.GetStartPoint(snapshot).Position)
124124
letuiElement=
125125
if self.UiElements.ContainsKey trackingSpanthen
126+
#if DEBUG
126127
logErrorf"Added a tracking span twice, this is not allowed and will result in invalid values!%A"(trackingSpan.GetText snapshot)
128+
#endif
127129
self.UiElements.[trackingSpan]
128130
else
129131
letdefaultStackPanel= self.CreateDefaultStackPanel()
@@ -152,11 +154,15 @@ type CodeLensDisplayService (view : IWpfTextView, buffer : ITextBuffer, layerNam
152154
letfirstLine= view.TextViewLines.FirstVisibleLine
153155
view.DisplayTextLineContainingBufferPosition(firstLine.Start,0., ViewRelativePosition.Top)
154156
self.RelayoutRequested.Enqueue(())
155-
with e-> logErrorf"Error in line lens provider:%A" e
156-
157+
with e->
158+
#if DEBUG
159+
logErrorf"Error in line lens provider:%A" e
160+
#else
161+
()
162+
#endif
163+
157164
/// Public non-thread-safe method to add line lens for a given tracking span.
158165
/// Returns an UIElement which can be used to add Ui elements and to remove the line lens later.
159-
160166
memberself.AddCodeLens(trackingSpan:ITrackingSpan)=
161167
if trackingSpan.TextBuffer<> bufferthen failwith"TrackingSpan text buffer does not equal with CodeLens text buffer"
162168
letGrid= self.AddTrackingSpan trackingSpan
@@ -171,20 +177,36 @@ type CodeLensDisplayService (view : IWpfTextView, buffer : ITextBuffer, layerNam
171177
self.UiElements.Remove trackingSpan|> ignore
172178
try
173179
self.CodeLensLayer.RemoveAdornment(Grid)
174-
with e->
180+
with e->
181+
#if DEBUG
175182
logExceptionWithContext(e,"Removing line lens")
183+
#else
184+
()
185+
#endif
176186
else
187+
#if DEBUG
177188
logWarningf"No ui element is attached to this tracking span!"
189+
#else
190+
()
191+
#endif
178192
letlineNumber=
179193
(trackingSpan.GetStartPoint self.CurrentBufferSnapshot).Position
180194
|> self.CurrentBufferSnapshot.GetLineNumberFromPosition
181195
if self.TrackingSpans.ContainsKey lineNumberthen
182196
if self.TrackingSpans.[lineNumber].Remove trackingSpan|>notthen
197+
#if DEBUG
183198
logWarningf"No tracking span is accociated with this line number%d!" lineNumber
199+
#else
200+
()
201+
#endif
184202
if self.TrackingSpans.[lineNumber].Count=0then
185203
self.TrackingSpans.Remove lineNumber|> ignore
186204
else
205+
#if DEBUG
187206
logWarningf"No tracking span is accociated with this line number%d!" lineNumber
207+
#else
208+
()
209+
#endif
188210

189211
abstractmemberAddUiElementToCodeLens :ITrackingSpan*UIElement->unit
190212
defaultself.AddUiElementToCodeLens(trackingSpan:ITrackingSpan,uiElement:UIElement)=
@@ -238,7 +260,12 @@ type CodeLensDisplayService (view : IWpfTextView, buffer : ITextBuffer, layerNam
238260
applyFuncOnLineStackPanels line(fun ui->
239261
ui.Visibility<- Visibility.Hidden
240262
)
241-
with e-> logErrorf"Error in non visible lines iteration%A" e
263+
with e->
264+
#if DEBUG
265+
logErrorf"Error in non visible lines iteration%A" e
266+
#else
267+
()
268+
#endif
242269
for lineNumberin newVisibleLineNumbersdo
243270
try
244271
letline=
@@ -248,7 +275,12 @@ type CodeLensDisplayService (view : IWpfTextView, buffer : ITextBuffer, layerNam
248275
ui.Visibility<- Visibility.Visible
249276
self.LayoutUIElementOnLine view line ui
250277
)
251-
with e-> logErrorf"Error in new visible lines iteration%A" e
278+
with e->
279+
#if DEBUG
280+
logErrorf"Error in new visible lines iteration%A" e
281+
#else
282+
()
283+
#endif
252284
ifnot e.VerticalTranslation&& e.NewViewState.ViewportHeight<> e.OldViewState.ViewportHeightthen
253285
self.RelayoutRequested.Enqueue()// Unfortunately zooming requires a relayout too, to ensure that no weird layout happens due to unkown reasons.
254286
if self.RelayoutRequested.Count>0then
@@ -267,7 +299,12 @@ type CodeLensDisplayService (view : IWpfTextView, buffer : ITextBuffer, layerNam
267299

268300
self.AsyncCustomLayoutOperation visibleLineNumbers buffer
269301
|> RoslynHelpers.StartAsyncSafe self.LayoutChangedCts.Token"HandleLayoutChanged"
270-
with e-> logExceptionWithContext(e,"Layout changed")
302+
with e->
303+
#if DEBUG
304+
logExceptionWithContext(e,"Layout changed")
305+
#else
306+
()
307+
#endif
271308

272309
abstractLayoutUIElementOnLine :IWpfTextView->ITextViewLine->Grid->unit
273310

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

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ type CodeLensGeneralTagger (view, buffer) as self =
3232
letleft= Canvas.GetLeft parent
3333
lettop= Canvas.GetTop parent
3434
letwidth= parent.ActualWidth
35-
logInfof"Width of parent:%.4f" width
3635
left+ width, top
3736
|_->
3837
try
@@ -47,12 +46,20 @@ type CodeLensGeneralTagger (view, buffer) as self =
4746
// Calling the method twice fixes this bug and ensures that all values are correct.
4847
// Okay not really :( Must be replaced later with an own calculation depending on editor font settings!
4948
if7* offset> int g.Leftthen
49+
#if DEBUG
5050
logErrorf"Incorrect return from geometry measure"
51+
#else
52+
()
53+
#endif
5154
Canvas.GetLeft ui, g.Top
5255
else
5356
g.Left, g.Top
5457
with e->
58+
#if DEBUG
5559
logExceptionWithContext(e,"Error in layout ui element on line")
60+
#else
61+
()
62+
#endif
5663
Canvas.GetLeft ui, Canvas.GetTop ui
5764
Canvas.SetLeft(ui, left)
5865
Canvas.SetTop(ui, top)
@@ -89,7 +96,12 @@ type CodeLensGeneralTagger (view, buffer) as self =
8996
self, stackPanel, AdornmentRemovedCallback(fun _ _->()))|> ignore
9097
self.AddedAdornments.Add stackPanel|> ignore
9198
|_->()
92-
with e-> logExceptionWithContext(e,"LayoutChanged, processing new visible lines")
99+
with e->
100+
#if DEBUG
101+
logExceptionWithContext(e,"LayoutChanged, processing new visible lines")
102+
#else
103+
()
104+
#endif
93105
}|> Async.Ignore
94106

95107
overrideself.AddUiElementToCodeLens(trackingSpan:ITrackingSpan,uiElement:UIElement)=
@@ -114,7 +126,11 @@ type CodeLensGeneralTagger (view, buffer) as self =
114126
letlineNumber=
115127
try
116128
snapshot.GetLineNumberFromPosition(span.Start.Position)
117-
with e-> logExceptionWithContext(e,"line number tagging");0
129+
with e->
130+
#if DEBUG
131+
logExceptionWithContext(e,"line number tagging")
132+
#endif
133+
0
118134
if self.TrackingSpans.ContainsKey(lineNumber)&& self.TrackingSpans.[lineNumber]|> Seq.isEmpty|>notthen
119135

120136
lettagSpan= snapshot.GetLineFromLineNumber(lineNumber).Extent
@@ -128,26 +144,40 @@ type CodeLensGeneralTagger (view, buffer) as self =
128144
letspan=
129145
try
130146
tagSpan.TranslateTo(span.Snapshot, SpanTrackingMode.EdgeExclusive)
131-
with e-> logExceptionWithContext(e,"tag span translation"); tagSpan
147+
with e->
148+
#if DEBUG
149+
logExceptionWithContext(e,"tag span translation")
150+
#endif
151+
tagSpan
132152
letsizes=
133153
try
134154
stackPanels|> Seq.map(fun ui->
135155
ui.Measure(Size(10000.,10000.))
136156
ui.DesiredSize)
137-
with e-> logExceptionWithContext(e,"internal tagging"); Seq.empty
157+
with e->
158+
#if DEBUG
159+
logExceptionWithContext(e,"internal tagging")
160+
#endif
161+
Seq.empty
138162
letheight=
139163
try
140164
sizes
141165
|> Seq.map(fun size-> size.Height)
142166
|> Seq.sortDescending
143167
|> Seq.tryHead
144168
|> Option.defaultValue0.
145-
with e-> logExceptionWithContext(e,"height tagging");0.
169+
with e->
170+
#if DEBUG
171+
logExceptionWithContext(e,"height tagging")
172+
#endif
173+
0.
146174

147175
yield TagSpan(span, CodeLensGeneralTag(0., height,0.,0.,0., PositionAffinity.Predecessor, stackPanels, self)):> ITagSpan<CodeLensGeneralTag>
148176
}
149-
with e->
177+
with e->
178+
#if DEBUG
150179
logErrorf"Error in code lens get tags%A" e
180+
#endif
151181
Seq.empty
152182

153183

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,17 @@ type internal FSharpCodeLensService
174174
return Some(taggedText, navigation)
175175
elsereturn None
176176
with e->
177+
#if DEBUG
177178
logErrorf"Error in lazy line lens computation.%A" e
179+
#endif
178180
return None
179181
}
180182

181183
let inlinesetNewResultsAndWarnIfOverriden fullDeclarationText value=
182184
if newResults.ContainsKey fullDeclarationTextthen
185+
#if DEBUG
183186
logWarningf"New results already contains:%A" fullDeclarationText
187+
#endif
184188
newResults.[fullDeclarationText]<- value
185189
for symbolUsein symbolUsesdo
186190
if symbolUse.IsFromDefinitionthen
@@ -281,7 +285,10 @@ type internal FSharpCodeLensService
281285
textSnapshot.CreateTrackingSpan(declarationSpan, SpanTrackingMode.EdgeExclusive)
282286
codeLensToAdd.Add(trackingSpan, res)
283287
newResults.[fullDeclarationText]<-(trackingSpan, res)
284-
with e-> logExceptionWithContext(e,"Line Lens tracking tag span creation")
288+
with e->
289+
#if DEBUG
290+
logExceptionWithContext(e,"Line Lens tracking tag span creation")
291+
#endif
285292
()
286293
lastResults<- newResults
287294
do! Async.SwitchToContext uiContext|> liftAsync
@@ -306,16 +313,15 @@ type internal FSharpCodeLensService
306313
lineLens.RelayoutRequested.Enqueue()
307314
sb.Begin()
308315
else
316+
#if DEBUG
309317
logWarningf"Couldn't retrieve code lens information for%A" codeLens.FullTypeSignature
310-
// logInfo "Adding text box!"
318+
#endif
311319
}|>(RoslynHelpers.StartAsyncSafe CancellationToken.None)"UIElement creation"
312320

313321
for valuein tagsToUpdatedo
314322
lettrackingSpan,(newTrackingSpan,_,codeLens)= value.Key, value.Value
315-
// logInfof "Adding ui element for %A" (codeLens.TaggedText)
316323
lineLens.RemoveCodeLens trackingSpan|> ignore
317324
letGrid= lineLens.AddCodeLens newTrackingSpan
318-
// logInfof "Trackingspan %A is being added." trackingSpan
319325
if codeLens.Computed&&(isNull codeLens.UiElement|>not)then
320326
letuiElement= codeLens.UiElement
321327
lineLens.AddUiElementToCodeLensOnce(newTrackingSpan, uiElement)
@@ -334,7 +340,6 @@ type internal FSharpCodeLensService
334340

335341
for oldResultin oldResultsdo
336342
lettrackingSpan,_= oldResult.Value
337-
// logInfof "removing trackingSpan %A" trackingSpan
338343
lineLens.RemoveCodeLens trackingSpan|> ignore
339344

340345
ifnot firstTimeCheckedthen
@@ -351,8 +356,11 @@ type internal FSharpCodeLensService
351356
do! executeCodeLenseAsync()
352357
do! Async.Sleep(1000)
353358
with
354-
| e-> logErrorf"Line Lens startup failed with:%A" e
355-
numberOfFails<- numberOfFails+1
359+
| e->
360+
#if DEBUG
361+
logErrorf"Line Lens startup failed with:%A" e
362+
#endif
363+
numberOfFails<- numberOfFails+1
356364
}|> Async.Start
357365
end
358366

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ type internal LineLensDisplayService (view, buffer) =
3030
letbounds= line.GetCharacterBounds(line.Start)
3131
line.TextRight+5.0, bounds.Top-1.
3232
with e->
33+
#if DEBUG
3334
logExceptionWithContext(e,"Error in layout ui element on line")
35+
#endif
3436
Canvas.GetLeft ui, Canvas.GetTop ui
3537
Canvas.SetLeft(ui, left)
3638
Canvas.SetTop(ui, top)
@@ -63,5 +65,10 @@ type internal LineLensDisplayService (view, buffer) =
6365
view.GetTextViewLineContainingBufferPosition l.Start
6466
self.LayoutUIElementOnLine view line grid
6567
)
66-
with e-> logExceptionWithContext(e,"LayoutChanged, processing new visible lines")
68+
with e->
69+
#if DEBUG
70+
logExceptionWithContext(e,"LayoutChanged, processing new visible lines")
71+
#else
72+
()
73+
#endif
6774
}|> Async.Ignore

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp