From b6bddebd2853faeda68f419de239b38e1216770e Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Fri, 18 Nov 2022 07:29:16 +0100 Subject: [PATCH] Test create interface file JSX V4. --- analysis/tests/bsconfig.json | 2 +- analysis/tests/src/expected/CodeLens.res.txt | 2 +- .../src/expected/CreateInterface.res.txt | 40 +++++++++---------- analysis/tests/src/expected/Div.res.txt | 3 +- analysis/tests/src/expected/Fragment.res.txt | 4 +- analysis/tests/src/expected/Hover.res.txt | 10 ----- analysis/tests/src/expected/Jsx2.res.txt | 4 -- analysis/tests/src/expected/Jsx2.resi.txt | 4 +- 8 files changed, 25 insertions(+), 44 deletions(-) diff --git a/analysis/tests/bsconfig.json b/analysis/tests/bsconfig.json index cef97db16..979db5c5c 100644 --- a/analysis/tests/bsconfig.json +++ b/analysis/tests/bsconfig.json @@ -11,5 +11,5 @@ ], "bsc-flags": ["-w -33-44"], "bs-dependencies": ["@rescript/react"], - "jsx": { "version": 3 } + "jsx": { "version": 4 } } diff --git a/analysis/tests/src/expected/CodeLens.res.txt b/analysis/tests/src/expected/CodeLens.res.txt index 06472d5e4..92203f3bc 100644 --- a/analysis/tests/src/expected/CodeLens.res.txt +++ b/analysis/tests/src/expected/CodeLens.res.txt @@ -1,7 +1,7 @@ Code Lens src/CodeLens.res [{ "range": {"start": {"line": 9, "character": 4}, "end": {"line": 9, "character": 8}}, - "command": {"title": "{\"name\": string} => React.element", "command": ""} + "command": {"title": "'name", "command": ""} }, { "range": {"start": {"line": 4, "character": 4}, "end": {"line": 4, "character": 6}}, "command": {"title": "(~opt1: int=?, ~a: int, ~b: int, unit, ~opt2: int=?, unit, ~c: int) => int", "command": ""} diff --git a/analysis/tests/src/expected/CreateInterface.res.txt b/analysis/tests/src/expected/CreateInterface.res.txt index 4e1212948..877f23c89 100644 --- a/analysis/tests/src/expected/CreateInterface.res.txt +++ b/analysis/tests/src/expected/CreateInterface.res.txt @@ -1,19 +1,19 @@ Create Interface src/CreateInterface.res type r = {name: string, age: int} let add: (~x: int, ~y: int) => int -@react.component -let make: (~name: string) => React.element +type props<'name> = {name: 'name} +let make: props => React.element module Other: { - @react.component - let otherComponentName: (~name: string) => React.element + type props<'name> = {name: 'name} + let otherComponentName: props => React.element } module Mod: { - @react.component - let make: (~name: string) => React.element + type props<'name> = {name: 'name} + let make: props => React.element } module type ModTyp = { - @react.component - let make: (~name: string) => React.element + type props<'name> = {name: 'name} + let make: React.componentLike, React.element> } @module("path") external dirname: string => string = "dirname" @module("path") @variadic @@ -55,15 +55,15 @@ module type FT = { module Functor: ( X: { let a: int - @react.component - let make: (~name: string) => React.element + type props<'name> = {name: 'name} + let make: React.componentLike, React.element> let b: int }, Y: ModTyp, ) => { - @react.component - let make: (~name: string) => React.element + type props<'name> = {name: 'name} + let make: React.componentLike, React.element> } } module NormaList = List @@ -79,8 +79,8 @@ module type OptT = { let withOpt2: (~x: int=?, ~y: int) => int } module type Opt3 = { - @react.component - let withOpt3: (~x: option, ~y: int) => int + type props<'x, 'y> = {x: 'x, y: 'y} + let withOpt3: React.componentLike, int>, int> } } module Opt: { @@ -95,18 +95,18 @@ module Opt: { let withOpt2: (~x: int=?, ~y: int) => int } module Opt3: { - @react.component - let withOpt3: (~x: option, ~y: int) => int + type props<'x, 'y> = {x: 'x, y: 'y} + let withOpt3: props, int> => int } module type Opt3 = { - @react.component - let withOpt3: (~x: option, ~y: int) => int + type props<'x, 'y> = {x: 'x, y: 'y} + let withOpt3: props, int> => int } } module Opt2: OptT module Opt3 = Opt module Memo: { - @react.component - let make: (~name: string) => React.element + type props<'name> = {name: 'name} + let make: React.component> } diff --git a/analysis/tests/src/expected/Div.res.txt b/analysis/tests/src/expected/Div.res.txt index 9e09ba202..07d5cde73 100644 --- a/analysis/tests/src/expected/Div.res.txt +++ b/analysis/tests/src/expected/Div.res.txt @@ -1,6 +1,5 @@ Hover src/Div.res 0:10 -getLocItem #3: heuristic for
-{"contents": {"kind": "markdown", "value": "```rescript\n(\n string,\n ~props: ReactDOM_V3.domProps=?,\n array,\n) => React.element\n```\n\n---\n\n```\n \n```\n```rescript\ntype ReactDOM_V3.domProps = Props.domProps\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22ReactDOM_V3.res%22%2C57%2C2%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype React.element = Jsx.element\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C0%2C0%5D)\n"}} +{"contents": {"kind": "markdown", "value": "```rescript\nstring\n```"}} Complete src/Div.res 3:17 posCursor:[3:17] posNoWhite:[3:16] Found expr:[3:4->3:17] diff --git a/analysis/tests/src/expected/Fragment.res.txt b/analysis/tests/src/expected/Fragment.res.txt index 4000b1501..676c2ef7f 100644 --- a/analysis/tests/src/expected/Fragment.res.txt +++ b/analysis/tests/src/expected/Fragment.res.txt @@ -1,7 +1,5 @@ Hover src/Fragment.res 6:19 -getLocItem #4: heuristic for within fragments: take make as makeProps does not work -the type is not great but jump to definition works -{"contents": {"kind": "markdown", "value": "```rescript\nReact.component<{\"children\": React.element}>\n```\n\n---\n\n```\n \n```\n```rescript\ntype React.component<'props> = Jsx.component<'props>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C12%2C0%5D)\n"}} +{"contents": {"kind": "markdown", "value": "```rescript\nReact.component>\n```\n\n---\n\n```\n \n```\n```rescript\ntype React.component<'props> = Jsx.component<'props>\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C12%2C0%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype SectionHeader.props<'children> = {children: 'children}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Fragment.res%22%2C1%2C2%5D)\n\n\n---\n\n```\n \n```\n```rescript\ntype React.element = Jsx.element\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22React.res%22%2C0%2C0%5D)\n"}} Hover src/Fragment.res 9:56 Nothing at that position. Now trying to use completion. diff --git a/analysis/tests/src/expected/Hover.res.txt b/analysis/tests/src/expected/Hover.res.txt index 3eb902317..a01f29366 100644 --- a/analysis/tests/src/expected/Hover.res.txt +++ b/analysis/tests/src/expected/Hover.res.txt @@ -20,19 +20,9 @@ Hover src/Hover.res 33:4 {"contents": {"kind": "markdown", "value": "```rescript\nunit => int\n```\n\nDoc comment for functionWithTypeAnnotation"}} Hover src/Hover.res 37:13 -getLocItem #5: heuristic for JSX and compiler combined: -~x becomes Props#x -heuristic for: [Props, x], give loc of `x` -n1:Props n2:name {"contents": {"kind": "markdown", "value": "```rescript\nstring\n```"}} Hover src/Hover.res 42:15 -getLocItem #7: heuristic for JSX on type-annotated labeled (~arg:t): -(~arg:t) becomes Props#arg -Props has the location range of arg:t -arg has the location range of arg -heuristic for: [Props, arg], give loc of `arg` -n1:Props n2:name {"contents": {"kind": "markdown", "value": "```rescript\nstring\n```"}} Hover src/Hover.res 46:10 diff --git a/analysis/tests/src/expected/Jsx2.res.txt b/analysis/tests/src/expected/Jsx2.res.txt index 8dfba3444..2b3b921f9 100644 --- a/analysis/tests/src/expected/Jsx2.res.txt +++ b/analysis/tests/src/expected/Jsx2.res.txt @@ -1,6 +1,4 @@ Definition src/Jsx2.res 5:9 -getLocItem #4: heuristic for within fragments: take make as makeProps does not work -the type is not great but jump to definition works {"uri": "Jsx2.res", "range": {"start": {"line": 2, "character": 6}, "end": {"line": 2, "character": 10}}} Complete src/Jsx2.res 8:15 @@ -204,8 +202,6 @@ Completable: Cjsx([M], k, [prop, k]) }] Definition src/Jsx2.res 58:11 -getLocItem #4: heuristic for within fragments: take make as makeProps does not work -the type is not great but jump to definition works {"uri": "Component.res", "range": {"start": {"line": 1, "character": 4}, "end": {"line": 1, "character": 8}}} Complete src/Jsx2.res 68:10 diff --git a/analysis/tests/src/expected/Jsx2.resi.txt b/analysis/tests/src/expected/Jsx2.resi.txt index aa95d5bc3..b79c52420 100644 --- a/analysis/tests/src/expected/Jsx2.resi.txt +++ b/analysis/tests/src/expected/Jsx2.resi.txt @@ -1,7 +1,5 @@ Hover src/Jsx2.resi 1:4 -getLocItem #1: heuristic for makeProps in interface files -n1:componentLike n2:unit n3:string -{"contents": {"kind": "markdown", "value": "```rescript\n(~first: string, ~key: string=?, unit) => {\"first\": string}\n```"}} +{"contents": {"kind": "markdown", "value": "```rescript\nprops\n```\n\n---\n\n```\n \n```\n```rescript\ntype props<'first> = {first: 'first}\n```\nGo to: [Type definition](command:rescript-vscode.go_to_location?%5B%22Jsx2.resi%22%2C0%2C0%5D)\n"}} Hover src/Jsx2.resi 4:4 {"contents": {"kind": "markdown", "value": "```rescript\nint\n```"}}