Skip to content

Commit 707598e

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents 313bb7e + ec2d71e commit 707598e

File tree

27 files changed

+603
-132
lines changed

27 files changed

+603
-132
lines changed

.vscode/tasks.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"label": "Run tests",
66
"type": "shell",
77
"command": "make check",
8-
"problemMatcher": ["$ada"],
8+
"problemMatcher": ["$ada-error", "$ada-warning", "$ada-info"],
99
"group": "test"
1010
},
1111
{
@@ -30,7 +30,7 @@
3030
"type": "ada",
3131
"command": "make",
3232
"args": ["GPRBUILD_CARGS=-cargs:ada -gnatef"],
33-
"problemMatcher": ["$ada"],
33+
"problemMatcher": ["$ada-error", "$ada-warning", "$ada-info"],
3434
"group": "build",
3535
"label": "ada: Build current project",
3636
"presentation": {

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ by providing extra tool command line options via the `args` property of the obje
197197
"-gargs",
198198
"-vh"
199199
],
200-
"problemMatcher": ["$ada"],
200+
"problemMatcher": ["$ada-error", "$ada-warning", "$ada-info"],
201201
"group": "build",
202202
"label": "ada: Build current project"
203203
}
@@ -225,7 +225,7 @@ You can also customize the working directory of the task or the environment vari
225225
"MY_ENV_VAR": "value"
226226
}
227227
},
228-
"problemMatcher": ["$ada"],
228+
"problemMatcher": ["$ada-error", "$ada-warning", "$ada-info"],
229229
"group": "build",
230230
"label": "ada: Build current project"
231231
}

doc/Getting-Started.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ Your new `tasks.json` file should look similar to the JSON below:
189189
"-gnatef"
190190
],
191191
"problemMatcher": [
192-
"$ada"
192+
"$ada-error",
193+
"$ada-warning",
194+
"$ada-info"
193195
],
194196
"group": {
195197
"kind": "build",

integration/vscode/Code Samples/docker/.vscode/tasks.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
"-cargs",
1515
"-gnatef"
1616
],
17-
"problemMatcher": ["$ada"],
17+
"problemMatcher": ["$ada-error", "$ada-warning", "$ada-info"],
1818
"group": {
1919
"kind": "build",
2020
"isDefault": true
2121
}
2222
}
2323
]
24-
}
24+
}

integration/vscode/Code Samples/gnatprove/.vscode/tasks.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"-cargs",
1818
"-gnatef"
1919
],
20-
"problemMatcher": ["$ada"],
20+
"problemMatcher": ["$ada-error", "$ada-warning", "$ada-info"],
2121
"group": {
2222
"kind": "build",
2323
"isDefault": true

integration/vscode/Code Samples/hello/.vscode/tasks.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
]
1515
},
1616
"problemMatcher": [
17-
"$ada"
17+
"$ada-error",
18+
"$ada-warning",
19+
"$ada-info"
1820
],
1921
"group": "build",
2022
"label": "ada: Build project",

integration/vscode/ada/package.json

+291-53
Large diffs are not rendered by default.

integration/vscode/ada/schemas/als-settings-schema.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
"projectDiagnostics": {
2626
"type": "boolean",
2727
"default": true,
28-
"description": "Controls whether or not the Ada Language Server should emit project diagnostics into the VS Code Problems view."
28+
"description": "Controls whether or not the Ada Language Server should emit diagnostics about project loading."
2929
},
3030
"alireDiagnostics": {
3131
"type": "boolean",
3232
"default": true,
33-
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to alire into the VS Code Problems view."
33+
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to Alire."
3434
},
3535
"defaultCharset": {
3636
"type": "string",
@@ -88,12 +88,12 @@
8888
"adaFileDiagnostics": {
8989
"type": "boolean",
9090
"default": true,
91-
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to the edition of Ada Files into the VS Code Problems view."
91+
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to the edition of Ada files."
9292
},
9393
"gprFileDiagnostics": {
9494
"type": "boolean",
9595
"default": true,
96-
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to the edition of GPR Files into the VS Code Problems view."
96+
"description": "Controls whether or not the Ada Language Server should emit diagnostics related to the edition of GPR files."
9797
},
9898
"foldComments": {
9999
"type": "boolean",

integration/vscode/ada/src/clients.ts

+59-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { existsSync } from 'fs';
22
import * as vscode from 'vscode';
33
import {
4+
DidChangeConfigurationNotification,
45
LanguageClient,
56
LanguageClientOptions,
67
MessageSignature,
78
ServerOptions,
9+
State,
810
} from 'vscode-languageclient/node';
911
import { logger } from './extension';
1012
import { logErrorAndThrow, setTerminalEnvironment } from './helpers';
@@ -124,16 +126,69 @@ export function createClient(
124126
// Register the server for ada sources documents
125127
documentSelector: [{ scheme: 'file', language: id }],
126128
synchronize: {
127-
// Synchronize the setting section 'ada' to the server
128-
configurationSection: 'ada',
129129
// Notify the server about file changes to Ada files contain in the workspace
130130
fileEvents: vscode.workspace.createFileSystemWatcher(pattern),
131131
},
132-
// Include the ada.* settings in the initialize request sent to the server
133-
initializationOptions: () => ({ ada: vscode.workspace.getConfiguration('ada') }),
132+
initializationOptions: () =>
133+
/**
134+
* Only include the settings that are explicitly set in one of the
135+
* VS Code scopes to avoid unintentionally overriding ALS settings
136+
* from .als.json or other applicable configuration files.
137+
*/
138+
({ ada: getExplicitlySetConfiguration() }),
134139
};
140+
135141
// Create the language client
136142
const client = new AdaLanguageClient(id, name, serverOptions, clientOptions);
143+
144+
context.subscriptions.push(
145+
vscode.workspace.onDidChangeConfiguration(async (e) => {
146+
if (e.affectsConfiguration('ada') && client.state === State.Running) {
147+
await client.sendNotification(DidChangeConfigurationNotification.type, {
148+
settings: {
149+
ada: getExplicitlySetConfiguration(),
150+
},
151+
});
152+
}
153+
}),
154+
);
155+
137156
client.serverEnv = serverEnv;
138157
return client;
139158
}
159+
160+
/**
161+
* ALS settings can come from configuration files (e.g. .als.json) and from VS
162+
* Code.
163+
*
164+
* Settings from config files are loaded first. To avoid overwriting them
165+
* unintentionally, settings from VS Code should only be sent if they were
166+
* explicitly set in one of the VS Code configuration scopes.
167+
*
168+
* This function returns that set of settings.
169+
*
170+
* @returns a dictionary of ada.* settings that have been explicitly set in one
171+
* of the VS Code configuration scopes.
172+
*/
173+
function getExplicitlySetConfiguration(): { [k: string]: unknown } {
174+
// Get all ada.* settings
175+
const adaConfig = vscode.workspace.getConfiguration('ada');
176+
const explicitSettings = Object.fromEntries(
177+
Object.entries(adaConfig).filter(([key]) => {
178+
// Filter to settings that are explicitly set
179+
const info = adaConfig.inspect(key);
180+
return (
181+
info &&
182+
[
183+
info.globalValue,
184+
info.workspaceValue,
185+
info.workspaceFolderValue,
186+
info.globalLanguageValue,
187+
info.workspaceLanguageValue,
188+
info.workspaceFolderLanguageValue,
189+
].some((v) => v !== undefined)
190+
);
191+
}),
192+
);
193+
return explicitSettings;
194+
}

integration/vscode/ada/src/commands.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { AdaConfig, getOrAskForProgram, initializeConfig } from './debugConfigPr
1010
import { adaExtState, logger, mainOutputChannel } from './extension';
1111
import { findAdaMain, getProjectFileRelPath, getSymbols } from './helpers';
1212
import {
13-
DEFAULT_PROBLEM_MATCHER,
13+
DEFAULT_PROBLEM_MATCHERS,
1414
SimpleTaskDef,
1515
TASK_PROVE_FILE_PLAIN_NAME,
1616
TASK_PROVE_LINE_PLAIN_NAME,
@@ -1026,7 +1026,7 @@ async function sparkProveSubprogram(
10261026
* empty problem matcher list which would hide problems from the
10271027
* Problems view.
10281028
*/
1029-
task.problemMatchers.length > 0 ? task.problemMatchers : [DEFAULT_PROBLEM_MATCHER],
1029+
task.problemMatchers.length > 0 ? task.problemMatchers : DEFAULT_PROBLEM_MATCHERS,
10301030
);
10311031

10321032
/**

integration/vscode/ada/src/gnatTaskProvider.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import commandExists from 'command-exists';
1919
import * as vscode from 'vscode';
2020
import { getProjectFromConfigOrALS, sparkLimitRegionArg, sparkLimitSubpArg } from './commands';
21-
import { DEFAULT_PROBLEM_MATCHER, WarningMessageExecution } from './taskProviders';
21+
import { DEFAULT_PROBLEM_MATCHERS, WarningMessageExecution } from './taskProviders';
2222

2323
/**
2424
* Callback to provide an extra argument for a tool
@@ -238,7 +238,7 @@ export class GnatTaskProvider implements vscode.TaskProvider<vscode.Task> {
238238
msg,
239239
GnatTaskProvider.gnatType,
240240
this.obsoleteWarningExecution,
241-
DEFAULT_PROBLEM_MATCHER,
241+
DEFAULT_PROBLEM_MATCHERS,
242242
),
243243
];
244244
} else {
@@ -269,7 +269,7 @@ export class GnatTaskProvider implements vscode.TaskProvider<vscode.Task> {
269269
task.name,
270270
GnatTaskProvider.gnatType,
271271
this.obsoleteWarningExecution,
272-
DEFAULT_PROBLEM_MATCHER,
272+
DEFAULT_PROBLEM_MATCHERS,
273273
);
274274
}
275275
}

integration/vscode/ada/src/gnattest.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { addCoverageData, GnatcovFileCoverage } from './gnatcov';
1111
import { getScenarioArgs } from './gnatTaskProvider';
1212
import { escapeRegExp, exe, setTerminalEnvironment, slugify } from './helpers';
1313
import {
14-
DEFAULT_PROBLEM_MATCHER,
14+
DEFAULT_PROBLEM_MATCHERS,
1515
findTaskByName,
1616
runTaskSequence,
1717
SimpleTaskDef,
@@ -750,7 +750,7 @@ async function handleRunRequestedTests(
750750
`Create GNATcoverage XML report`,
751751
TASK_TYPE_ADA,
752752
undefined,
753-
DEFAULT_PROBLEM_MATCHER,
753+
DEFAULT_PROBLEM_MATCHERS,
754754
),
755755
))!;
756756
gnatcovReportTask.presentationOptions.reveal = vscode.TaskRevealKind.Never;
@@ -841,7 +841,7 @@ async function buildTestDriverAndReportErrors(
841841
instTaskName,
842842
TASK_TYPE_ADA,
843843
undefined,
844-
DEFAULT_PROBLEM_MATCHER,
844+
DEFAULT_PROBLEM_MATCHERS,
845845
),
846846
))!;
847847
instTask.presentationOptions.reveal =
@@ -878,7 +878,7 @@ async function buildTestDriverAndReportErrors(
878878
buildTaskName,
879879
TASK_TYPE_ADA,
880880
undefined,
881-
DEFAULT_PROBLEM_MATCHER,
881+
DEFAULT_PROBLEM_MATCHERS,
882882
),
883883
))!;
884884
buildTask.presentationOptions.reveal = vscode.TaskRevealKind.Never;

integration/vscode/ada/src/gprTaskProvider.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import * as vscode from 'vscode';
1919
import { LanguageClient } from 'vscode-languageclient/node';
2020
import { getMains, getExecutables, getProjectFile } from './helpers';
21-
import { DEFAULT_PROBLEM_MATCHER, WarningMessageExecution } from './taskProviders';
21+
import { DEFAULT_PROBLEM_MATCHERS, WarningMessageExecution } from './taskProviders';
2222

2323
/**
2424
*
@@ -62,7 +62,7 @@ export class GprTaskProvider implements vscode.TaskProvider<vscode.Task> {
6262
msg,
6363
GprTaskProvider.gprTaskType,
6464
this.obsoleteWarningExecution,
65-
DEFAULT_PROBLEM_MATCHER,
65+
DEFAULT_PROBLEM_MATCHERS,
6666
),
6767
];
6868
} else {
@@ -91,7 +91,7 @@ export class GprTaskProvider implements vscode.TaskProvider<vscode.Task> {
9191
task.name,
9292
GprTaskProvider.gprTaskType,
9393
this.obsoleteWarningExecution,
94-
DEFAULT_PROBLEM_MATCHER,
94+
DEFAULT_PROBLEM_MATCHERS,
9595
);
9696
}
9797
}

0 commit comments

Comments
 (0)