Skip to main content

registry_completions


func ensure_registry_initialized

Call Type: normal

View Source
def ensure_registry_initialized() -> None:
global _INITIALIZED, _REGISTRY_COMPLETIONS, _INLINE_DATA_COMPLETIONS
if _INITIALIZED:
return
try:
summaries = loader.load_all()
loader.print_report(summaries)
except Exception: # pragma: no cover
logger.exception("Failed to preload SDK registry for completions")
_REGISTRY_COMPLETIONS, _INLINE_DATA_COMPLETIONS = _build_registry_lookup()
_INITIALIZED = True


func registry_items_for_section

Call Type: normal

View Source
def registry_items_for_section(section: Optional[str], pfx: str) -> List[CompletionItem]:
ensure_registry_initialized()
if section not in (_REGISTRY_COMPLETIONS or {}):
return []
p = pfx.lower()
items: List[CompletionItem] = []
for entry in _REGISTRY_COMPLETIONS.get(section, []):
if not p or p in entry.label.lower():
items.append(entry.to_item())
return items


func inline_data_items

Call Type: normal

View Source
def inline_data_items(pfx: str) -> List[CompletionItem]:
ensure_registry_initialized()
if not _INLINE_DATA_COMPLETIONS:
return []
p = pfx.lower()
items: List[CompletionItem] = []
for entry in _INLINE_DATA_COMPLETIONS:
if not p or p in entry.label.lower():
items.append(entry.to_item())
return items


class RegistryCompletion

method to_item

Call Type: normal

View Source
@dataclass
class RegistryCompletion:
label: str
insert_text: str
detail: str
documentation: Optional[str]
sort_text: str
kind: CompletionItemKind
filter_text: Optional[str] = None

def to_item(self) -> CompletionItem:
doc = None
if self.documentation:
doc = MarkupContent(kind=MarkupKind.Markdown, value=self.documentation)
return CompletionItem(
label=self.label,
kind=self.kind,
detail=self.detail,
insert_text=self.insert_text,
insert_text_format=INSERT_TEXT_FORMAT_SNIPPET,
documentation=doc,
filter_text=self.filter_text or self.label,
sort_text=self.sort_text,
)