Skip to content

Commit

Permalink
Implement Request wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
Moosems committed Aug 1, 2024
1 parent c9c2356 commit 15f0bae
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions salve/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
)
from .server import Server

# from collegamento import FileClient



class IPC:
"""The IPC class is used to talk to the server and run commands. The public API includes the following methods:
Expand Down
56 changes: 56 additions & 0 deletions salve/wrappers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from pyeditorconfig import get_config
from token_tools import Token, normal_text_range

from .misc import Request
from .server_functions import (
find_autocompletions,
get_definition,
get_highlights,
get_replacements,
get_special_tokens,
)


def get_replacements_request_wrapper(request: Request) -> list[str]:
return get_replacements(
full_text=request["file"],
expected_keywords=request["expected_keywords"], # type: ignore
replaceable_word=request["current_word"], # type: ignore
)


def find_autocompletions_request_wrapper(request: Request) -> list[str]:
return find_autocompletions(
full_text=request["file"],
expected_keywords=request["expected_keywords"], # type: ignore
replaceable_word=request["current_word"], # type: ignore
)


def get_highlights_request_wrapper(request: Request) -> list[Token]:
return get_highlights(
full_text=request["file"],
language=request["language"], # type: ignore
text_range=request["text_range"], # type: ignore
)


def editorconfig_request_wrapper(request: Request) -> dict:
return get_config(request["file_path"]) # type: ignore


def get_definition_request_wrapper(request: Request) -> Token:
return get_definition(
request["file"],
request["definition_starters"], # type: ignore
request["current_word"], # type: ignore
)


def get_special_tokens_request_wrapper(request: Request) -> list[Token]:
return get_special_tokens(
request["file"],
normal_text_range(request["file"], request["text_range"])[ # type: ignore
1
],
)

0 comments on commit 15f0bae

Please sign in to comment.