From e8306feb051ebb2fde3e118a695ac7c71551d91d Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 14 Jan 2024 19:38:48 -0300 Subject: [PATCH] format code --- analysis/reanalyze/src/Arnold.ml | 8 +- analysis/reanalyze/src/DeadValue.ml | 12 +- analysis/reanalyze/src/Exception.ml | 54 ++++----- analysis/reanalyze/src/Log_.ml | 8 +- analysis/reanalyze/src/Reanalyze.ml | 4 +- .../reanalyze/src/WriteDeadAnnotations.ml | 62 +++++----- analysis/src/CompletionFrontEnd.ml | 108 ++++++++--------- analysis/src/DocumentSymbol.ml | 18 +-- analysis/src/Files.ml | 2 +- analysis/src/Hint.ml | 20 ++-- analysis/src/Packages.ml | 113 +++++++++--------- analysis/src/ProcessExtra.ml | 8 +- analysis/src/References.ml | 2 +- analysis/src/Scope.ml | 14 +-- analysis/src/SemanticTokens.ml | 24 ++-- tools/bin/version.ml | 2 +- 16 files changed, 230 insertions(+), 229 deletions(-) diff --git a/analysis/reanalyze/src/Arnold.ml b/analysis/reanalyze/src/Arnold.ml index e78222053..64f10b1f1 100644 --- a/analysis/reanalyze/src/Arnold.ml +++ b/analysis/reanalyze/src/Arnold.ml @@ -813,10 +813,10 @@ module Compile = struct | _ -> Stats.logHygieneNamedArgValue ~label ~loc; raise ArgError - [@@raises ArgError] + [@@raises ArgError] in functionArg () - [@@raises ArgError] + [@@raises ArgError] in let functionArgsOpt = try Some (functionDefinition.kind |> List.map getFunctionArg) @@ -1320,7 +1320,7 @@ let traverseAst ~valueBindingsTable = progressFunctionsFromAttributes valueBinding.vb_attributes with | None -> (progressFunctions, functionsToAnalyze) - | Some newProgressFunctions -> ( + | Some newProgressFunctions -> ( StringSet.union (StringSet.of_list newProgressFunctions) progressFunctions, @@ -1328,7 +1328,7 @@ let traverseAst ~valueBindingsTable = | Tpat_var (id, _) -> (Ident.name id, valueBinding.vb_expr.exp_loc) :: functionsToAnalyze - | _ -> functionsToAnalyze ))) + | _ -> functionsToAnalyze )) (StringSet.empty, []) in (progressFunctions0, functionsToAnalyze0 |> List.rev) diff --git a/analysis/reanalyze/src/DeadValue.ml b/analysis/reanalyze/src/DeadValue.ml index ffbc8361b..791213e08 100644 --- a/analysis/reanalyze/src/DeadValue.ml +++ b/analysis/reanalyze/src/DeadValue.ml @@ -45,12 +45,12 @@ let collectValueBinding super self (vb : Typedtree.value_binding) = | _ -> false in (if (not exists) && not isFirstClassModule then - (* This is never toplevel currently *) - let isToplevel = oldLastBinding = Location.none in - let sideEffects = SideEffects.checkExpr vb.vb_expr in - name - |> addValueDeclaration ~isToplevel ~loc ~moduleLoc:currentModulePath.loc - ~optionalArgs ~path ~sideEffects); + (* This is never toplevel currently *) + let isToplevel = oldLastBinding = Location.none in + let sideEffects = SideEffects.checkExpr vb.vb_expr in + name + |> addValueDeclaration ~isToplevel ~loc + ~moduleLoc:currentModulePath.loc ~optionalArgs ~path ~sideEffects); (match PosHash.find_opt decls loc_start with | None -> () | Some decl -> diff --git a/analysis/reanalyze/src/Exception.ml b/analysis/reanalyze/src/Exception.ml index 2973c3946..95bade64a 100644 --- a/analysis/reanalyze/src/Exception.ml +++ b/analysis/reanalyze/src/Exception.ml @@ -138,20 +138,20 @@ module Event = struct if !Common.Cli.debug then Log_.item "%a@." print ev; let nestedExceptions = loop Exceptions.empty nestedEvents in (if Exceptions.isEmpty nestedExceptions (* catch-all *) then - let name = - match nestedEvents with - | {kind = Call {callee}} :: _ -> callee |> Common.Path.toName - | _ -> "expression" |> Name.create - in - Log_.warning ~loc - (Common.ExceptionAnalysis - { - message = - Format.asprintf - "@{%s@} does not raise and is annotated with \ - redundant @doesNotRaise" - (name |> Name.toString); - })); + let name = + match nestedEvents with + | {kind = Call {callee}} :: _ -> callee |> Common.Path.toName + | _ -> "expression" |> Name.create + in + Log_.warning ~loc + (Common.ExceptionAnalysis + { + message = + Format.asprintf + "@{%s@} does not raise and is annotated with \ + redundant @doesNotRaise" + (name |> Name.toString); + })); loop exnSet rest | ({kind = Catches nestedEvents; exceptions} as ev) :: rest -> if !Common.Cli.debug then Log_.item "%a@." print ev; @@ -192,11 +192,11 @@ module Checks = struct let missingAnnotations = Exceptions.diff raiseSet exceptions in let redundantAnnotations = Exceptions.diff exceptions raiseSet in (if not (Exceptions.isEmpty missingAnnotations) then - let description = - Common.ExceptionAnalysisMissing - {exnName; exnTable; raiseSet; missingAnnotations; locFull} - in - Log_.warning ~loc description); + let description = + Common.ExceptionAnalysisMissing + {exnName; exnTable; raiseSet; missingAnnotations; locFull} + in + Log_.warning ~loc description); if not (Exceptions.isEmpty redundantAnnotations) then Log_.warning ~loc (Common.ExceptionAnalysis @@ -356,14 +356,14 @@ let traverseAst () = cases |> iterCases self | _ -> super.expr self expr |> ignore); (if isDoesNoRaise then - let nestedEvents = !currentEvents in - currentEvents := - { - Event.exceptions = Exceptions.empty; - loc; - kind = DoesNotRaise nestedEvents; - } - :: oldEvents); + let nestedEvents = !currentEvents in + currentEvents := + { + Event.exceptions = Exceptions.empty; + loc; + kind = DoesNotRaise nestedEvents; + } + :: oldEvents); expr in let getExceptionsFromAnnotations attributes = diff --git a/analysis/reanalyze/src/Log_.ml b/analysis/reanalyze/src/Log_.ml index ec98987cd..2bb6aa0e9 100644 --- a/analysis/reanalyze/src/Log_.ml +++ b/analysis/reanalyze/src/Log_.ml @@ -75,10 +75,10 @@ module Loc = struct pos_cnum = char; pos_fname = (let open Filename in - match is_implicit pos.pos_fname with - | _ when !Cli.ci -> basename pos.pos_fname - | true -> concat (Sys.getcwd ()) pos.pos_fname - | false -> pos.pos_fname); + match is_implicit pos.pos_fname with + | _ when !Cli.ci -> basename pos.pos_fname + | true -> concat (Sys.getcwd ()) pos.pos_fname + | false -> pos.pos_fname); } in Location.print_loc ppf diff --git a/analysis/reanalyze/src/Reanalyze.ml b/analysis/reanalyze/src/Reanalyze.ml index 0355c9cb7..e52a9c1f4 100644 --- a/analysis/reanalyze/src/Reanalyze.ml +++ b/analysis/reanalyze/src/Reanalyze.ml @@ -110,7 +110,7 @@ let cli () = let versionAndExit () = print_endline usage; exit 0 - [@@raises exit] + [@@raises exit] in let rec setAll cmtRoot = RunConfig.all (); @@ -216,7 +216,7 @@ let cli () = if !analysisKindSet = false then setConfig (); let cmtRoot = !cmtRootRef in runAnalysisAndReport ~cmtRoot - [@@raises exit] +[@@raises exit] module RunConfig = RunConfig module Log_ = Log_ diff --git a/analysis/reanalyze/src/WriteDeadAnnotations.ml b/analysis/reanalyze/src/WriteDeadAnnotations.ml index fb99fa24a..642bb3d87 100644 --- a/analysis/reanalyze/src/WriteDeadAnnotations.ml +++ b/analysis/reanalyze/src/WriteDeadAnnotations.ml @@ -42,33 +42,33 @@ let rec lineToString_ {original; declarations} = { original = (if String.length original >= col && col > 0 then - let original1, original2 = - try - ( String.sub original 0 col, - String.sub original col (originalLen - col) ) - with Invalid_argument _ -> (original, "") - in - if language = Res && declKind = VariantCase then - if - String.length original2 >= 2 - && (String.sub [@doesNotRaise]) original2 0 2 = "| " - then - original1 ^ "| " ^ annotationStr - ^ (String.sub [@doesNotRaise]) original2 2 - (String.length original2 - 2) - else if - String.length original2 >= 1 - && (String.sub [@doesNotRaise]) original2 0 1 = "|" - then - original1 ^ "|" ^ annotationStr - ^ (String.sub [@doesNotRaise]) original2 1 - (String.length original2 - 1) - else original1 ^ "| " ^ annotationStr ^ original2 - else original1 ^ annotationStr ^ original2 - else - match language = Ml with - | true -> original ^ annotationStr - | false -> annotationStr ^ original); + let original1, original2 = + try + ( String.sub original 0 col, + String.sub original col (originalLen - col) ) + with Invalid_argument _ -> (original, "") + in + if language = Res && declKind = VariantCase then + if + String.length original2 >= 2 + && (String.sub [@doesNotRaise]) original2 0 2 = "| " + then + original1 ^ "| " ^ annotationStr + ^ (String.sub [@doesNotRaise]) original2 2 + (String.length original2 - 2) + else if + String.length original2 >= 1 + && (String.sub [@doesNotRaise]) original2 0 1 = "|" + then + original1 ^ "|" ^ annotationStr + ^ (String.sub [@doesNotRaise]) original2 1 + (String.length original2 - 1) + else original1 ^ "| " ^ annotationStr ^ original2 + else original1 ^ annotationStr ^ original2 + else + match language = Ml with + | true -> original ^ annotationStr + | false -> annotationStr ^ original); declarations = nextDeclarations; } |> lineToString_ @@ -91,7 +91,7 @@ let readFile fileName = let line = {original = input_line channel; declarations = []} in lines := line :: !lines; loop () - [@@raises End_of_file] + [@@raises End_of_file] in try loop () with End_of_file -> @@ -122,9 +122,9 @@ let getLineAnnotation ~decl ~line = posAnnotation.pos_cnum - posAnnotation.pos_bol + offset ) ~text: (if decl.posAdjustment = FirstVariant then - (* avoid syntax error *) - "| @dead " - else "@dead ") + (* avoid syntax error *) + "| @dead " + else "@dead ") ~action:"Suppress dead code warning" else Format.asprintf "@. <-- line %d@. %s" decl.pos.pos_lnum diff --git a/analysis/src/CompletionFrontEnd.ml b/analysis/src/CompletionFrontEnd.ml index 8131e6b12..0fc4f3d48 100644 --- a/analysis/src/CompletionFrontEnd.ml +++ b/analysis/src/CompletionFrontEnd.ml @@ -697,60 +697,60 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor let attribute (iterator : Ast_iterator.iterator) ((id, payload) : Parsetree.attribute) = (if String.length id.txt >= 4 && String.sub id.txt 0 4 = "res." then - (* skip: internal parser attribute *) () - else if id.loc.loc_ghost then () - else if id.loc |> Loc.hasPos ~pos:posBeforeCursor then - let posStart, posEnd = Loc.range id.loc in - match - (Pos.positionToOffset text posStart, Pos.positionToOffset text posEnd) - with - | Some offsetStart, Some offsetEnd -> - (* Can't trust the parser's location - E.g. @foo. let x... gives as label @foo.let *) - let label = - let rawLabel = - String.sub text offsetStart (offsetEnd - offsetStart) - in - let ( ++ ) x y = - match (x, y) with - | Some i1, Some i2 -> Some (min i1 i2) - | Some _, None -> x - | None, _ -> y - in - let label = - match - String.index_opt rawLabel ' ' - ++ String.index_opt rawLabel '\t' - ++ String.index_opt rawLabel '\r' - ++ String.index_opt rawLabel '\n' - with - | None -> rawLabel - | Some i -> String.sub rawLabel 0 i - in - if label <> "" && label.[0] = '@' then - String.sub label 1 (String.length label - 1) - else label - in - found := true; - if debug then - Printf.printf "Attribute id:%s:%s label:%s\n" id.txt - (Loc.toString id.loc) label; - setResult (Completable.Cdecorator label) - | _ -> () - else if id.txt = "module" then - (match payload with - | PStr - [ - { - pstr_desc = - Pstr_eval - ( {pexp_loc; pexp_desc = Pexp_constant (Pconst_string (s, _))}, - _ ); - }; - ] - when locHasCursor pexp_loc -> - setResult (Completable.CdecoratorPayload (Module s)) - | _ -> ())); + (* skip: internal parser attribute *) () + else if id.loc.loc_ghost then () + else if id.loc |> Loc.hasPos ~pos:posBeforeCursor then + let posStart, posEnd = Loc.range id.loc in + match + (Pos.positionToOffset text posStart, Pos.positionToOffset text posEnd) + with + | Some offsetStart, Some offsetEnd -> + (* Can't trust the parser's location + E.g. @foo. let x... gives as label @foo.let *) + let label = + let rawLabel = + String.sub text offsetStart (offsetEnd - offsetStart) + in + let ( ++ ) x y = + match (x, y) with + | Some i1, Some i2 -> Some (min i1 i2) + | Some _, None -> x + | None, _ -> y + in + let label = + match + String.index_opt rawLabel ' ' + ++ String.index_opt rawLabel '\t' + ++ String.index_opt rawLabel '\r' + ++ String.index_opt rawLabel '\n' + with + | None -> rawLabel + | Some i -> String.sub rawLabel 0 i + in + if label <> "" && label.[0] = '@' then + String.sub label 1 (String.length label - 1) + else label + in + found := true; + if debug then + Printf.printf "Attribute id:%s:%s label:%s\n" id.txt + (Loc.toString id.loc) label; + setResult (Completable.Cdecorator label) + | _ -> () + else if id.txt = "module" then + match payload with + | PStr + [ + { + pstr_desc = + Pstr_eval + ( {pexp_loc; pexp_desc = Pexp_constant (Pconst_string (s, _))}, + _ ); + }; + ] + when locHasCursor pexp_loc -> + setResult (Completable.CdecoratorPayload (Module s)) + | _ -> ()); Ast_iterator.default_iterator.attribute iterator (id, payload) in let rec iterateFnArguments ~args ~iterator ~isPipe diff --git a/analysis/src/DocumentSymbol.ml b/analysis/src/DocumentSymbol.ml index 356541c5f..7beaafc0d 100644 --- a/analysis/src/DocumentSymbol.ml +++ b/analysis/src/DocumentSymbol.ml @@ -135,15 +135,15 @@ let command ~path = in (if Filename.check_suffix path ".res" then - let parser = - Res_driver.parsingEngine.parseImplementation ~forPrinter:false - in - let {Res_driver.parsetree = structure} = parser ~filename:path in - iterator.structure iterator structure |> ignore - else - let parser = Res_driver.parsingEngine.parseInterface ~forPrinter:false in - let {Res_driver.parsetree = signature} = parser ~filename:path in - iterator.signature iterator signature |> ignore); + let parser = + Res_driver.parsingEngine.parseImplementation ~forPrinter:false + in + let {Res_driver.parsetree = structure} = parser ~filename:path in + iterator.structure iterator structure |> ignore + else + let parser = Res_driver.parsingEngine.parseInterface ~forPrinter:false in + let {Res_driver.parsetree = signature} = parser ~filename:path in + iterator.signature iterator signature |> ignore); let isInside ({ range = diff --git a/analysis/src/Files.ml b/analysis/src/Files.ml index 9ab016da5..12d63794b 100644 --- a/analysis/src/Files.ml +++ b/analysis/src/Files.ml @@ -20,7 +20,7 @@ let relpath base path = let baselen = String.length base in let rest = String.sub path baselen (String.length path - baselen) in (if rest <> "" && rest.[0] = Filename.dir_sep.[0] then sliceToEnd rest 1 - else rest) + else rest) |> removeExtraDots else let rec loop bp pp = diff --git a/analysis/src/Hint.ml b/analysis/src/Hint.ml index 227d70f38..18c66f624 100644 --- a/analysis/src/Hint.ml +++ b/analysis/src/Hint.ml @@ -71,11 +71,11 @@ let inlay ~path ~pos ~maxLength ~debug = in let iterator = {Ast_iterator.default_iterator with value_binding} in (if Files.classifySourceFile path = Res then - let parser = - Res_driver.parsingEngine.parseImplementation ~forPrinter:false - in - let {Res_driver.parsetree = structure} = parser ~filename:path in - iterator.structure iterator structure |> ignore); + let parser = + Res_driver.parsingEngine.parseImplementation ~forPrinter:false + in + let {Res_driver.parsetree = structure} = parser ~filename:path in + iterator.structure iterator structure |> ignore); match Cmt.loadFullCmtFromPath ~path with | None -> None | Some full -> @@ -135,11 +135,11 @@ let codeLens ~path ~debug = (* We only print code lenses in implementation files. This is because they'd be redundant in interface files, where the definition itself will be the same thing as what would've been printed in the code lens. *) (if Files.classifySourceFile path = Res then - let parser = - Res_driver.parsingEngine.parseImplementation ~forPrinter:false - in - let {Res_driver.parsetree = structure} = parser ~filename:path in - iterator.structure iterator structure |> ignore); + let parser = + Res_driver.parsingEngine.parseImplementation ~forPrinter:false + in + let {Res_driver.parsetree = structure} = parser ~filename:path in + iterator.structure iterator structure |> ignore); match Cmt.loadFullCmtFromPath ~path with | None -> None | Some full -> diff --git a/analysis/src/Packages.ml b/analysis/src/Packages.ml index c0ef38b03..f2a8f0838 100644 --- a/analysis/src/Packages.ml +++ b/analysis/src/Packages.ml @@ -32,9 +32,10 @@ let newBsPackage ~rootPath = let bsconfigJson = Filename.concat rootPath "bsconfig.json" in let parseRaw raw = - let libBs = match !Cfg.isDocGenFromCompiler with - | true -> BuildSystem.getStdlib rootPath - | false -> BuildSystem.getLibBs rootPath + let libBs = + match !Cfg.isDocGenFromCompiler with + | true -> BuildSystem.getStdlib rootPath + | false -> BuildSystem.getLibBs rootPath in match Json.parse raw with | Some config -> ( @@ -48,10 +49,10 @@ let newBsPackage ~rootPath = (let namespace = FindFiles.getNamespace config in let rescriptVersion = getReScriptVersion () in let suffix = - match config |> Json.get "suffix" with - | Some (String suffix) -> suffix - | _ -> ".js" - in + match config |> Json.get "suffix" with + | Some (String suffix) -> suffix + | _ -> ".js" + in let uncurried = let ns = config |> Json.get "uncurried" in match (rescriptVersion, ns) with @@ -132,55 +133,55 @@ let newBsPackage ~rootPath = namespace; builtInCompletionModules = (if - opens_from_bsc_flags - |> List.find_opt (fun opn -> - match opn with - | ["RescriptCore"] -> true - | _ -> false) - |> Option.is_some - then - { - arrayModulePath = ["Array"]; - optionModulePath = ["Option"]; - stringModulePath = ["String"]; - intModulePath = ["Int"]; - floatModulePath = ["Float"]; - promiseModulePath = ["Promise"]; - listModulePath = ["List"]; - resultModulePath = ["Result"]; - exnModulePath = ["Exn"]; - } - else if - opens_from_bsc_flags - |> List.find_opt (fun opn -> - match opn with - | ["Belt"] -> true - | _ -> false) - |> Option.is_some - then - { - arrayModulePath = ["Array"]; - optionModulePath = ["Option"]; - stringModulePath = ["Js"; "String2"]; - intModulePath = ["Int"]; - floatModulePath = ["Float"]; - promiseModulePath = ["Js"; "Promise"]; - listModulePath = ["List"]; - resultModulePath = ["Result"]; - exnModulePath = ["Js"; "Exn"]; - } - else - { - arrayModulePath = ["Js"; "Array2"]; - optionModulePath = ["Belt"; "Option"]; - stringModulePath = ["Js"; "String2"]; - intModulePath = ["Belt"; "Int"]; - floatModulePath = ["Belt"; "Float"]; - promiseModulePath = ["Js"; "Promise"]; - listModulePath = ["Belt"; "List"]; - resultModulePath = ["Belt"; "Result"]; - exnModulePath = ["Js"; "Exn"]; - }); + opens_from_bsc_flags + |> List.find_opt (fun opn -> + match opn with + | ["RescriptCore"] -> true + | _ -> false) + |> Option.is_some + then + { + arrayModulePath = ["Array"]; + optionModulePath = ["Option"]; + stringModulePath = ["String"]; + intModulePath = ["Int"]; + floatModulePath = ["Float"]; + promiseModulePath = ["Promise"]; + listModulePath = ["List"]; + resultModulePath = ["Result"]; + exnModulePath = ["Exn"]; + } + else if + opens_from_bsc_flags + |> List.find_opt (fun opn -> + match opn with + | ["Belt"] -> true + | _ -> false) + |> Option.is_some + then + { + arrayModulePath = ["Array"]; + optionModulePath = ["Option"]; + stringModulePath = ["Js"; "String2"]; + intModulePath = ["Int"]; + floatModulePath = ["Float"]; + promiseModulePath = ["Js"; "Promise"]; + listModulePath = ["List"]; + resultModulePath = ["Result"]; + exnModulePath = ["Js"; "Exn"]; + } + else + { + arrayModulePath = ["Js"; "Array2"]; + optionModulePath = ["Belt"; "Option"]; + stringModulePath = ["Js"; "String2"]; + intModulePath = ["Belt"; "Int"]; + floatModulePath = ["Belt"; "Float"]; + promiseModulePath = ["Js"; "Promise"]; + listModulePath = ["Belt"; "List"]; + resultModulePath = ["Belt"; "Result"]; + exnModulePath = ["Js"; "Exn"]; + }); uncurried; }))) | None -> None diff --git a/analysis/src/ProcessExtra.ml b/analysis/src/ProcessExtra.ml index e0a90d656..e153c76cb 100644 --- a/analysis/src/ProcessExtra.ml +++ b/analysis/src/ProcessExtra.ml @@ -9,8 +9,8 @@ let addReference ~extra stamp loc = (loc :: (if Hashtbl.mem extra.internalReferences stamp then - Hashtbl.find extra.internalReferences stamp - else [])) + Hashtbl.find extra.internalReferences stamp + else [])) let extraForFile ~(file : File.t) = let extra = initExtra () in @@ -66,8 +66,8 @@ let addExternalReference ~extra moduleName path tip loc = ((path, tip, loc) :: (if Hashtbl.mem extra.externalReferences moduleName then - Hashtbl.find extra.externalReferences moduleName - else [])) + Hashtbl.find extra.externalReferences moduleName + else [])) let addFileReference ~extra moduleName loc = let newLocs = diff --git a/analysis/src/References.ml b/analysis/src/References.ml index e19439a20..e047a2ba1 100644 --- a/analysis/src/References.ml +++ b/analysis/src/References.ml @@ -66,7 +66,7 @@ let getLocItem ~full ~pos ~debug = | [ ({locType = Typed (_, _, LocalReference _)} as li1); ({locType = Typed (_, _, GlobalReference ("Js_OO", ["unsafe_downgrade"], _))} - as li2); + as li2); li3; ] (* For older compiler 9.0 or earlier *) diff --git a/analysis/src/Scope.ml b/analysis/src/Scope.ml index 54a6de558..0e092d2a4 100644 --- a/analysis/src/Scope.ml +++ b/analysis/src/Scope.ml @@ -14,7 +14,7 @@ let itemToString item = | Module (s, loc) -> "Module " ^ s ^ " " ^ Loc.toString loc | Value (s, loc, _, _) -> "Value " ^ s ^ " " ^ Loc.toString loc | Type (s, loc) -> "Type " ^ s ^ " " ^ Loc.toString loc - [@@live] +[@@live] let create () : t = [] let addConstructor ~name ~loc x = Constructor (name, loc) :: x @@ -24,12 +24,12 @@ let addOpen ~lid x = Open (Utils.flattenLongIdent lid @ ["place holder"]) :: x let addValue ~name ~loc ?contextPath x = let showDebug = !Cfg.debugFollowCtxPath in (if showDebug then - match contextPath with - | None -> Printf.printf "adding value '%s', no ctxPath\n" name - | Some contextPath -> - if showDebug then - Printf.printf "adding value '%s' with ctxPath: %s\n" name - (SharedTypes.Completable.contextPathToString contextPath)); + match contextPath with + | None -> Printf.printf "adding value '%s', no ctxPath\n" name + | Some contextPath -> + if showDebug then + Printf.printf "adding value '%s' with ctxPath: %s\n" name + (SharedTypes.Completable.contextPathToString contextPath)); Value (name, loc, contextPath, x) :: x let addType ~name ~loc x = Type (name, loc) :: x diff --git a/analysis/src/SemanticTokens.ml b/analysis/src/SemanticTokens.ml index 41fb70353..9ddd47b61 100644 --- a/analysis/src/SemanticTokens.ml +++ b/analysis/src/SemanticTokens.ml @@ -283,18 +283,18 @@ let command ~debug ~emitter ~path = (* there's an off-by one somehow in the AST *) in (if not selfClosing then - let lineStart, colStart = Loc.start pexp_loc in - let lineEnd, colEnd = Loc.end_ pexp_loc in - let length = if lineStart = lineEnd then colEnd - colStart else 0 in - let lineEndWhole, colEndWhole = Loc.end_ e.pexp_loc in - if length > 0 && colEndWhole > length then ( - emitter - |> emitJsxClose ~debug ~lid:lident.txt - ~pos:(lineEndWhole, colEndWhole - 1); - emitter (* <-- *) - |> emitJsxTag ~debug ~name:">" ~pos:posOfGreatherthanAfterProps; - emitter (* ... <-- *) - |> emitJsxTag ~debug ~name:">" ~pos:posOfFinalGreatherthan)); + let lineStart, colStart = Loc.start pexp_loc in + let lineEnd, colEnd = Loc.end_ pexp_loc in + let length = if lineStart = lineEnd then colEnd - colStart else 0 in + let lineEndWhole, colEndWhole = Loc.end_ e.pexp_loc in + if length > 0 && colEndWhole > length then ( + emitter + |> emitJsxClose ~debug ~lid:lident.txt + ~pos:(lineEndWhole, colEndWhole - 1); + emitter (* <-- *) + |> emitJsxTag ~debug ~name:">" ~pos:posOfGreatherthanAfterProps; + emitter (* ... <-- *) + |> emitJsxTag ~debug ~name:">" ~pos:posOfFinalGreatherthan)); args |> List.iter (fun (_lbl, arg) -> iterator.expr iterator arg) | Pexp_apply diff --git a/tools/bin/version.ml b/tools/bin/version.ml index 36ca949bb..6dd12fb01 100644 --- a/tools/bin/version.ml +++ b/tools/bin/version.ml @@ -1 +1 @@ -let version = "0.3.0" \ No newline at end of file +let version = "0.3.0"