Skip to content

Commit

Permalink
Merge branch 'topic/project_diagnostics' into 'master'
Browse files Browse the repository at this point in the history
Fix + test case for project diagnostics

See merge request eng/ide/ada_language_server!1527
  • Loading branch information
AnthonyLeonardoGracio committed Apr 2, 2024
2 parents f9b9c60 + 045e11a commit abbdd3c
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 14 deletions.
33 changes: 19 additions & 14 deletions source/ada/lsp-ada_handlers-project_diagnostics.adb
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ package body LSP.Ada_Handlers.Project_Diagnostics is
---------------------------------------

procedure Create_Project_Loading_Diagnostic is
Project_File : GNATCOLL.VFS.Virtual_File renames
Self.Handler.Project_Status.Project_File;
URI : constant LSP.Structures.DocumentUri :=
Self.Handler.To_URI (Project_File.Display_Full_Name);
Sloc : constant LSP.Structures.A_Range :=
Sloc : constant LSP.Structures.A_Range :=
(start => (0, 0),
an_end => (0, 0));
begin
Expand All @@ -112,15 +108,24 @@ package body LSP.Ada_Handlers.Project_Diagnostics is
Parent_Diagnostic.message := Project_Loading_Status_Messages
(Self.Last_Status);
else
Parent_Diagnostic.message := "Project Problems";
Parent_Diagnostic.relatedInformation.Append
(LSP .Structures.DiagnosticRelatedInformation'
(location => LSP.Structures.Location'
(uri => URI,
a_range => Sloc,
others => <>),
message => Project_Loading_Status_Messages
(Self.Last_Status)));
declare
Project_File : GNATCOLL.VFS.Virtual_File renames
Self.Handler.Project_Status.Project_File;
URI : constant LSP.Structures.DocumentUri :=
Self.Handler.To_URI
(Project_File.Display_Full_Name);
begin
Parent_Diagnostic.message := "Project Problems";
Parent_Diagnostic.relatedInformation.Append
(LSP.Structures.DiagnosticRelatedInformation'
(location =>
LSP.Structures.Location'
(uri => URI, a_range => Sloc,
others => <>),
message =>
Project_Loading_Status_Messages
(Self.Last_Status)));
end;
end if;
end Create_Project_Loading_Diagnostic;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project A is
end A;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project B is
end B;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
procedure Main is
begin
null;
end Main;
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
[
{
"comment": [
"Test the project diagnostics when we have several .gpr files in the ",
"root directory, without having set the 'ada.projectFile' setting.",
"It also checks that we propose a quickfix to set 'ada.projectFile'."
]
},
{
"start": {
"cmd": ["${ALS}"]
}
},
{
"send": {
"request": {
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"rootUri": "$URI{.}",
"capabilities": {}
}
},
"wait": [
{
"id": 1,
"result": {
"capabilities": {
"executeCommandProvider": {
"commands": ["<HAS>", "als-refactor-add-parameters"]
}
}
}
}
]
}
},
{
"send": {
"request": {
"jsonrpc": "2.0",
"method": "initialized",
"params": {}
},
"wait": []
}
},
{
"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;\n"
}
}
},
"wait": []
}
},
{
"send": {
"request": {
"jsonrpc": "2.0",
"id": 2,
"method": "workspace/executeCommand",
"params": {
"command": "als-source-dirs"
}
},
"wait": [
{
"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": "No project was loaded, because more than one project file has been found in the root directory. Please change configuration to point a correct project file."
}
]
}
}
]
}
},
{
"send": {
"request": {
"jsonrpc": "2.0",
"id": 6,
"method": "textDocument/codeAction",
"params": {
"textDocument": {
"uri": "$URI{main.adb}"
},
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 0
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 0
}
},
"message": "No project was loaded, because more than one project file has been found in the root directory. Please change configuration to point a correct project file.",
"severity": 1,
"source": "project"
}
],
"triggerKind": 2
}
}
},
"wait": []
}
},
{
"send": {
"request": {
"jsonrpc": "2.0",
"id": 13,
"method": "textDocument/codeAction",
"params": {
"textDocument": {
"uri": "$URI{main.adb}"
},
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 0
}
},
"context": {
"diagnostics": [
{
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 0
}
},
"message": "No project was loaded, because more than one project file has been found in the root directory. Please change configuration to point a correct project file.",
"severity": 1,
"source": "project"
}
],
"triggerKind": 2
}
}
},
"wait": [
{
"id": 13,
"result": [
{
"title": "Open settings for ada.projectFile",
"kind": "quickfix",
"diagnostics": [
{
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 0
}
},
"severity": 1,
"source": "project",
"message": "No project was loaded, because more than one project file has been found in the root directory. Please change configuration to point a correct project file."
}
],
"isPreferred": true,
"command": {
"title": "Open settings for ada.projectFile",
"command": "workbench.action.openSettings",
"arguments": "ada.projectFile"
}
}
]
}
]
}
},
{
"stop": {
"exit_code": 0
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title: 'project_config.multiple_project_diagnostics'

0 comments on commit abbdd3c

Please sign in to comment.