Skip to content

Commit c6bb31e

Browse files
authored
Bug fixes and new fields added to LSP (#328)
Closes #326
1 parent 36b1ab1 commit c6bb31e

File tree

6 files changed

+354
-112
lines changed

6 files changed

+354
-112
lines changed

generator/lsp.json

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5503,6 +5503,17 @@
55035503
},
55045504
"documentation": "Title of the command, like `save`."
55055505
},
5506+
{
5507+
"name": "tooltip",
5508+
"type": {
5509+
"kind": "base",
5510+
"name": "string"
5511+
},
5512+
"optional": true,
5513+
"documentation": "An optional tooltip.\n\n@since 3.18.0\n@proposed",
5514+
"since": "3.18.0",
5515+
"proposed": true
5516+
},
55065517
{
55075518
"name": "command",
55085519
"type": {
@@ -9328,6 +9339,20 @@
93289339
"optional": true,
93299340
"documentation": "CodeActionKinds that this server may return.\n\nThe list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server\nmay list out every specific kind they provide."
93309341
},
9342+
{
9343+
"name": "documentation",
9344+
"type": {
9345+
"kind": "array",
9346+
"element": {
9347+
"kind": "reference",
9348+
"name": "CodeActionKindDocumentation"
9349+
}
9350+
},
9351+
"optional": true,
9352+
"documentation": "Static documentation for a class of code actions.\n\nDocumentation from the provider should be shown in the code actions menu if either:\n\n- Code actions of `kind` are requested by the editor. In this case, the editor will show the documentation that\n most closely matches the requested code action kind. For example, if a provider has documentation for\n both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`,\n the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`.\n\n- Any code actions of `kind` are returned by the provider.\n\nAt most one documentation entry should be shown per provider.\n\n@since 3.18.0\n@proposed",
9353+
"since": "3.18.0",
9354+
"proposed": true
9355+
},
93319356
{
93329357
"name": "resolveProvider",
93339358
"type": {
@@ -10452,7 +10477,7 @@
1045210477
}
1045310478
]
1045410479
},
10455-
"documentation": "The label of this parameter information.\n\nEither a string or an inclusive start and exclusive end offsets within its containing\nsignature label. (see SignatureInformation.label). The offsets are based on a UTF-16\nstring representation as `Position` and `Range` does.\n\n*Note*: a label of type string should be a substring of its containing signature label.\nIts intended use case is to highlight the parameter label part in the `SignatureInformation.label`."
10480+
"documentation": "The label of this parameter information.\n\nEither a string or an inclusive start and exclusive end offsets within its containing\nsignature label. (see SignatureInformation.label). The offsets are based on a UTF-16\nstring representation as `Position` and `Range` does.\n\nTo avoid ambiguities a server should use the [start, end] offset value instead of using\na substring. Whether a client support this is controlled via `labelOffsetSupport` client\ncapability.\n\n*Note*: a label of type string should be a substring of its containing signature label.\nIts intended use case is to highlight the parameter label part in the `SignatureInformation.label`."
1045610481
},
1045710482
{
1045810483
"name": "documentation",
@@ -10475,6 +10500,30 @@
1047510500
],
1047610501
"documentation": "Represents a parameter of a callable-signature. A parameter can\nhave a label and a doc-comment."
1047710502
},
10503+
{
10504+
"name": "CodeActionKindDocumentation",
10505+
"properties": [
10506+
{
10507+
"name": "kind",
10508+
"type": {
10509+
"kind": "reference",
10510+
"name": "CodeActionKind"
10511+
},
10512+
"documentation": "The kind of the code action being documented.\n\nIf the kind is generic, such as `CodeActionKind.Refactor`, the documentation will be shown whenever any\nrefactorings are returned. If the kind if more specific, such as `CodeActionKind.RefactorExtract`, the\ndocumentation will only be shown when extract refactoring code actions are returned."
10513+
},
10514+
{
10515+
"name": "command",
10516+
"type": {
10517+
"kind": "reference",
10518+
"name": "Command"
10519+
},
10520+
"documentation": "Command that is ued to display the documentation to the user.\n\nThe title of this documentation code action is taken from {@linkcode Command.title}"
10521+
}
10522+
],
10523+
"documentation": "Documentation for a class of code actions.\n\n@since 3.18.0\n@proposed",
10524+
"since": "3.18.0",
10525+
"proposed": true
10526+
},
1047810527
{
1047910528
"name": "NotebookCellTextDocumentFilter",
1048010529
"properties": [
@@ -12281,6 +12330,17 @@
1228112330
"optional": true,
1228212331
"documentation": "Whether the client honors the change annotations in\ntext edits and resource operations returned via the\n`CodeAction#edit` property by for example presenting\nthe workspace edit in the user interface and asking\nfor confirmation.\n\n@since 3.16.0",
1228312332
"since": "3.16.0"
12333+
},
12334+
{
12335+
"name": "documentationSupport",
12336+
"type": {
12337+
"kind": "base",
12338+
"name": "boolean"
12339+
},
12340+
"optional": true,
12341+
"documentation": "Whether the client supports documentation for a class of\ncode actions.\n\n@since 3.18.0\n@proposed",
12342+
"since": "3.18.0",
12343+
"proposed": true
1228412344
}
1228512345
],
1228612346
"documentation": "The Client Capabilities of a {@link CodeActionRequest}."
@@ -14331,6 +14391,12 @@
1433114391
"value": "source.fixAll",
1433214392
"documentation": "Base kind for auto-fix source actions: `source.fixAll`.\n\nFix all actions automatically fix errors that have a clear fix that do not require user input.\nThey should not suppress errors or perform unsafe fixes such as generating new types or classes.\n\n@since 3.15.0",
1433314393
"since": "3.15.0"
14394+
},
14395+
{
14396+
"name": "Notebook",
14397+
"value": "notebook",
14398+
"documentation": "Base kind for all code actions applying to the entire notebook's scope. CodeActionKinds using\nthis should always begin with `notebook.`\n\n@since 3.18.0",
14399+
"since": "3.18.0"
1433414400
}
1433514401
],
1433614402
"supportsCustomValues": true,

noxfile.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ def lint(session: nox.Session):
3939
session.run("ruff", "--version")
4040
session.run("mypy", "--version")
4141

42-
session.run("ruff", "check", ".")
43-
session.run("ruff", "check", "--select=I001", ".")
4442
session.run("ruff", "format", "--check", ".")
43+
4544
session.run("mypy", "--strict", "--no-incremental", "./packages/python/lsprotocol")
4645

4746
session.log("Linting: generated Rust code.")
@@ -59,10 +58,7 @@ def format(session: nox.Session):
5958
def _format_code(session: nox.Session):
6059
session.install("ruff")
6160
session.run("ruff", "--version")
62-
63-
session.run("ruff", "check", "--fix", "--select=I001", ".")
6461
session.run("ruff", "format", ".")
65-
session.run("ruff", "check", "--fix", ".")
6662

6763

6864
@nox.session()

packages/python/lsprotocol/types.py

Lines changed: 99 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
import enum
1111
import functools
1212
from typing import Any, Dict, Optional, Sequence, Tuple, Union
13-
1413
import attrs
15-
1614
from . import validators
1715

1816
__lsp_version__ = "3.17.0"
@@ -454,6 +452,12 @@ class CodeActionKind(str, enum.Enum):
454452
455453
@since 3.15.0"""
456454
# Since: 3.15.0
455+
Notebook = "notebook"
456+
"""Base kind for all code actions applying to the entire notebook's scope. CodeActionKinds using
457+
this should always begin with `notebook.`
458+
459+
@since 3.18.0"""
460+
# Since: 3.18.0
457461

458462

459463
@enum.unique
@@ -4038,6 +4042,17 @@ class Command:
40384042
command: str = attrs.field(validator=attrs.validators.instance_of(str))
40394043
"""The identifier of the actual command handler."""
40404044

4045+
tooltip: Optional[str] = attrs.field(
4046+
validator=attrs.validators.optional(attrs.validators.instance_of(str)),
4047+
default=None,
4048+
)
4049+
"""An optional tooltip.
4050+
4051+
@since 3.18.0
4052+
@proposed"""
4053+
# Since: 3.18.0
4054+
# Proposed
4055+
40414056
arguments: Optional[Sequence[LSPAny]] = attrs.field(default=None)
40424057
"""Arguments that the command handler should be
40434058
invoked with."""
@@ -4120,6 +4135,27 @@ class CodeActionOptions:
41204135
The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server
41214136
may list out every specific kind they provide."""
41224137

4138+
documentation: Optional[Sequence["CodeActionKindDocumentation"]] = attrs.field(
4139+
default=None
4140+
)
4141+
"""Static documentation for a class of code actions.
4142+
4143+
Documentation from the provider should be shown in the code actions menu if either:
4144+
4145+
- Code actions of `kind` are requested by the editor. In this case, the editor will show the documentation that
4146+
most closely matches the requested code action kind. For example, if a provider has documentation for
4147+
both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`,
4148+
the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`.
4149+
4150+
- Any code actions of `kind` are returned by the provider.
4151+
4152+
At most one documentation entry should be shown per provider.
4153+
4154+
@since 3.18.0
4155+
@proposed"""
4156+
# Since: 3.18.0
4157+
# Proposed
4158+
41234159
resolve_provider: Optional[bool] = attrs.field(
41244160
validator=attrs.validators.optional(attrs.validators.instance_of(bool)),
41254161
default=None,
@@ -4154,6 +4190,27 @@ class CodeActionRegistrationOptions:
41544190
The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server
41554191
may list out every specific kind they provide."""
41564192

4193+
documentation: Optional[Sequence["CodeActionKindDocumentation"]] = attrs.field(
4194+
default=None
4195+
)
4196+
"""Static documentation for a class of code actions.
4197+
4198+
Documentation from the provider should be shown in the code actions menu if either:
4199+
4200+
- Code actions of `kind` are requested by the editor. In this case, the editor will show the documentation that
4201+
most closely matches the requested code action kind. For example, if a provider has documentation for
4202+
both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`,
4203+
the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`.
4204+
4205+
- Any code actions of `kind` are returned by the provider.
4206+
4207+
At most one documentation entry should be shown per provider.
4208+
4209+
@since 3.18.0
4210+
@proposed"""
4211+
# Since: 3.18.0
4212+
# Proposed
4213+
41574214
resolve_provider: Optional[bool] = attrs.field(
41584215
validator=attrs.validators.optional(attrs.validators.instance_of(bool)),
41594216
default=None,
@@ -6855,6 +6912,10 @@ class ParameterInformation:
68556912
signature label. (see SignatureInformation.label). The offsets are based on a UTF-16
68566913
string representation as `Position` and `Range` does.
68576914
6915+
To avoid ambiguities a server should use the [start, end] offset value instead of using
6916+
a substring. Whether a client support this is controlled via `labelOffsetSupport` client
6917+
capability.
6918+
68586919
*Note*: a label of type string should be a substring of its containing signature label.
68596920
Its intended use case is to highlight the parameter label part in the `SignatureInformation.label`."""
68606921

@@ -6863,6 +6924,29 @@ class ParameterInformation:
68636924
in the UI but can be omitted."""
68646925

68656926

6927+
@attrs.define
6928+
class CodeActionKindDocumentation:
6929+
"""Documentation for a class of code actions.
6930+
6931+
@since 3.18.0
6932+
@proposed"""
6933+
6934+
# Since: 3.18.0
6935+
# Proposed
6936+
6937+
kind: Union[CodeActionKind, str] = attrs.field()
6938+
"""The kind of the code action being documented.
6939+
6940+
If the kind is generic, such as `CodeActionKind.Refactor`, the documentation will be shown whenever any
6941+
refactorings are returned. If the kind if more specific, such as `CodeActionKind.RefactorExtract`, the
6942+
documentation will only be shown when extract refactoring code actions are returned."""
6943+
6944+
command: Command = attrs.field()
6945+
"""Command that is ued to display the documentation to the user.
6946+
6947+
The title of this documentation code action is taken from {@linkcode Command.title}"""
6948+
6949+
68666950
@attrs.define
68676951
class NotebookCellTextDocumentFilter:
68686952
"""A notebook cell text document filter denotes a cell text
@@ -8238,6 +8322,18 @@ class CodeActionClientCapabilities:
82388322
@since 3.16.0"""
82398323
# Since: 3.16.0
82408324

8325+
documentation_support: Optional[bool] = attrs.field(
8326+
validator=attrs.validators.optional(attrs.validators.instance_of(bool)),
8327+
default=None,
8328+
)
8329+
"""Whether the client supports documentation for a class of
8330+
code actions.
8331+
8332+
@since 3.18.0
8333+
@proposed"""
8334+
# Since: 3.18.0
8335+
# Proposed
8336+
82418337

82428338
@attrs.define
82438339
class CodeLensClientCapabilities:
@@ -12726,6 +12822,7 @@ def is_special_property(cls: type, property_name: str) -> bool:
1272612822
"CodeActionContext": CodeActionContext,
1272712823
"CodeActionDisabled": CodeActionDisabled,
1272812824
"CodeActionKind": CodeActionKind,
12825+
"CodeActionKindDocumentation": CodeActionKindDocumentation,
1272912826
"CodeActionOptions": CodeActionOptions,
1273012827
"CodeActionParams": CodeActionParams,
1273112828
"CodeActionRegistrationOptions": CodeActionRegistrationOptions,

packages/rust/lsprotocol/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lsprotocol"
3-
version = "0.1.0-alpha.1"
3+
version = "0.1.0-alpha.2"
44
edition = "2021"
55
description = "Rust types for Language Server Protocol generated from LSP specification."
66
authors = ["Microsoft Corporation <[email protected]>"]

0 commit comments

Comments
 (0)