Skip to content

Commit

Permalink
LSP update adds new TextDocument InlineCompletion request (#211)
Browse files Browse the repository at this point in the history
Closes #210
  • Loading branch information
karthiknadig committed May 22, 2023
1 parent a38cc58 commit 314fffc
Show file tree
Hide file tree
Showing 9 changed files with 1,573 additions and 1,250 deletions.
4 changes: 2 additions & 2 deletions generator-plugins/dotnet/dotnet_special_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


def generate_special_classes(spec: model.LSPModel, types: TypeData) -> None:
"""Generate code for special classes in LSP"""
"""Generate code for special classes in LSP."""
for special_class in SPECIAL_CLASSES:
for struct_def in spec.structures + spec.typeAliases:
if struct_def.name == special_class:
Expand All @@ -27,7 +27,7 @@ def generate_special_classes(spec: model.LSPModel, types: TypeData) -> None:
def generate_special_class(
struct_def: model.Structure, spec: model.LSPModel, types: TypeData
) -> Dict[str, str]:
"""Generate code for a special class"""
"""Generate code for a special class."""
lines: List[str] = []

if struct_def.name == "LSPObject":
Expand Down
11 changes: 5 additions & 6 deletions generator-plugins/python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def _generate_field_validator(


def _to_class_name(lsp_method_name: str) -> str:
"""Convert from LSP method name (e.g., textDocument/didSave) to python
class name (e.g., TextDocumentDidSave)"""
"""Convert from LSP method name (e.g., textDocument/didSave) to python class name
(e.g., TextDocumentDidSave)"""
name = lsp_method_name[2:] if lsp_method_name.startswith("$/") else lsp_method_name
name = name.replace("/", "_")
name = METHOD_NAME_RE_1.sub(r"\1_\2", name)
Expand All @@ -77,8 +77,8 @@ def lines_to_str(lines: Union[Sequence[str], List[str]]) -> str:


def _sanitize_comment(text: str) -> str:
"""LSP spec comments can contain newlines or characters that should not be
used or can cause issues with python code clean them up."""
"""LSP spec comments can contain newlines or characters that should not be used or
can cause issues with python code clean them up."""
return text.replace("\r", "").replace("\n", "")


Expand Down Expand Up @@ -137,8 +137,7 @@ def _capitalized_item_name(original: str) -> str:
def _get_indented_documentation(
documentation: Optional[str], indent: str = ""
) -> Optional[str]:
"""Clean up doc string from LSP model and word wrap with correct indent
level."""
"""Clean up doc string from LSP model and word wrap with correct indent level."""
doc = (
indent.join(documentation.splitlines(keepends=True)) if documentation else None
)
Expand Down
8 changes: 6 additions & 2 deletions generator-plugins/rust/rust_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,19 @@ def generate_response(
types.add_type_info(response_def, response_def.name, lines)


def generate_partial_result(request_def: model.Request, types: TypeData) -> None:
def generate_partial_result(
request_def: model.Request, types: TypeData, spec: model.LSPModel
) -> None:
if not request_def.partialResult:
return

if request_def.partialResult.kind not in ["and", "or"]:
return


def generate_registration_options(request_def: model.Request, types: TypeData) -> None:
def generate_registration_options(
request_def: model.Request, types: TypeData, spec: model.LSPModel
) -> None:
if not request_def.registrationOptions:
return

Expand Down
Loading

0 comments on commit 314fffc

Please sign in to comment.