Skip to content

Commit 6f8e6e0

Browse files
committed
One component per module.
1 parent 155a198 commit 6f8e6e0

File tree

5 files changed

+109
-79
lines changed

5 files changed

+109
-79
lines changed

analysis/tests/src/CreateInterface.res

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ let add = (~x, ~y) => x + y
77
@react.component
88
let make = (~name) => React.string(name)
99

10-
@react.component
11-
let otherComponentName = (~name) => React.string(name)
10+
module Other = {
11+
@react.component
12+
let otherComponentName = (~name) => React.string(name)
13+
}
1214

1315
module Mod = {
1416
@react.component
@@ -40,8 +42,7 @@ let f1 = 10
4042

4143
@inline let f2 = "some string"
4244

43-
@genType
44-
@inline
45+
@genType @inline
4546
let f3 = 10
4647

4748
@genType @inline
@@ -95,32 +96,42 @@ module type OptT = {
9596
@react.component
9697
let withOpt1: (~x: int=?, ~y: int) => int
9798

98-
@react.component
99-
let withOpt2: (~x: int=?, ~y: int) => int
99+
module type Opt2 = {
100+
@react.component
101+
let withOpt2: (~x: int=?, ~y: int) => int
102+
}
100103

101-
@react.component
102-
let withOpt3: (~x: option<int>, ~y: int) => int
104+
module type Opt3 = {
105+
@react.component
106+
let withOpt3: (~x: option<int>, ~y: int) => int
107+
}
103108
}
104109

105110
module Opt = {
106111
@react.component
107112
let withOpt1 = (~x=3, ~y) => x + y
108113

109-
@react.component
110-
let withOpt2 = (~x=?, ~y) =>
111-
switch x {
112-
| None => 0
113-
| Some(x) => x
114-
} +
115-
y
114+
module Opt2 = {
115+
@react.component
116+
let withOpt2 = (~x: option<int>=?, ~y: int) =>
117+
switch x {
118+
| None => 0
119+
| Some(x) => x
120+
} +
121+
y
122+
}
123+
module type Opt2 = module type of Opt2
116124

117-
@react.component
118-
let withOpt3 = (~x, ~y) =>
119-
switch x {
120-
| None => 0
121-
| Some(x) => x
122-
} +
123-
y
125+
module Opt3 = {
126+
@react.component
127+
let withOpt3 = (~x: option<int>, ~y: int) =>
128+
switch x {
129+
| None => 0
130+
| Some(x) => x
131+
} +
132+
y
133+
}
134+
module type Opt3 = module type of Opt3
124135
}
125136

126137
module Opt2: OptT = Opt

analysis/tests/src/Hover.res

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ let functionWithTypeAnnotation: unit => int = () => 1
3838
let make = (~name) => React.string(name)
3939
// ^hov
4040

41-
@react.component
42-
let make2 = (~name: string) => React.string(name)
43-
// ^hov
41+
module C2 = {
42+
@react.component
43+
let make2 = (~name: string) => React.string(name)
44+
// ^hov
45+
}
4446

4547
let num = 34
4648
// ^hov

analysis/tests/src/Jsx2.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module Ext = {
6464
external make: (~align: string=?) => React.element = "Typography"
6565
}
6666

67-
let _ = (Ext.make, Ext.makeProps)
67+
let _ = Ext.make
6868

6969
// <Ext al
7070
// ^com

analysis/tests/src/expected/CreateInterface.res.txt

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ type r = {name: string, age: int}
33
let add: (~x: int, ~y: int) => int
44
@react.component
55
let make: (~name: string) => React.element
6-
@react.component
7-
let otherComponentName: (~name: string) => React.element
6+
module Other: {
7+
@react.component
8+
let otherComponentName: (~name: string) => React.element
9+
}
810
module Mod: {
911
@react.component
1012
let make: (~name: string) => React.element
@@ -28,8 +30,7 @@ external padLeft: (
2830
@inline
2931
let f1: int
3032
@inline let f2: string
31-
@genType
32-
@inline
33+
@genType @inline
3334
let f3: int
3435
@genType @inline
3536
let f4: string
@@ -73,18 +74,34 @@ and D: ModTyp
7374
module type OptT = {
7475
@react.component
7576
let withOpt1: (~x: int=?, ~y: int) => int
76-
@react.component
77-
let withOpt2: (~x: int=?, ~y: int) => int
78-
@react.component
79-
let withOpt3: (~x: option<int>, ~y: int) => int
77+
module type Opt2 = {
78+
@react.component
79+
let withOpt2: (~x: int=?, ~y: int) => int
80+
}
81+
module type Opt3 = {
82+
@react.component
83+
let withOpt3: (~x: option<int>, ~y: int) => int
84+
}
8085
}
8186
module Opt: {
8287
@react.component
8388
let withOpt1: (~x: int=?, ~y: int) => int
84-
@react.component
85-
let withOpt2: (~x: int=?, ~y: int) => int
86-
@react.component
87-
let withOpt3: (~x: option<int>, ~y: int) => int
89+
module Opt2: {
90+
@react.component
91+
let withOpt2: (~x: int=?, ~y: int) => int
92+
}
93+
module type Opt2 = {
94+
@react.component
95+
let withOpt2: (~x: int=?, ~y: int) => int
96+
}
97+
module Opt3: {
98+
@react.component
99+
let withOpt3: (~x: option<int>, ~y: int) => int
100+
}
101+
module type Opt3 = {
102+
@react.component
103+
let withOpt3: (~x: option<int>, ~y: int) => int
104+
}
88105
}
89106
module Opt2: OptT
90107
module Opt3 = Opt

analysis/tests/src/expected/Hover.res.txt

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ heuristic for: [Props, x], give loc of `x`
2626
n1:Props n2:name
2727
{"contents": "```rescript\nstring\n```"}
2828

29-
Hover src/Hover.res 41:13
29+
Hover src/Hover.res 42:15
3030
getLocItem #7: heuristic for JSX on type-annotated labeled (~arg:t):
3131
(~arg:t) becomes Props#arg
3232
Props has the location range of arg:t
@@ -35,84 +35,84 @@ heuristic for: [Props, arg], give loc of `arg`
3535
n1:Props n2:name
3636
{"contents": "```rescript\nstring\n```"}
3737

38-
Hover src/Hover.res 44:10
38+
Hover src/Hover.res 46:10
3939
{"contents": "```rescript\nint\n```"}
4040

41-
Hover src/Hover.res 47:13
41+
Hover src/Hover.res 49:13
4242
{"contents": "```rescript\nmodule Logger = {\n let log: string => unit\n}\n```"}
4343

44-
Hover src/Hover.res 52:7
44+
Hover src/Hover.res 54:7
4545
{"contents": "```rescript\nmodule Logger = {\n let log: string => unit\n}\n```"}
4646

47-
Definition src/Hover.res 58:14
48-
{"uri": "Hover.res", "range": {"start": {"line": 47, "character": 12}, "end": {"line": 47, "character": 18}}}
47+
Definition src/Hover.res 60:14
48+
{"uri": "Hover.res", "range": {"start": {"line": 49, "character": 12}, "end": {"line": 49, "character": 18}}}
4949

50-
Hover src/Hover.res 61:9
50+
Hover src/Hover.res 63:9
5151
{"contents": "```rescript\nmodule IdDefinedTwice = {\n let y: int\n let _x: int\n}\n```"}
5252

53-
Hover src/Hover.res 72:7
53+
Hover src/Hover.res 74:7
5454
{"contents": "```rescript\nmodule A = {\n let x: int\n}\n```"}
5555

56-
Hover src/Hover.res 75:7
56+
Hover src/Hover.res 77:7
5757
{"contents": "```rescript\nmodule A = {\n let x: int\n}\n```"}
5858

59-
Hover src/Hover.res 89:10
59+
Hover src/Hover.res 91:10
6060
Nothing at that position. Now trying to use completion.
61-
posCursor:[89:10] posNoWhite:[89:8] Found expr:[86:3->89:9]
62-
JSX <Comp:[86:3->86:7] > _children:86:7
61+
posCursor:[91:10] posNoWhite:[91:8] Found expr:[88:3->91:9]
62+
JSX <Comp:[88:3->88:7] > _children:88:7
6363
null
6464

65-
Hover src/Hover.res 96:10
65+
Hover src/Hover.res 98:10
6666
Nothing at that position. Now trying to use completion.
67-
posCursor:[96:10] posNoWhite:[96:9] Found expr:[93:3->96:10]
68-
JSX <Comp1:[93:3->93:8] > _children:93:8
67+
posCursor:[98:10] posNoWhite:[98:9] Found expr:[95:3->98:10]
68+
JSX <Comp1:[95:3->95:8] > _children:95:8
6969
null
7070

71-
Hover src/Hover.res 101:25
71+
Hover src/Hover.res 103:25
7272
{"contents": "```rescript\nfloat\n```"}
7373

74-
Hover src/Hover.res 104:21
74+
Hover src/Hover.res 106:21
7575
{"contents": "```rescript\nint\n```"}
7676

77-
Hover src/Hover.res 114:16
77+
Hover src/Hover.res 116:16
7878
{"contents": "```rescript\nAA.cond<[< #str(string)]> => AA.cond<[< #str(string)]>\n```"}
7979

80-
Hover src/Hover.res 117:25
80+
Hover src/Hover.res 119:25
8181
{"contents": "```rescript\nAA.cond<[< #str(string)]> => AA.cond<[< #str(string)]>\n```"}
8282

83-
Hover src/Hover.res 120:3
83+
Hover src/Hover.res 122:3
8484
Nothing at that position. Now trying to use completion.
85-
Attribute id:live:[120:0->120:5] label:live
85+
Attribute id:live:[122:0->122:5] label:live
8686
Completable: Cdecorator(live)
8787
{"contents": "The `@live` decorator is for reanalyze, a static analysis tool for ReScript that can do dead code analysis.\n\n`@live` tells the dead code analysis that the value should be considered live, even though it might appear to be dead. This is typically used in case of FFI where there are indirect ways to access values. It can be added to everything that could otherwise be considered unused by the dead code analysis - values, functions, arguments, records, individual record fields, and so on.\n\n[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#live-decorator).\n\nHint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!"}
8888

89-
Hover src/Hover.res 123:4
89+
Hover src/Hover.res 125:4
9090
{"contents": "```rescript\n(. ()) => unit => int\n```"}
9191

92-
Hover src/Hover.res 129:4
92+
Hover src/Hover.res 131:4
9393
{"contents": "```rescript\n(. ()) => (. ()) => int\n```"}
9494

95-
Hover src/Hover.res 132:4
95+
Hover src/Hover.res 134:4
9696
{"contents": "```rescript\n(. unit, unit) => int\n```"}
9797

98-
Hover src/Hover.res 135:5
98+
Hover src/Hover.res 137:5
9999
{"contents": "```rescript\n(. ()) => unit => int\n```"}
100100

101-
Hover src/Hover.res 142:9
101+
Hover src/Hover.res 144:9
102102
{"contents": "```rescript\nint\n```\n\ndoc comment 1"}
103103

104-
Hover src/Hover.res 146:6
104+
Hover src/Hover.res 148:6
105105
{"contents": "```rescript\nint\n```\n\n doc comment 2 "}
106106

107-
Hover src/Hover.res 163:23
107+
Hover src/Hover.res 165:23
108108
{"contents": "```rescript\nfoo<bar>\n```\n\n```rescript\ntype foo<'a> = {content: 'a, zzz: string}\n```"}
109109

110-
Hover src/Hover.res 165:22
110+
Hover src/Hover.res 167:22
111111
{"contents": "```rescript\nfoobar\n```\n\n```rescript\ntype foobar = foo<bar>\n```"}
112112

113-
Complete src/Hover.res 168:16
114-
posCursor:[168:16] posNoWhite:[168:15] Found expr:[168:5->168:16]
115-
Pexp_field [168:5->168:15] _:[174:2->168:16]
113+
Complete src/Hover.res 170:16
114+
posCursor:[170:16] posNoWhite:[170:15] Found expr:[170:5->170:16]
115+
Pexp_field [170:5->170:15] _:[176:2->170:16]
116116
Completable: Cpath Value[x1].content.""
117117
[{
118118
"label": "age",
@@ -122,9 +122,9 @@ Completable: Cpath Value[x1].content.""
122122
"documentation": null
123123
}]
124124

125-
Complete src/Hover.res 171:16
126-
posCursor:[171:16] posNoWhite:[171:15] Found expr:[171:5->171:16]
127-
Pexp_field [171:5->171:15] _:[174:2->171:16]
125+
Complete src/Hover.res 173:16
126+
posCursor:[173:16] posNoWhite:[173:15] Found expr:[173:5->173:16]
127+
Pexp_field [173:5->173:15] _:[176:2->173:16]
128128
Completable: Cpath Value[x2].content.""
129129
[{
130130
"label": "age",
@@ -134,9 +134,9 @@ Completable: Cpath Value[x2].content.""
134134
"documentation": null
135135
}]
136136

137-
Complete src/Hover.res 180:16
138-
posCursor:[180:16] posNoWhite:[180:15] Found expr:[180:5->180:16]
139-
Pexp_field [180:5->180:15] _:[185:0->180:16]
137+
Complete src/Hover.res 182:16
138+
posCursor:[182:16] posNoWhite:[182:15] Found expr:[182:5->182:16]
139+
Pexp_field [182:5->182:15] _:[187:0->182:16]
140140
Completable: Cpath Value[y1].content.""
141141
[{
142142
"label": "age",
@@ -146,9 +146,9 @@ Completable: Cpath Value[y1].content.""
146146
"documentation": null
147147
}]
148148

149-
Complete src/Hover.res 183:16
150-
posCursor:[183:16] posNoWhite:[183:15] Found expr:[183:5->183:16]
151-
Pexp_field [183:5->183:15] _:[185:0->183:16]
149+
Complete src/Hover.res 185:16
150+
posCursor:[185:16] posNoWhite:[185:15] Found expr:[185:5->185:16]
151+
Pexp_field [185:5->185:15] _:[187:0->185:16]
152152
Completable: Cpath Value[y2].content.""
153153
[{
154154
"label": "age",

0 commit comments

Comments
 (0)