mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
completions: Sort completion items
This commit is contained in:
parent
3cdc3a159c
commit
bcb8e4ea14
12 changed files with 135 additions and 22 deletions
|
@ -20,12 +20,28 @@
|
|||
|
||||
import typing as T
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
|
||||
from .ast_utils import AstNode
|
||||
from .lsp_utils import Completion
|
||||
from .tokenizer import Token, TokenType
|
||||
|
||||
|
||||
class CompletionPriority(Enum):
|
||||
ENUM_MEMBER = "00"
|
||||
NAMED_OBJECT = "01"
|
||||
OBJECT_MEMBER = "02"
|
||||
CLASS = "03"
|
||||
NAMESPACE = "04"
|
||||
KEYWORD = "05"
|
||||
# An available namespace that hasn't been imported yet
|
||||
IMPORT_NAMESPACE = "99"
|
||||
|
||||
|
||||
def get_sort_key(priority: CompletionPriority, name: str):
|
||||
return f"{priority.value} {name}"
|
||||
|
||||
|
||||
@dataclass
|
||||
class CompletionContext:
|
||||
client_supports_completion_choice: bool
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue