Skip to content

Commit

Permalink
Merge branch 'master' into ppx_hover
Browse files Browse the repository at this point in the history
  • Loading branch information
PizieDust authored Jun 18, 2024
2 parents 85fc619 + ce00b5b commit 3899d3a
Show file tree
Hide file tree
Showing 63 changed files with 1,670 additions and 440 deletions.
27 changes: 27 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@ merlin NEXT_VERSION
+ merlin binary
- Implement new expand-node command for expanding PPX annotations (#1745)

merlin 5.1
==========
Tue Jun 18 12:00:42 CEST 2024

+ merlin binary
- Support project-wide occurrences queries using index files (#1766)
- The file format is described in library `Merlin_lib.index_format`
- Two new configuration directives are introduced:
- `SOURCE_ROOT` that is used to resolve relative paths found in the
indexes.
- `INDEX` that is used to declare the list of index files Merlin should
use when looking for occurrences.
- A new `UNIT_NAME` configuration directive that can be used to tell Merlin
the correct name of the current unit in the presence of wrapping (#1776)
- Perform incremental indexation of the buffer when typing. (#1777)
- `merlin-lib.commands`: Add a `find_command_opt`` alternative to
`find_command` that does not raise (#1778)
- Prevent uid clashes by not returning PWO for defs located in the current
interface file (#1781)
- Reset uid counters when restoring the typer cache so that uids are stable
across re-typing (#1779)
- Improve the behavior on occurrences when the cursor is on a label /
constructor declaration (#1785)
+ editor modes
- emacs: add basic support for project-wide occurrences (#1766)
- vim: add basic support for project-wide occurrences (#1767, @Julow)

merlin 5.0
==========
Fri May 17 19:59:42 CET 2024
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ preprocess:
promote:
dune promote

bench:
bench_disabled:
merl-an benchmark -p /projects/irmin -s 1 --data=merl-an_bench
echo "Top 10 slowest queries:"
jq -s "[ (map(.sample_id |= tostring)) + (map(.sample_id |= tostring)) | group_by(.sample_id)[] | select(length > 1) | add ] | sort_by( .responses[0].timing.clock) | reverse | .[:10]" merl-an_bench/query_responses.json merl-an_bench/commands.json
echo "Benchmark result:"
jq . merl-an_bench/bench.json

.PHONY: all build dev clean test promote bench
bench:
echo ""

.PHONY: all build dev clean test promote bench bench_disabled
40 changes: 40 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Release procedure

## Project organization

Merlin maintains multiple branches for multiple versions of the compiler. The current active support branches are:

- `master` with support for OCaml 5.2
- `501` with support for OCaml 5.1
- `414` with support for OCaml 4.14

Development happens on the `master` branch and bug fixes that should be
backported to other supported branches should be added to the appropriate
[project](https://github.com/ocaml/merlin/projects?type=classic).

Major changes were specific to OCaml 5.2 so the subsequent releases have a major
version number at `5` (like `v5.0-502`) while support releases will stay with
the version number `4` (like `v4.15-414` or `v4.15-501`).

## Before the release

- A PR is opened with the updated changelog for each released branch. The
changelog should contain an appropriate timestamp for the release.
- Additionally, for each non-master released version, the PR also contains the
required backports.

## Release

We use `dune-release` to release Merlin.

For each released branch:
- Merge the corresponding PR.
- Run `dune-release tag v4.15-414`.
The tag should always formed in the same way:
```
"v%s-%s" merlin_version ocaml_version
```
For example: `v4.14-414`, `v5.0-502` etc.
- Run `dune-release` and follow the instructions, but say `No` when asked if a PR should be created on opam's repository.
- For multiple releases it is best to group all the releases in a single opam PR. Additionally it is often not necessary to release the `dot-merlin-package`.
- Cherry-pick the commits from every branch created by `dune-release`, make the necessary changes (like removing the `dot-merlin-reader` packages) and open the PR on opam.
33 changes: 0 additions & 33 deletions bench.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1 @@
FROM ocaml/opam:ubuntu-20.04-ocaml-5.2

WORKDIR /app

RUN sudo apt-get update
RUN sudo apt-get -y install jq
COPY . .
RUN sudo chown -R opam /app
RUN eval $(opam env)

# install merlin
RUN opam install .

# install merl-an
## cache workaround: https://github.com/ocurrent/current-bench/issues/468#issuecomment-1621030354
ADD https://api.github.com/repos/pitag-ha/merl-an/git/refs/heads/main .merl-an-info
RUN opam pin -y merl-an https://github.com/pitag-ha/merl-an.git

RUN eval $(opam env)

# create directory for projects to run benchmarks on
RUN sudo mkdir /projects
RUN sudo chown opam /projects
WORKDIR /projects

# build irmin
RUN git clone https://github.com/mirage/irmin.git
WORKDIR /projects/irmin
RUN git checkout 8da4d16e7cc8beddfc8a824feca325426bae08a9
RUN sudo apt install -y gnuplot-x11 libgmp-dev pkg-config libffi-dev
RUN opam switch import /app/bench/irmin.opam.export --no-checksums
RUN opam exec -- dune build

WORKDIR /app
34 changes: 34 additions & 0 deletions bench.Dockerfile.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM ocaml/opam:ubuntu-20.04-ocaml-5.2

WORKDIR /app

RUN sudo apt-get update
RUN sudo apt-get -y install jq
COPY . .
RUN sudo chown -R opam /app
RUN eval $(opam env)

# install merlin
RUN opam install .

# install merl-an
## cache workaround: https://github.com/ocurrent/current-bench/issues/468#issuecomment-1621030354
ADD https://api.github.com/repos/pitag-ha/merl-an/git/refs/heads/main .merl-an-info
RUN opam pin -y merl-an https://github.com/pitag-ha/merl-an.git

RUN eval $(opam env)

# create directory for projects to run benchmarks on
RUN sudo mkdir /projects
RUN sudo chown opam /projects
WORKDIR /projects

# build irmin
RUN git clone https://github.com/mirage/irmin.git
WORKDIR /projects/irmin
RUN git checkout 8da4d16e7cc8beddfc8a824feca325426bae08a9
RUN sudo apt install -y gnuplot-x11 libgmp-dev pkg-config libffi-dev
RUN opam switch import /app/bench/irmin.opam.export --no-checksums
RUN opam exec -- dune build

WORKDIR /app
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(lang dune 2.9)
(lang dune 3.0)
(name merlin)
(using menhir 2.0)

Expand Down
56 changes: 39 additions & 17 deletions emacs/merlin.el
Original file line number Diff line number Diff line change
Expand Up @@ -1784,37 +1784,33 @@ Empty string defaults to jumping to all these."
(let ((inhibit-read-only t)
(buffer-undo-list t)
(pending-line)
(pending-lines-text))
(pending-lines-text)
(previous-buf))
(erase-buffer)
(occur-mode)
(insert (propertize (format "%d occurrences in buffer: %s"
(length lst)
src-buff)
'font-lock-face list-matching-lines-buffer-name-face
'read-only t
'occur-title (get-buffer src-buff)))
(insert "\n")
(dolist (pos positions)
(let* ((marker (cdr (assoc 'marker pos)))
(start (assoc 'start pos))
(let* ((start (assoc 'start pos))
(end (assoc 'end pos))
(file (cdr (assoc 'file pos)))
(occ-buff (if file (find-file-noselect file) src-buff))
(marker (with-current-buffer occ-buff
(copy-marker (merlin--point-of-pos start))))
(line (cdr (assoc 'line start)))
(start-buf-pos (with-current-buffer src-buff
(start-buf-pos (with-current-buffer occ-buff
(merlin--point-of-pos start)))
(end-buf-pos (with-current-buffer src-buff
(end-buf-pos (with-current-buffer occ-buff
(merlin--point-of-pos end)))
(prefix-length 8)
(start-offset (+ prefix-length
(cdr (assoc 'col start))))
(lines-text
(if (equal line pending-line)
pending-lines-text
(if (and (equal line pending-line) occ-buff)
pending-lines-text
(merlin--occurrence-text line
marker
start-buf-pos
end-buf-pos
src-buff))))

occ-buff))))
;; Insert the critical text properties that occur-mode
;; makes use of
(add-text-properties start-offset
Expand All @@ -1828,9 +1824,22 @@ Empty string defaults to jumping to all these."
;; found in order to accumulate multiple matches within
;; one line.
(when (and pending-lines-text
(not (equal line pending-line)))
(or (not (equal line pending-line))
(not (equal previous-buf occ-buff))))
(insert pending-lines-text))

(when (not (equal previous-buf occ-buff))
(insert (propertize (format "Occurrences in buffer %s:"
;(length lst)
occ-buff)
'font-lock-face
list-matching-lines-buffer-name-face
'read-only t
'occur-title occ-buff))
(insert "\n"))

(setq pending-line line)
(setq previous-buf occ-buff)
(setq pending-lines-text lines-text)))

;; Catch final pending text
Expand Down Expand Up @@ -1860,6 +1869,19 @@ Empty string defaults to jumping to all these."
(merlin-occurrences-list r)
(error "%s" r)))))

(defun merlin--project-occurrences ()
(merlin-call "occurrences" "-scope" "project" "-identifier-at"
(merlin-unmake-point (point))))

(defun merlin-project-occurrences ()
"List all occurrences of identifier under cursor in buffer."
(interactive)
(let ((r (merlin--project-occurrences)))
(when r
(if (listp r)
(merlin-occurrences-list r)
(error "%s" r)))))

;;;;;;;;;;;;;;;;;;;
;; OPEN REFACTOR ;;
;;;;;;;;;;;;;;;;;;;
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion merlin.opam
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ build: [
]
depends: [
"ocaml" {>= "5.2" & < "5.3"}
"dune" {>= "2.9.0"}
"dune" {>= "3.0.0"}
"merlin-lib" {= version}
"dot-merlin-reader" {>= "5.0"}
"ocaml-index" {>= "1.0" & post}
"yojson" {>= "2.0.0"}
"conf-jq" {with-test}
"ppxlib" {with-test}
Expand Down Expand Up @@ -70,3 +71,6 @@ See https://github.com/OCamlPro/opam-user-setup
"
{success & !user-setup:installed}
]
pin-depends: [
["ocaml-index.1.0" "git+https://github.com/voodoos/ocaml-index#82b08987921884daeeb5dccc345a2dcb667fe113"]
]
4 changes: 4 additions & 0 deletions src/analysis/ast_iterators.ml
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,7 @@ let iter_on_usages ~f (local_defs : Mtyper.typedtree) =
begin match local_defs with
| `Interface signature -> iter.signature iter signature
| `Implementation structure -> iter.structure iter structure end

let iterator_on_usages ~f =
let occ_iter = Cmt_format.iter_on_occurrences ~f in
iter_only_visible occ_iter
4 changes: 3 additions & 1 deletion src/analysis/context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ let inspect_browse_tree ~cursor lid browse : t option =
| Type_declaration _
| Extension_constructor _
| Module_binding_name _
| Module_declaration_name _ ->
| Module_declaration_name _
| Label_declaration _
| Constructor_declaration _ ->
None
| Module_expr _
| Open_description _ -> Some Module_path
Expand Down
7 changes: 5 additions & 2 deletions src/analysis/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@
-open Merlin_utils
-open Merlin_specific
-open Merlin_extend
-open Merlin_kernel)
-open Merlin_kernel
-open Merlin_index_format)
(libraries
merlin_config
merlin_specific
merlin_extend
merlin_kernel
merlin_utils
merlin_index_format
ocaml_parsing
ocaml_preprocess
query_protocol
ocaml_typing
ocaml_utils
str))
str
unix))
23 changes: 0 additions & 23 deletions src/analysis/index_format.ml

This file was deleted.

Loading

0 comments on commit 3899d3a

Please sign in to comment.