Skip to content

Commit 5847075

Browse files
committed
Allow string as a folding range kind to stay compatible with 3.16 & fix meta model generation.
1 parent 37677eb commit 5847075

7 files changed

Lines changed: 235 additions & 77 deletions

File tree

client/src/common/foldingRange.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99

1010
import {
1111
ClientCapabilities, CancellationToken, ServerCapabilities, DocumentSelector, FoldingRangeRequest, FoldingRangeParams,
12-
FoldingRangeRegistrationOptions, FoldingRangeOptions
12+
FoldingRangeRegistrationOptions, FoldingRangeOptions, FoldingRangeKind
1313
} from 'vscode-languageserver-protocol';
1414

1515
import { TextDocumentLanguageFeature, FeatureClient, ensure } from './features';
@@ -33,7 +33,8 @@ export class FoldingRangeFeature extends TextDocumentLanguageFeature<boolean | F
3333
capability.dynamicRegistration = true;
3434
capability.rangeLimit = 5000;
3535
capability.lineFoldingOnly = true;
36-
capability.collapsedText = false;
36+
capability.foldingRangeKind = { valueSet: [ FoldingRangeKind.Comment, FoldingRangeKind.Imports, FoldingRangeKind.Region ] };
37+
capability.foldingRange = { collapsedText: false };
3738
}
3839

3940
public initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void {

protocol/metaModel.json

Lines changed: 116 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,7 +2380,7 @@
23802380
"name": "FoldingRangeKind"
23812381
},
23822382
"optional": true,
2383-
"documentation": "Describes the kind of the folding range such as `comment' or 'region'. The kind\nis used to categorize folding ranges and used by commands like 'Fold all comments'. See\n[FoldingRangeKind](#FoldingRangeKind) for an enumeration of standardized kinds."
2383+
"documentation": "Describes the kind of the folding range such as `comment' or 'region'. The kind\nis used to categorize folding ranges. See [FoldingRangeKind](#FoldingRangeKind)\nfor an enumeration of standardized kinds."
23842384
},
23852385
{
23862386
"name": "collapsedText",
@@ -11796,13 +11796,49 @@
1179611796
"documentation": "If set, the client signals that it only supports folding complete lines.\nIf set, client will ignore specified `startCharacter` and `endCharacter`\nproperties in a FoldingRange."
1179711797
},
1179811798
{
11799-
"name": "collapsedText",
11799+
"name": "foldingRangeKind",
1180011800
"type": {
11801-
"kind": "base",
11802-
"name": "boolean"
11801+
"kind": "literal",
11802+
"value": {
11803+
"properties": [
11804+
{
11805+
"name": "valueSet",
11806+
"type": {
11807+
"kind": "array",
11808+
"element": {
11809+
"kind": "reference",
11810+
"name": "FoldingRangeKind"
11811+
}
11812+
},
11813+
"optional": true
11814+
}
11815+
]
11816+
}
1180311817
},
1180411818
"optional": true,
11805-
"documentation": "If set, the client signals that it supports setting collapsedText on\nfolding ranges to display instead of the default text.\n@since 3.17.0\n@proposed",
11819+
"documentation": "Specific options for the folding range kind.\n@since 3.17.0\n@proposed",
11820+
"since": "3.17.0",
11821+
"proposed": true
11822+
},
11823+
{
11824+
"name": "foldingRange",
11825+
"type": {
11826+
"kind": "literal",
11827+
"value": {
11828+
"properties": [
11829+
{
11830+
"name": "collapsedText",
11831+
"type": {
11832+
"kind": "base",
11833+
"name": "boolean"
11834+
},
11835+
"optional": true
11836+
}
11837+
]
11838+
}
11839+
},
11840+
"optional": true,
11841+
"documentation": "Specific options for the folding range.\n@since 3.17.0\n@proposed",
1180611842
"since": "3.17.0",
1180711843
"proposed": true
1180811844
}
@@ -12331,7 +12367,8 @@
1233112367
"name": "Region",
1233212368
"value": "region"
1233312369
}
12334-
]
12370+
],
12371+
"supportsCustomValues": true
1233512372
},
1233612373
{
1233712374
"name": "SymbolKind",
@@ -12770,6 +12807,54 @@
1277012807
}
1277112808
]
1277212809
},
12810+
{
12811+
"name": "CodeActionKind",
12812+
"type": {
12813+
"kind": "base",
12814+
"name": "string"
12815+
},
12816+
"values": [
12817+
{
12818+
"name": "Empty",
12819+
"value": ""
12820+
},
12821+
{
12822+
"name": "QuickFix",
12823+
"value": "quickfix"
12824+
},
12825+
{
12826+
"name": "Refactor",
12827+
"value": "refactor"
12828+
},
12829+
{
12830+
"name": "RefactorExtract",
12831+
"value": "refactor.extract"
12832+
},
12833+
{
12834+
"name": "RefactorInline",
12835+
"value": "refactor.inline"
12836+
},
12837+
{
12838+
"name": "RefactorRewrite",
12839+
"value": "refactor.rewrite"
12840+
},
12841+
{
12842+
"name": "Source",
12843+
"value": "source"
12844+
},
12845+
{
12846+
"name": "SourceOrganizeImports",
12847+
"value": "source.organizeImports"
12848+
},
12849+
{
12850+
"name": "SourceFixAll",
12851+
"value": "source.fixAll",
12852+
"since": "3.15.0"
12853+
}
12854+
],
12855+
"supportsCustomValues": true,
12856+
"documentation": "The kind of a code action.\nKinds are a hierarchical list of identifiers separated by `.`, e.g. `\"refactor.extract.function\"`.\nThe set of kinds is open and client needs to announce the kinds it supports to the server during\ninitialization."
12857+
},
1277312858
{
1277412859
"name": "MarkupKind",
1277512860
"type": {
@@ -12787,6 +12872,31 @@
1278712872
}
1278812873
]
1278912874
},
12875+
{
12876+
"name": "PositionEncodingKind",
12877+
"type": {
12878+
"kind": "base",
12879+
"name": "string"
12880+
},
12881+
"values": [
12882+
{
12883+
"name": "UTF8",
12884+
"value": "utf-8"
12885+
},
12886+
{
12887+
"name": "UTF16",
12888+
"value": "utf-16"
12889+
},
12890+
{
12891+
"name": "UTF32",
12892+
"value": "utf-32"
12893+
}
12894+
],
12895+
"supportsCustomValues": true,
12896+
"documentation": "A type indicating how positions are encoded,\nspecifically what column offsets mean.\n@since 3.17.0\n@proposed",
12897+
"since": "3.17.0",
12898+
"proposed": true
12899+
},
1279012900
{
1279112901
"name": "FileChangeType",
1279212902
"type": {
@@ -13376,14 +13486,6 @@
1337613486
},
1337713487
"documentation": "MarkedString can be used to render human readable text. It is either a markdown string\nor a code-block that provides a language and a code snippet. The language identifier\nis semantically equal to the optional language identifier in fenced code blocks in GitHub\nissues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting\nThe pair of a language and a value is an equivalent to markdown:\n```${language}\n${value}\n```\nNote that markdown strings will be sanitized - that means html will be escaped.\n@deprecated use MarkupContent instead."
1337813488
},
13379-
{
13380-
"name": "CodeActionKind",
13381-
"type": {
13382-
"kind": "base",
13383-
"name": "string"
13384-
},
13385-
"documentation": "The kind of a code action.\nKinds are a hierarchical list of identifiers separated by `.`, e.g. `\"refactor.extract.function\"`.\nThe set of kinds is open and client needs to announce the kinds it supports to the server during\ninitialization."
13386-
},
1338713489
{
1338813490
"name": "TraceValues",
1338913491
"type": {
@@ -13426,16 +13528,6 @@
1342613528
"documentation": "A document filter describes a top level text document or\na notebook cell document.\n@since 3.17.0 - proposed support for NotebookCellTextDocumentFilter.",
1342713529
"since": "3.17.0 - proposed support for NotebookCellTextDocumentFilter."
1342813530
},
13429-
{
13430-
"name": "PositionEncodingKind",
13431-
"type": {
13432-
"kind": "base",
13433-
"name": "string"
13434-
},
13435-
"documentation": "A type indicating how positions are encoded,\nspecifically what column offsets mean.\n@since 3.17.0\n@proposed",
13436-
"since": "3.17.0",
13437-
"proposed": true
13438-
},
1343913531
{
1344013532
"name": "GlobPattern",
1344113533
"type": {

protocol/metaModel.schema.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"$ref": "#/definitions/MetaModel",
32
"$schema": "http://json-schema.org/draft-07/schema#",
43
"definitions": {
54
"AndType": {
@@ -111,6 +110,10 @@
111110
"description": "Since when (release number) this enumeration is available. Is undefined if not known.",
112111
"type": "string"
113112
},
113+
"supportsCustomValues": {
114+
"description": "Whether the enumeration supports custom values (e.g. values which are not part of the set defined in `values`). If omitted no custom values are supported.",
115+
"type": "boolean"
116+
},
114117
"type": {
115118
"$ref": "#/definitions/EnumerationType",
116119
"description": "The type of the elements."
@@ -681,6 +684,22 @@
681684
"type"
682685
],
683686
"type": "object"
687+
},
688+
"TypeKind": {
689+
"enum": [
690+
"base",
691+
"reference",
692+
"array",
693+
"map",
694+
"and",
695+
"or",
696+
"tuple",
697+
"literal",
698+
"stringLiteral",
699+
"integerLiteral",
700+
"booleanLiteral"
701+
],
702+
"type": "string"
684703
}
685704
}
686705
}

protocol/src/common/protocol.foldingRange.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { RequestHandler } from 'vscode-jsonrpc';
7-
import { TextDocumentIdentifier, uinteger, FoldingRange } from 'vscode-languageserver-types';
7+
import { TextDocumentIdentifier, uinteger, FoldingRange, FoldingRangeKind } from 'vscode-languageserver-types';
88

99
import { ProtocolRequestType } from './messages';
1010
import type {
@@ -14,33 +14,61 @@ import type {
1414
// ---- capabilities
1515

1616
export interface FoldingRangeClientCapabilities {
17+
1718
/**
1819
* Whether implementation supports dynamic registration for folding range
1920
* providers. If this is set to `true` the client supports the new
2021
* `FoldingRangeRegistrationOptions` return value for the corresponding
2122
* server capability as well.
2223
*/
2324
dynamicRegistration?: boolean;
25+
2426
/**
2527
* The maximum number of folding ranges that the client prefers to receive
2628
* per document. The value serves as a hint, servers are free to follow the
2729
* limit.
2830
*/
2931
rangeLimit?: uinteger;
32+
3033
/**
3134
* If set, the client signals that it only supports folding complete lines.
3235
* If set, client will ignore specified `startCharacter` and `endCharacter`
3336
* properties in a FoldingRange.
3437
*/
3538
lineFoldingOnly?: boolean;
39+
3640
/**
37-
* If set, the client signals that it supports setting collapsedText on
38-
* folding ranges to display instead of the default text.
41+
* Specific options for the folding range kind.
3942
*
4043
* @since 3.17.0
4144
* @proposed
4245
*/
43-
collapsedText?: boolean;
46+
foldingRangeKind? : {
47+
/**
48+
* The folding range kind values the client supports. When this
49+
* property exists the client also guarantees that it will
50+
* handle values outside its set gracefully and falls back
51+
* to a default value when unknown.
52+
*/
53+
valueSet?: FoldingRangeKind[];
54+
};
55+
56+
/**
57+
* Specific options for the folding range.
58+
* @since 3.17.0
59+
* @proposed
60+
*/
61+
foldingRange?: {
62+
/**
63+
* If set, the client signals that it supports setting collapsedText on
64+
* folding ranges to display custom labels instead of the default text.
65+
*
66+
* @since 3.17.0
67+
* @proposed
68+
*/
69+
collapsedText?: boolean;
70+
};
71+
4472
}
4573

4674
export interface FoldingRangeOptions extends WorkDoneProgressOptions {

tools/src/metaModel.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,13 @@ export type Enumeration = {
406406
*/
407407
values: EnumerationEntry[];
408408

409+
/**
410+
* Whether the enumeration supports custom values (e.g. values which are not
411+
* part of the set defined in `values`). If omitted no custom values are
412+
* supported.
413+
*/
414+
supportsCustomValues?: boolean;
415+
409416
/**
410417
* An optional documentation.
411418
*/

0 commit comments

Comments
 (0)