Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def register_completions(ls: JsonLanguageServer, *args):
"""Register completions method on the client."""
params = RegistrationParams([Registration(str(uuid.uuid4()), COMPLETION,
{"triggerCharacters": "[':']"})])
response = await ls.register_capability_async(params)
if response is None:
ls.show_message('Successfully registered completions method')
else:
ls.show_message('Error happened during completions registration.',
MessageType.Error)
def parse_wdl(ls: Server, uri: str):
ls.show_message_log('Validating ' + uri, MessageType.Info)
diagnostics, wdl = _parse_wdl(ls, uri)
ls.publish_diagnostics(uri, diagnostics)
ls.show_message_log(
'{} {}'.format('Valid' if wdl else 'Invalid', uri),
MessageType.Info if wdl else MessageType.Warning
)
async def unregister_completions(ls: JsonLanguageServer, *args):
"""Unregister completions method on the client."""
params = UnregistrationParams([Unregistration(str(uuid.uuid4()), COMPLETION)])
response = await ls.unregister_capability_async(params)
if response is None:
ls.show_message('Successfully unregistered completions method')
else:
ls.show_message('Error happened during completions unregistration.',
MessageType.Error)
types = _get_types(doc.children, dict())
ls.wdl_types[uri] = types
ls.wdl_defs[uri], ls.wdl_refs[uri] = _get_links(doc.children, types, dict(), dict())
ls.wdl_symbols[uri] = sorted(_get_symbols(doc.children, []))
return list(_lint_wdl(ls, doc)), doc
except WDL.Error.MultipleValidationErrors as errs:
return [_diagnostic_err(e) for e in errs.exceptions], None
except WDLError as e:
return [_diagnostic_err(e)], None
except Exception as e:
ls.show_message_log(str(e), MessageType.Error)
return [], None
def show_message(self, message, msg_type=MessageType.Info):
"""Sends message to the client to display message."""
self.notify(WINDOW_SHOW_MESSAGE, ShowMessageParams(msg_type, message))
def show_message(self, message, msg_type=MessageType.Info) -> None:
"""Sends message to the client to display message."""
self.lsp.show_message(message, msg_type)
def show_message_log(self, message, msg_type=MessageType.Log):
"""Sends message to the client's output channel."""
self.notify(WINDOW_LOG_MESSAGE, LogMessageParams(msg_type, message))
def show_message_log(self, message, msg_type=MessageType.Log) -> None:
"""Sends message to the client's output channel."""
self.lsp.show_message_log(message, msg_type)
def _check_linter_available(ls: Server):
if getattr(_check_linter_available, 'skip', False):
return
if not WDL.Lint._shellcheck_available:
ls.show_message('''
WDL task command linter is not available on the system PATH.
Please install ShellCheck and/or add it to the PATH:
https://github.com/koalaman/shellcheck#installing
''', MessageType.Warning)
_check_linter_available.skip = True