Skip to content

Reset the uid counter when restoring the typer's state#1779

Merged
voodoos merged 4 commits intoocaml:masterfrom
voodoos:reset-uid-counter
Jun 11, 2024
Merged

Reset the uid counter when restoring the typer's state#1779
voodoos merged 4 commits intoocaml:masterfrom
voodoos:reset-uid-counter

Conversation

@voodoos
Copy link
Copy Markdown
Collaborator

@voodoos voodoos commented Jun 10, 2024

This ensures uids are stable between edits. This is important for features such as project-wide occurrences that first identify definitions' uids before looking them up in an external table. We need these uids to coincide with the ones of emitted by the compiler.

Since some tables use uids as keys, we have to clean them properly. This is done using the Stamped_hashtable datastructure introduced in 147f0c3.

@voodoos voodoos force-pushed the reset-uid-counter branch from af9f1ea to 121f81a Compare June 10, 2024 12:46
voodoos added a commit to voodoos/merlin that referenced this pull request Jun 10, 2024
@voodoos voodoos mentioned this pull request Jun 10, 2024
21 tasks
voodoos added a commit to voodoos/merlin that referenced this pull request Jun 10, 2024
@voodoos voodoos force-pushed the reset-uid-counter branch from 4a04846 to b645c2d Compare June 10, 2024 13:47
voodoos added a commit to voodoos/merlin that referenced this pull request Jun 10, 2024
@voodoos voodoos force-pushed the reset-uid-counter branch from d379077 to 0591b4e Compare June 10, 2024 15:10
voodoos added a commit to voodoos/merlin that referenced this pull request Jun 11, 2024
@voodoos voodoos force-pushed the reset-uid-counter branch 2 times, most recently from 5565494 to 78dbf3e Compare June 11, 2024 10:31
voodoos added a commit to voodoos/merlin that referenced this pull request Jun 11, 2024
@voodoos voodoos force-pushed the reset-uid-counter branch from 73245b5 to 4354d7f Compare June 11, 2024 12:01
voodoos added a commit to voodoos/merlin that referenced this pull request Jun 11, 2024
@voodoos voodoos force-pushed the reset-uid-counter branch from 4354d7f to 2f651c8 Compare June 11, 2024 12:01
voodoos added 4 commits June 11, 2024 17:20
This ensures UIDs are stable between edits.
Since some table use uids as keys, we have to clean them properly.
This is done using the Stamped_hashtable datastructure introduced in 147f0c3
when Dune is < 3.16
when ocaml-index is not installed
@voodoos voodoos force-pushed the reset-uid-counter branch from 40461f3 to 42bda3d Compare June 11, 2024 15:23
@voodoos voodoos merged commit dd625e6 into ocaml:master Jun 11, 2024
voodoos added a commit to voodoos/opam-repository that referenced this pull request Jun 18, 2024
CHANGES:

Tue Jun 18 12:00:42 CEST 2024

  + merlin binary
    - Support project-wide occurrences queries using index files (ocaml/merlin#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 (ocaml/merlin#1776)
    - Perform incremental indexation of the buffer when typing. (ocaml/merlin#1777)
    - `merlin-lib.commands`: Add a `find_command_opt`` alternative to
      `find_command` that does not raise (ocaml/merlin#1778)
    - Prevent uid clashes by not returning PWO for defs located in the current
      interface file (ocaml/merlin#1781)
    - Reset uid counters when restoring the typer cache so that uids are stable
      across re-typing (ocaml/merlin#1779)
    - Improve the behavior on occurrences when the cursor is on a label /
      constructor declaration (ocaml/merlin#1785)
  + editor modes
    - emacs: add basic support for project-wide occurrences (ocaml/merlin#1766)
    - vim: add basic support for project-wide occurrences (ocaml/merlin#1767, @Julow)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Jun 18, 2024
CHANGES:

Tue Jun 18 12:00:42 CEST 2024

  + merlin binary
    - Support project-wide occurrences queries using index files (ocaml/merlin#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 (ocaml/merlin#1776)
    - Perform incremental indexation of the buffer when typing. (ocaml/merlin#1777)
    - `merlin-lib.commands`: Add a `find_command_opt`` alternative to
      `find_command` that does not raise (ocaml/merlin#1778)
    - Prevent uid clashes by not returning PWO for defs located in the current
      interface file (ocaml/merlin#1781)
    - Reset uid counters when restoring the typer cache so that uids are stable
      across re-typing (ocaml/merlin#1779)
    - Improve the behavior on occurrences when the cursor is on a label /
      constructor declaration (ocaml/merlin#1785)
  + editor modes
    - emacs: add basic support for project-wide occurrences (ocaml/merlin#1766)
    - vim: add basic support for project-wide occurrences (ocaml/merlin#1767, @Julow)

[new release] ocaml-index (1.0)

CHANGES:

### Added

- Initial release.
- The `aggregate`` command that finishes reduction of shapes in cmt files and
  store the output in a single index file.
- The `stats` command that prints information about an index file.
- The `dump` command that prints all locs of an index.
voodoos added a commit to voodoos/opam-repository that referenced this pull request Jun 18, 2024
CHANGES:

Tue Jun 18 12:00:42 CEST 2024

  + merlin binary
    - Support project-wide occurrences queries using index files (ocaml/merlin#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 (ocaml/merlin#1776)
    - Perform incremental indexation of the buffer when typing. (ocaml/merlin#1777)
    - `merlin-lib.commands`: Add a `find_command_opt`` alternative to
      `find_command` that does not raise (ocaml/merlin#1778)
    - Prevent uid clashes by not returning PWO for defs located in the current
      interface file (ocaml/merlin#1781)
    - Reset uid counters when restoring the typer cache so that uids are stable
      across re-typing (ocaml/merlin#1779)
    - Improve the behavior on occurrences when the cursor is on a label /
      constructor declaration (ocaml/merlin#1785)
  + editor modes
    - emacs: add basic support for project-wide occurrences (ocaml/merlin#1766)
    - vim: add basic support for project-wide occurrences (ocaml/merlin#1767, @Julow)

[new release] ocaml-index (1.0)

CHANGES:

### Added

- Initial release.
- The `aggregate`` command that finishes reduction of shapes in cmt files and
  store the output in a single index file.
- The `stats` command that prints information about an index file.
- The `dump` command that prints all locs of an index.
avsm pushed a commit to avsm/opam-repository that referenced this pull request Sep 5, 2024
CHANGES:

Tue Jun 18 12:00:42 CEST 2024

  + merlin binary
    - Support project-wide occurrences queries using index files (ocaml/merlin#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 (ocaml/merlin#1776)
    - Perform incremental indexation of the buffer when typing. (ocaml/merlin#1777)
    - `merlin-lib.commands`: Add a `find_command_opt`` alternative to
      `find_command` that does not raise (ocaml/merlin#1778)
    - Prevent uid clashes by not returning PWO for defs located in the current
      interface file (ocaml/merlin#1781)
    - Reset uid counters when restoring the typer cache so that uids are stable
      across re-typing (ocaml/merlin#1779)
    - Improve the behavior on occurrences when the cursor is on a label /
      constructor declaration (ocaml/merlin#1785)
  + editor modes
    - emacs: add basic support for project-wide occurrences (ocaml/merlin#1766)
    - vim: add basic support for project-wide occurrences (ocaml/merlin#1767, @Julow)

[new release] ocaml-index (1.0)

CHANGES:

### Added

- Initial release.
- The `aggregate`` command that finishes reduction of shapes in cmt files and
  store the output in a single index file.
- The `stats` command that prints information about an index file.
- The `dump` command that prints all locs of an index.
liam923 added a commit to liam923/merlin that referenced this pull request Jun 13, 2025
* Revert "occurrences: add support for project-wide occurrences"

This reverts commit fa1e8b1.

* occurrences: do not attempt to shrink the selection of idents that needs parenthesis

Doing that properly require compiler support for located longidents.

cherry picked from upstream commit 1850cbe

* refactor: extract identifier parsing from query commands

cherry picked from upstream commit 082a1ac

* occ: improve handling of paths in current buffer

cherry picked from upstream commit 02959ba

* test: promote

cherry picked from upstream commit a1547db

* test: show issue with paths that need parens / spaces

cherry picked from upstream commit a687b15

* Make reconstruct identifier more robust

It's always correct to have a space after the parenthesis and it is sometimes
necessary, for infix operators that start with `*` for example.

cherry picked from upstream commit ab56eea

* promote slight test improvement

cherry picked from upstream commit ee41c4d

* context: improve cursor position detection

cherry picked from upstream commit 9f8cbf4

* Revert: remove raparsing of longident to index modules in paths

This reparsing has very bad performances. The correct way to deal with
issue is to have the compiler store precise locations in longidents.

cherry picked from upstream commit df27557

* Upgrade dune to 3.0 and fix warnings

dune 2.9.0 is not compatible with OCaml 5.2 anyway.

cherry picked from upstream commit 617a91d

* lib: expose config manipulation utilities

cherry picked from upstream commit b77b724

* config: handle SOURCE_ROOT directive

cherry picked from upstream commit dd23fbd

* occurrences: add support for project-wide occurrences

cherry picked from upstream commit 34e2688

* [emacs] handle project-wide-occurrences in  occur-mode

cherry picked from upstream commit a34cc1c

* Backport PR ocaml#1717 from upstream

* Backport PR ocaml#1711 from upstream

* refactor: properly define mtyper cache type

cherry picked from upstream commit 1577d8f

* Do not traverse `merlin.hide` nodes when iterating

cherry picked from upstream commit 4d5560e

* occurrences: incrementally index the buffer in Mtyper

cherry picked from upstream commit a4bb508

* Correctly identify which locs are in the current buffer

cherry picked from upstream commit 139272e

* occ: add a test showing clashes between mli and ml uids

cherry picked from upstream commit a0dbfb2

* occ: do no return PWO for definitions in a mli

We don't have a way to identify uids in interfaces with uids in
implementations. This might lead to mixing up results that share
the same uid.

cherry picked from upstream commit 38c28f2

* test: add test showing issue with at origin occurrences

Labels and constructors are not highlighted correctly when the cursor is on their declaration

cherry picked from upstream commit af14a1f

* Better context inference

cherry picked from upstream commit 7bd03f0

* Fix crashing when logging lid

cherry picked from upstream commit 5b96c62

* Backport PR ocaml#1779 from upstream

* Revert "Do not traverse `merlin.hide` nodes when iterating"

This reverts commit 24ba67e4761f045139f5767d3e26c0a17084b002.

* Add cms cache support to cache information

---------

Co-authored-by: Ulysse Gérard <thevoodoos@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant