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

override FoldingRangeKind to StrEnum #14

Merged
merged 1 commit into from
Aug 14, 2023
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
1 change: 1 addition & 0 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

ENUM_OVERRIDES = {
'CodeActionKind': 'StrEnum',
'FoldingRangeKind': 'StrEnum',
'WatchKind': 'IntFlag',
} # type: Dict[str, Literal['StrEnum', 'IntFlag']]

Expand Down
15 changes: 7 additions & 8 deletions lsp_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class LSPErrorCodes(IntEnum):
the cancel. """


class FoldingRangeKind(Enum):
class FoldingRangeKind(StrEnum):
""" A set of predefined range kinds. """
Comment = 'comment'
""" Folding range for a comment """
Expand Down Expand Up @@ -2488,8 +2488,7 @@ class CodeLens(TypedDict):
""" The command this code lens represents. """
data: NotRequired['LSPAny']
""" A data entry field that is preserved on a code lens item between
a {@link CodeLensRequest} and a [CodeLensResolveRequest]
(#CodeLensResolveRequest) """
a {@link CodeLensRequest} and a {@link CodeLensResolveRequest} """


class CodeLensRegistrationOptions(TypedDict):
Expand Down Expand Up @@ -2903,14 +2902,14 @@ class Position(TypedDict):
offset of b is 3 since `𐐀` is represented using two code units in UTF-16.
Since 3.17 clients and servers can agree on a different string encoding
representation (e.g. UTF-8). The client announces it's supported encoding
via the client capability [`general.positionEncodings`](#clientCapabilities).
via the client capability [`general.positionEncodings`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#clientCapabilities).
The value is an array of position encodings the client supports, with
decreasing preference (e.g. the encoding at index `0` is the most preferred
one). To stay backwards compatible the only mandatory encoding is UTF-16
represented via the string `utf-16`. The server can pick one of the
encodings offered by the client and signals that encoding back to the
client via the initialize result's property
[`capabilities.positionEncoding`](#serverCapabilities). If the string value
[`capabilities.positionEncoding`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverCapabilities). If the string value
`utf-16` is missing from the client's capability `general.positionEncodings`
servers can safely assume that the client supports UTF-16. If the server
omits the position encoding in its initialize result the encoding defaults
Expand Down Expand Up @@ -5567,7 +5566,7 @@ class __TextDocumentFilter_Type_1(TypedDict):
scheme: NotRequired[str]
""" A Uri {@link Uri.scheme scheme}, like `file` or `untitled`. """
pattern: NotRequired[str]
""" A glob pattern, like `*.{ts,js}`. """
""" A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. """


class __TextDocumentFilter_Type_2(TypedDict):
Expand All @@ -5576,7 +5575,7 @@ class __TextDocumentFilter_Type_2(TypedDict):
scheme: str
""" A Uri {@link Uri.scheme scheme}, like `file` or `untitled`. """
pattern: NotRequired[str]
""" A glob pattern, like `*.{ts,js}`. """
""" A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. """


class __TextDocumentFilter_Type_3(TypedDict):
Expand All @@ -5585,7 +5584,7 @@ class __TextDocumentFilter_Type_3(TypedDict):
scheme: NotRequired[str]
""" A Uri {@link Uri.scheme scheme}, like `file` or `untitled`. """
pattern: str
""" A glob pattern, like `*.{ts,js}`. """
""" A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. """


class __WorkspaceEditClientCapabilities_changeAnnotationSupport_Type_1(TypedDict):
Expand Down
15 changes: 7 additions & 8 deletions lsp_types_sublime_text_33.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class LSPErrorCodes(IntEnum):
the cancel. """


class FoldingRangeKind(Enum):
class FoldingRangeKind(StrEnum):
""" A set of predefined range kinds. """
Comment = 'comment'
""" Folding range for a comment """
Expand Down Expand Up @@ -2611,8 +2611,7 @@ class TokenFormat(Enum):
# The command this code lens represents.
'command': NotRequired['Command'],
# A data entry field that is preserved on a code lens item between
# a {@link CodeLensRequest} and a [CodeLensResolveRequest]
# (#CodeLensResolveRequest)
# a {@link CodeLensRequest} and a {@link CodeLensResolveRequest}
'data': NotRequired['LSPAny'],
})
""" A code lens represents a {@link Command command} that should be shown along with
Expand Down Expand Up @@ -3087,14 +3086,14 @@ class TokenFormat(Enum):
offset of b is 3 since `𐐀` is represented using two code units in UTF-16.
Since 3.17 clients and servers can agree on a different string encoding
representation (e.g. UTF-8). The client announces it's supported encoding
via the client capability [`general.positionEncodings`](#clientCapabilities).
via the client capability [`general.positionEncodings`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#clientCapabilities).
The value is an array of position encodings the client supports, with
decreasing preference (e.g. the encoding at index `0` is the most preferred
one). To stay backwards compatible the only mandatory encoding is UTF-16
represented via the string `utf-16`. The server can pick one of the
encodings offered by the client and signals that encoding back to the
client via the initialize result's property
[`capabilities.positionEncoding`](#serverCapabilities). If the string value
[`capabilities.positionEncoding`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverCapabilities). If the string value
`utf-16` is missing from the client's capability `general.positionEncodings`
servers can safely assume that the client supports UTF-16. If the server
omits the position encoding in its initialize result the encoding defaults
Expand Down Expand Up @@ -5936,7 +5935,7 @@ class TokenFormat(Enum):
'language': str,
# A Uri {@link Uri.scheme scheme}, like `file` or `untitled`.
'scheme': NotRequired[str],
# A glob pattern, like `*.{ts,js}`.
# A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples.
'pattern': NotRequired[str],
})

Expand All @@ -5946,7 +5945,7 @@ class TokenFormat(Enum):
'language': NotRequired[str],
# A Uri {@link Uri.scheme scheme}, like `file` or `untitled`.
'scheme': str,
# A glob pattern, like `*.{ts,js}`.
# A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples.
'pattern': NotRequired[str],
})

Expand All @@ -5956,7 +5955,7 @@ class TokenFormat(Enum):
'language': NotRequired[str],
# A Uri {@link Uri.scheme scheme}, like `file` or `untitled`.
'scheme': NotRequired[str],
# A glob pattern, like `*.{ts,js}`.
# A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples.
'pattern': str,
})

Expand Down
20 changes: 10 additions & 10 deletions lsprotocol/lsp.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"kind": "reference",
"name": "ImplementationRegistrationOptions"
},
"documentation": "A request to resolve the implementation locations of a symbol at a given text\ndocument position. The request's parameter is of type [TextDocumentPositionParams]\n(#TextDocumentPositionParams) the response is of type {@link Definition} or a\nThenable that resolves to such."
"documentation": "A request to resolve the implementation locations of a symbol at a given text\ndocument position. The request's parameter is of type {@link TextDocumentPositionParams}\nthe response is of type {@link Definition} or a Thenable that resolves to such."
},
{
"method": "textDocument/typeDefinition",
Expand Down Expand Up @@ -105,7 +105,7 @@
"kind": "reference",
"name": "TypeDefinitionRegistrationOptions"
},
"documentation": "A request to resolve the type definition locations of a symbol at a given text\ndocument position. The request's parameter is of type [TextDocumentPositionParams]\n(#TextDocumentPositionParams) the response is of type {@link Definition} or a\nThenable that resolves to such."
"documentation": "A request to resolve the type definition locations of a symbol at a given text\ndocument position. The request's parameter is of type {@link TextDocumentPositionParams}\nthe response is of type {@link Definition} or a Thenable that resolves to such."
},
{
"method": "workspace/workspaceFolders",
Expand Down Expand Up @@ -293,7 +293,7 @@
"kind": "reference",
"name": "DeclarationRegistrationOptions"
},
"documentation": "A request to resolve the type definition locations of a symbol at a given text\ndocument position. The request's parameter is of type [TextDocumentPositionParams]\n(#TextDocumentPositionParams) the response is of type {@link Declaration}\nor a typed array of {@link DeclarationLink} or a Thenable that resolves\nto such."
"documentation": "A request to resolve the type definition locations of a symbol at a given text\ndocument position. The request's parameter is of type {@link TextDocumentPositionParams}\nthe response is of type {@link Declaration} or a typed array of {@link DeclarationLink}\nor a Thenable that resolves to such."
},
{
"method": "textDocument/selectionRange",
Expand Down Expand Up @@ -1274,7 +1274,7 @@
"kind": "reference",
"name": "DefinitionRegistrationOptions"
},
"documentation": "A request to resolve the definition location of a symbol at a given text\ndocument position. The request's parameter is of type [TextDocumentPosition]\n(#TextDocumentPosition) the response is of either type {@link Definition}\nor a typed array of {@link DefinitionLink} or a Thenable that resolves\nto such."
"documentation": "A request to resolve the definition location of a symbol at a given text\ndocument position. The request's parameter is of type {@link TextDocumentPosition}\nthe response is of either type {@link Definition} or a typed array of\n{@link DefinitionLink} or a Thenable that resolves to such."
},
{
"method": "textDocument/references",
Expand Down Expand Up @@ -1346,7 +1346,7 @@
"kind": "reference",
"name": "DocumentHighlightRegistrationOptions"
},
"documentation": "Request to resolve a {@link DocumentHighlight} for a given\ntext document position. The request's parameter is of type [TextDocumentPosition]\n(#TextDocumentPosition) the request response is of type [DocumentHighlight[]]\n(#DocumentHighlight) or a Thenable that resolves to such."
"documentation": "Request to resolve a {@link DocumentHighlight} for a given\ntext document position. The request's parameter is of type {@link TextDocumentPosition}\nthe request response is an array of type {@link DocumentHighlight}\nor a Thenable that resolves to such."
},
{
"method": "textDocument/documentSymbol",
Expand Down Expand Up @@ -5818,7 +5818,7 @@
"name": "LSPAny"
},
"optional": true,
"documentation": "A data entry field that is preserved on a code lens item between\na {@link CodeLensRequest} and a [CodeLensResolveRequest]\n(#CodeLensResolveRequest)"
"documentation": "A data entry field that is preserved on a code lens item between\na {@link CodeLensRequest} and a {@link CodeLensResolveRequest}"
}
],
"documentation": "A code lens represents a {@link Command command} that should be shown along with\nsource text, like the number of references, a way to run tests, etc.\n\nA code lens is _unresolved_ when no command is associated to it. For performance\nreasons the creation of a code lens and resolving should be done in two stages."
Expand Down Expand Up @@ -6754,7 +6754,7 @@
"documentation": "Character offset on a line in a document (zero-based).\n\nThe meaning of this offset is determined by the negotiated\n`PositionEncodingKind`.\n\nIf the character value is greater than the line length it defaults back to the\nline length."
}
],
"documentation": "Position in a text document expressed as zero-based line and character\noffset. Prior to 3.17 the offsets were always based on a UTF-16 string\nrepresentation. So a string of the form `a𐐀b` the character offset of the\ncharacter `a` is 0, the character offset of `𐐀` is 1 and the character\noffset of b is 3 since `𐐀` is represented using two code units in UTF-16.\nSince 3.17 clients and servers can agree on a different string encoding\nrepresentation (e.g. UTF-8). The client announces it's supported encoding\nvia the client capability [`general.positionEncodings`](#clientCapabilities).\nThe value is an array of position encodings the client supports, with\ndecreasing preference (e.g. the encoding at index `0` is the most preferred\none). To stay backwards compatible the only mandatory encoding is UTF-16\nrepresented via the string `utf-16`. The server can pick one of the\nencodings offered by the client and signals that encoding back to the\nclient via the initialize result's property\n[`capabilities.positionEncoding`](#serverCapabilities). If the string value\n`utf-16` is missing from the client's capability `general.positionEncodings`\nservers can safely assume that the client supports UTF-16. If the server\nomits the position encoding in its initialize result the encoding defaults\nto the string value `utf-16`. Implementation considerations: since the\nconversion from one encoding into another requires the content of the\nfile / line the conversion is best done where the file is read which is\nusually on the server side.\n\nPositions are line end character agnostic. So you can not specify a position\nthat denotes `\\r|\\n` or `\\n|` where `|` represents the character offset.\n\n@since 3.17.0 - support for negotiated position encoding.",
"documentation": "Position in a text document expressed as zero-based line and character\noffset. Prior to 3.17 the offsets were always based on a UTF-16 string\nrepresentation. So a string of the form `a𐐀b` the character offset of the\ncharacter `a` is 0, the character offset of `𐐀` is 1 and the character\noffset of b is 3 since `𐐀` is represented using two code units in UTF-16.\nSince 3.17 clients and servers can agree on a different string encoding\nrepresentation (e.g. UTF-8). The client announces it's supported encoding\nvia the client capability [`general.positionEncodings`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#clientCapabilities).\nThe value is an array of position encodings the client supports, with\ndecreasing preference (e.g. the encoding at index `0` is the most preferred\none). To stay backwards compatible the only mandatory encoding is UTF-16\nrepresented via the string `utf-16`. The server can pick one of the\nencodings offered by the client and signals that encoding back to the\nclient via the initialize result's property\n[`capabilities.positionEncoding`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverCapabilities). If the string value\n`utf-16` is missing from the client's capability `general.positionEncodings`\nservers can safely assume that the client supports UTF-16. If the server\nomits the position encoding in its initialize result the encoding defaults\nto the string value `utf-16`. Implementation considerations: since the\nconversion from one encoding into another requires the content of the\nfile / line the conversion is best done where the file is read which is\nusually on the server side.\n\nPositions are line end character agnostic. So you can not specify a position\nthat denotes `\\r|\\n` or `\\n|` where `|` represents the character offset.\n\n@since 3.17.0 - support for negotiated position encoding.",
"since": "3.17.0 - support for negotiated position encoding."
},
{
Expand Down Expand Up @@ -14590,7 +14590,7 @@
"name": "string"
},
"optional": true,
"documentation": "A glob pattern, like `*.{ts,js}`."
"documentation": "A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples."
}
]
}
Expand Down Expand Up @@ -14623,7 +14623,7 @@
"name": "string"
},
"optional": true,
"documentation": "A glob pattern, like `*.{ts,js}`."
"documentation": "A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples."
}
]
}
Expand Down Expand Up @@ -14656,7 +14656,7 @@
"kind": "base",
"name": "string"
},
"documentation": "A glob pattern, like `*.{ts,js}`."
"documentation": "A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples."
}
]
}
Expand Down
Loading