Skip to content

Commit 6cf2873

Browse files
committed
Merge branch 'origin/edge' into 'master'
For eng/shared/anod#412 Depends-On: eng/shared/anod!4533
2 parents 8703c3c + e35db6e commit 6cf2873

File tree

191 files changed

+6790
-1415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+6790
-1415
lines changed

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ test-vscode-extension:
140140

141141
# Run VSCode extension tests
142142
- echo -e "\e[0Ksection_start:`date +%s`:test_vscode[collapsed=true]\r\e[0Kanod test vscode-extension"
143-
- anod test vscode-extension --qualifier=$ACI_TRACK_QUALIFIER --minimal
143+
- anod test vscode-extension $ACI_TRACK_QUALIFIER --minimal
144144

145145
- VSCODE_BUILD_SPACE=$(anod info test vscode-extension $ACI_TRACK_QUALIFIER --show working_dir)
146146
- echo -e "\e[0Ksection_end:`date +%s`:test_vscode\r\e[0K"

doc/metaModel.json

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9087,58 +9087,6 @@
90879087
],
90889088
"documentation": "Provider options for a [DocumentLinkRequest](#DocumentLinkRequest)."
90899089
},
9090-
{
9091-
"name": "FormattingOptions",
9092-
"properties": [
9093-
{
9094-
"name": "tabSize",
9095-
"type": {
9096-
"kind": "base",
9097-
"name": "uinteger"
9098-
},
9099-
"documentation": "Size of a tab in spaces."
9100-
},
9101-
{
9102-
"name": "insertSpaces",
9103-
"type": {
9104-
"kind": "base",
9105-
"name": "boolean"
9106-
},
9107-
"documentation": "Prefer spaces over tabs."
9108-
},
9109-
{
9110-
"name": "trimTrailingWhitespace",
9111-
"type": {
9112-
"kind": "base",
9113-
"name": "boolean"
9114-
},
9115-
"optional": true,
9116-
"documentation": "Trim trailing whitespace on a line.\n\n@since 3.15.0",
9117-
"since": "3.15.0"
9118-
},
9119-
{
9120-
"name": "insertFinalNewline",
9121-
"type": {
9122-
"kind": "base",
9123-
"name": "boolean"
9124-
},
9125-
"optional": true,
9126-
"documentation": "Insert a newline character at the end of the file if one does not exist.\n\n@since 3.15.0",
9127-
"since": "3.15.0"
9128-
},
9129-
{
9130-
"name": "trimFinalNewlines",
9131-
"type": {
9132-
"kind": "base",
9133-
"name": "boolean"
9134-
},
9135-
"optional": true,
9136-
"documentation": "Trim all newlines after the final newline at the end of the file.\n\n@since 3.15.0",
9137-
"since": "3.15.0"
9138-
}
9139-
],
9140-
"documentation": "Value-object describing what options formatting should use."
9141-
},
91429090
{
91439091
"name": "DocumentFormattingOptions",
91449092
"properties": [],

doc/metaModel.patch.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,76 @@
132132
}
133133
],
134134
"structures": [
135+
{
136+
"name": "FormattingOptions",
137+
"properties": [
138+
{
139+
"name": "tabSize",
140+
"type": {
141+
"kind": "base",
142+
"name": "uinteger"
143+
},
144+
"documentation": "Size of a tab in spaces."
145+
},
146+
{
147+
"name": "insertSpaces",
148+
"type": {
149+
"kind": "base",
150+
"name": "boolean"
151+
},
152+
"documentation": "Prefer spaces over tabs."
153+
},
154+
{
155+
"name": "trimTrailingWhitespace",
156+
"type": {
157+
"kind": "base",
158+
"name": "boolean"
159+
},
160+
"optional": true,
161+
"documentation": "Trim trailing whitespace on a line.\n\n@since 3.15.0",
162+
"since": "3.15.0"
163+
},
164+
{
165+
"name": "insertFinalNewline",
166+
"type": {
167+
"kind": "base",
168+
"name": "boolean"
169+
},
170+
"optional": true,
171+
"documentation": "Insert a newline character at the end of the file if one does not exist.\n\n@since 3.15.0",
172+
"since": "3.15.0"
173+
},
174+
{
175+
"name": "trimFinalNewlines",
176+
"type": {
177+
"kind": "base",
178+
"name": "boolean"
179+
},
180+
"optional": true,
181+
"documentation": "Trim all newlines after the final newline at the end of the file.\n\n@since 3.15.0",
182+
"since": "3.15.0"
183+
},
184+
{
185+
"name": "gnatFormatMaxSize",
186+
"type": {
187+
"kind": "base",
188+
"name": "uinteger"
189+
},
190+
"optional": true,
191+
"documentation": "Maximum line width for gnatformat"
192+
},
193+
{
194+
"name": "gnatFormatContinuationLineIndent",
195+
"type": {
196+
"kind": "base",
197+
"name": "uinteger"
198+
},
199+
"optional": true,
200+
"documentation": "Continuation Line Indentation size (defaults to indentation-1) for gnatformat"
201+
}
202+
],
203+
"documentation": "Value-object describing what options formatting should use."
204+
},
135205
{
136206
"name": "AlsCheckSyntaxParams",
137207
"properties": [

doc/settings.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ prefixing each setting name with `ada.`, e.g.
1616
"ada.scenarioVariables": {
1717
"LIBRARY_TYPE": "static"
1818
},
19-
"ada.onTypeFormatting.indentOnly": true
19+
"ada.onTypeFormatting.indentOnly": true,
20+
"useGnatformat": true
2021
}
2122
```
2223

@@ -58,6 +59,7 @@ Ada Language Server understands these settings:
5859
* [relocateBuildTree](#relocatebuildtree)
5960
* [rootDir](#rootdir)
6061
* [enableDiagnostics](#enablediagnostics)
62+
* [projectDiagnostics](#projectdiagnostics)
6163
* [enableIndexing](#enableindexing)
6264
* [renameInComments](#renameincomments)
6365
* [namedNotationThreshold](#namednotationthreshold)
@@ -67,6 +69,7 @@ Ada Language Server understands these settings:
6769
* [followSymlinks](#followsymlinks)
6870
* [documentationStyle](#documentationstyle)
6971
* [onTypeFormatting.indentOnly](#ontypeformattingindentonly)
72+
* [useGnatformat](#usegnatformat)
7073

7174
----
7275

@@ -141,6 +144,16 @@ The value is a boolean.
141144
'enableDiagnostics': false
142145
```
143146

147+
## projectDiagnostics
148+
149+
This setting needs `enableDiagnostics` enabled and can be disabled to remove
150+
project related diagnotics.
151+
The value is a boolean.
152+
153+
```javascript
154+
'enableDiagnostics': false
155+
```
156+
144157
## enableIndexing
145158

146159
By default, the server indexes the source files after loading a project,
@@ -275,3 +288,9 @@ An equivalent setting `gpr.trace.server` exists for tracing the communcation bet
275288
This option controls if the `textDocument/onTypeFormatting` request only indents a new line, or if
276289
it additionally tries to format the previous node. By default, this option is enabled, that is,
277290
`textDocument/onTypeFormatting` only indents new lines.
291+
292+
## useGnatformat
293+
294+
This option controls the formatting provider for the `textDocument/formatting`,
295+
`textDocument/rangeFormatting` and `textDocument/onTypeFormatting` request. By default, this option
296+
is enabled and ALS uses GNATformat as its formatting provider. If disabled, GNATpp is used instead.

doc/traces.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,9 @@ in `initialize` response.
6161
Log lalpp output if `yes`.
6262

6363
ALS.LAL_PP_OUTPUT_ON_FORMATTING=yes
64+
65+
## `ALS.GNATFORMAT` (default no)
66+
67+
Use GNATformat as format provider.
68+
69+
ALS.GNATFORMAT=yes

gnat/lsp_server.gpr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ with "lal_refactor.gpr";
1111
with "ada_libfswatch.gpr";
1212
with "libgnatdoc.gpr";
1313
with "spawn.gpr";
14+
with "gnatformat.gpr";
1415

1516
with "lsp_3_17";
1617
with "lsp_common";

integration/vscode/ada/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@
297297
},
298298
"order": 1
299299
},
300+
"ada.projectDiagnostics": {
301+
"scope": "window",
302+
"type": "boolean",
303+
"default": true,
304+
"description": "Controls whether or not the Ada Language Server should emit project diagnostics into the VS Code Problems view.\n\nNote: this setting is ignored if `ada.enableDiagnostics` is disabled and a workspace reload is necessary to refresh the diagnostics after modifying this setting."
305+
},
300306
"ada.defaultCharset": {
301307
"scope": "window",
302308
"type": "string",
@@ -323,6 +329,12 @@
323329
"title": "Formatting",
324330
"order": 1,
325331
"properties": {
332+
"ada.useGnatformat": {
333+
"scope": "window",
334+
"type": "boolean",
335+
"default": true,
336+
"markdownDescription": "Enable GNATformat as the formatting provider for Ada source files."
337+
},
326338
"ada.onTypeFormatting.indentOnly": {
327339
"scope": "window",
328340
"type": "boolean",

integration/vscode/ada/src/ExtensionState.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class ExtensionState {
4747
/**
4848
* The following fields are caches for ALS requests or costly properties.
4949
*/
50-
cachedProjectFile: string | undefined;
50+
cachedProjectUri: vscode.Uri | undefined;
5151
cachedObjectDir: string | undefined;
5252
cachedMains: string[] | undefined;
5353
cachedExecutables: string[] | undefined;
@@ -57,7 +57,7 @@ export class ExtensionState {
5757
private sparkTaskProvider?: SimpleTaskProvider;
5858

5959
public clearALSCache() {
60-
this.cachedProjectFile = undefined;
60+
this.cachedProjectUri = undefined;
6161
this.cachedObjectDir = undefined;
6262
this.cachedMains = undefined;
6363
this.cachedExecutables = undefined;
@@ -184,16 +184,26 @@ export class ExtensionState {
184184
};
185185

186186
/**
187-
* @returns the full path of the main project file from the ALS
187+
* @returns the URI of the main project file from the ALS
188188
*/
189-
public async getProjectFile(): Promise<string> {
190-
if (!this.cachedProjectFile) {
191-
this.cachedProjectFile = (await this.adaClient.sendRequest(ExecuteCommandRequest.type, {
189+
public async getProjectUri(): Promise<vscode.Uri | undefined> {
190+
if (!this.cachedProjectUri) {
191+
const strUri = (await this.adaClient.sendRequest(ExecuteCommandRequest.type, {
192192
command: 'als-project-file',
193193
})) as string;
194+
if (strUri != '') {
195+
this.cachedProjectUri = vscode.Uri.parse(strUri, true);
196+
}
194197
}
195198

196-
return this.cachedProjectFile;
199+
return this.cachedProjectUri;
200+
}
201+
202+
/**
203+
* @returns the full path of the main project file from the ALS
204+
*/
205+
public async getProjectFile(): Promise<string> {
206+
return (await this.getProjectUri())?.fsPath ?? '';
197207
}
198208

199209
/**

integration/vscode/ada/test/suite/general/extension.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import * as assert from 'assert';
22
import { adaExtState } from '../../../src/extension';
3-
import { getProjectFile, getObjectDir } from '../../../src/helpers';
4-
import { assertEqualToFileContent, activate } from '../utils';
3+
import { getObjectDir } from '../../../src/helpers';
4+
import { activate, assertEqualToFileContent } from '../utils';
55

6-
import * as vscode from 'vscode';
76
import { readFileSync, writeFileSync } from 'fs';
8-
import { basename } from 'path';
7+
import * as vscode from 'vscode';
98

109
suite('Extensions Test Suite', function () {
1110
// Make sure the extension is activated
@@ -14,9 +13,14 @@ suite('Extensions Test Suite', function () {
1413
});
1514
test('Project File Response', async () => {
1615
if (vscode.workspace.workspaceFolders !== undefined) {
17-
const result: string = await getProjectFile(adaExtState.adaClient);
18-
const name = basename(result);
19-
assert.strictEqual(name, 'prj.gpr');
16+
// Uri obtained from the ALS
17+
const alsUri = await adaExtState.getProjectUri();
18+
// Uri manually computed based on the loaded workspace
19+
const wsUri = vscode.Uri.joinPath(vscode.workspace.workspaceFolders[0].uri, 'prj.gpr');
20+
// Ask for fsPath, it will resolve wsUri._fsPath
21+
wsUri.fsPath != null
22+
// Both should match
23+
assert.deepStrictEqual(alsUri, wsUri);
2024
} else {
2125
throw new Error('No workspace folder found for the specified URI');
2226
}

integration/vscode/ada/test/suite/general/helpers.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ suite('which and envHasExec', function () {
3030
suite('findAdaMain', function () {
3131
test('Find one main (simple case)', async function () {
3232
/* Test that findAdaMain works in a simple case */
33-
const uri = Uri.joinPath(workspace.workspaceFolders![0].uri, 'src', 'main1.adb');
33+
const folders = workspace.workspaceFolders;
34+
assert(folders && folders.length > 0);
35+
const uri = Uri.joinPath(folders[0].uri, 'src', 'main1.adb');
3436
const adaMain = await findAdaMain(uri.fsPath);
3537
assert(adaMain);
3638
});
3739
test('Find one main (case sensitivity)', async function () {
3840
/* Test the behavior of findAdaMain with respect to case sensitivity */
39-
const uri_uppercase = Uri.joinPath(workspace.workspaceFolders![0].uri, 'src', 'MAIN1.ADB');
41+
const folders = workspace.workspaceFolders;
42+
assert(folders && folders.length > 0);
43+
const uri_uppercase = Uri.joinPath(folders[0].uri, 'src', 'MAIN1.ADB');
4044
const adaMain_from_uppercase = await findAdaMain(uri_uppercase.fsPath);
4145

4246
/* On Windows we should have a main here, otherwise we should not */

0 commit comments

Comments
 (0)