Skip to content

Commit 170dcc8

Browse files
authored
Merge pull request #154 from rescript-lang/comp
Add test cases for completion of react.component
2 parents b89323a + cb1da30 commit 170dcc8

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

analysis/src/NewCompletions.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,15 @@ let processCompletable ~findItems ~package ~rawOpens
602602
"variadic";
603603
]
604604
|> List.filter (fun decorator -> Utils.startsWith decorator prefix)
605+
|> List.map (fun decorator ->
606+
let parts = String.split_on_char '.' prefix in
607+
let len = String.length prefix in
608+
let dec2 =
609+
if List.length parts > 1 then
610+
String.sub decorator len (String.length decorator - len)
611+
else decorator
612+
in
613+
dec2)
605614
|> List.map mkDecorator
606615
| Clabel (funPath, prefix) ->
607616
let labels =

analysis/tests/src/Complete.res

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,8 @@ let zzz = 11
5353

5454
//^com let comp = <O.Comp z
5555

56+
//^doc
5657

57-
//^doc
58+
//^com @reac
59+
60+
//^com @react.

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,3 +538,21 @@ DocumentSymbol tests/src/Complete.res
538538
}
539539
]
540540

541+
Complete tests/src/Complete.res 56:2
542+
[{
543+
"label": "react.component",
544+
"kind": 4,
545+
"tags": [],
546+
"detail": "",
547+
"documentation": null
548+
}]
549+
550+
Complete tests/src/Complete.res 58:2
551+
[{
552+
"label": "component",
553+
"kind": 4,
554+
"tags": [],
555+
"detail": "",
556+
"documentation": null
557+
}]
558+

0 commit comments

Comments
 (0)