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

Ensure all string enum values are comparable to strings #15

Merged
merged 4 commits into from
Apr 16, 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
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 """

Loading