From 0fdda0a8a095ea2d3025b6dc0710ed1a5cfd13ed Mon Sep 17 00:00:00 2001 From: Rustam Sadykov Date: Wed, 3 Dec 2025 18:41:39 +0100 Subject: [PATCH] [aiir, lsp] add folding range request GitOrigin-RevId: 40ad30f2a30e3f2b197ba4ec4d038020e93758f6 --- .../jetbrains/lsp/protocol/FoldingRange.kt | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 fleet/lsp.protocol/srcCommonMain/com/jetbrains/lsp/protocol/FoldingRange.kt diff --git a/fleet/lsp.protocol/srcCommonMain/com/jetbrains/lsp/protocol/FoldingRange.kt b/fleet/lsp.protocol/srcCommonMain/com/jetbrains/lsp/protocol/FoldingRange.kt new file mode 100644 index 000000000000..63b01ab3ecbc --- /dev/null +++ b/fleet/lsp.protocol/srcCommonMain/com/jetbrains/lsp/protocol/FoldingRange.kt @@ -0,0 +1,61 @@ +package com.jetbrains.lsp.protocol + +import kotlinx.serialization.Serializable +import kotlinx.serialization.builtins.ListSerializer +import kotlinx.serialization.builtins.serializer + +@Serializable +data class FoldingRangeParams( + val textDocument: TextDocumentIdentifier, + override val workDoneToken: ProgressToken? = null, + override val partialResultToken: ProgressToken? = null, +) : WorkDoneProgressParams, PartialResultParams + +@Serializable +data class FoldingRange( + /** + * The zero-based line number from where the folded range starts. + */ + val startLine: Int, + + /** + * The zero-based line number where the folded range ends. + */ + val endLine: Int, + + /** + * The zero-based character offset from where the folded range starts. If not defined, defaults + * to the length of the start line. + */ + val startCharacter: Int? = null, + + /** + * The zero-based character offset before the folded range ends. If not defined, defaults to the + * length of the end line. + */ + val endCharacter: Int? = null, + + /** + * Describes the kind of the folding range such as [FoldingRangeKind.Comment] or [FoldingRangeKind.Region]. + * The kind is used to categorize folding ranges and used by commands like 'Fold all comments'. + * @see FoldingRangeKind + */ + val kind: FoldingRangeKind? = null, + + /** + * The text that the client should show when the specified range is + * collapsed. If not defined or not supported by the client, a default + * will be chosen by the client. + * + * @since 3.17.0 + */ + val collapsedText: String? = null +) + +val FoldingRangeRequestType: RequestType, Unit> = + RequestType( + "textDocument/foldingRange", + FoldingRangeParams.serializer(), + ListSerializer(FoldingRange.serializer()), + Unit.serializer(), + )