Skip to content

Commit a9fe83f

Browse files
author
mergerepo
committed
Merge remote branch 'origin/master' into edge
(no-precommit-check no-tn-check)
2 parents 68223b7 + cd99f41 commit a9fe83f

File tree

6 files changed

+297
-13
lines changed

6 files changed

+297
-13
lines changed

integration/vscode/ada/src/gnatproveTaskProvider.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default class gnatproveTaskProvider implements vscode.TaskProvider<vscode
5555

5656
// Arguments for proof of selected region need to be evaluated here
5757
if (definition.taskKind == taskKinds.proveRegion) {
58-
const args = getGnatproveArgs('${config:ada.projectFile}', ['-u', '${fileBasename}', '--limit-region=${fileBasename}:' + getSelectedRegion(vscode.window.activeTextEditor)]);
58+
const args = getGnatproveArgs(['-u', '${fileBasename}', '--limit-region=${fileBasename}:' + getSelectedRegion(vscode.window.activeTextEditor)]);
5959
const shell = new vscode.ShellExecution('gnatprove', args);
6060
return new vscode.Task(definition, vscode.TaskScope.Workspace, task.name, 'ada', shell, '$ada');
6161
}
@@ -67,7 +67,7 @@ export default class gnatproveTaskProvider implements vscode.TaskProvider<vscode
6767
.then(subprogram =>
6868
{
6969
let args = (definition.taskKind == taskKinds.examineSubprogram) ? ['--mode=flow'] : [];
70-
args = getGnatproveArgs('${config:ada.projectFile}', args.concat(['-u', '${fileBasename}', '--limit-subp=${fileBasename}:' + subprogram]));
70+
args = getGnatproveArgs(args.concat(['-u', '${fileBasename}', '--limit-subp=${fileBasename}:' + subprogram]));
7171
const shell = new vscode.ShellExecution('gnatprove', args);
7272
return new vscode.Task(definition, vscode.TaskScope.Workspace, task.name, 'ada', shell, '$ada');
7373
});
@@ -96,14 +96,14 @@ const getTasks = (): vscode.Task[] => {
9696
// Examine the project
9797
const examineProject = makeTask(
9898
taskKinds.examineProject,
99-
getGnatproveArgs('${config:ada.projectFile}', ['--mode=flow']),
99+
getGnatproveArgs(['--mode=flow']),
100100
'Examine project'
101101
);
102102

103103
// Examine the file
104104
const examineFile = makeTask(
105105
taskKinds.examineFile,
106-
getGnatproveArgs('${config:ada.projectFile}', ['--mode=flow', '-u', '${fileBasename}']),
106+
getGnatproveArgs(['--mode=flow', '-u', '${fileBasename}']),
107107
'Examine file'
108108
);
109109

@@ -117,14 +117,14 @@ const getTasks = (): vscode.Task[] => {
117117
// Prove the project
118118
const proveProject = makeTask(
119119
taskKinds.proveProject,
120-
getGnatproveArgs('${config:ada.projectFile}', []),
120+
getGnatproveArgs([]),
121121
'Prove project'
122122
);
123123

124124
// Prove the file
125125
const proveFile = makeTask(
126126
taskKinds.proveFile,
127-
getGnatproveArgs('${config:ada.projectFile}', ['-u', '${fileBasename}']),
127+
getGnatproveArgs(['-u', '${fileBasename}']),
128128
'Prove file'
129129
);
130130

@@ -145,7 +145,7 @@ const getTasks = (): vscode.Task[] => {
145145
// Prove the selected line line
146146
const proveLine = makeTask(
147147
taskKinds.proveLine,
148-
getGnatproveArgs('${config:ada.projectFile}', ['-u', '${fileBasename}', '--limit-line=${fileBasename}:${lineNumber}']),
148+
getGnatproveArgs(['-u', '${fileBasename}', '--limit-line=${fileBasename}:${lineNumber}']),
149149
'Prove line'
150150
);
151151

@@ -208,23 +208,26 @@ const getSelectedRegion = (editor: vscode.TextEditor | undefined): string => {
208208
}
209209
};
210210

211-
const getGnatproveArgs = (projectFile: string, args: string[]): string[] => {
211+
const getGnatproveArgs = (args: string[]): string[] => {
212212
// Append args (if any) and `-gnatef` to generate full file names in errors/warnings
213213
const p_gnatef = ['-cargs', '-gnatef'];
214-
return commonArgs(projectFile).concat(args, p_gnatef);
214+
return commonArgs().concat(args, p_gnatef);
215215
};
216216

217-
// return '-P project.gpr -XVAR=value` optiona
218-
const commonArgs = (projectFile?: string): string[] => {
217+
// return '-P project.gpr -XVAR=value` options
218+
const commonArgs = (): string[] => {
219219
const vars: string[][] = Object.entries(
220220
vscode.workspace.getConfiguration('ada').get('scenarioVariables') ?? []
221221
);
222222
const fold = (args: string[], item: string[]): string[] => {
223223
const option = '-X' + item[0] + '=' + item[1];
224224
return args.concat([option]);
225225
};
226+
226227
// Set projectFile is any
227-
const prj = projectFile ? ['-P', projectFile] : [];
228+
const prj = vscode.workspace.getConfiguration('ada').get(
229+
'projectFile') != "" ? ['-P', "${config:ada.projectFile}"] : [];
230+
228231
// for each scenarioVariables put `-Xname=value` option
229232
return vars.reduce(fold, prj);
230233
};

source/ada/lsp-ada_completions-parameters.adb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ package body LSP.Ada_Completions.Parameters is
8383

8484
begin
8585
for N of reverse Context.Find_All_Env_Elements (Name_Node) loop
86-
if N.Kind in Ada_Basic_Subp_Decl then
86+
if N.Kind in Ada_Basic_Subp_Decl
87+
| Ada_Null_Subp_Decl_Range
88+
| Ada_Expr_Function_Range
89+
then
8790
declare
8891
Assoc : LSP.Ada_Completions.Generic_Assoc_Utils.Assoc_Data;
8992
Spec : constant Libadalang.Analysis.Base_Subp_Spec
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project Default is
2+
end Default;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
procedure Foo is
2+
function Bar
3+
(I, J, K : Integer; L : Float := 1.0) return Float is (L);
4+
procedure Bar (A, B : Integer) is null;
5+
procedure Bar (C : String);
6+
X : Float;
7+
begin
8+
X := Bar (
9+
end Foo;
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
[
2+
{
3+
"comment": [
4+
"Test param completion for: expression function, null procedure and",
5+
"procedure without a body"
6+
]
7+
},
8+
{
9+
"start": {
10+
"cmd": [
11+
"${ALS}"
12+
]
13+
}
14+
},
15+
{
16+
"send": {
17+
"request": {
18+
"jsonrpc": "2.0",
19+
"id": 1,
20+
"method": "initialize",
21+
"params": {
22+
"processId": 199714,
23+
"rootUri": "$URI{.}",
24+
"capabilities": {
25+
"workspace": {
26+
"applyEdit": true
27+
},
28+
"textDocument": {
29+
"completion": {
30+
"completionItem": {
31+
"snippetSupport": true,
32+
"documentationFormat": [
33+
"markdown",
34+
"plaintext"
35+
]
36+
}
37+
}
38+
},
39+
"window": {
40+
"workDoneProgress": true
41+
}
42+
}
43+
}
44+
},
45+
"wait": [
46+
{
47+
"jsonrpc": "2.0",
48+
"id": 1,
49+
"result": {
50+
"capabilities": {
51+
"textDocumentSync": 2,
52+
"completionProvider": {
53+
"triggerCharacters": [
54+
".",
55+
",",
56+
"'",
57+
"("
58+
],
59+
"resolveProvider": true
60+
}
61+
}
62+
}
63+
}
64+
]
65+
}
66+
},
67+
{
68+
"send": {
69+
"request": {
70+
"jsonrpc": "2.0",
71+
"method": "initialized"
72+
},
73+
"wait": []
74+
}
75+
},
76+
{
77+
"send": {
78+
"request": {
79+
"jsonrpc": "2.0",
80+
"method": "workspace/didChangeConfiguration",
81+
"params": {
82+
"settings": {
83+
"ada": {
84+
"projectFile":"$URI{default.gpr}"
85+
}
86+
}
87+
}
88+
},
89+
"wait": [
90+
{
91+
"jsonrpc": "2.0",
92+
"method": "$/progress",
93+
"params": {
94+
"token": "<ANY>",
95+
"value": {
96+
"kind": "end"
97+
}
98+
}
99+
}
100+
]
101+
}
102+
},
103+
{
104+
"send": {
105+
"request": {
106+
"jsonrpc": "2.0",
107+
"method": "textDocument/didOpen",
108+
"params": {
109+
"textDocument": {
110+
"uri": "$URI{foo.adb}",
111+
"languageId": "Ada",
112+
"version": 0,
113+
"text": "procedure Foo is\n function Bar\n (I, J, K : Integer; L : Float := 1.0) return Float is (L);\n procedure Bar (A, B : Integer) is null;\n procedure Bar (C : String);\n X : Float;\nbegin\n X := Bar (\nend Foo;\n"
114+
}
115+
}
116+
},
117+
"wait": []
118+
}
119+
},
120+
{
121+
"send": {
122+
"request": {
123+
"jsonrpc": "2.0",
124+
"id": 5,
125+
"method": "textDocument/completion",
126+
"params": {
127+
"textDocument": {
128+
"uri": "$URI{foo.adb}"
129+
},
130+
"position": {
131+
"line": 7,
132+
"character": 13
133+
},
134+
"context": {
135+
"triggerKind": 2
136+
}
137+
}
138+
},
139+
"wait": [
140+
{
141+
"id": 5,
142+
"result": {
143+
"isIncomplete": false,
144+
"items": [
145+
{
146+
"label": "Params of Bar",
147+
"kind": 15,
148+
"detail": "procedure Bar (C : String)",
149+
"documentation": "at foo.adb (5:4)",
150+
"sortText": "+00",
151+
"insertText": "C => ${1:String})$0",
152+
"insertTextFormat": 2,
153+
"additionalTextEdits": []
154+
},
155+
{
156+
"label": "C",
157+
"kind": 5,
158+
"sortText": "+01",
159+
"insertText": "C => ",
160+
"insertTextFormat": 1,
161+
"additionalTextEdits": []
162+
},
163+
{
164+
"label": "Params of Bar",
165+
"kind": 15,
166+
"detail": "procedure Bar (A, B : Integer) is null",
167+
"documentation": "at foo.adb (4:4)",
168+
"sortText": "+02",
169+
"insertText": "${1:A : Integer}, ${2:B : Integer})$0",
170+
"insertTextFormat": 2,
171+
"additionalTextEdits": []
172+
},
173+
{
174+
"label": "A",
175+
"kind": 5,
176+
"sortText": "+03",
177+
"insertText": "A => ",
178+
"insertTextFormat": 1,
179+
"additionalTextEdits": []
180+
},
181+
{
182+
"label": "B",
183+
"kind": 5,
184+
"sortText": "+04",
185+
"insertText": "B => ",
186+
"insertTextFormat": 1,
187+
"additionalTextEdits": []
188+
},
189+
{
190+
"label": "Params of Bar",
191+
"kind": 15,
192+
"detail": "function Bar\n (I, J, K : Integer; L : Float := 1.0) return Float",
193+
"documentation": "at foo.adb (2:4)",
194+
"sortText": "+05",
195+
"insertText": "I => ${1:Integer}, J => ${2:Integer}, K => ${3:Integer}, L => ${4:Float})$0",
196+
"insertTextFormat": 2,
197+
"additionalTextEdits": []
198+
},
199+
{
200+
"label": "I",
201+
"kind": 5,
202+
"sortText": "+06",
203+
"insertText": "I => ",
204+
"insertTextFormat": 1,
205+
"additionalTextEdits": []
206+
},
207+
{
208+
"label": "J",
209+
"kind": 5,
210+
"sortText": "+07",
211+
"insertText": "J => ",
212+
"insertTextFormat": 1,
213+
"additionalTextEdits": []
214+
},
215+
{
216+
"label": "K",
217+
"kind": 5,
218+
"sortText": "+08",
219+
"insertText": "K => ",
220+
"insertTextFormat": 1,
221+
"additionalTextEdits": []
222+
},
223+
{
224+
"label": "L",
225+
"kind": 5,
226+
"sortText": "+09",
227+
"insertText": "L => ",
228+
"insertTextFormat": 1,
229+
"additionalTextEdits": []
230+
}
231+
]
232+
}
233+
}
234+
]
235+
}
236+
},
237+
{
238+
"send": {
239+
"request": {
240+
"jsonrpc": "2.0",
241+
"method": "textDocument/didClose",
242+
"params": {
243+
"textDocument": {
244+
"uri": "$URI{foo.adb}"
245+
}
246+
}
247+
},
248+
"wait": []
249+
}
250+
},
251+
{
252+
"send": {
253+
"request": {
254+
"jsonrpc": "2.0",
255+
"id": 12,
256+
"method": "shutdown"
257+
},
258+
"wait": []
259+
}
260+
},
261+
{
262+
"stop": {
263+
"exit_code": 0
264+
}
265+
}
266+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'testsuite/ada_lsp/completion.param.non_basic_calls'

0 commit comments

Comments
 (0)