Skip to content

Commit 0597a6e

Browse files
committed
pipe complete int constants
1 parent cd8612e commit 0597a6e

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,13 @@ let rec getCompletionsForContextPath ~full ~opens ~rawOpens ~allFiles ~pos ~env
11761176
(Completion.Value
11771177
(Ctype.newconstr (Path.Pident (Ident.create "string")) []));
11781178
]
1179+
| CPInt ->
1180+
[
1181+
Completion.create ~name:"int" ~env
1182+
~kind:
1183+
(Completion.Value
1184+
(Ctype.newconstr (Path.Pident (Ident.create "int")) []));
1185+
]
11791186
| CPArray ->
11801187
[
11811188
Completion.create ~name:"array" ~env

analysis/src/CompletionFrontEnd.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ let findNamedArgCompletable ~(args : arg list) ~endPos ~posBeforeCursor
138138
let rec exprToContextPath (e : Parsetree.expression) =
139139
match e.pexp_desc with
140140
| Pexp_constant (Pconst_string _) -> Some Completable.CPString
141+
| Pexp_constant (Pconst_integer _) -> Some CPInt
141142
| Pexp_array _ -> Some CPArray
142143
| Pexp_ident {txt} -> Some (CPId (Utils.flattenLongIdent txt, Value))
143144
| Pexp_field (e1, {txt = Lident name}) -> (

analysis/src/SharedTypes.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ module Completable = struct
505505
type contextPath =
506506
| CPString
507507
| CPArray
508+
| CPInt
508509
| CPApply of contextPath * Asttypes.arg_label list
509510
| CPId of string list * completionContext
510511
| CPField of contextPath * string
@@ -534,6 +535,7 @@ module Completable = struct
534535
in
535536
let rec contextPathToString = function
536537
| CPString -> "string"
538+
| CPInt -> "int"
537539
| CPApply (cp, labels) ->
538540
contextPathToString cp ^ "("
539541
^ (labels

analysis/tests/src/Completion.res

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ let header2 = `
403403
background-color: ${red}; `
404404
// ^com
405405

406-
// let _ = `color: ${r
406+
// let _ = `color: ${r
407407
// ^com
408408

409409
let onClick = evt => {
@@ -414,3 +414,6 @@ let onClick = evt => {
414414
// ^com
415415
Js.log("Hello")
416416
}
417+
418+
// let _ = 123->t
419+
// ^com

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,8 +1625,8 @@ Resolved opens 2 Completion.res Completion.res
16251625
}]
16261626

16271627
Complete src/Completion.res 405:22
1628-
posCursor:[405:22] posNoWhite:[405:21] Found expr:[405:11->417:0]
1629-
Pexp_apply ...__ghost__[0:-1->0:-1] (...[405:11->415:1], ...[417:0->417:0])
1628+
posCursor:[405:22] posNoWhite:[405:21] Found expr:[405:11->420:0]
1629+
Pexp_apply ...__ghost__[0:-1->0:-1] (...[405:11->415:1], ...[420:0->420:0])
16301630
posCursor:[405:22] posNoWhite:[405:21] Found expr:[405:11->415:1]
16311631
Pexp_apply ...__ghost__[0:-1->0:-1] (...[405:11->405:19], ...[405:21->415:1])
16321632
posCursor:[405:22] posNoWhite:[405:21] Found expr:[405:21->415:1]
@@ -1702,3 +1702,22 @@ Resolved opens 2 Completion.res Completion.res
17021702
"documentation": null
17031703
}]
17041704

1705+
Complete src/Completion.res 417:17
1706+
posCursor:[417:17] posNoWhite:[417:16] Found expr:[417:11->417:17]
1707+
Completable: Cpath int->t
1708+
Raw opens: 2 Shadow.B.place holder ... Shadow.A.place holder
1709+
Resolved opens 2 Completion.res Completion.res
1710+
[{
1711+
"label": "Belt.Int.toString",
1712+
"kind": 12,
1713+
"tags": [],
1714+
"detail": "int => string",
1715+
"documentation": {"kind": "markdown", "value": "\n Converts a given `int` to a `string`. Uses the JavaScript `String` constructor under the hood.\n\n ```res example\n Js.log(Belt.Int.toString(1) === \"1\") /* true */\n ```\n"}
1716+
}, {
1717+
"label": "Belt.Int.toFloat",
1718+
"kind": 12,
1719+
"tags": [],
1720+
"detail": "int => float",
1721+
"documentation": {"kind": "markdown", "value": "\n Converts a given `int` to a `float`.\n\n ```res example\n Js.log(Belt.Int.toFloat(1) === 1.0) /* true */\n ```\n"}
1722+
}]
1723+

0 commit comments

Comments
 (0)