Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes and new fields added to LSP #328

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 67 additions & 1 deletion generator/lsp.json
Original file line number Diff line number Diff line change
Expand Up @@ -5503,6 +5503,17 @@
},
"documentation": "Title of the command, like `save`."
},
{
"name": "tooltip",
"type": {
"kind": "base",
"name": "string"
},
"optional": true,
"documentation": "An optional tooltip.\n\n@since 3.18.0\n@proposed",
"since": "3.18.0",
"proposed": true
},
{
"name": "command",
"type": {
Expand Down Expand Up @@ -9328,6 +9339,20 @@
"optional": true,
"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."
},
{
"name": "documentation",
"type": {
"kind": "array",
"element": {
"kind": "reference",
"name": "CodeActionKindDocumentation"
}
},
"optional": true,
"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",
"since": "3.18.0",
"proposed": true
},
{
"name": "resolveProvider",
"type": {
Expand Down Expand Up @@ -10452,7 +10477,7 @@
}
]
},
"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`."
"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`."
},
{
"name": "documentation",
Expand All @@ -10475,6 +10500,30 @@
],
"documentation": "Represents a parameter of a callable-signature. A parameter can\nhave a label and a doc-comment."
},
{
"name": "CodeActionKindDocumentation",
"properties": [
{
"name": "kind",
"type": {
"kind": "reference",
"name": "CodeActionKind"
},
"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."
},
{
"name": "command",
"type": {
"kind": "reference",
"name": "Command"
},
"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}"
}
],
"documentation": "Documentation for a class of code actions.\n\n@since 3.18.0\n@proposed",
"since": "3.18.0",
"proposed": true
},
{
"name": "NotebookCellTextDocumentFilter",
"properties": [
Expand Down Expand Up @@ -12281,6 +12330,17 @@
"optional": true,
"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",
"since": "3.16.0"
},
{
"name": "documentationSupport",
"type": {
"kind": "base",
"name": "boolean"
},
"optional": true,
"documentation": "Whether the client supports documentation for a class of\ncode actions.\n\n@since 3.18.0\n@proposed",
"since": "3.18.0",
"proposed": true
}
],
"documentation": "The Client Capabilities of a {@link CodeActionRequest}."
Expand Down Expand Up @@ -14331,6 +14391,12 @@
"value": "source.fixAll",
"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",
"since": "3.15.0"
},
{
"name": "Notebook",
"value": "notebook",
"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",
"since": "3.18.0"
}
],
"supportsCustomValues": true,
Expand Down
6 changes: 1 addition & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ def lint(session: nox.Session):
session.run("ruff", "--version")
session.run("mypy", "--version")

session.run("ruff", "check", ".")
session.run("ruff", "check", "--select=I001", ".")
session.run("ruff", "format", "--check", ".")

session.run("mypy", "--strict", "--no-incremental", "./packages/python/lsprotocol")

session.log("Linting: generated Rust code.")
Expand All @@ -59,10 +58,7 @@ def format(session: nox.Session):
def _format_code(session: nox.Session):
session.install("ruff")
session.run("ruff", "--version")

session.run("ruff", "check", "--fix", "--select=I001", ".")
session.run("ruff", "format", ".")
session.run("ruff", "check", "--fix", ".")


@nox.session()
Expand Down
101 changes: 99 additions & 2 deletions packages/python/lsprotocol/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import enum
import functools
from typing import Any, Dict, Optional, Sequence, Tuple, Union

import attrs

from . import validators

__lsp_version__ = "3.17.0"
Expand Down Expand Up @@ -454,6 +452,12 @@ class CodeActionKind(str, enum.Enum):

@since 3.15.0"""
# Since: 3.15.0
Notebook = "notebook"
"""Base kind for all code actions applying to the entire notebook's scope. CodeActionKinds using
this should always begin with `notebook.`

@since 3.18.0"""
# Since: 3.18.0


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

tooltip: Optional[str] = attrs.field(
validator=attrs.validators.optional(attrs.validators.instance_of(str)),
default=None,
)
"""An optional tooltip.

@since 3.18.0
@proposed"""
# Since: 3.18.0
# Proposed

arguments: Optional[Sequence[LSPAny]] = attrs.field(default=None)
"""Arguments that the command handler should be
invoked with."""
Expand Down Expand Up @@ -4120,6 +4135,27 @@ class CodeActionOptions:
The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server
may list out every specific kind they provide."""

documentation: Optional[Sequence["CodeActionKindDocumentation"]] = attrs.field(
default=None
)
"""Static documentation for a class of code actions.

Documentation from the provider should be shown in the code actions menu if either:

- Code actions of `kind` are requested by the editor. In this case, the editor will show the documentation that
most closely matches the requested code action kind. For example, if a provider has documentation for
both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`,
the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`.

- Any code actions of `kind` are returned by the provider.

At most one documentation entry should be shown per provider.

@since 3.18.0
@proposed"""
# Since: 3.18.0
# Proposed

resolve_provider: Optional[bool] = attrs.field(
validator=attrs.validators.optional(attrs.validators.instance_of(bool)),
default=None,
Expand Down Expand Up @@ -4154,6 +4190,27 @@ class CodeActionRegistrationOptions:
The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server
may list out every specific kind they provide."""

documentation: Optional[Sequence["CodeActionKindDocumentation"]] = attrs.field(
default=None
)
"""Static documentation for a class of code actions.

Documentation from the provider should be shown in the code actions menu if either:

- Code actions of `kind` are requested by the editor. In this case, the editor will show the documentation that
most closely matches the requested code action kind. For example, if a provider has documentation for
both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`,
the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`.

- Any code actions of `kind` are returned by the provider.

At most one documentation entry should be shown per provider.

@since 3.18.0
@proposed"""
# Since: 3.18.0
# Proposed

resolve_provider: Optional[bool] = attrs.field(
validator=attrs.validators.optional(attrs.validators.instance_of(bool)),
default=None,
Expand Down Expand Up @@ -6855,6 +6912,10 @@ class ParameterInformation:
signature label. (see SignatureInformation.label). The offsets are based on a UTF-16
string representation as `Position` and `Range` does.

To avoid ambiguities a server should use the [start, end] offset value instead of using
a substring. Whether a client support this is controlled via `labelOffsetSupport` client
capability.

*Note*: a label of type string should be a substring of its containing signature label.
Its intended use case is to highlight the parameter label part in the `SignatureInformation.label`."""

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


@attrs.define
class CodeActionKindDocumentation:
"""Documentation for a class of code actions.

@since 3.18.0
@proposed"""

# Since: 3.18.0
# Proposed

kind: Union[CodeActionKind, str] = attrs.field()
"""The kind of the code action being documented.

If the kind is generic, such as `CodeActionKind.Refactor`, the documentation will be shown whenever any
refactorings are returned. If the kind if more specific, such as `CodeActionKind.RefactorExtract`, the
documentation will only be shown when extract refactoring code actions are returned."""

command: Command = attrs.field()
"""Command that is ued to display the documentation to the user.

The title of this documentation code action is taken from {@linkcode Command.title}"""


@attrs.define
class NotebookCellTextDocumentFilter:
"""A notebook cell text document filter denotes a cell text
Expand Down Expand Up @@ -8238,6 +8322,18 @@ class CodeActionClientCapabilities:
@since 3.16.0"""
# Since: 3.16.0

documentation_support: Optional[bool] = attrs.field(
validator=attrs.validators.optional(attrs.validators.instance_of(bool)),
default=None,
)
"""Whether the client supports documentation for a class of
code actions.

@since 3.18.0
@proposed"""
# Since: 3.18.0
# Proposed


@attrs.define
class CodeLensClientCapabilities:
Expand Down Expand Up @@ -12726,6 +12822,7 @@ def is_special_property(cls: type, property_name: str) -> bool:
"CodeActionContext": CodeActionContext,
"CodeActionDisabled": CodeActionDisabled,
"CodeActionKind": CodeActionKind,
"CodeActionKindDocumentation": CodeActionKindDocumentation,
"CodeActionOptions": CodeActionOptions,
"CodeActionParams": CodeActionParams,
"CodeActionRegistrationOptions": CodeActionRegistrationOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/rust/lsprotocol/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lsprotocol"
version = "0.1.0-alpha.1"
version = "0.1.0-alpha.2"
edition = "2021"
description = "Rust types for Language Server Protocol generated from LSP specification."
authors = ["Microsoft Corporation <[email protected]>"]
Expand Down
Loading
Loading