From 0153f3548c0385921af916974037f43e98c87507 Mon Sep 17 00:00:00 2001 From: Carl Gay Date: Mon, 11 Mar 2024 01:05:42 -0400 Subject: [PATCH] Use standard Dylan comment style --- sources/handlers.dylan | 17 +++++----- sources/json-rpc.dylan | 77 +++++++++++++++--------------------------- 2 files changed, 36 insertions(+), 58 deletions(-) diff --git a/sources/handlers.dylan b/sources/handlers.dylan index e362d01..ecc3af7 100644 --- a/sources/handlers.dylan +++ b/sources/handlers.dylan @@ -69,15 +69,14 @@ define handler initialize send-response(session, id, response-params); end handler; -/* Handler for 'initialized' message. - * - * Example: {"jsonrpc":"2.0","method":"initialized","params":{}} - * - * Here we will register the dynamic capabilities of the server with the client. - * Note we don't do this yet, any capabilities are registered statically in the - * 'initialize' message. - * Here also we will start the compiler session. - */ +// Handler for 'initialized' message. +// +// Example: {"jsonrpc":"2.0","method":"initialized","params":{}} +// +// Here we will register the dynamic capabilities of the server with the client. +// Note we don't do this yet, any capabilities are registered statically in the +// 'initialize' message. +// Here also we will start the compiler session. define handler initialized (session :: , id, params) /* Commented out because we don't need to do this (yet) diff --git a/sources/json-rpc.dylan b/sources/json-rpc.dylan index 6e8969a..ad1fb44 100644 --- a/sources/json-rpc.dylan +++ b/sources/json-rpc.dylan @@ -52,14 +52,11 @@ define function read-headers(stm) end if end function; -/** - * Make a string-table from a sequence of key value pairs. - * This is just for convenience. -*/ +// Make a from a sequence of key value pairs. +// This is just for convenience. define function json (#rest kvs) => (table :: ) let count :: = size(kvs); - let ts = ash(count, -1); - let table = make(, size: ts); + let table = make(, size: floor/(count, 2)); for (i from 0 below count by 2) let key = kvs[i]; let value = kvs[i + 1]; @@ -78,10 +75,9 @@ define method read-json-message (stream :: ) => (json :: ) end end method read-json-message; -/* Write a message with the base protocol headers - * See: https://microsoft.github.io/language-server-protocol/specification#headerPart - * We always assume the default encoding. - */ +// Write a message with the base protocol headers +// See: https://microsoft.github.io/language-server-protocol/specification#headerPart +// We always assume the default encoding. define method write-json-message (stream :: , json :: ) => () let content-length = size(json); @@ -123,57 +119,43 @@ define generic send-raw-message define generic receive-raw-message (session :: ) => (message :: ); -/* - * Send a request message. - * Optionally, register a callback to be called with the response - * to this message. - * The callback is a function as defined with 'define message-handler'. - */ +// Send a request message. +// Optionally, register a callback to be called with the response +// to this message. +// The callback is a function as defined with 'define message-handler'. define generic send-request (session :: , method-name :: , params :: , #key callback) => (); -/* - * Send the response to a request with identifier id. - * This applies to a successful request. - */ +// Send the response to a request with identifier id. +// This applies to a successful request. define generic send-response (session :: , id :: , result :: ) => (); -/* - * Send an error response to the request with identifier id. - * Optionally include a human-readable error message and extra data - */ +// Send an error response to the request with identifier id. +// Optionally include a human-readable error message and extra data define generic send-error-response (session :: , id :: , error-code :: , #key error-message, error-data) => (); -/* - * Send an LSP notification-type message. - * This has a method name but no ID because it isn't replied to - */ +// Send an LSP notification-type message. +// This has a method name but no ID because it isn't replied to define generic send-notification (session :: , method-name :: , params :: ) => (); -/* - * Get the next message. - * If the message is a notification or request, return it - * for processing. If it is a response to a request sent - * by the server, look up the reponse callback and call it. - */ +// Get the next message. +// If the message is a notification or request, return it +// for processing. If it is a response to a request sent +// by the server, look up the reponse callback and call it. define generic receive-message (session :: ) => (method-name :: , id :: , params :: ); -/* - * Flush any pending messages through the connection. - */ +// Flush any pending messages through the connection. define generic flush (session :: ) => (); -/* - * Make the 'skeleton' of a JSONRPC 2.0 message. - */ +// Make the 'skeleton' of a JSONRPC 2.0 message. define function make-message (#key method-name, id) let msg = json("jsonrpc", "2.0"); if (method-name) @@ -198,11 +180,10 @@ define method send-notification end; end method; -/** receive a request or response. - * If it is a request, return the request method, id and params. - * If it is a response (to a request we sent to the client), look - * up the callback, call it and loop round for another message. - */ +// Receive a request or response. +// If it is a request, return the request method, id and params. +// If it is a response (to a request we sent to the client), look +// up the callback, call it and loop round for another message. define method receive-message (session :: ) => (method-name :: , id, params); @@ -268,10 +249,8 @@ define method send-error-response send-raw-message(session, message); end method; -/* - * A session communicating over standard in/out. - * This is the only one implemented for now. - */ +// A session communicating over standard in/out. +// This is the only one implemented for now. define class () constant slot session-input-stream :: , required-init-keyword: input-stream:;