Skip to content

Commit

Permalink
Ensure all string enum values are comparable to strings (#15)
Browse files Browse the repository at this point in the history
* Ensure all string enum values are comparable to strings

* add LanguageKind

* generate types

* new line at the end

---------

Co-authored-by: Предраг Николић <[email protected]>
  • Loading branch information
jwortmann and predragnikolic authored Apr 16, 2024
1 parent 6bb8d43 commit fe5ef32
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 26 deletions.
13 changes: 13 additions & 0 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,20 @@

ENUM_OVERRIDES = {
'CodeActionKind': 'StrEnum',
'DocumentDiagnosticReportKind': 'StrEnum',
'FailureHandlingKind': 'StrEnum',
'FileOperationPatternKind': 'StrEnum',
'FoldingRangeKind': 'StrEnum',
'LanguageKind': 'StrEnum',
'MarkupKind': 'StrEnum',
'MonikerKind': 'StrEnum',
'PositionEncodingKind': 'StrEnum',
'ResourceOperationKind': 'StrEnum',
'SemanticTokenModifiers': 'StrEnum',
'SemanticTokenTypes': 'StrEnum',
'TokenFormat': 'StrEnum',
'TraceValues': 'StrEnum',
'UniquenessLevel': 'StrEnum',
'WatchKind': 'IntFlag',
} # type: Dict[str, Literal['StrEnum', 'IntFlag']]

Expand Down
25 changes: 12 additions & 13 deletions lsp_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RegExp = str


class SemanticTokenTypes(Enum):
class SemanticTokenTypes(StrEnum):
""" A set of predefined token types. This set is not fixed
an clients can specify additional token types via the
corresponding client capabilities.
Expand Down Expand Up @@ -46,7 +46,7 @@ class SemanticTokenTypes(Enum):
""" @since 3.17.0 """


class SemanticTokenModifiers(Enum):
class SemanticTokenModifiers(StrEnum):
""" A set of predefined token modifiers. This set is not fixed
an clients can specify additional token types via the
corresponding client capabilities.
Expand All @@ -64,7 +64,7 @@ class SemanticTokenModifiers(Enum):
DefaultLibrary = 'defaultLibrary'


class DocumentDiagnosticReportKind(Enum):
class DocumentDiagnosticReportKind(StrEnum):
""" The document diagnostic report kinds.
@since 3.17.0 """
Expand Down Expand Up @@ -165,7 +165,7 @@ class SymbolTag(IntEnum):
""" Render a symbol as obsolete, usually using a strike-out. """


class UniquenessLevel(Enum):
class UniquenessLevel(StrEnum):
""" Moniker uniqueness level to define scope of the moniker.
@since 3.16.0 """
Expand All @@ -181,7 +181,7 @@ class UniquenessLevel(Enum):
""" The moniker is globally unique """


class MonikerKind(Enum):
class MonikerKind(StrEnum):
""" The moniker kind.
@since 3.16.0 """
Expand Down Expand Up @@ -405,7 +405,7 @@ class TraceValue(Enum):
""" Verbose message tracing. """


class MarkupKind(Enum):
class MarkupKind(StrEnum):
""" Describes the content type that a client supports in various
result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
Expand All @@ -417,7 +417,7 @@ class MarkupKind(Enum):
""" Markdown is supported as a content format """


class LanguageKind(Enum):
class LanguageKind(StrEnum):
""" Predefined Language kinds
@since 3.18.0
@proposed """
Expand Down Expand Up @@ -500,7 +500,7 @@ class InlineCompletionTriggerKind(IntEnum):
""" Completion was triggered automatically while editing. """


class PositionEncodingKind(Enum):
class PositionEncodingKind(StrEnum):
""" A set of predefined position encoding kinds.
@since 3.17.0 """
Expand Down Expand Up @@ -602,7 +602,7 @@ class CodeActionTriggerKind(IntEnum):
also be triggered when file content changes. """


class FileOperationPatternKind(Enum):
class FileOperationPatternKind(StrEnum):
""" A pattern kind describing if a glob pattern matches a file a folder or
both.
Expand All @@ -623,7 +623,7 @@ class NotebookCellKind(IntEnum):
""" A code-cell is source code. """


class ResourceOperationKind(Enum):
class ResourceOperationKind(StrEnum):
Create = 'create'
""" Supports creating new files and folders. """
Rename = 'rename'
Expand All @@ -632,7 +632,7 @@ class ResourceOperationKind(Enum):
""" Supports deleting existing files and folders. """


class FailureHandlingKind(Enum):
class FailureHandlingKind(StrEnum):
Abort = 'abort'
""" Applying the workspace change is simply aborted if one of the changes provided
fails. All operations executed before the failing operation stay executed. """
Expand All @@ -654,7 +654,7 @@ class PrepareSupportDefaultBehavior(IntEnum):
according the to language's syntax rule. """


class TokenFormat(Enum):
class TokenFormat(StrEnum):
Relative = 'relative'


Expand Down Expand Up @@ -5850,4 +5850,3 @@ class ClientSemanticTokensRequestFullDelta(TypedDict):
delta: NotRequired[bool]
""" The client will send the `textDocument/semanticTokens/full/delta` request if
the server provides a corresponding handler. """

25 changes: 12 additions & 13 deletions lsp_types_sublime_text_33.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RegExp = str


class SemanticTokenTypes(Enum):
class SemanticTokenTypes(StrEnum):
""" A set of predefined token types. This set is not fixed
an clients can specify additional token types via the
corresponding client capabilities.
Expand Down Expand Up @@ -46,7 +46,7 @@ class SemanticTokenTypes(Enum):
""" @since 3.17.0 """


class SemanticTokenModifiers(Enum):
class SemanticTokenModifiers(StrEnum):
""" A set of predefined token modifiers. This set is not fixed
an clients can specify additional token types via the
corresponding client capabilities.
Expand All @@ -64,7 +64,7 @@ class SemanticTokenModifiers(Enum):
DefaultLibrary = 'defaultLibrary'


class DocumentDiagnosticReportKind(Enum):
class DocumentDiagnosticReportKind(StrEnum):
""" The document diagnostic report kinds.
@since 3.17.0 """
Expand Down Expand Up @@ -165,7 +165,7 @@ class SymbolTag(IntEnum):
""" Render a symbol as obsolete, usually using a strike-out. """


class UniquenessLevel(Enum):
class UniquenessLevel(StrEnum):
""" Moniker uniqueness level to define scope of the moniker.
@since 3.16.0 """
Expand All @@ -181,7 +181,7 @@ class UniquenessLevel(Enum):
""" The moniker is globally unique """


class MonikerKind(Enum):
class MonikerKind(StrEnum):
""" The moniker kind.
@since 3.16.0 """
Expand Down Expand Up @@ -405,7 +405,7 @@ class TraceValue(Enum):
""" Verbose message tracing. """


class MarkupKind(Enum):
class MarkupKind(StrEnum):
""" Describes the content type that a client supports in various
result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
Expand All @@ -417,7 +417,7 @@ class MarkupKind(Enum):
""" Markdown is supported as a content format """


class LanguageKind(Enum):
class LanguageKind(StrEnum):
""" Predefined Language kinds
@since 3.18.0
@proposed """
Expand Down Expand Up @@ -500,7 +500,7 @@ class InlineCompletionTriggerKind(IntEnum):
""" Completion was triggered automatically while editing. """


class PositionEncodingKind(Enum):
class PositionEncodingKind(StrEnum):
""" A set of predefined position encoding kinds.
@since 3.17.0 """
Expand Down Expand Up @@ -602,7 +602,7 @@ class CodeActionTriggerKind(IntEnum):
also be triggered when file content changes. """


class FileOperationPatternKind(Enum):
class FileOperationPatternKind(StrEnum):
""" A pattern kind describing if a glob pattern matches a file a folder or
both.
Expand All @@ -623,7 +623,7 @@ class NotebookCellKind(IntEnum):
""" A code-cell is source code. """


class ResourceOperationKind(Enum):
class ResourceOperationKind(StrEnum):
Create = 'create'
""" Supports creating new files and folders. """
Rename = 'rename'
Expand All @@ -632,7 +632,7 @@ class ResourceOperationKind(Enum):
""" Supports deleting existing files and folders. """


class FailureHandlingKind(Enum):
class FailureHandlingKind(StrEnum):
Abort = 'abort'
""" Applying the workspace change is simply aborted if one of the changes provided
fails. All operations executed before the failing operation stay executed. """
Expand All @@ -654,7 +654,7 @@ class PrepareSupportDefaultBehavior(IntEnum):
according the to language's syntax rule. """


class TokenFormat(Enum):
class TokenFormat(StrEnum):
Relative = 'relative'


Expand Down Expand Up @@ -6221,4 +6221,3 @@ class TokenFormat(Enum):
})
""" @since 3.18.0
@proposed """

0 comments on commit fe5ef32

Please sign in to comment.