diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fd917d7b..93c9d8ba1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - Fix accidental output of extra `|` when producing exhaustive switch code for polyvariants. https://github.com/rescript-lang/rescript-vscode/pull/805 - Fix JS syntax highlighting in single-line FFI extension points. https://github.com/rescript-lang/rescript-vscode/pull/807 - Fix signature help in uncurried mode. https://github.com/rescript-lang/rescript-vscode/pull/809 +- Fix various issues in uncurried mode. https://github.com/rescript-lang/rescript-vscode/pull/810 ## 1.18.0 diff --git a/analysis/src/CompletionBackEnd.ml b/analysis/src/CompletionBackEnd.ml index 3ca0b904c..2888a37b1 100644 --- a/analysis/src/CompletionBackEnd.ml +++ b/analysis/src/CompletionBackEnd.ml @@ -1133,7 +1133,14 @@ let getOpens ~debug ~rawOpens ~package ~env = if debug && packageOpens <> [] then Printf.printf "%s\n" ("Package opens " - ^ String.concat " " (packageOpens |> List.map pathToString)); + ^ String.concat " " + (packageOpens + |> List.map (fun p -> + p + |> List.map (fun name -> + (* Unify formatting between curried and uncurried *) + if name = "PervasivesU" then "Pervasives" else name) + |> pathToString))); let resolvedOpens = resolveOpens ~env (List.rev (packageOpens @ rawOpens)) ~package in @@ -1147,8 +1154,11 @@ let getOpens ~debug ~rawOpens ~package ~env = |> List.map (fun (e : QueryEnv.t) -> let name = Uri.toString e.file.uri in - if Utils.startsWith name "pervasives." then - Filename.chop_extension name + (* Unify formatting between curried and uncurried *) + if + name = "pervasives.res" || name = "pervasives.resi" + || name = "pervasivesU.res" || name = "pervasivesU.resi" + then "pervasives" else name))); (* Last open takes priority *) List.rev resolvedOpens diff --git a/analysis/src/CompletionFrontEnd.ml b/analysis/src/CompletionFrontEnd.ml index 797f28248..dd3d933eb 100644 --- a/analysis/src/CompletionFrontEnd.ml +++ b/analysis/src/CompletionFrontEnd.ml @@ -148,7 +148,7 @@ let rec exprToContextPath (e : Parsetree.expression) = (match exprs with | [] -> None | exp :: _ -> exprToContextPath exp)) - | Pexp_ident {txt = Lident "|."} -> None + | Pexp_ident {txt = Lident ("|." | "|.u")} -> None | Pexp_ident {txt} -> Some (CPId (Utils.flattenLongIdent txt, Value)) | Pexp_field (e1, {txt = Lident name}) -> ( match exprToContextPath e1 with @@ -162,7 +162,7 @@ let rec exprToContextPath (e : Parsetree.expression) = | None -> None | Some contexPath -> Some (CPObj (contexPath, txt))) | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident "|."}}, + ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, [ (_, lhs); (_, {pexp_desc = Pexp_apply (d, args); pexp_loc; pexp_attributes}); @@ -175,7 +175,7 @@ let rec exprToContextPath (e : Parsetree.expression) = pexp_attributes; } | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident "|."}}, + ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, [(_, lhs); (_, {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes})] ) -> (* Transform away pipe with identifier *) @@ -211,13 +211,13 @@ let completePipeChain (exp : Parsetree.expression) = (* When the left side of the pipe we're completing is a function application. Example: someArray->Js.Array2.map(v => v + 2)-> *) | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident "|."}}, + ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, [_; (_, {pexp_desc = Pexp_apply (d, _)})] ) -> exprToContextPath exp |> Option.map (fun ctxPath -> (ctxPath, d.pexp_loc)) (* When the left side of the pipe we're completing is an identifier application. Example: someArray->filterAllTheGoodStuff-> *) | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident "|."}}, + ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, [_; (_, {pexp_desc = Pexp_ident _; pexp_loc})] ) -> exprToContextPath exp |> Option.map (fun ctxPath -> (ctxPath, pexp_loc)) | _ -> None @@ -813,7 +813,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text = scope := oldScope); resetCurrentCtxPath oldCtxPath | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident "|."; loc = opLoc}}, + ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u"); loc = opLoc}}, [ (_, lhs); (_, {pexp_desc = Pexp_extension _; pexp_loc = {loc_ghost = true}}); @@ -837,7 +837,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text = setResult (Cpath (CPId (lidPath, Value))) | Pexp_construct (lid, eOpt) -> let lidPath = flattenLidCheckDot lid in - if debug then + if debug && lid.txt <> Lident "Function$" then Printf.printf "Pexp_construct %s:%s %s\n" (lidPath |> String.concat "\n") (Loc.toString lid.loc) @@ -911,7 +911,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text = | _ -> Cpath (CPId (compNamePath, Module))) else iterateJsxProps ~iterator jsxProps | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident "|."}}, + ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, [ (_, lhs); (_, {pexp_desc = Pexp_ident {txt = Longident.Lident id; loc}}); @@ -920,13 +920,13 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text = (* Case foo->id *) setPipeResult ~lhs ~id |> ignore | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident "|."; loc = opLoc}}, + ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u"); loc = opLoc}}, [(_, lhs); _] ) when Loc.end_ opLoc = posCursor -> (* Case foo-> *) setPipeResult ~lhs ~id:"" |> ignore | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident "|."}}, + ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, [_; (_, {pexp_desc = Pexp_apply (funExpr, args)})] ) when (* Normally named arg completion fires when the cursor is right after the expression. E.g in foo(~<---there @@ -957,7 +957,8 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text = argCompletable |> iterateFnArguments ~isPipe:true ~args ~iterator; resetCurrentCtxPath oldCtxPath) | Some argCompletable -> setResult argCompletable) - | Pexp_apply ({pexp_desc = Pexp_ident {txt = Lident "|."}}, [_; _]) -> + | Pexp_apply + ({pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, [_; _]) -> (* Ignore any other pipe. *) () | Pexp_apply (funExpr, args) diff --git a/analysis/src/CompletionJsx.ml b/analysis/src/CompletionJsx.ml index aede04516..bf79e0401 100644 --- a/analysis/src/CompletionJsx.ml +++ b/analysis/src/CompletionJsx.ml @@ -731,7 +731,11 @@ let getJsxLabels ~componentPath ~findTypeOfValue ~package = in let rec getLabels (t : Types.type_expr) = match t.desc with - | Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> getLabels t1 + | Tlink t1 + | Tsubst t1 + | Tpoly (t1, []) + | Tconstr (Pident {name = "function$"}, [t1; _], _) -> + getLabels t1 | Tarrow ( Nolabel, { diff --git a/analysis/src/CreateInterface.ml b/analysis/src/CreateInterface.ml index 25048d4e8..023f38dc3 100644 --- a/analysis/src/CreateInterface.ml +++ b/analysis/src/CreateInterface.ml @@ -164,11 +164,13 @@ let printSignature ~extractor ~signature = let buf = Buffer.create 10 in - let getComponentTypeV3 (typ : Types.type_expr) = + let rec getComponentTypeV3 (typ : Types.type_expr) = let reactElement = Ctype.newconstr (Pdot (Pident (Ident.create "React"), "element", 0)) [] in match typ.desc with + | Tconstr (Pident {name = "function$"}, [typ; _], _) -> + getComponentTypeV3 typ | Tarrow (_, {desc = Tobject (tObj, _)}, retType, _) -> Some (tObj, retType) | Tconstr ( Pdot (Pident {name = "React"}, "component", _), @@ -183,11 +185,13 @@ let printSignature ~extractor ~signature = | _ -> None in - let getComponentTypeV4 (typ : Types.type_expr) = + let rec getComponentTypeV4 (typ : Types.type_expr) = let reactElement = Ctype.newconstr (Pdot (Pident (Ident.create "React"), "element", 0)) [] in match typ.desc with + | Tconstr (Pident {name = "function$"}, [typ; _], _) -> + getComponentTypeV4 typ | Tarrow (_, {desc = Tconstr (Path.Pident propsId, typeArgs, _)}, retType, _) when Ident.name propsId = "props" -> Some (typeArgs, retType) @@ -410,6 +414,8 @@ let printSignature ~extractor ~signature = let command ~path ~cmiFile = match Shared.tryReadCmi cmiFile with | Some cmi_info -> + (* For reading the config *) + let _ = Cmt.loadFullCmtFromPath ~path in let extractor = SourceFileExtractor.create ~path in printSignature ~extractor ~signature:cmi_info.cmi_sign | None -> "" diff --git a/analysis/src/Packages.ml b/analysis/src/Packages.ml index afe8e19b6..0f4d9b497 100644 --- a/analysis/src/Packages.ml +++ b/analysis/src/Packages.ml @@ -82,7 +82,11 @@ let newBsPackage ~rootPath = | None -> [] in let opens = - ["Pervasives"; "JsxModules"] :: opens_from_namespace + [ + (if uncurried then "PervasivesU" else "Pervasives"); + "JsxModules"; + ] + :: opens_from_namespace |> List.rev_append opens_from_bsc_flags |> List.map (fun path -> path @ ["place holder"]) in diff --git a/analysis/src/TypeUtils.ml b/analysis/src/TypeUtils.ml index 856ca07f9..369630775 100644 --- a/analysis/src/TypeUtils.ml +++ b/analysis/src/TypeUtils.ml @@ -198,12 +198,14 @@ let getBuiltinFromTypePath path = | Path.Pident id when Ident.name id = "result" -> Some Result | Path.Pident id when Ident.name id = "lazy_t" -> Some Lazy | Path.Pident id when Ident.name id = "char" -> Some Char - | Pdot (Pident id, "result", _) when Ident.name id = "Pervasives" -> + | Pdot (Pident id, "result", _) + when Ident.name id = "Pervasives" || Ident.name id = "PervasivesU" -> Some Result | _ -> None -let pathFromTypeExpr (t : Types.type_expr) = +let rec pathFromTypeExpr (t : Types.type_expr) = match t.desc with + | Tconstr (Pident {name = "function$"}, [t; _], _) -> pathFromTypeExpr t | Tconstr (path, _typeArgs, _) | Tlink {desc = Tconstr (path, _typeArgs, _)} | Tsubst {desc = Tconstr (path, _typeArgs, _)} @@ -513,7 +515,10 @@ let getArgs ~env (t : Types.type_expr) ~full = let rec getArgsLoop ~env (t : Types.type_expr) ~full ~currentArgumentPosition = match t.desc with - | Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> + | Tlink t1 + | Tsubst t1 + | Tpoly (t1, []) + | Tconstr (Pident {name = "function$"}, [t1; _], _) -> getArgsLoop ~full ~env ~currentArgumentPosition t1 | Tarrow (Labelled l, tArg, tRet, _) -> (SharedTypes.Completable.Labelled l, tArg) diff --git a/analysis/src/Xform.ml b/analysis/src/Xform.ml index 829b372a5..87166cad4 100644 --- a/analysis/src/Xform.ml +++ b/analysis/src/Xform.ml @@ -195,7 +195,10 @@ module AddTypeAnnotation = struct in let rec processFunction ~argNum (e : Parsetree.expression) = match e.pexp_desc with - | Pexp_fun (argLabel, _, pat, e) -> + | Pexp_fun (argLabel, _, pat, e) + | Pexp_construct + ( {txt = Lident "Function$"}, + Some {pexp_desc = Pexp_fun (argLabel, _, pat, e)} ) -> let isUnlabeledOnlyArg = argNum = 1 && argLabel = Nolabel && diff --git a/analysis/tests/package-lock.json b/analysis/tests/package-lock.json index c1d438a87..946ef95e9 100644 --- a/analysis/tests/package-lock.json +++ b/analysis/tests/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "rescript": "^11.0.0-alpha.1" + "rescript": "11.0.0-alpha.1" }, "devDependencies": { "@rescript/react": "^0.11.0-rc.3" diff --git a/analysis/tests/package.json b/analysis/tests/package.json index cb1651891..c3ef1f6b9 100644 --- a/analysis/tests/package.json +++ b/analysis/tests/package.json @@ -8,6 +8,6 @@ "@rescript/react": "^0.11.0-rc.3" }, "dependencies": { - "rescript": "^11.0.0-alpha.1" + "rescript": "11.0.0-alpha.1" } } diff --git a/analysis/tests/src/SignatureHelpUncurried.res b/analysis/tests/src/SignatureHelpUncurried.res deleted file mode 100644 index fea6b8dfd..000000000 --- a/analysis/tests/src/SignatureHelpUncurried.res +++ /dev/null @@ -1,78 +0,0 @@ -@@uncurried - -type someVariant = One | Two | Three - -/** Does stuff. */ -let someFunc = (one: int, ~two: option=?, ~three: unit => unit, ~four: someVariant, ()) => { - ignore(one) - ignore(two) - ignore(three()) - ignore(four) -} - -let otherFunc = (first: string, second: int, third: float) => { - ignore(first) - ignore(second) - ignore(third) -} - -// let _ = someFunc( -// ^she - -// let _ = someFunc(1 -// ^she - -// let _ = someFunc(123, ~two -// ^she - -// let _ = someFunc(123, ~two="123" -// ^she - -// let _ = someFunc(123, ~two="123", ~four -// ^she - -// let _ = someFunc(123, ~two="123", ~four=O -// ^she - -// let _ = otherFunc( -// ^she - -// let _ = otherFunc("123" -// ^she - -// let _ = otherFunc("123", 123, 123.0) -// ^she - -// let _ = Completion.Lib.foo(~age -// ^she - -let iAmSoSpecial = (iJustHaveOneArg: string) => { - ignore(iJustHaveOneArg) -} - -// let _ = iAmSoSpecial( -// ^she - -// let _ = "hello"->otherFunc(1 -// ^she - -let fn = (age: int, name: string, year: int) => { - ignore(age) - ignore(name) - ignore(year) -} - -// let _ = fn(22, ) -// ^she - -// let _ = fn(22, , 2023) -// ^she - -// let _ = fn(12, "hello", ) -// ^she - -// let _ = fn({ iAmSoSpecial() }) -// ^she - -// let _ = fn({ iAmSoSpecial({ someFunc() }) }) -// ^she diff --git a/analysis/tests/src/expected/SignatureHelpUncurried.res.txt b/analysis/tests/src/expected/SignatureHelpUncurried.res.txt deleted file mode 100644 index be2ba4290..000000000 --- a/analysis/tests/src/expected/SignatureHelpUncurried.res.txt +++ /dev/null @@ -1,396 +0,0 @@ -Signature help src/SignatureHelpUncurried.res 18:20 -posCursor:[18:19] posNoWhite:[18:18] Found expr:[18:11->18:20] -Pexp_apply ...[18:11->18:19] (...[48:0->18:20]) -posCursor:[18:19] posNoWhite:[18:18] Found expr:[18:11->18:19] -Pexp_ident someFunc:[18:11->18:19] -Completable: Cpath Value[someFunc] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[someFunc] -Path someFunc -argAtCursor: unlabelled<0> -extracted params: -[. - int, ~two: string=?, ~three: (. unit) => unit, ~four: someVariant, unit] -{ - "signatures": [{ - "label": "(.\n int,\n ~two: string=?,\n ~three: (. unit) => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [1, 8], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [12, 26], "documentation": {"kind": "markdown", "value": "```rescript\noption\n```"}}, {"label": [30, 54], "documentation": {"kind": "markdown", "value": "```rescript\n(. unit) => unit\n```"}}, {"label": [58, 76], "documentation": {"kind": "markdown", "value": "```rescript\nsomeVariant\n```\n```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelpUncurried.res%22%2C2%2C0%5D)"}}, {"label": [80, 84], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}], - "documentation": {"kind": "markdown", "value": " Does stuff. "} - }], - "activeSignature": 0, - "activeParameter": 0 -} - -Signature help src/SignatureHelpUncurried.res 21:21 -posCursor:[21:19] posNoWhite:[21:18] Found expr:[21:11->21:21] -Pexp_apply ...[21:11->21:19] (...[21:20->21:21]) -posCursor:[21:19] posNoWhite:[21:18] Found expr:[21:11->21:19] -Pexp_ident someFunc:[21:11->21:19] -Completable: Cpath Value[someFunc] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[someFunc] -Path someFunc -argAtCursor: unlabelled<0> -extracted params: -[. - int, ~two: string=?, ~three: (. unit) => unit, ~four: someVariant, unit] -{ - "signatures": [{ - "label": "(.\n int,\n ~two: string=?,\n ~three: (. unit) => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [1, 8], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [12, 26], "documentation": {"kind": "markdown", "value": "```rescript\noption\n```"}}, {"label": [30, 54], "documentation": {"kind": "markdown", "value": "```rescript\n(. unit) => unit\n```"}}, {"label": [58, 76], "documentation": {"kind": "markdown", "value": "```rescript\nsomeVariant\n```\n```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelpUncurried.res%22%2C2%2C0%5D)"}}, {"label": [80, 84], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}], - "documentation": {"kind": "markdown", "value": " Does stuff. "} - }], - "activeSignature": 0, - "activeParameter": 0 -} - -Signature help src/SignatureHelpUncurried.res 24:29 -posCursor:[24:19] posNoWhite:[24:18] Found expr:[24:11->24:29] -Pexp_apply ...[24:11->24:19] (...[24:20->24:23], ~two24:26->24:29=...[24:26->24:29]) -posCursor:[24:19] posNoWhite:[24:18] Found expr:[24:11->24:19] -Pexp_ident someFunc:[24:11->24:19] -Completable: Cpath Value[someFunc] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[someFunc] -Path someFunc -argAtCursor: ~two -extracted params: -[. - int, ~two: string=?, ~three: (. unit) => unit, ~four: someVariant, unit] -{ - "signatures": [{ - "label": "(.\n int,\n ~two: string=?,\n ~three: (. unit) => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [1, 8], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [12, 26], "documentation": {"kind": "markdown", "value": "```rescript\noption\n```"}}, {"label": [30, 54], "documentation": {"kind": "markdown", "value": "```rescript\n(. unit) => unit\n```"}}, {"label": [58, 76], "documentation": {"kind": "markdown", "value": "```rescript\nsomeVariant\n```\n```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelpUncurried.res%22%2C2%2C0%5D)"}}, {"label": [80, 84], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}], - "documentation": {"kind": "markdown", "value": " Does stuff. "} - }], - "activeSignature": 0, - "activeParameter": 1 -} - -Signature help src/SignatureHelpUncurried.res 27:33 -posCursor:[27:19] posNoWhite:[27:18] Found expr:[27:11->27:35] -Pexp_apply ...[27:11->27:19] (...[27:20->27:23], ~two27:26->27:29=...[27:30->27:35]) -posCursor:[27:19] posNoWhite:[27:18] Found expr:[27:11->27:19] -Pexp_ident someFunc:[27:11->27:19] -Completable: Cpath Value[someFunc] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[someFunc] -Path someFunc -argAtCursor: ~two -extracted params: -[. - int, ~two: string=?, ~three: (. unit) => unit, ~four: someVariant, unit] -{ - "signatures": [{ - "label": "(.\n int,\n ~two: string=?,\n ~three: (. unit) => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [1, 8], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [12, 26], "documentation": {"kind": "markdown", "value": "```rescript\noption\n```"}}, {"label": [30, 54], "documentation": {"kind": "markdown", "value": "```rescript\n(. unit) => unit\n```"}}, {"label": [58, 76], "documentation": {"kind": "markdown", "value": "```rescript\nsomeVariant\n```\n```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelpUncurried.res%22%2C2%2C0%5D)"}}, {"label": [80, 84], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}], - "documentation": {"kind": "markdown", "value": " Does stuff. "} - }], - "activeSignature": 0, - "activeParameter": 1 -} - -Signature help src/SignatureHelpUncurried.res 30:38 -posCursor:[30:19] posNoWhite:[30:18] Found expr:[30:11->30:42] -Pexp_apply ...[30:11->30:19] (...[30:20->30:23], ~two30:26->30:29=...[30:30->30:35], ~four30:38->30:42=...[30:38->30:42]) -posCursor:[30:19] posNoWhite:[30:18] Found expr:[30:11->30:19] -Pexp_ident someFunc:[30:11->30:19] -Completable: Cpath Value[someFunc] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[someFunc] -Path someFunc -argAtCursor: ~four -extracted params: -[. - int, ~two: string=?, ~three: (. unit) => unit, ~four: someVariant, unit] -{ - "signatures": [{ - "label": "(.\n int,\n ~two: string=?,\n ~three: (. unit) => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [1, 8], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [12, 26], "documentation": {"kind": "markdown", "value": "```rescript\noption\n```"}}, {"label": [30, 54], "documentation": {"kind": "markdown", "value": "```rescript\n(. unit) => unit\n```"}}, {"label": [58, 76], "documentation": {"kind": "markdown", "value": "```rescript\nsomeVariant\n```\n```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelpUncurried.res%22%2C2%2C0%5D)"}}, {"label": [80, 84], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}], - "documentation": {"kind": "markdown", "value": " Does stuff. "} - }], - "activeSignature": 0, - "activeParameter": 3 -} - -Signature help src/SignatureHelpUncurried.res 33:42 -posCursor:[33:19] posNoWhite:[33:18] Found expr:[33:11->33:44] -Pexp_apply ...[33:11->33:19] (...[33:20->33:23], ~two33:26->33:29=...[33:30->33:35], ~four33:38->33:42=...[33:43->33:44]) -posCursor:[33:19] posNoWhite:[33:18] Found expr:[33:11->33:19] -Pexp_ident someFunc:[33:11->33:19] -Completable: Cpath Value[someFunc] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[someFunc] -Path someFunc -argAtCursor: ~four -extracted params: -[. - int, ~two: string=?, ~three: (. unit) => unit, ~four: someVariant, unit] -{ - "signatures": [{ - "label": "(.\n int,\n ~two: string=?,\n ~three: (. unit) => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [1, 8], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [12, 26], "documentation": {"kind": "markdown", "value": "```rescript\noption\n```"}}, {"label": [30, 54], "documentation": {"kind": "markdown", "value": "```rescript\n(. unit) => unit\n```"}}, {"label": [58, 76], "documentation": {"kind": "markdown", "value": "```rescript\nsomeVariant\n```\n```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelpUncurried.res%22%2C2%2C0%5D)"}}, {"label": [80, 84], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}], - "documentation": {"kind": "markdown", "value": " Does stuff. "} - }], - "activeSignature": 0, - "activeParameter": 3 -} - -Signature help src/SignatureHelpUncurried.res 36:21 -posCursor:[36:20] posNoWhite:[36:19] Found expr:[36:11->36:21] -Pexp_apply ...[36:11->36:20] (...[48:0->36:21]) -posCursor:[36:20] posNoWhite:[36:19] Found expr:[36:11->36:20] -Pexp_ident otherFunc:[36:11->36:20] -Completable: Cpath Value[otherFunc] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[otherFunc] -Path otherFunc -argAtCursor: unlabelled<0> -extracted params: -[. string, int, float] -{ - "signatures": [{ - "label": "(. string, int, float) => unit", - "parameters": [{"label": [1, 9], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}, {"label": [11, 14], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}, {"label": [16, 21], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}] - }], - "activeSignature": 0, - "activeParameter": 0 -} - -Signature help src/SignatureHelpUncurried.res 39:24 -posCursor:[39:20] posNoWhite:[39:19] Found expr:[39:11->39:26] -Pexp_apply ...[39:11->39:20] (...[39:21->39:26]) -posCursor:[39:20] posNoWhite:[39:19] Found expr:[39:11->39:20] -Pexp_ident otherFunc:[39:11->39:20] -Completable: Cpath Value[otherFunc] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[otherFunc] -Path otherFunc -argAtCursor: unlabelled<0> -extracted params: -[. string, int, float] -{ - "signatures": [{ - "label": "(. string, int, float) => unit", - "parameters": [{"label": [1, 9], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}, {"label": [11, 14], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}, {"label": [16, 21], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}] - }], - "activeSignature": 0, - "activeParameter": 0 -} - -Signature help src/SignatureHelpUncurried.res 42:35 -posCursor:[42:20] posNoWhite:[42:19] Found expr:[42:11->42:39] -Pexp_apply ...[42:11->42:20] (...[42:21->42:26], ...[42:28->42:31], ...[42:33->42:38]) -posCursor:[42:20] posNoWhite:[42:19] Found expr:[42:11->42:20] -Pexp_ident otherFunc:[42:11->42:20] -Completable: Cpath Value[otherFunc] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[otherFunc] -Path otherFunc -argAtCursor: unlabelled<2> -extracted params: -[. string, int, float] -{ - "signatures": [{ - "label": "(. string, int, float) => unit", - "parameters": [{"label": [1, 9], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}, {"label": [11, 14], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}, {"label": [16, 21], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}] - }], - "activeSignature": 0, - "activeParameter": 2 -} - -Signature help src/SignatureHelpUncurried.res 45:33 -posCursor:[45:29] posNoWhite:[45:28] Found expr:[45:11->45:34] -Pexp_apply ...[45:11->45:29] (~age45:31->45:34=...[45:31->45:34]) -posCursor:[45:29] posNoWhite:[45:28] Found expr:[45:11->45:29] -Pexp_ident Completion.Lib.foo:[45:11->45:29] -Completable: Cpath Value[Completion, Lib, foo] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[Completion, Lib, foo] -Path Completion.Lib.foo -argAtCursor: ~age -extracted params: -[(~age: int, ~name: string] -{ - "signatures": [{ - "label": "(~age: int, ~name: string) => string", - "parameters": [{"label": [0, 10], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [12, 25], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}] - }], - "activeSignature": 0, - "activeParameter": 0 -} - -Signature help src/SignatureHelpUncurried.res 52:24 -posCursor:[52:23] posNoWhite:[52:22] Found expr:[52:11->52:24] -Pexp_apply ...[52:11->52:23] (...[58:0->52:24]) -posCursor:[52:23] posNoWhite:[52:22] Found expr:[52:11->52:23] -Pexp_ident iAmSoSpecial:[52:11->52:23] -Completable: Cpath Value[iAmSoSpecial] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[iAmSoSpecial] -Path iAmSoSpecial -argAtCursor: unlabelled<0> -extracted params: -[. string] -{ - "signatures": [{ - "label": "(. string) => unit", - "parameters": [{"label": [1, 9], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}] - }], - "activeSignature": 0, - "activeParameter": 0 -} - -Signature help src/SignatureHelpUncurried.res 55:31 -posCursor:[55:29] posNoWhite:[55:28] Found expr:[55:11->55:31] -Pexp_apply ...[55:18->55:20] (...[55:11->55:18], ...[55:20->55:31]) -posCursor:[55:29] posNoWhite:[55:28] Found expr:[55:20->55:31] -Pexp_apply ...[55:20->55:29] (...[55:30->55:31]) -posCursor:[55:29] posNoWhite:[55:28] Found expr:[55:20->55:29] -Pexp_ident otherFunc:[55:20->55:29] -Completable: Cpath Value[otherFunc] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[otherFunc] -Path otherFunc -argAtCursor: unlabelled<1> -extracted params: -[. string, int, float] -{ - "signatures": [{ - "label": "(. string, int, float) => unit", - "parameters": [{"label": [1, 9], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}, {"label": [11, 14], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}, {"label": [16, 21], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}] - }], - "activeSignature": 0, - "activeParameter": 1 -} - -Signature help src/SignatureHelpUncurried.res 64:17 -posCursor:[64:13] posNoWhite:[64:12] Found expr:[64:11->64:19] -Pexp_apply ...[64:11->64:13] (...[64:14->64:16]) -posCursor:[64:13] posNoWhite:[64:12] Found expr:[64:11->64:13] -Pexp_ident fn:[64:11->64:13] -Completable: Cpath Value[fn] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[fn] -Path fn -argAtCursor: unlabelled<1> -extracted params: -[. int, string, int] -{ - "signatures": [{ - "label": "(. int, string, int) => unit", - "parameters": [{"label": [1, 6], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [8, 14], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [16, 19], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}] - }], - "activeSignature": 0, - "activeParameter": 1 -} - -Signature help src/SignatureHelpUncurried.res 67:17 -posCursor:[67:13] posNoWhite:[67:12] Found expr:[67:11->67:25] -Pexp_apply ...[67:11->67:13] (...[67:14->67:16], ...[67:20->67:24]) -posCursor:[67:13] posNoWhite:[67:12] Found expr:[67:11->67:13] -Pexp_ident fn:[67:11->67:13] -Completable: Cpath Value[fn] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[fn] -Path fn -argAtCursor: unlabelled<1> -extracted params: -[. int, string, int] -{ - "signatures": [{ - "label": "(. int, string, int) => unit", - "parameters": [{"label": [1, 6], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [8, 14], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [16, 19], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}] - }], - "activeSignature": 0, - "activeParameter": 1 -} - -Signature help src/SignatureHelpUncurried.res 70:26 -posCursor:[70:13] posNoWhite:[70:12] Found expr:[70:11->70:28] -Pexp_apply ...[70:11->70:13] (...[70:14->70:16], ...[70:18->70:25]) -posCursor:[70:13] posNoWhite:[70:12] Found expr:[70:11->70:13] -Pexp_ident fn:[70:11->70:13] -Completable: Cpath Value[fn] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[fn] -Path fn -argAtCursor: unlabelled<2> -extracted params: -[. int, string, int] -{ - "signatures": [{ - "label": "(. int, string, int) => unit", - "parameters": [{"label": [1, 6], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [8, 14], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [16, 19], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}] - }], - "activeSignature": 0, - "activeParameter": 2 -} - -Signature help src/SignatureHelpUncurried.res 73:29 -posCursor:[73:28] posNoWhite:[73:27] Found expr:[73:11->73:33] -Pexp_apply ...[73:11->73:13] (...[73:16->73:30]) -posCursor:[73:28] posNoWhite:[73:27] Found expr:[73:16->73:30] -Pexp_apply ...[73:16->73:28] (...[73:29->73:30]) -posCursor:[73:28] posNoWhite:[73:27] Found expr:[73:16->73:28] -Pexp_ident iAmSoSpecial:[73:16->73:28] -Completable: Cpath Value[iAmSoSpecial] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[iAmSoSpecial] -Path iAmSoSpecial -argAtCursor: unlabelled<0> -extracted params: -[. string] -{ - "signatures": [{ - "label": "(. string) => unit", - "parameters": [{"label": [1, 9], "documentation": {"kind": "markdown", "value": "```rescript\nstring\n```"}}] - }], - "activeSignature": 0, - "activeParameter": 0 -} - -Signature help src/SignatureHelpUncurried.res 76:40 -posCursor:[76:39] posNoWhite:[76:38] Found expr:[76:11->76:47] -Pexp_apply ...[76:11->76:13] (...[76:16->76:44]) -posCursor:[76:39] posNoWhite:[76:38] Found expr:[76:16->76:44] -Pexp_apply ...[76:16->76:28] (...[76:31->76:41]) -posCursor:[76:39] posNoWhite:[76:38] Found expr:[76:31->76:41] -Pexp_apply ...[76:31->76:39] (...[76:40->76:41]) -posCursor:[76:39] posNoWhite:[76:38] Found expr:[76:31->76:39] -Pexp_ident someFunc:[76:31->76:39] -Completable: Cpath Value[someFunc] -Package opens Pervasives.JsxModules.place holder -Resolved opens 1 pervasives -ContextPath Value[someFunc] -Path someFunc -argAtCursor: unlabelled<0> -extracted params: -[. - int, ~two: string=?, ~three: (. unit) => unit, ~four: someVariant, unit] -{ - "signatures": [{ - "label": "(.\n int,\n ~two: string=?,\n ~three: (. unit) => unit,\n ~four: someVariant,\n unit,\n) => unit", - "parameters": [{"label": [1, 8], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}, {"label": [12, 26], "documentation": {"kind": "markdown", "value": "```rescript\noption\n```"}}, {"label": [30, 54], "documentation": {"kind": "markdown", "value": "```rescript\n(. unit) => unit\n```"}}, {"label": [58, 76], "documentation": {"kind": "markdown", "value": "```rescript\nsomeVariant\n```\n```rescript\ntype someVariant = One | Two | Three\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22SignatureHelpUncurried.res%22%2C2%2C0%5D)"}}, {"label": [80, 84], "documentation": {"kind": "markdown", "value": "```rescript\nint\n```"}}], - "documentation": {"kind": "markdown", "value": " Does stuff. "} - }], - "activeSignature": 0, - "activeParameter": 0 -} - diff --git a/analysis/vendor/ml/printtyp.ml b/analysis/vendor/ml/printtyp.ml index 1f6a5da34..74a5c694a 100644 --- a/analysis/vendor/ml/printtyp.ml +++ b/analysis/vendor/ml/printtyp.ml @@ -49,10 +49,11 @@ let ident ppf id = pp_print_string ppf (ident_name id) (* Print a path *) let ident_pervasives = Ident.create_persistent "Pervasives" +let ident_pervasives_u = Ident.create_persistent "PervasivesU" let printing_env = ref Env.empty let non_shadowed_pervasive = function | Pdot(Pident id, s, _pos) as path -> - Ident.same id ident_pervasives && + (Ident.same id ident_pervasives || Ident.same id ident_pervasives_u) && (try Path.same path (Env.lookup_type (Lident s) !printing_env) with Not_found -> true) | _ -> false diff --git a/analysis/vendor/res_syntax/res_outcome_printer.ml b/analysis/vendor/res_syntax/res_outcome_printer.ml index da54dc626..7be5f6d1e 100644 --- a/analysis/vendor/res_syntax/res_outcome_printer.ml +++ b/analysis/vendor/res_syntax/res_outcome_printer.ml @@ -322,9 +322,7 @@ let rec printOutTypeDoc (outType : Outcometree.out_type) = ] and printOutArrowType ~uncurried typ = - let uncurried = - if !Config.uncurried <> Legacy then not uncurried else uncurried - in + let uncurried = Res_uncurried.getDotted ~uncurried !Config.uncurried in let typArgs, typ = collectArrowArgs typ [] in let args = Doc.join