diff --git a/doc/settings.md b/doc/settings.md index 27d0446aa..0ed379824 100644 --- a/doc/settings.md +++ b/doc/settings.md @@ -35,24 +35,22 @@ for `initializationOptions`. On the protocol level messages look like: Ada Language Server understands these settings: - * [projectFile](#projectFile) - * [scenarioVariables](#scenarioVariables) - * [defaultCharset](#defaultCharset) - * [relocateBuildTree](#relocateBuildTree) - * [rootDir](#rootDir) - * [enableDiagnostics](#enableDiagnostics) - * [enableIndexing](#enableIndexing) - * [renameInComments](#renameInComments) - * [namedNotationThreshold](#namedNotationThreshold) - * [foldComments](#foldComments) - * [followSymlinks](#followSymlinks) - * [documentationStyle](#documentationStyle) - * [onTypeFormatting.indentOnly](#onTypeFormatting.indentOnly) +* [projectFile](#projectfile) +* [scenarioVariables](#scenariovariables) +* [defaultCharset](#defaultcharset) +* [relocateBuildTree](#relocatebuildtree) +* [rootDir](#rootdir) +* [enableDiagnostics](#enablediagnostics) +* [enableIndexing](#enableindexing) +* [renameInComments](#renameincomments) +* [namedNotationThreshold](#namednotationthreshold) +* [foldComments](#foldcomments) +* [followSymlinks](#followsymlinks) +* [documentationStyle](#documentationstyle) +* [onTypeFormatting.indentOnly](#ontypeformattingindentonly) ---- - - ## projectFile You can configure the GNAT Project File via the `projectFile` key. @@ -67,6 +65,7 @@ root folder, then ALS will use it. ``` ## scenarioVariables + You can configure scenario variables via the `scenarioVariables` key. The setting has an object value. Keys in this object correspond to scenario variables names and string values to variables values. @@ -76,7 +75,9 @@ scenario variables names and string values to variables values. 'BUILD_MODE': 'DEBUG' } ``` + ## defaultCharset + You can set the character set to use when the server has to use when reading files from disk by specifying an `defaultCharset` key. The default is `iso-8859-1`. This should have a string value. @@ -86,28 +87,33 @@ files from disk by specifying an `defaultCharset` key. The default is ``` ## relocateBuildTree + With this option it is possible to achieve out-of-tree build. That is, real object, library or exec directories are relocated to the current working directory or dir if specified. Ensure that it is full normalized path ended with the directory separator. Visit -https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/building_with_gprbuild.html#switches +the [gprbuild documentation](https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/building_with_gprbuild.html#switches) for more details about the corresponding gprbuild switch. + ```javascript 'relocateBuildTree': '/home/user/project/build/' ``` ## rootDir + This option is to be used with relocateBuildTree above and cannot be specified alone. This option specifies the root directory for artifacts for proper relocation. Ensure that it is full normalized path ended with the directory separator. Visit -https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/building_with_gprbuild.html#switches +the [gprbuild documentation](https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/building_with_gprbuild.html#switches) for more details about the corresponding gprbuild switch. + ```javascript 'relocateBuildTree': '/home/user/project/' ``` ## enableDiagnostics + You can explicitly deactivate the emission of diagnostics, via the `enableDiagnostics` key. By default, diagnostics are enabled. The value is a boolean. @@ -117,6 +123,7 @@ The value is a boolean. ``` ## enableIndexing + By default, the server indexes the source files after loading a project, to speed up subsequent requests. This behavior can be controlled via the `enableIndexing` flag in this request. @@ -127,6 +134,7 @@ The value is a boolean. ``` ## renameInComments + The language server is able to edit Ada comments while executing `textDocument/rename` request. To enable this just set `renameInComments` setting to `true`. @@ -137,6 +145,7 @@ The value is a boolean. ``` ## useCompletionSnippets + Whether we should use snippets in completion results. Snippets can be returned in case of subprogram calls for instance, with placeholders for each parameter needed by the subprogram. @@ -147,25 +156,27 @@ The value is a boolean. ``` ## displayMethodAncestryOnNavigation + This setting controls the policy for displaying overriding and overridden subprograms on navigation requests such as `textDocument/definition`, `textDocument/declaration` or `textDocument/implementation`. The different policies are: - * `never`: Never list overridding and/or overridden suprograms. - * `usage_and_abstract_only`: List overridding and/or overridden suprograms - on dispatching calls and on abstract subprogram declarations. - * `definition_only`: List overridding and/or overridden suprograms on - declarations only. - * `always`: Always list overridding and/or overridden suprograms when - possible. +* `never`: Never list overridding and/or overridden suprograms. +* `usage_and_abstract_only`: List overridding and/or overridden suprograms + on dispatching calls and on abstract subprogram declarations. +* `definition_only`: List overridding and/or overridden suprograms on + declarations only. +* `always`: Always list overridding and/or overridden suprograms when + possible. ```javascript 'displayMethodAncestryOnNavigation': 'always' ``` ## namedNotationThreshold + This setting defines the number of parameters/components at which point named notation is used for subprogram/aggregate completion snippets. The value is a number. The default value is `3`. @@ -175,12 +186,14 @@ The value is a number. The default value is `3`. ``` ## foldComments + When this setting is `true` the server sends blocks information for comments which can be used for folding comment blocks. The value is a boolean. The default is `true`. ```javascript 'foldComments': false ``` + ## followSymlinks When this setting is `false` the server doesn't do any attempts to normalize file names sent by a client. @@ -193,6 +206,7 @@ The value is a boolean. The default is `true`. ``` ## documentationStyle + The language server supports different styles to document entities in the source code. This setting controls primary documentation style of entities. When documentation for the entity is not found, the language server uses a few @@ -201,10 +215,10 @@ declaration, extract documentation from subprogram's body, etc.) Supported styles are: - * `gnat`: Default style, based on GNAT coding standard with some - enhancements. - * `leading`: Documentation for the entities extracted from the comments - before the entity declaration. +* `gnat`: Default style, based on GNAT coding standard with some + enhancements. +* `leading`: Documentation for the entities extracted from the comments + before the entity declaration. For more information about documentation styles see GNATdoc User's Manual. diff --git a/integration/vscode/ada/package.json b/integration/vscode/ada/package.json index 7a3a70557..1bc1996d9 100644 --- a/integration/vscode/ada/package.json +++ b/integration/vscode/ada/package.json @@ -1,7 +1,7 @@ { "name": "ada", - "displayName": "Language Support for Ada", - "description": "A Language Server providing Ada and SPARK support in Visual Studio Code", + "displayName": "Ada", + "description": "Ada & SPARK IntelliSense, code browsing, debugging and more.", "version": "24.0.999", "publisher": "AdaCore", "license": "GPL-3.0", @@ -276,50 +276,69 @@ "configuration": [ { "type": "object", - "title": "Ada", + "title": "Project", + "order": 0, "properties": { - "ada.trace.server": { - "scope": "window", - "type": "string", - "enum": [ - "off", - "messages", - "verbose" - ], - "default": "off", - "description": "Traces the communication between VSCode and the Ada language server." - }, - "gpr.trace.server": { - "scope": "window", - "type": "string", - "enum": [ - "off", - "messages", - "verbose" - ], - "default": "off", - "description": "Traces the communication between VSCode and the GPR language server." - }, "ada.projectFile": { - "scope": "resource", + "scope": "window", "type": "string", "default": "", - "description": "Project file (*.gpr) for given workspace." + "description": "GPR project file (*.gpr) for this workspace.\n\nIt is recommended to set this to a relative path starting at the root of the workspace.", + "order": 0 }, "ada.scenarioVariables": { - "scope": "resource", + "scope": "window", "type": "object", "default": {}, - "description": "Scenario variables." + "description": "Scenario variables to apply to the GPR project file.\n\nThis value should be provided as an object where the property names are GPR scenario variables and the values are strings.", + "patternProperties": { + ".*": { + "type": "string" + } + }, + "order": 1 }, "ada.defaultCharset": { - "scope": "resource", + "scope": "window", "type": "string", "default": "iso-8859-1", - "description": "The character set to use while reading files from disk." + "description": "The character set that the Ada Language Server should use when reading files from disk." }, + "ada.relocateBuildTree": { + "scope": "window", + "type": "string", + "default": "", + "description": "The folder for out-of-tree build.", + "markdownDescription": "The path to a directory used for out-of-tree builds. This feature is related to the [--relocate-build-tree GPRbuild command line switch](https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/building_with_gprbuild.html#switches)." + }, + "ada.rootDir": { + "scope": "window", + "type": "string", + "default": "", + "markdownDescription": "This setting must be used in conjunction with the `relocateBuildTree` setting.\n\nIt specifies the root directory for artifact relocation. It corresponds to the [--root-dir GPRbuild command line switch](https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/building_with_gprbuild.html#switches)." + } + } + }, + { + "type": "object", + "title": "Formatting", + "order": 1, + "properties": { + "ada.onTypeFormatting.indentOnly": { + "scope": "window", + "type": "boolean", + "default": true, + "markdownDescription": "If the VS Code `editor.formatOnType` setting is enabled, the Ada Language Server will format Ada code while it is being typed in the editor, in particular when a new line is typed.\n\nThis setting controls whether formatting should only perform the indentation of the new line (true) or also format the previous line (false)." + } + } + }, + { + "type": "object", + "title": "UI", + "order": 2, + "properties": { "ada.documentationStyle": { - "scope": "resource", + "scope": "window", "type": "string", "enum": [ "gnat", @@ -330,10 +349,10 @@ "Documentation for the entities extracted from the comments before the entity declaration." ], "default": "gnat", - "description": "Controls primary documentation style of entities." + "description": "Controls the primary documentation style of entities." }, "ada.displayMethodAncestryOnNavigation": { - "scope": "resource", + "scope": "window", "type": "string", "enum": [ "never", @@ -351,75 +370,84 @@ "description": "Controls the policy for displaying overriding and overridden subprograms on navigation requests such as 'Go To Definition' or 'Go To Implementations'." }, "ada.enableDiagnostics": { - "scope": "resource", - "type": "boolean", - "default": true, - "description": "The emission of diagnostics." - }, - "ada.enableIndexing": { - "scope": "resource", + "scope": "window", "type": "boolean", "default": true, - "description": "Controls indexing the source files after loading a project." + "description": "Controls whether or not the Ada Language Server should emit diagnostics into the VS Code Problems view." }, "ada.foldComments": { - "scope": "resource", - "type": "boolean", - "default": true, - "description": "Controls the inclusion of comments in folding blocks." - }, - "ada.followSymlinks": { - "scope": "resource", + "scope": "window", "type": "boolean", "default": true, - "description": "Controls the file names normalization sent by a client." + "description": "Controls whether comments should be folded like code blocks." }, "ada.namedNotationThreshold": { - "scope": "resource", + "scope": "window", "type": "integer", "default": 3, - "description": "Defines the number of parameters/components at which point named notation is used for completion snippets." - }, - "ada.relocateBuildTree": { - "scope": "resource", - "type": "string", - "default": "", - "description": "The folder for out-of-tree build." - }, - "ada.rootDir": { - "scope": "resource", - "type": "string", - "default": "", - "description": "The root directory for artifacts for proper relocation. Used with relocateBuildTree." + "description": "Defines the number of parameters/components beyond which named notation is used for completion snippets." }, "ada.useCompletionSnippets": { - "scope": "resource", + "scope": "window", "type": "boolean", "default": false, - "description": "Enable snippets in completion results (e.g: subprogram calls)." + "description": "Enable snippets in completion results (e.g. subprogram calls)." }, "ada.renameInComments": { - "scope": "resource", + "scope": "window", "type": "boolean", "default": false, - "description": "Enable editing Ada comments while executing `textDocument/rename` request." - }, - "ada.onTypeFormatting.indentOnly": { - "scope": "resource", - "type": "boolean", - "default": true, - "description": "Controls if the `textDocument/onTypeFormatting` request only indents a new line, or if it additionally tries to format the previous node." + "description": "Enable editing Ada comments to update references to an entity when it is being renamed." } } }, { - "title": "Shortcut Menu Bar configuration", + "type": "object", + "title": "Miscelaneous", "properties": { - "gpr.buildProject-icon": { - "title": "Build the Ada Project", + "ada.enableIndexing": { + "scope": "window", + "type": "boolean", + "default": true, + "description": "Controls whether the Ada Language Server should index the source files immediately after loading a project.\n\nIf set to false, indexing will be deferred to the time when an action requiring the index is first performed, e.g. hovering over a referenced entity to get its documentation." + }, + "ada.followSymlinks": { + "scope": "window", "type": "boolean", "default": true, - "description": "show icon for 'Build' " + "description": "Controls the Ada Language Server normalizes the file paths received from the client." + }, + "ada.trace.server": { + "scope": "window", + "type": "string", + "enum": [ + "off", + "messages", + "verbose" + ], + "enumDescriptions": [ + "No traces are emitted.", + "Brief traces are emitted for each request sent and each response received.", + "Verbose traces are emitted for each request sent and each response received, including the message content." + ], + "default": "off", + "description": "Instructs the VS Code language client to log the communication with the Ada language server in the VS Code output window 'Ada Language Server'." + }, + "gpr.trace.server": { + "scope": "window", + "type": "string", + "enum": [ + "off", + "messages", + "verbose" + ], + "enumDescriptions": [ + "No traces are emitted.", + "Brief traces are emitted for each request sent and each response received.", + "Verbose traces are emitted for each request sent and each response received, including the message content." + ], + "default": "off", + "description": "Instructs the VS Code language client to log the communication with the GPR language server in the VS Code output window 'GPR Language Server'." } } } diff --git a/source/ada/lsp-ada_handlers.adb b/source/ada/lsp-ada_handlers.adb index 9553535dc..5c61b2e86 100644 --- a/source/ada/lsp-ada_handlers.adb +++ b/source/ada/lsp-ada_handlers.adb @@ -33,7 +33,6 @@ with VSS.JSON.Streams; with Libadalang.Analysis; with Libadalang.Common; -with Libadalang.Helpers; with Laltools.Common; with Laltools.Partial_GNATPP; @@ -167,6 +166,11 @@ package body LSP.Ada_Handlers is Position : LSP.Structures.TextDocumentPositionParams'Class) return Libadalang.Analysis.Defining_Name; + function Project_Predefined_Units + (Self : in out Message_Handler; + Context : LSP.Ada_Contexts.Context) + return Libadalang.Analysis.Analysis_Unit_Array; + ----------------------------- -- Allocate_Progress_Token -- ----------------------------- @@ -786,13 +790,14 @@ package body LSP.Ada_Handlers is use LAL_Refactor.Auto_Import; use LSP.Structures; + function Units_Provider return Analysis_Unit_Array is + (Self.Project_Predefined_Units (Context.all) + & Context.Analysis_Units); + -- Concatenates user units with predefined units + Single_Location : constant Boolean := Value.a_range.start = Value.a_range.an_end; - Units_Vector : Libadalang.Helpers.Unit_Vectors.Vector; - Units_Array : constant Analysis_Unit_Array := - Context.Analysis_Units; - Name : Libadalang.Analysis.Name := No_Name; Import_Suggestions : Import_Type_Ordered_Set; @@ -801,30 +806,13 @@ package body LSP.Ada_Handlers is return; end if; - for Unit of Units_Array loop - Units_Vector.Append (Unit); - end loop; - - for F in Self.Project_Predefined_Sources.Iterate loop - declare - VF : GNATCOLL.VFS.Virtual_File renames - LSP.Ada_File_Sets.File_Sets.Element (F); - begin - Units_Vector.Append - (Context.LAL_Context.Get_From_File - (VF.Display_Full_Name, - -- ??? What is the charset for predefined - -- files? - "")); - end; - end loop; - if not Is_Auto_Import_Available - (Node.Unit, - Document.To_Source_Location (Value.a_range.start), - Units_Vector, - Name, - Import_Suggestions) + (Unit => Node.Unit, + Location => + Document.To_Source_Location (Value.a_range.start), + Units => Units_Provider'Access, + Name => Name, + Available_Imports => Import_Suggestions) then return; end if; @@ -4587,6 +4575,31 @@ package body LSP.Ada_Handlers is Self.Sender.On_Definition_Response (Id, Response); end On_TypeDefinition_Request; + ------------------------------ + -- Project_Predefined_Units -- + ------------------------------ + + function Project_Predefined_Units + (Self : in out Message_Handler; + Context : LSP.Ada_Contexts.Context) + return Libadalang.Analysis.Analysis_Unit_Array + is + use Libadalang.Analysis; + + Units_Count : constant Natural := + Self.Project_Predefined_Sources.Length; + Predefined_Units : Analysis_Unit_Array (1 .. Units_Count); + Index : Natural := Predefined_Units'First; + + begin + for Source in Self.Project_Predefined_Sources.Iterate loop + Predefined_Units (Index) := + Context.Get_AU (LSP.Ada_File_Sets.File_Sets.Element (Source)); + Index := @ + 1; + end loop; + return Predefined_Units; + end Project_Predefined_Units; + ------------------------- -- Publish_Diagnostics -- ------------------------- diff --git a/testsuite/settings-doc/get-extension-settings.py b/testsuite/settings-doc/get-extension-settings.py index a7df782f1..c071aa2e9 100644 --- a/testsuite/settings-doc/get-extension-settings.py +++ b/testsuite/settings-doc/get-extension-settings.py @@ -2,5 +2,9 @@ import json pkg = json.load(sys.stdin) -settings = pkg["contributes"]["configuration"][0]["properties"].keys() +settings = [] + +for group in pkg["contributes"]["configuration"]: + settings.extend(group["properties"].keys()) + print("\n".join(settings))