Skip to content

Commit 1aaaba5

Browse files
Make GNATformat the default for the ALS
Adapt tests that can be ported to GNATformat's back-end and just set 'useGnatformat' to false for gnatpp's specific tests. For eng/ide/ada_language_server#1588
1 parent 2347e29 commit 1aaaba5

File tree

9 files changed

+436
-453
lines changed

9 files changed

+436
-453
lines changed

source/ada/lsp-ada_configurations.ads

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private
165165
Rename_In_Comments : Boolean := False;
166166
Folding_Comments : Boolean := True;
167167
Use_Completion_Snippets : Boolean := True;
168-
Use_Gnatformat : Boolean := False;
168+
Use_Gnatformat : Boolean := True;
169169
Indent_Only : Boolean := True;
170170
Follow_Symlinks : Boolean := True;
171171
Insert_With_Clauses : Boolean := True;

testsuite/ada_lsp/T616-016.formatting_incorrect_code/test.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
[
22
{
3-
"comment": [
4-
"Test formatting request"
5-
]
3+
"comment": ["Test formatting request"]
64
},
75
{
86
"start": {
9-
"cmd": [
10-
"${ALS}"
11-
]
7+
"cmd": ["${ALS}"]
128
}
139
},
1410
{
@@ -110,7 +106,7 @@
110106
"id": 3,
111107
"error": {
112108
"code": -32803,
113-
"message": "GNATPP: Syntactically invalid code can't be formatted"
109+
"message": "GNATFORMAT: Syntactically invalid code can't be formatted"
114110
}
115111
}
116112
]
Lines changed: 127 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,130 @@
11
[
2-
{
3-
"comment": [
4-
"Check that formatting request takes switches from a project file into account"
5-
]
6-
}, {
7-
"start": {
8-
"cmd": ["${ALS}"]
9-
}
10-
}, {
11-
"send": {
12-
"request": {"jsonrpc":"2.0","id":0,"method":"initialize","params":{
13-
"processId":1,
14-
"rootUri":"$URI{.}",
15-
"capabilities":{}}
16-
},
17-
"wait":[{ "id": 0,
18-
"result":{
19-
"capabilities":{
20-
"textDocumentSync":2,
21-
"documentFormattingProvider":true
22-
}
23-
}
24-
}]
25-
}
26-
}, {
27-
"send": {
28-
"request": {
29-
"jsonrpc":"2.0",
30-
"method":"workspace/didChangeConfiguration",
31-
"params":{
32-
"settings":{
33-
"ada":{
34-
}
35-
}
36-
}
37-
},
38-
"wait":[]
39-
}
40-
}, {
41-
"send": {
42-
"request": {
43-
"jsonrpc":"2.0",
44-
"method":"textDocument/didOpen",
45-
"params":{
46-
"textDocument": {
47-
"uri": "$URI{main.adb}",
48-
"languageId": "ada",
49-
"version": 1,
50-
"text": "procedure Main is begin null;\nend Main;\n"
51-
}
52-
}
53-
},
54-
"wait":[]
55-
}
56-
}, {
57-
"send": {
58-
"request": {
59-
"jsonrpc":"2.0",
60-
"id":"format",
61-
"method":"textDocument/formatting",
62-
"params":{
63-
"textDocument": {
64-
"uri": "$URI{main.adb}"
65-
},
66-
"options": {
67-
"tabSize": 4,
68-
"insertSpaces": true
69-
}
70-
}
71-
},
72-
"wait":[{
73-
"id": "format",
74-
"result": [
75-
{
76-
"range": {
77-
"start": {
78-
"line": 0,
79-
"character": 0
80-
},
81-
"end": {
82-
"line": 2,
83-
"character": 0
84-
}
2+
{
3+
"comment": [
4+
"Check that formatting request takes switches from a project file into account"
5+
]
6+
},
7+
{
8+
"start": {
9+
"cmd": ["${ALS}"]
10+
}
11+
},
12+
{
13+
"send": {
14+
"request": {
15+
"jsonrpc": "2.0",
16+
"id": 0,
17+
"method": "initialize",
18+
"params": {
19+
"processId": 1,
20+
"rootUri": "$URI{.}",
21+
"capabilities": {}
22+
}
23+
},
24+
"wait": [
25+
{
26+
"id": 0,
27+
"result": {
28+
"capabilities": {
29+
"textDocumentSync": 2,
30+
"documentFormattingProvider": true
31+
}
32+
}
33+
}
34+
]
35+
}
36+
},
37+
{
38+
"send": {
39+
"request": {
40+
"jsonrpc": "2.0",
41+
"method": "workspace/didChangeConfiguration",
42+
"params": {
43+
"settings": {
44+
"ada": {
45+
"useGnatformat": false
46+
}
47+
}
48+
}
49+
},
50+
"wait": []
51+
}
52+
},
53+
{
54+
"send": {
55+
"request": {
56+
"jsonrpc": "2.0",
57+
"method": "textDocument/didOpen",
58+
"params": {
59+
"textDocument": {
60+
"uri": "$URI{main.adb}",
61+
"languageId": "ada",
62+
"version": 1,
63+
"text": "procedure Main is begin null;\nend Main;\n"
64+
}
65+
}
66+
},
67+
"wait": []
68+
}
69+
},
70+
{
71+
"send": {
72+
"request": {
73+
"jsonrpc": "2.0",
74+
"id": "format",
75+
"method": "textDocument/formatting",
76+
"params": {
77+
"textDocument": {
78+
"uri": "$URI{main.adb}"
79+
},
80+
"options": {
81+
"tabSize": 4,
82+
"insertSpaces": true
83+
}
84+
}
85+
},
86+
"wait": [
87+
{
88+
"id": "format",
89+
"result": [
90+
{
91+
"range": {
92+
"start": {
93+
"line": 0,
94+
"character": 0
8595
},
86-
"newText": "PROCEDURE Main IS\nBEGIN\n NULL;\nEND Main;\n"
87-
}
88-
]
89-
}]
90-
}
91-
}, {
92-
"send": {
93-
"request": {
94-
"jsonrpc":"2.0",
95-
"id": "shutdown",
96-
"method":"shutdown",
97-
"params":null
98-
},
99-
"wait":[{ "id": "shutdown", "result": null }]
100-
}
101-
}, {
102-
"send": {
103-
"request": {"jsonrpc":"2.0", "method":"exit"},
104-
"wait":[]
105-
}
106-
}, {
107-
"stop": {
108-
"exit_code": 0
109-
}
110-
}
96+
"end": {
97+
"line": 2,
98+
"character": 0
99+
}
100+
},
101+
"newText": "PROCEDURE Main IS\nBEGIN\n NULL;\nEND Main;\n"
102+
}
103+
]
104+
}
105+
]
106+
}
107+
},
108+
{
109+
"send": {
110+
"request": {
111+
"jsonrpc": "2.0",
112+
"id": "shutdown",
113+
"method": "shutdown",
114+
"params": null
115+
},
116+
"wait": [{ "id": "shutdown", "result": null }]
117+
}
118+
},
119+
{
120+
"send": {
121+
"request": { "jsonrpc": "2.0", "method": "exit" },
122+
"wait": []
123+
}
124+
},
125+
{
126+
"stop": {
127+
"exit_code": 0
128+
}
129+
}
111130
]

testsuite/ada_lsp/V628-024.symbol_diff/test.json

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
[
22
{
3-
"comment": [
4-
"Tests if symbols diff works"
5-
]
3+
"comment": ["Tests if symbols diff works"]
64
},
75
{
86
"start": {
9-
"cmd": [
10-
"${ALS}",
11-
"--tracefile=./traces.cfg"
12-
]
7+
"cmd": ["${ALS}", "--tracefile=./traces.cfg"]
138
}
149
},
1510
{
@@ -26,9 +21,7 @@
2621
"applyEdit": true,
2722
"workspaceEdit": {
2823
"documentChanges": true,
29-
"resourceOperations": [
30-
"rename"
31-
]
24+
"resourceOperations": ["rename"]
3225
}
3326
},
3427
"textDocument": {
@@ -37,15 +30,9 @@
3730
"dynamicRegistration": true,
3831
"completionItem": {
3932
"snippetSupport": false,
40-
"documentationFormat": [
41-
"plaintext",
42-
"markdown"
43-
],
33+
"documentationFormat": ["plaintext", "markdown"],
4434
"resolveSupport": {
45-
"properties": [
46-
"detail",
47-
"documentation"
48-
]
35+
"properties": ["detail", "documentation"]
4936
}
5037
}
5138
},
@@ -100,7 +87,8 @@
10087
"enableDiagnostics": true,
10188
"followSymlinks": false,
10289
"documentationStyle": "gnat",
103-
"foldComments": false
90+
"foldComments": false,
91+
"useGnatformat": false
10492
}
10593
}
10694
}
@@ -230,8 +218,7 @@
230218
}
231219
}
232220
},
233-
"wait": [
234-
]
221+
"wait": []
235222
}
236223
},
237224
{

testsuite/ada_lsp/V701-011.formatting.options_precedence/default.gpr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ project Default is
22

33
for Main use ("main.adb");
44

5-
package Pretty_Printer is
6-
for Default_Switches ("Ada") use ("--indentation=10");
7-
end Pretty_Printer;
5+
package Format is
6+
for Indentation ("Ada") use "10";
7+
end Format;
88

99
end Default;

0 commit comments

Comments
 (0)