Skip to content

Commit 359d064

Browse files
committed
rename lineInfo to lineAnnotation
1 parent 18446ea commit 359d064

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

analysis/reanalyze/src/Common.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ type deadWarning =
238238
| WarningDeadValueWithSideEffects
239239
| IncorrectDeadAnnotation
240240

241+
type lineAnnotation = (decl * line) option
242+
241243
type description =
242244
| Circular of {message : string}
243245
| ExceptionAnalysis of {message : string}
@@ -248,8 +250,8 @@ type description =
248250
deadWarning : deadWarning;
249251
path : string;
250252
message : string;
251-
shouldWriteAnnotation : bool;
252-
lineInfo : (decl * line) option;
253+
shouldWriteLineAnnotation : bool;
254+
lineAnnotation : lineAnnotation;
253255
}
254256
| Termination of {termination : termination; message : string}
255257

analysis/reanalyze/src/DeadCommon.ml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,14 @@ let emitWarning ~decl ~message deadWarning =
400400
| Value {isToplevel; sideEffects} -> isToplevel && sideEffects
401401
| _ -> false
402402
in
403-
let shouldWriteAnnotation =
403+
let shouldWriteLineAnnotation =
404404
(not (isToplevelValueWithSideEffects decl))
405405
&& Suppress.filter decl.pos
406406
&& deadWarning <> IncorrectDeadAnnotation
407407
in
408-
let lineInfo =
409-
if shouldWriteAnnotation then decl |> WriteDeadAnnotations.onDeadDecl
408+
let lineAnnotation =
409+
if shouldWriteLineAnnotation then
410+
WriteDeadAnnotations.addLineAnnotation ~decl
410411
else None
411412
in
412413
decl.path
@@ -418,8 +419,8 @@ let emitWarning ~decl ~message deadWarning =
418419
deadWarning;
419420
path = Path.withoutHead decl.path;
420421
message;
421-
lineInfo;
422-
shouldWriteAnnotation;
422+
lineAnnotation;
423+
shouldWriteLineAnnotation;
423424
})
424425

425426
module Decl = struct

analysis/reanalyze/src/Log_.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ let missingRaiseInfoToText {exnTable; missingAnnotations; locFull} =
110110

111111
let logAdditionalInfo ~(description : description) =
112112
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
115116
else ""
116117
| ExceptionAnalysisMissing missingRaiseInfo ->
117118
missingRaiseInfoToText missingRaiseInfo

analysis/reanalyze/src/WriteDeadAnnotations.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ let offsetOfPosAdjustment = function
109109
| FirstVariant | Nothing -> 0
110110
| OtherVariant -> 2
111111

112-
let getLineInformation ~decl ~line =
112+
let getLineAnnotation ~decl ~line =
113113
if !Cli.json then
114114
let posAnnotation = decl |> getPosAnnotation in
115115
let offset = decl.posAdjustment |> offsetOfPosAdjustment in
@@ -127,13 +127,13 @@ let getLineInformation ~decl ~line =
127127
Format.asprintf "@. <-- line %d@. %s" decl.pos.pos_lnum
128128
(line |> lineToString)
129129

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"
131131

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
135135

136-
let onDeadDecl decl =
136+
let addLineAnnotation ~decl : lineAnnotation =
137137
let fileName = decl.pos.pos_fname in
138138
if Sys.file_exists fileName then (
139139
if fileName <> !currentFile then (

0 commit comments

Comments
 (0)