File tree Expand file tree Collapse file tree 4 files changed +19
-15
lines changed Expand file tree Collapse file tree 4 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -238,6 +238,8 @@ type deadWarning =
238
238
| WarningDeadValueWithSideEffects
239
239
| IncorrectDeadAnnotation
240
240
241
+ type lineAnnotation = (decl * line ) option
242
+
241
243
type description =
242
244
| Circular of {message : string }
243
245
| ExceptionAnalysis of {message : string }
@@ -248,8 +250,8 @@ type description =
248
250
deadWarning : deadWarning ;
249
251
path : string ;
250
252
message : string ;
251
- shouldWriteAnnotation : bool ;
252
- lineInfo : ( decl * line ) option ;
253
+ shouldWriteLineAnnotation : bool ;
254
+ lineAnnotation : lineAnnotation ;
253
255
}
254
256
| Termination of {termination : termination ; message : string }
255
257
Original file line number Diff line number Diff line change @@ -400,13 +400,14 @@ let emitWarning ~decl ~message deadWarning =
400
400
| Value {isToplevel; sideEffects} -> isToplevel && sideEffects
401
401
| _ -> false
402
402
in
403
- let shouldWriteAnnotation =
403
+ let shouldWriteLineAnnotation =
404
404
(not (isToplevelValueWithSideEffects decl))
405
405
&& Suppress. filter decl.pos
406
406
&& deadWarning <> IncorrectDeadAnnotation
407
407
in
408
- let lineInfo =
409
- if shouldWriteAnnotation then decl |> WriteDeadAnnotations. onDeadDecl
408
+ let lineAnnotation =
409
+ if shouldWriteLineAnnotation then
410
+ WriteDeadAnnotations. addLineAnnotation ~decl
410
411
else None
411
412
in
412
413
decl.path
@@ -418,8 +419,8 @@ let emitWarning ~decl ~message deadWarning =
418
419
deadWarning;
419
420
path = Path. withoutHead decl.path;
420
421
message;
421
- lineInfo ;
422
- shouldWriteAnnotation ;
422
+ lineAnnotation ;
423
+ shouldWriteLineAnnotation ;
423
424
})
424
425
425
426
module Decl = struct
Original file line number Diff line number Diff line change @@ -110,8 +110,9 @@ let missingRaiseInfoToText {exnTable; missingAnnotations; locFull} =
110
110
111
111
let logAdditionalInfo ~(description : description ) =
112
112
match description with
113
- | DeadWarning {lineInfo; shouldWriteAnnotation} ->
114
- if shouldWriteAnnotation then WriteDeadAnnotations. lineInfoToString lineInfo
113
+ | DeadWarning {lineAnnotation; shouldWriteLineAnnotation} ->
114
+ if shouldWriteLineAnnotation then
115
+ WriteDeadAnnotations. lineAnnotationToString lineAnnotation
115
116
else " "
116
117
| ExceptionAnalysisMissing missingRaiseInfo ->
117
118
missingRaiseInfoToText missingRaiseInfo
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ let offsetOfPosAdjustment = function
109
109
| FirstVariant | Nothing -> 0
110
110
| OtherVariant -> 2
111
111
112
- let getLineInformation ~decl ~line =
112
+ let getLineAnnotation ~decl ~line =
113
113
if ! Cli. json then
114
114
let posAnnotation = decl |> getPosAnnotation in
115
115
let offset = decl.posAdjustment |> offsetOfPosAdjustment in
@@ -127,13 +127,13 @@ let getLineInformation ~decl ~line =
127
127
Format. asprintf " @. <-- line %d@. %s" decl.pos.pos_lnum
128
128
(line |> lineToString)
129
129
130
- let getNoLineInfo () = if ! Cli. json then " " else " \n <-- Can't find line"
130
+ let cantFindLine () = if ! Cli. json then " " else " \n <-- Can't find line"
131
131
132
- let lineInfoToString = function
133
- | None -> getNoLineInfo ()
134
- | Some (decl , line ) -> getLineInformation ~decl ~line
132
+ let lineAnnotationToString = function
133
+ | None -> cantFindLine ()
134
+ | Some (decl , line ) -> getLineAnnotation ~decl ~line
135
135
136
- let onDeadDecl decl =
136
+ let addLineAnnotation ~ decl : lineAnnotation =
137
137
let fileName = decl.pos.pos_fname in
138
138
if Sys. file_exists fileName then (
139
139
if fileName <> ! currentFile then (
You can’t perform that action at this time.
0 commit comments