Skip to content

Commit

Permalink
Compatibility with Merlin 503 (#1386)
Browse files Browse the repository at this point in the history
* Use compat lib where required
* Update compiler and merlin version in pkg and ci
* Promote normal tests changes
  • Loading branch information
voodoos authored Jan 10, 2025
1 parent 6cde996 commit a7ce29f
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ jobs:
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "5.2"
ocaml-compiler: "ocaml-base-compiler.5.3.0"

# Remove this pin once a compatible version of Merlin has been released
# - name: Pin dev Merlin
# run: opam pin https://github.com/ocaml/merlin.git#main
- name: Pin dev Merlin
run: opam --cli=2.1 pin --with-version=5.4-503 https://github.com/ocaml/merlin.git#main

- name: Build and install dependencies
run: opam install .
Expand Down Expand Up @@ -81,13 +81,17 @@ jobs:
- name: Set-up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "5.2"
ocaml-compiler: "ocaml-base-compiler.5.3.0"

- name: Set git user
run: |
git config --global user.name github-actions[bot]
git config --global user.email github-actions[bot]@users.noreply.github.com
# Remove this pin once a compatible version of Merlin has been released
- name: Pin dev Merlin
run: opam --cli=2.1 pin --with-version=5.4-503 https://github.com/ocaml/merlin.git#main

- name: Install dependencies
run: |
opam install . --deps-only
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
[`ocamllsp/typeSearch`](/ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md) request (#1369)

- Make MerlinJump code action configurable (#1376)
- Add support for OCaml 5.3 (#1386)

- Add custom [`ocamllsp/jump`](/ocaml-lsp-server/docs/ocamllsp/merlinJump-spec.md) request (#1374)

Expand Down
4 changes: 2 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ possible and does not make any assumptions about IO.
dyn
stdune
(fiber (and (>= 3.1.1) (< 4.0.0)))
(ocaml (and (>= 5.2.0) (< 5.3)))
(ocaml (and (>= 5.3) (< 5.4)))
xdg
ordering
dune-build-info
Expand All @@ -70,7 +70,7 @@ possible and does not make any assumptions about IO.
(csexp (>= 1.5))
(ocamlformat-rpc-lib (>= 0.21.0))
(odoc :with-doc)
(merlin-lib (and (>= 5.2) (< 6.0)))
(merlin-lib (and (>= 5.4) (< 6.0)))
(ppx_yojson_conv :with-dev-setup)))

(package
Expand Down
4 changes: 2 additions & 2 deletions ocaml-lsp-server.opam
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ depends: [
"dyn"
"stdune"
"fiber" {>= "3.1.1" & < "4.0.0"}
"ocaml" {>= "5.2.0" & < "5.3"}
"ocaml" {>= "5.3" & < "5.4"}
"xdg"
"ordering"
"dune-build-info"
Expand All @@ -45,7 +45,7 @@ depends: [
"csexp" {>= "1.5"}
"ocamlformat-rpc-lib" {>= "0.21.0"}
"odoc" {with-doc}
"merlin-lib" {>= "5.2" & < "6.0"}
"merlin-lib" {>= "5.4" & < "6.0"}
"ppx_yojson_conv" {with-dev-setup}
]
dev-repo: "git+https://github.com/ocaml/ocaml-lsp.git"
Expand Down
9 changes: 7 additions & 2 deletions ocaml-lsp-server/src/code_actions/action_extract.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
open Import
open Option.O
module H = Ocaml_parsing.Ast_helper
module Typedtree_utils = Merlin_analysis.Typedtree_utils

let range_contains_loc range loc =
match Range.of_loc_opt loc with
Expand Down Expand Up @@ -75,8 +76,12 @@ let tightest_enclosing_binder_position typedtree range =
| Texp_open (_, body) -> found_if_expr_contains body
| Texp_letop { body; _ } -> found_if_case_contains [ body ]
| Texp_function (_, Tfunction_cases { cases; _ }) -> found_if_case_contains cases
| Texp_match (_, cases, _) -> found_if_case_contains cases
| Texp_try (_, cases) -> found_if_case_contains cases
| Texp_match _ ->
let m = Typedtree_utils.texp_match_of_expr expr |> Option.value_exn in
found_if_case_contains m.computation_cases
| Texp_try _ ->
let t = Typedtree_utils.texp_try_of_expr expr |> Option.value_exn in
found_if_case_contains t.value_cases
| _ -> ())
in
let structure_item_iter (iter : I.iterator) (item : Typedtree.structure_item) =
Expand Down
3 changes: 2 additions & 1 deletion ocaml-lsp-server/src/folding_range.ml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ let fold_over_parsetree (parsetree : Mreader.parsetree) =
| Ppat_exception _
| Ppat_extension _
| Ppat_open _
| Ppat_any -> Ast_iterator.default_iterator.pat self p
| Ppat_any
| _ -> Ast_iterator.default_iterator.pat self p
in
let expr (self : Ast_iterator.iterator) (expr : Parsetree.expression) =
match expr.pexp_desc with
Expand Down
6 changes: 4 additions & 2 deletions ocaml-lsp-server/src/semantic_highlighting.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
open Import
open Fiber.O
module Array_view = Lsp.Private.Array_view
module Parsetree_utils = Merlin_analysis.Parsetree_utils

(* TODO:
Expand Down Expand Up @@ -508,7 +509,7 @@ end = struct

let const loc (constant : Parsetree.constant) =
let token_type =
match constant with
match Parsetree_utils.constant_desc constant with
| Parsetree.Pconst_integer _ | Pconst_float _ -> Token_type.of_builtin Number
| Pconst_char _ | Pconst_string _ -> Token_type.of_builtin String
in
Expand Down Expand Up @@ -719,7 +720,8 @@ end = struct
| Ppat_tuple _
| Ppat_lazy _
| Ppat_any
| Ppat_interval _ -> `Default_iterator
| Ppat_interval _
| _ -> `Default_iterator
with
| `Default_iterator -> Ast_iterator.default_iterator.pat self pat
| `Custom_iterator -> self.attributes self ppat_attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ The type int is not compatible with the type unit",
{
"diagnostics": [
{
"message": "This expression has type unit but an expression was expected of type int",
"message": "The constructor () has type unit but an expression was expected of type int",
"range": {
"end": {
"character": 42,
Expand Down Expand Up @@ -457,7 +457,7 @@ The type int is not compatible with the type unit",
"source": "ocamllsp",
},
{
"message": "This expression has type string but an expression was expected of type int",
"message": "This constant has type string but an expression was expected of type int",
"range": {
"end": {
"character": 9,
Expand Down

0 comments on commit a7ce29f

Please sign in to comment.