Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
24319eb
Add change entry.
Tim-ats-d May 16, 2025
a7a3729
Add a new command to extract expression into a fresh let binding.
Tim-ats-d Jul 16, 2025
500487f
Merge branch 'main' into refactor-extraction
Tim-ats-d Jul 16, 2025
1595bf4
Code quality.
Tim-ats-d Jul 17, 2025
d2d6e08
Add a function to determine if an expression is extractable inside a …
Tim-ats-d Jul 18, 2025
38055ff
More tests.
Tim-ats-d Jul 18, 2025
f388319
Attempt to fix a bug with binding belonging to a module.
Tim-ats-d Jul 18, 2025
1795632
Add change entry.
Tim-ats-d Jul 18, 2025
aee93b0
Add another test.
Tim-ats-d Jul 18, 2025
7f90f47
Fix generation for parameter that appears twice, parenthised generat…
Tim-ats-d Jul 21, 2025
baedfc7
Code quality.
Tim-ats-d Jul 21, 2025
3627558
Replace location heuristic by a proper analysis.
Tim-ats-d Jul 21, 2025
195ed6d
Remove path of value living in a module inside extracted expression.
Tim-ats-d Jul 22, 2025
af58896
Make extraction works in submodule.
Tim-ats-d Jul 24, 2025
b064a8b
Clean up expression before printing.
Tim-ats-d Jul 25, 2025
f3db927
Generate a suffix when a name is given and already used in current sc…
Tim-ats-d Jul 25, 2025
7551d2f
Fix a test.
Tim-ats-d Jul 25, 2025
d1d3c11
Take Ulysse's comments into account.
Tim-ats-d Sep 8, 2025
bc4e53d
Merge branch 'main' into refactor-extraction
Tim-ats-d Sep 8, 2025
c50af5b
Remove function type declaration.
Tim-ats-d Sep 8, 2025
28a421e
Fix constant extraction nested in a modules.
Tim-ats-d Sep 8, 2025
7fe97e7
Last fixes.
Tim-ats-d Sep 9, 2025
32f03f0
WIP.
Tim-ats-d Sep 9, 2025
daf74d9
Reproduce a bug.
Tim-ats-d Sep 9, 2025
7a00505
Merge branch 'state-of-work' into refactor-extraction
Tim-ats-d Sep 9, 2025
3ec6dcc
Last fixes.
Tim-ats-d Sep 11, 2025
d314db6
Fix CLI doc and typos.
Tim-ats-d Sep 25, 2025
11805ba
Clean up.
Tim-ats-d Sep 26, 2025
d3f6bdf
Add FIXME tests.
Tim-ats-d Sep 26, 2025
68b02e7
Fix PR nb.
Tim-ats-d Sep 30, 2025
fc8c063
Ensure minimality for refactor issue examples.
Tim-ats-d Oct 2, 2025
86cf319
Fix the path names in extractions
voodoos Oct 2, 2025
ee60e2d
Revert "Fix the path names in extractions"
voodoos Oct 2, 2025
9bb9388
Attempt #2 at fixing pathed param names
voodoos Oct 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
unreleased
==========

+ merlin library
- Implement new refactor-extract-region command for extracting region to a fresh let binding (#1948)
- Fix `merlin_reader` for OpenBSD (#1956)

merlin 5.5
Expand Down
19 changes: 19 additions & 0 deletions doc/dev/PROTOCOL.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,25 @@ The result is returned as a list of:
}
```

### `refactor-extract-region -start <position> -end <position> -extract-name <name>`

```
-start <position> Where extracted region start
-end <position> Where extracted region end
-extract-name <name> Name used for the generated let binding
```

Returns the string `Nothing to do` (if extractor is not ables to select an expression to extract in the given position interval) or the following object:

```javascript
{
'start': position, // the start of the region to be substituted
'end': position, // the end of the region to be substituted
'content' string, // the content of the substitution
'selection_range': location // the location where to position the cursor for easy renaming of the generated let binding
}
```

### `syntax-document -position <position>`

-position <position> The position of the keyword to be documented
Expand Down
16 changes: 16 additions & 0 deletions src/analysis/parsetree_utils.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
open Std

open Parsetree

type nonrec constant_desc = constant_desc

let constant_desc c = c.pconst_desc

let filter_merlin_attr =
let default = Ast_mapper.default_mapper in
let keep attr =
let { Location.txt; _ }, _ = Ast_helper.Attr.as_tuple attr in
not (Std.String.is_prefixed ~by:"merlin." txt)
in
let attributes mapper attrs =
default.Ast_mapper.attributes mapper (List.filter ~f:keep attrs)
in
{ default with Ast_mapper.attributes }

let expr_remove_merlin_attributes expr =
filter_merlin_attr.Ast_mapper.expr filter_merlin_attr expr
3 changes: 3 additions & 0 deletions src/analysis/parsetree_utils.mli
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ open Parsetree
type nonrec constant_desc = constant_desc

val constant_desc : constant -> constant_desc

(** Filter parsetree attributes which are prefixed by ["merlin."] in given expression. *)
val expr_remove_merlin_attributes : expression -> expression
Loading
Loading