Skip to content

Commit ffc0225

Browse files
authored
Reuse original env when instantiating type (#7231)
* Reuse original env when instantiating type * Clean up code comment * Okay, somethings did change * After building local compiler * Fix doc thing? * Add changelog entry
1 parent c58a3c7 commit ffc0225

File tree

7 files changed

+99
-3
lines changed

7 files changed

+99
-3
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
1313
# 12.0.0-alpha.8 (Unreleased)
1414

15+
#### :bug: Bug fix
16+
17+
- Editor: Fix issue where pipe completions would not trigger with generic type arguments. https://github.com/rescript-lang/rescript/pull/7231
18+
1519
# 12.0.0-alpha.7
1620

1721
#### :bug: Bug fix

CONTRIBUTING.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,19 @@ After adding a new file to the repository that should go into the npm package -
119119

120120
```sh
121121
make lib # Build compiler and standard library
122-
./bsc myTestFile.res
122+
./cli/bsc myTestFile.res
123+
```
124+
125+
To view the untyped tree of the file run:
126+
127+
```sh
128+
./cli/bsc -dparsetree myTestFile.res
129+
```
130+
131+
To view the typed tree of the file run:
132+
133+
```sh
134+
./cli/bsc -dtypedtree myTestFile.res
123135
```
124136

125137
### Project

analysis/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ See main CONTRIBUTING.md's repo structure. Additionally, `examples/` is a conven
1616
dune exec -- rescript-editor-analysis --help
1717
```
1818

19+
Add verbose logging via:
20+
21+
```shell
22+
dune exec -- rescript-editor-analysis debug-dump verbose test
23+
```
24+
1925
## History
2026

2127
This project is based on a fork of [Reason Language Server](https://github.com/jaredly/reason-language-server).

analysis/src/TypeUtils.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ let extractFunctionTypeWithEnv ~env ~package typ =
270270
| Tconstr (path, typeArgs, _) -> (
271271
match References.digConstructor ~env ~package path with
272272
| Some
273-
( env,
273+
( _env,
274274
{
275275
item = {decl = {type_manifest = Some t1; type_params = typeParams}};
276276
} ) ->

tests/analysis_tests/tests/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module Firebase = {
2+
module Firestore = {
3+
type firestore
4+
5+
type documentReference<'documentdata> = {
6+
id: string,
7+
path: string,
8+
}
9+
10+
type documentSnapshot<'documentdata> = {
11+
id: string,
12+
ref: documentReference<'documentdata>,
13+
}
14+
15+
@module("firebase/firestore") @variadic
16+
external doc: (firestore, string, array<string>) => documentReference<'documentdata> = "doc"
17+
18+
@module("firebase/firestore")
19+
external getDoc: documentReference<'documentdata> => Promise.t<
20+
documentSnapshot<'documentdata>,
21+
> = "getDoc"
22+
}
23+
}
24+
25+
module Sample = {
26+
open Firebase
27+
28+
external store: Firestore.firestore = "store"
29+
30+
let ref = store->Firestore.doc("some_id", [])
31+
// ref.
32+
// ^com
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Complete src/Firebase.res 30:9
2+
posCursor:[30:9] posNoWhite:[30:8] Found expr:[30:5->30:9]
3+
Pexp_field [30:5->30:8] _:[32:0->30:9]
4+
Completable: Cpath Value[ref].""
5+
Raw opens: 1 Firebase.place holder
6+
Package opens Pervasives.JsxModules.place holder
7+
Resolved opens 1 Firebase
8+
ContextPath Value[ref].""
9+
ContextPath Value[ref]
10+
Path ref
11+
ContextPath Value[ref]->
12+
ContextPath Value[ref]
13+
Path ref
14+
CPPipe pathFromEnv:Firebase.Firestore found:true
15+
Path Firebase.Firestore.
16+
[{
17+
"label": "id",
18+
"kind": 5,
19+
"tags": [],
20+
"detail": "string",
21+
"documentation": {"kind": "markdown", "value": "```rescript\nid: string\n```\n\n```rescript\ntype documentReference<'documentdata> = {\n id: string,\n path: string,\n}\n```"}
22+
}, {
23+
"label": "path",
24+
"kind": 5,
25+
"tags": [],
26+
"detail": "string",
27+
"documentation": {"kind": "markdown", "value": "```rescript\npath: string\n```\n\n```rescript\ntype documentReference<'documentdata> = {\n id: string,\n path: string,\n}\n```"}
28+
}, {
29+
"label": "->Firestore.getDoc",
30+
"kind": 12,
31+
"tags": [],
32+
"detail": "documentReference<\n 'documentdata,\n> => Promise.t<documentSnapshot<'documentdata>>",
33+
"documentation": null,
34+
"sortText": "getDoc",
35+
"insertText": "->Firestore.getDoc",
36+
"additionalTextEdits": [{
37+
"range": {"start": {"line": 30, "character": 8}, "end": {"line": 30, "character": 9}},
38+
"newText": ""
39+
}]
40+
}]
41+

0 commit comments

Comments
 (0)