Skip to content

Commit

Permalink
Avoid certain cases where 'is' is in its own line
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopsazevedo committed Aug 1, 2024
1 parent c8ef0d8 commit 3433675
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 8 deletions.
87 changes: 79 additions & 8 deletions extensions/default_unparsing_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5309,17 +5309,88 @@
{
"kind": "recurse_field",
"field": "f_aspects"
},
"line",
{
"kind": "text",
"text": "is"
}
]
],
"id": "subp_spec"
},
{
"kind": "recurse_field",
"field": "f_decls"
"kind": "ifKind",
"field": "f_aspects",
"default": {
"kind": "ifBreak",
"groupId": "subp_spec",
"flatContents": {
"kind": "group",
"document": [
{
"kind": "group",
"document": [
"line",
{
"kind": "text",
"text": "is"
}
]
},
{
"kind": "recurse_field",
"field": "f_decls"
}
]
},
"breakContents": {
"kind": "group",
"document": [
"hardline",
{
"kind": "text",
"text": "is"
},
{
"kind": "recurse_field",
"field": "f_decls"
}
]
}
},
"null": {
"kind": "ifBreak",
"groupId": "subp_spec",
"flatContents": {
"kind": "group",
"document": [
{
"kind": "group",
"document": [
"line",
{
"kind": "text",
"text": "is"
}
]
},
{
"kind": "recurse_field",
"field": "f_decls"
}
]
},
"breakContents": {
"kind": "group",
"document": [
"line",
{
"kind": "text",
"text": "is"
},
{
"kind": "recurse_field",
"field": "f_decls"
}
]
}
},
"matchers": []
},
{
"kind": "text",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function To_Source_Location_Range
(Self : Langkit_Text_Document'Class; A_Range : LSP.Structures.A_Range)
return Langkit_Support.Slocs.Source_Location_Range
is
begin
return
Langkit_Support.Slocs.Make_Range
(Self.To_Source_Location (A_Range.start),
Self.To_Source_Location (A_Range.an_end));
end To_Source_Location_Range;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function To_Source_Location_Range
(Self : Langkit_Text_Document'Class; A_Range : LSP.Structures.A_Range)
return Langkit_Support.Slocs.Source_Location_Range is
begin
return
Langkit_Support.Slocs.Make_Range
(Self.To_Source_Location (A_Range.start),
Self.To_Source_Location (A_Range.an_end));
end To_Source_Location_Range;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
driver: unparser
rule: subp_body
description: |
For a `SubpBody` node whose `f_decls` is empty, null `f_aspects` and
`f_subp_spec` breaks, test that the `is` is added to the end of
`f_subp_spec` if it fits.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function To_Source_Location_Range
(Self : Langkit_Text_Document'Class; A_Range : LSP.Structures.A_Range)
return Langkit_Support.Slocs.Source_Location_Range is
I : Integer;
begin
return
Langkit_Support.Slocs.Make_Range
(Self.To_Source_Location (A_Range.start),
Self.To_Source_Location (A_Range.an_end));
end To_Source_Location_Range;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function To_Source_Location_Range
(Self : Langkit_Text_Document'Class; A_Range : LSP.Structures.A_Range)
return Langkit_Support.Slocs.Source_Location_Range
is
I : Integer;
begin
return
Langkit_Support.Slocs.Make_Range
(Self.To_Source_Location (A_Range.start),
Self.To_Source_Location (A_Range.an_end));
end To_Source_Location_Range;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
driver: unparser
rule: subp_body
description: |
For a `SubpBody` node whose `f_decls` is not empty, null `f_aspects` and
`f_subp_spec` breaks, test that a line break is added before the `is`.

0 comments on commit 3433675

Please sign in to comment.