Skip to content

Allow -pp to return an AST#1394

Merged
voodoos merged 2 commits intomasterfrom
ast-in-pp
Nov 18, 2021
Merged

Allow -pp to return an AST#1394
voodoos merged 2 commits intomasterfrom
ast-in-pp

Conversation

@let-def
Copy link
Copy Markdown
Contributor

@let-def let-def commented Oct 26, 2021

Merlin expects a source preprocessor -pp to return sources.
However, some existing preprocessors return marshalled ASTs.
This patch adds support for this situation, and should fix:

Merlin functionalities will be reduced:

  • recovery is up to -pp
  • no support for placeholder insertion for completion
  • lexer_ident will fallback to the unpreprocessed source to reconstruct
    identifiers

Merlin functionalities will be reduced:
- recovery is up to -pp
- no support for placeholder insertion for completion
- lexer_ident will fallback to the unpreprocessed source to reconstruct
  identifiers
@Kakadu
Copy link
Copy Markdown

Kakadu commented Oct 26, 2021

If I want to test your PR with ocaml-lsp, what should I do?

@voodoos
Copy link
Copy Markdown
Collaborator

voodoos commented Oct 26, 2021

If I want to test your PR with ocaml-lsp, what should I do?

That is not an easy task because ocaml-lsp is vendoring merlin.
But maybe you can test using merlin directly ?

For example you can ask for the type of the expression at line 3 column 5 in file test.ml by calling the following command:

ocamlmerlin single type-enclosing -position 3:5 -filename test.ml < test.ml

@Kakadu
Copy link
Copy Markdown

Kakadu commented Oct 26, 2021

For example you can ask for the type of the expression at line 3 column 5 in file test.ml by calling the following command:

ocamlmerlin single type-enclosing -position 3:5 -filename test.ml < test.ml

The issue being discussed involves preprocessing of input files by external tools, so (I'm afraid) it will not be so easy to test it from command line. And recent abandoning of .merlin files should complicate everything too.

@voodoos
Copy link
Copy Markdown
Collaborator

voodoos commented Oct 26, 2021

If you use Dune to build your project then just build it before starting ocamlmerlin and the configuration should be read as usual.

@let-def
Copy link
Copy Markdown
Contributor Author

let-def commented Oct 27, 2021

I confirm, I tested from the command line with:

ocamlmerlin server check-configuration -filename src/core/Core.mli   < src/core/Core.mli

@Kakadu
Copy link
Copy Markdown

Kakadu commented Oct 27, 2021

I confirm, I tested from the command line with:

ocamlmerlin server check-configuration -filename src/core/Core.mli   < src/core/Core.mli

I tried your branch and nothing changes comparately from opam's merlin

➜  pat-match git:(master) ✗ ocamlmerlin server -vnum                                                                                           
v4.3.1-412-15-g6fb8af9f
➜  pat-match git:(master) ✗ ocamlmerlin server check-configuration -filename OCanren/src/core/Core.mli   < OCanren/src/core/Core.mli         
{"class":"failure","value":"Empty file","notifications":[],"timing":{"clock":52,"cpu":52,"query":0,"pp":21,"reader":30,"ppx":0,"typer":0,"error":0}}

@let-def
Copy link
Copy Markdown
Contributor Author

let-def commented Oct 28, 2021

It works here.
Can you give more information on your setup? OS, versions of compiler and packages (camlp5).
Also, try using single instead of server: ocamlmerlin single check-configuration...

@Kakadu
Copy link
Copy Markdown

Kakadu commented Oct 28, 2021

I tested again, rebased ocaml-lsp-server to use new merlin and the issue is fixed. Thanks!

@voodoos voodoos merged commit eb8df3e into master Nov 18, 2021
voodoos added a commit that referenced this pull request Nov 18, 2021
voodoos added a commit that referenced this pull request Nov 22, 2021
voodoos added a commit to voodoos/opam-repository that referenced this pull request Nov 23, 2021
CHANGES:

Mon Jul 26 11:12:21 PM CET 2021

  + merlin binary
    - Mbrowse.select_leaf: correctly ignore merlin.hide (ocaml/merlin#1376)
    - enable `occurences` to work when looking for locally abstract types
      (ocaml/merlin#1382)
    - handle `-alert` compiler flag (ocaml/merlin#1401)
    - avoid a race condition when the process started to read a configuration
      file crashes/is not found (ocaml/merlin#1378, @antalsz)
    - log the backtrace even when the exception is a Failure (ocaml/merlin#1377, @antalsz)
    - ignore `-error-style` compiler flag (ocaml/merlin#1402, @nojb)
    - fix handling of record field expressions (ocaml/merlin#1375)
    - allow -pp to return an AST (ocaml/merlin#1394)
    - fix merlin crashing due to short-paths (ocaml/merlin#1334, fixes ocaml/merlin#1322)
  + editor modes
    - update quick setup instructions for emacs (ocaml/merlin#1380, @ScriptDevil)
  + test suite
    - improve record field destruction testing (ocaml/merlin#1375)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Nov 23, 2021
CHANGES:

Mon Jul 26 11:12:21 PM CET 2021

  + ocaml support
    - add support for 4.13
    - stopped actively supporting version older than 4.12
  + merlin binary
    - Mbrowse.select_leaf: correctly ignore merlin.hide (ocaml/merlin#1376)
    - enable `occurences` to work when looking for locally abstract types
      (ocaml/merlin#1382)
    - handle `-alert` compiler flag (ocaml/merlin#1401)
    - avoid a race condition when the process started to read a configuration
      file crashes/is not found (ocaml/merlin#1378, @antalsz)
    - log the backtrace even when the exception is a Failure (ocaml/merlin#1377, @antalsz)
    - ignore `-error-style` compiler flag (ocaml/merlin#1402, @nojb)
    - fix handling of record field expressions (ocaml/merlin#1375)
    - allow -pp to return an AST (ocaml/merlin#1394)
    - fix merlin crashing due to short-paths (ocaml/merlin#1334, fixes ocaml/merlin#1322)
  + editor modes
    - update quick setup instructions for emacs (ocaml/merlin#1380, @ScriptDevil)
  + test suite
    - improve record field destruction testing (ocaml/merlin#1375)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Nov 23, 2021
CHANGES:

Mon Jul 26 11:12:21 PM CET 2021

  + merlin binary
    - Mbrowse.select_leaf: correctly ignore merlin.hide (ocaml/merlin#1376)
    - enable `occurences` to work when looking for locally abstract types
      (ocaml/merlin#1382)
    - handle `-alert` compiler flag (ocaml/merlin#1401)
    - avoid a race condition when the process started to read a configuration
      file crashes/is not found (ocaml/merlin#1378, @antalsz)
    - log the backtrace even when the exception is a Failure (ocaml/merlin#1377, @antalsz)
    - ignore `-error-style` compiler flag (ocaml/merlin#1402, @nojb)
    - fix handling of record field expressions (ocaml/merlin#1375)
    - allow -pp to return an AST (ocaml/merlin#1394)
    - fix merlin crashing due to short-paths (ocaml/merlin#1334, fixes ocaml/merlin#1322)
  + editor modes
    - update quick setup instructions for emacs (ocaml/merlin#1380, @ScriptDevil)
  + test suite
    - improve record field destruction testing (ocaml/merlin#1375)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Nov 23, 2021
CHANGES:

Tue Nov 23 11:45:21 PM CET 2021

  + merlin binary
    - Mbrowse.select_leaf: correctly ignore merlin.hide (ocaml/merlin#1376)
    - make `occurences` work when looking for locally abstract types (ocaml/merlin#1382)
    - handle `-alert` compiler flag
    - improve destruct calls on record fields (ocaml/merlin#1375)
    - avoid a race condition when the process started to read a configuration
      file crashes/is not found (ocaml/merlin#1378, @antalsz)
    - log the backtrace even when the exception is a Failure (ocaml/merlin#1377, @antalsz)
    - allow -pp to return an AST (ocaml/merlin#1394)
    - ignore `-error-style` compiler flag (ocaml/merlin#1402, @nojb)
    - fix handling of record field expressions (ocaml/merlin#1375)
  + test suite
    - improve record field destruction testing (ocaml/merlin#1375)
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.

4 participants