From 3971a9dcec90e28fca8dfcfb7218b0cd2a489360 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 9 Apr 2026 09:40:49 -0400
Subject: [PATCH 41/48] FIXME: WIP on more capabilities

---
 gcc/lsp/gcc-impl/server.cc |  22 +++
 gcc/lsp/lsp-spec.cc        |  87 +++++++++++
 gcc/lsp/lsp-spec.h         | 305 +++++++++++++++++++++++++++++++++++++
 3 files changed, 414 insertions(+)

diff --git a/gcc/lsp/gcc-impl/server.cc b/gcc/lsp/gcc-impl/server.cc
index 71d0e6849da..aad79fcb747 100644
--- a/gcc/lsp/gcc-impl/server.cc
+++ b/gcc/lsp/gcc-impl/server.cc
@@ -711,6 +711,21 @@ lsp::gcc_impl::server::mediator::get_ServerCapabilities ()
 {
   lsp::spec::ServerCapabilities result;
 
+#if 1
+  result.completionProvider.set_optional_value
+    (lsp::spec::CompletionOptions ()); // FIXME
+#endif
+
+#if 1
+  result.hoverProvider.set_optional_value
+    (lsp::spec::HoverOptions ()); // FIXME
+#endif
+
+#if 1
+  result.signatureHelpProvider.set_optional_value
+    (lsp::spec::SignatureHelpOptions ()); // FIXME
+#endif
+
 #if 1
   result.declarationProvider.set_optional_value
     (lsp::spec::boolean (true)); // FIXME
@@ -720,7 +735,14 @@ lsp::gcc_impl::server::mediator::get_ServerCapabilities ()
   result.documentSymbolProvider.set_optional_value
     (lsp::spec::boolean (true)); // FIXME
 #endif
+
+#if 1
+  result.semanticTokensProvider.set_optional_value
+    (lsp::spec::SemanticTokensOptions ()); // FIXME
+#endif
+
   // FIXME
+
   return result;
 }
 
diff --git a/gcc/lsp/lsp-spec.cc b/gcc/lsp/lsp-spec.cc
index e59d36475f7..876e5769057 100644
--- a/gcc/lsp/lsp-spec.cc
+++ b/gcc/lsp/lsp-spec.cc
@@ -392,21 +392,108 @@ lsp::spec::InitializeParams::to_json () const
   gcc_unreachable (); // FIXME
 }
 
+// struct CompletionOptions
+
+BEGIN_DEFINE_FROM_JSON(CompletionOptions)
+{
+  UNMARSHAL_OPTIONAL_PROPERTY (string, triggerCharacters);
+  UNMARSHAL_OPTIONAL_PROPERTY (string, allCommitCharacters);
+  UNMARSHAL_OPTIONAL_PROPERTY (boolean, resolveProvider);
+}
+END_DEFINE_FROM_JSON
+
+BEGIN_DEFINE_TO_JSON(CompletionOptions)
+{
+  MARSHAL_OPTIONAL_PROPERTY (string, triggerCharacters);
+  MARSHAL_OPTIONAL_PROPERTY (string, allCommitCharacters);
+  MARSHAL_OPTIONAL_PROPERTY (boolean, resolveProvider);
+}
+END_DEFINE_TO_JSON
+
+// struct HoverOptions
+
+BEGIN_DEFINE_FROM_JSON(HoverOptions)
+{
+  // empty
+}
+END_DEFINE_FROM_JSON
+
+BEGIN_DEFINE_TO_JSON(HoverOptions)
+{
+  // empty
+}
+END_DEFINE_TO_JSON
+
+// struct SignatureHelpOptions
+
+BEGIN_DEFINE_FROM_JSON(SignatureHelpOptions)
+{
+  UNMARSHAL_OPTIONAL_PROPERTY (string, triggerCharacters);
+  UNMARSHAL_OPTIONAL_PROPERTY (string, retriggerCharacters);
+}
+END_DEFINE_FROM_JSON
+
+BEGIN_DEFINE_TO_JSON(SignatureHelpOptions)
+{
+  MARSHAL_OPTIONAL_PROPERTY (string, triggerCharacters);
+  MARSHAL_OPTIONAL_PROPERTY (string, retriggerCharacters);
+}
+END_DEFINE_TO_JSON
+
+// struct SemanticTokensLegend
+
+BEGIN_DEFINE_FROM_JSON(SemanticTokensLegend)
+{
+  UNMARSHAL_REQUIRED_PROPERTY (vector<string>, tokenTypes);
+  UNMARSHAL_REQUIRED_PROPERTY (vector<string>, tokenModifiers);
+}
+END_DEFINE_FROM_JSON
+
+BEGIN_DEFINE_TO_JSON(SemanticTokensLegend)
+{
+  MARSHAL_REQUIRED_PROPERTY (vector<string>, tokenTypes);
+  MARSHAL_REQUIRED_PROPERTY (vector<string>, tokenModifiers);
+}
+END_DEFINE_TO_JSON
+
+// struct SemanticTokensOptions
+
+BEGIN_DEFINE_FROM_JSON(SemanticTokensOptions)
+{
+  UNMARSHAL_REQUIRED_PROPERTY (SemanticTokensLegend, legend);
+}
+END_DEFINE_FROM_JSON
+
+BEGIN_DEFINE_TO_JSON(SemanticTokensOptions)
+{
+  MARSHAL_REQUIRED_PROPERTY (SemanticTokensLegend, legend);
+}
+END_DEFINE_TO_JSON
+
 // struct ServerCapabilities
 
 BEGIN_DEFINE_FROM_JSON(ServerCapabilities)
 {
   // FIXME
+
+  UNMARSHAL_OPTIONAL_PROPERTY (CompletionOptions, completionProvider);
+  UNMARSHAL_OPTIONAL_PROPERTY (HoverOptions, hoverProvider);
+  UNMARSHAL_OPTIONAL_PROPERTY (SignatureHelpOptions, signatureHelpProvider);
   UNMARSHAL_OPTIONAL_PROPERTY (boolean, declarationProvider);
   UNMARSHAL_OPTIONAL_PROPERTY (boolean, documentSymbolProvider);
+  UNMARSHAL_OPTIONAL_PROPERTY (SemanticTokensOptions, semanticTokensProvider);
 }
 END_DEFINE_FROM_JSON
 
 BEGIN_DEFINE_TO_JSON(ServerCapabilities)
 {
   // FIXME
+  MARSHAL_OPTIONAL_PROPERTY (CompletionOptions, completionProvider);
+  MARSHAL_OPTIONAL_PROPERTY (HoverOptions, hoverProvider);
+  MARSHAL_OPTIONAL_PROPERTY (SignatureHelpOptions, signatureHelpProvider);
   MARSHAL_OPTIONAL_PROPERTY (boolean, declarationProvider);
   MARSHAL_OPTIONAL_PROPERTY (boolean, documentSymbolProvider);
+  MARSHAL_OPTIONAL_PROPERTY (SemanticTokensOptions, semanticTokensProvider);
 }
 END_DEFINE_TO_JSON
 
diff --git a/gcc/lsp/lsp-spec.h b/gcc/lsp/lsp-spec.h
index 25bbf5f045d..078a5391c9d 100644
--- a/gcc/lsp/lsp-spec.h
+++ b/gcc/lsp/lsp-spec.h
@@ -332,14 +332,319 @@ struct InitializeParams // FIXME : public WorkDoneProgressParams
   // FIXME
 };
 
+struct CompletionOptions
+{
+  DECLARE_JSON_METHODS(CompletionOptions);
+
+  optional<string> triggerCharacters;
+  optional<string> allCommitCharacters;
+  optional<boolean> resolveProvider;
+
+  // FIXME:
+#if 0
+	/**
+	 * The server supports the following `CompletionItem` specific
+	 * capabilities.
+	 *
+	 * @since 3.17.0
+	 */
+	completionItem?: {
+		/**
+		 * The server has support for completion item label
+		 * details (see also `CompletionItemLabelDetails`) when receiving
+		 * a completion item in a resolve call.
+		 *
+		 * @since 3.17.0
+		 */
+		labelDetailsSupport?: boolean;
+	}
+#endif
+};
+
+struct HoverOptions
+{
+  DECLARE_JSON_METHODS(HoverOptions);
+  // empty
+};
+
+struct SignatureHelpOptions
+{
+  DECLARE_JSON_METHODS(SignatureHelpOptions);
+
+  optional<string> triggerCharacters;
+  optional<string> retriggerCharacters;
+};
+
+struct SemanticTokensLegend
+{
+  DECLARE_JSON_METHODS(SemanticTokensLegend);
+
+  vector<string> tokenTypes;
+  vector<string> tokenModifiers;
+};
+
+struct SemanticTokensOptions
+{
+  DECLARE_JSON_METHODS(SemanticTokensOptions);
+
+  SemanticTokensLegend legend;
+};
+
 struct ServerCapabilities
 {
   DECLARE_JSON_METHODS(ServerCapabilities)
 
   // FIXME:
 
+#if 0
+  positionEncoding?: PositionEncodingKind;
+
+	/**
+	 * Defines how text documents are synced. Is either a detailed structure
+	 * defining each notification or for backwards compatibility the
+	 * TextDocumentSyncKind number. If omitted it defaults to
+	 * `TextDocumentSyncKind.None`.
+	 */
+	textDocumentSync?: TextDocumentSyncOptions | TextDocumentSyncKind;
+
+	/**
+	 * Defines how notebook documents are synced.
+	 *
+	 * @since 3.17.0
+	 */
+	notebookDocumentSync?: NotebookDocumentSyncOptions
+		| NotebookDocumentSyncRegistrationOptions;
+#endif
+
+  optional<CompletionOptions> completionProvider;
+  optional<HoverOptions> hoverProvider;
+  optional<SignatureHelpOptions> signatureHelpProvider;
   optional<boolean> declarationProvider;
+
+#if 0
+	/**
+	 * The server provides goto definition support.
+	 */
+	definitionProvider?: boolean | DefinitionOptions;
+
+	/**
+	 * The server provides goto type definition support.
+	 *
+	 * @since 3.6.0
+	 */
+	typeDefinitionProvider?: boolean | TypeDefinitionOptions
+		| TypeDefinitionRegistrationOptions;
+
+	/**
+	 * The server provides goto implementation support.
+	 *
+	 * @since 3.6.0
+	 */
+	implementationProvider?: boolean | ImplementationOptions
+		| ImplementationRegistrationOptions;
+
+	/**
+	 * The server provides find references support.
+	 */
+	referencesProvider?: boolean | ReferenceOptions;
+
+	/**
+	 * The server provides document highlight support.
+	 */
+	documentHighlightProvider?: boolean | DocumentHighlightOptions;
+#endif
+
   optional<boolean> documentSymbolProvider;
+
+#if 0
+	/**
+	 * The server provides code actions. The `CodeActionOptions` return type is
+	 * only valid if the client signals code action literal support via the
+	 * property `textDocument.codeAction.codeActionLiteralSupport`.
+	 */
+	codeActionProvider?: boolean | CodeActionOptions;
+
+	/**
+	 * The server provides code lens.
+	 */
+	codeLensProvider?: CodeLensOptions;
+
+	/**
+	 * The server provides document link support.
+	 */
+	documentLinkProvider?: DocumentLinkOptions;
+
+	/**
+	 * The server provides color provider support.
+	 *
+	 * @since 3.6.0
+	 */
+	colorProvider?: boolean | DocumentColorOptions
+		| DocumentColorRegistrationOptions;
+
+	/**
+	 * The server provides document formatting.
+	 */
+	documentFormattingProvider?: boolean | DocumentFormattingOptions;
+
+	/**
+	 * The server provides document range formatting.
+	 */
+	documentRangeFormattingProvider?: boolean | DocumentRangeFormattingOptions;
+
+	/**
+	 * The server provides document formatting on typing.
+	 */
+	documentOnTypeFormattingProvider?: DocumentOnTypeFormattingOptions;
+
+	/**
+	 * The server provides rename support. RenameOptions may only be
+	 * specified if the client states that it supports
+	 * `prepareSupport` in its initial `initialize` request.
+	 */
+	renameProvider?: boolean | RenameOptions;
+
+	/**
+	 * The server provides folding provider support.
+	 *
+	 * @since 3.10.0
+	 */
+	foldingRangeProvider?: boolean | FoldingRangeOptions
+		| FoldingRangeRegistrationOptions;
+
+	/**
+	 * The server provides execute command support.
+	 */
+	executeCommandProvider?: ExecuteCommandOptions;
+
+	/**
+	 * The server provides selection range support.
+	 *
+	 * @since 3.15.0
+	 */
+	selectionRangeProvider?: boolean | SelectionRangeOptions
+		| SelectionRangeRegistrationOptions;
+
+	/**
+	 * The server provides linked editing range support.
+	 *
+	 * @since 3.16.0
+	 */
+	linkedEditingRangeProvider?: boolean | LinkedEditingRangeOptions
+		| LinkedEditingRangeRegistrationOptions;
+
+	/**
+	 * The server provides call hierarchy support.
+	 *
+	 * @since 3.16.0
+	 */
+	callHierarchyProvider?: boolean | CallHierarchyOptions
+		| CallHierarchyRegistrationOptions;
+#endif
+  optional<SemanticTokensOptions> semanticTokensProvider;
+
+#if 0
+	/**
+	 * Whether server provides moniker support.
+	 *
+	 * @since 3.16.0
+	 */
+	monikerProvider?: boolean | MonikerOptions | MonikerRegistrationOptions;
+
+	/**
+	 * The server provides type hierarchy support.
+	 *
+	 * @since 3.17.0
+	 */
+	typeHierarchyProvider?: boolean | TypeHierarchyOptions
+		 | TypeHierarchyRegistrationOptions;
+
+	/**
+	 * The server provides inline values.
+	 *
+	 * @since 3.17.0
+	 */
+	inlineValueProvider?: boolean | InlineValueOptions
+		 | InlineValueRegistrationOptions;
+
+	/**
+	 * The server provides inlay hints.
+	 *
+	 * @since 3.17.0
+	 */
+	inlayHintProvider?: boolean | InlayHintOptions
+		 | InlayHintRegistrationOptions;
+
+	/**
+	 * The server has support for pull model diagnostics.
+	 *
+	 * @since 3.17.0
+	 */
+	diagnosticProvider?: DiagnosticOptions | DiagnosticRegistrationOptions;
+
+	/**
+	 * The server provides workspace symbol support.
+	 */
+	workspaceSymbolProvider?: boolean | WorkspaceSymbolOptions;
+
+	/**
+	 * Workspace specific server capabilities
+	 */
+	workspace?: {
+		/**
+		 * The server supports workspace folder.
+		 *
+		 * @since 3.6.0
+		 */
+		workspaceFolders?: WorkspaceFoldersServerCapabilities;
+
+		/**
+		 * The server is interested in file notifications/requests.
+		 *
+		 * @since 3.16.0
+		 */
+		fileOperations?: {
+			/**
+			 * The server is interested in receiving didCreateFiles
+			 * notifications.
+			 */
+			didCreate?: FileOperationRegistrationOptions;
+
+			/**
+			 * The server is interested in receiving willCreateFiles requests.
+			 */
+			willCreate?: FileOperationRegistrationOptions;
+
+			/**
+			 * The server is interested in receiving didRenameFiles
+			 * notifications.
+			 */
+			didRename?: FileOperationRegistrationOptions;
+
+			/**
+			 * The server is interested in receiving willRenameFiles requests.
+			 */
+			willRename?: FileOperationRegistrationOptions;
+
+			/**
+			 * The server is interested in receiving didDeleteFiles file
+			 * notifications.
+			 */
+			didDelete?: FileOperationRegistrationOptions;
+
+			/**
+			 * The server is interested in receiving willDeleteFiles file
+			 * requests.
+			 */
+			willDelete?: FileOperationRegistrationOptions;
+		};
+	};
+
+	/**
+	 * Experimental server capabilities.
+	 */
+	experimental?: LSPAny;
+  #endif
 };
 
 struct InitializeResult
-- 
2.49.0

