Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit 79b81f5

Browse files
committed
Vendor and hook up the outcome printer from the syntax repo.
Fixes #33 - Vendor the ourcome printer from https://github.com/rescript-lang/syntax - Make monads ppx use 406 AST to compile the vendored code (inline records) - Pass around / calculate recursion status to correctly print multiple and recursive type definitions.
1 parent 5f79d56 commit 79b81f5

19 files changed

+2124
-307
lines changed

Changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Remove semicolon in module top level preview.
66
- Support syntax highlight in hover fenced blocks.
77
- Fix printing of variant arguments.
8+
- Use outcome printer from the syntax to print type declarations.
89

910
## Release 1.0.0 of rescript-vscode
1011
This [commit](https://github.com/rescript-lang/rescript-editor-support/commit/d45f45793a307a3bb87dcac0542fd412669f1b6e) is vendored in [rescript-vscode 1.0.0](https://github.com/rescript-lang/rescript-vscode/releases/tag/1.0.0).

examples/example-project/src/ZZ.res

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,32 @@ type inline =
3737
| D({x: int, y: string})
3838
| E({x: int, y: string})
3939
| F
40+
41+
module MSig
42+
: {
43+
type rec t = | A (list<s>)
44+
and s = list<t>
45+
46+
let x : int
47+
}
48+
= {
49+
type rec t = | A (list<s>)
50+
and s = list<t>
51+
52+
let x = 14
53+
}
54+
55+
module Impl = {
56+
type rec t = | A (list<s>)
57+
and s = list<t>
58+
59+
type w = int
60+
61+
let x = 14
62+
}
63+
64+
module Impl2 = { include Impl};
65+
66+
module D = MSig
67+
module E = Impl
68+
module F = Impl2

src/ppx/Ppx_Monads.re

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ the result of the whole thing to be unit, use `let%consume`.
4848
*/
4949

5050
open Migrate_parsetree
51-
open OCaml_402.Ast
51+
open OCaml_406.Ast
5252

5353
/***
5454
* https://ocsigen.org/lwt/dev/api/Ppx_lwt
@@ -154,12 +154,12 @@ let mapper =
154154
Ast_helper.Exp.attr(
155155
[%expr [%e front]([%e mapper.expr(mapper, expr)], ~f=([%p pat]) => [%e mapper.expr(mapper, continuation)])],
156156
({txt: "ocaml.explanation", loc}, PStr([
157-
Ast_helper.Str.eval(Ast_helper.Exp.constant(Const_string(explanation, None)))
157+
Ast_helper.Str.eval(Ast_helper.Exp.constant(Pconst_string(explanation, None)))
158158
]))
159159
)
160160
}
161161
| _ => Ast_mapper.default_mapper.expr(mapper, expr)
162162
}
163163
};
164164

165-
let () = Driver.register(~name="ppx_monads", ~args=[], Versions.ocaml_402, (_config, _cookies) => mapper);
165+
let () = Driver.register(~name="ppx_monads", ~args=[], Versions.ocaml_406, (_config, _cookies) => mapper);

src/ppx/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
(name Ppx_monads)
44
(flags :standard -w -9)
55
(libraries compiler-libs ocaml-migrate-parsetree ppx_tools_versioned)
6-
(preprocess (pps ppx_tools_versioned.metaquot_402))
6+
(preprocess (pps ppx_tools_versioned.metaquot_406))
77
(kind ppx_rewriter))
88

src/rescript-editor-support/Hover.re

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ let showModuleTopLevel =
3030
|> List.map(item =>
3131
switch (item.SharedTypes.item) {
3232
/*** TODO pretty print module contents */
33-
| SharedTypes.MType({decl}) =>
34-
" " ++ (decl |> Shared.declToString(item.name.txt))
33+
| SharedTypes.MType({decl}, recStatus) =>
34+
" " ++ (decl |> Shared.declToString(~recStatus, item.name.txt))
3535
| Module(_) => " module " ++ item.name.txt
3636
| MValue(typ) =>
3737
" let " ++ item.name.txt ++ ": " ++ (typ |> Shared.typeToString) /* TODO indent */

src/rescript-editor-support/MessageHandlers.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ let handlers:
721721
let (item, siblings) =
722722
switch (item) {
723723
| MValue(v) => (v |> Shared.variableKind, [])
724-
| MType(t) => (t.decl |> Shared.declarationKind, [])
724+
| MType(t, _) => (t.decl |> Shared.declarationKind, [])
725725
| Module(Structure(contents)) => (Module, getItems(contents))
726726
| Module(Ident(_)) => (Module, [])
727727
};

0 commit comments

Comments
 (0)