Skip to content

Commit

Permalink
Merge branch 'topic/fix_missing' into 'edge'
Browse files Browse the repository at this point in the history
Handle exceptions in `Project_Tree.Update_Sources`

See merge request eng/ide/ada_language_server!1205
  • Loading branch information
reznikmm committed May 26, 2023
2 parents 2c3403f + 5a9f20c commit 973e7d4
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/ada/lsp-ada_handlers.adb
Original file line number Diff line number Diff line change
Expand Up @@ -5016,6 +5016,8 @@ package body LSP.Ada_Handlers is
Build_Path => Self.Project_Environment.Build_Path,
Environment => Environment);

Self.Project_Tree.Update_Sources (With_Runtime => True);

exception
when E : GPR2.Project_Error
| GPR2.Processing_Error
Expand Down Expand Up @@ -5045,7 +5047,6 @@ package body LSP.Ada_Handlers is
Self.Project_Status := No_Runtime_Found;
end if;

Self.Project_Tree.Update_Sources (With_Runtime => True);
Update_Project_Predefined_Sources (Self);

if Self.Project_Tree.Root_Project.Kind in GPR2.Aggregate_Kind then
Expand Down
4 changes: 4 additions & 0 deletions testsuite/ada_lsp/project_config.missing_file/main.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
procedure Main is
begin
null;
end Main;
4 changes: 4 additions & 0 deletions testsuite/ada_lsp/project_config.missing_file/prj1.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project Prj1 is
for Source_Files use ("missing.ads", "main.adb");
end Prj1;

113 changes: 113 additions & 0 deletions testsuite/ada_lsp/project_config.missing_file/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
[
{
"comment":[
"This test check language server is able to report errors",
"when loading a project with missing files."
]
}, {
"start": {
"cmd": ["${ALS}"]
}
}, {
"send": {
"request": {"jsonrpc":"2.0","id":0,"method":"initialize","params":{
"processId":1,
"rootUri":"$URI{.}",
"capabilities":{}}
},
"wait":[{
"id": 0,
"result":{
"capabilities":{
"textDocumentSync": 2,
"definitionProvider":true
}
}
}]
}
}, {
"send": {
"request": {
"jsonrpc":"2.0",
"method":"workspace/didChangeConfiguration",
"params":{
"settings":{
"ada":{
"projectFile": "prj1.gpr"
}
}
}
},
"wait":[
{
"jsonrpc": "2.0",
"method": "window/showMessage",
"params": {
"type": 1,
"message": "<ANY>"
}
}
]
}
}, {
"send": {
"request": {
"jsonrpc":"2.0",
"method":"textDocument/didOpen",
"params":{
"textDocument": {
"uri": "$URI{main.adb}",
"languageId": "ada",
"version": 1,
"text": "procedure Main is\nbegin\n null;\nend Main;"
}
}
},
"wait":[
{
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
"uri":"$URI{main.adb}",
"diagnostics":[
{
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line":0,
"character":0
}
},
"severity": 1,
"source": "project",
"message": "Project file has error and can't be loaded."
}
]
}
}
]
}
}, {
"send": {
"request": {
"jsonrpc":"2.0",
"id": "shutdown",
"method":"shutdown",
"params":null
},
"wait":[{ "id": "shutdown", "result": null }]
}
}, {
"send": {
"request": {"jsonrpc":"2.0", "method":"exit", "params":{}},
"wait":[]
}
}, {
"stop": {
"exit_code": 0
}
}
]
1 change: 1 addition & 0 deletions testsuite/ada_lsp/project_config.missing_file/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title: 'project_config.missing_file'

0 comments on commit 973e7d4

Please sign in to comment.