From e47a4880cb2266965e3ae5c480fb06352ada191e Mon Sep 17 00:00:00 2001 From: xvw Date: Mon, 23 Sep 2024 16:58:31 +0200 Subject: [PATCH] Add polarity search and type search in protocol --- doc/dev/PROTOCOL.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/dev/PROTOCOL.md b/doc/dev/PROTOCOL.md index 7d03d986f7..2868758373 100644 --- a/doc/dev/PROTOCOL.md +++ b/doc/dev/PROTOCOL.md @@ -425,6 +425,34 @@ The result is returned as a list of: Returns the type of the expression when typechecked in the environment around the specified position. +### `search-by-polarity` -position -query + + -position Position to search + -query The query + +Returns a list (in the form of a completion list) of values matching the query. A query is defined by polarity (and does not support type parameters). Arguments are prefixed with `-` and the return type is prefixed with `+`. For example, to find a function that takes a string and returns an integer: `-string +int`. `-list +option` will returns every definition that take a list an option. + +### `search-by-type` -position -query -limit + + -position Position to search + -query The query + -limit a maximum-size of the result set + +Returns a list of values matching the query. A query is a type expression, ie: `string -> int option` will search every definition that take a string and returns an option of int. It is also possible to search by polarity. + +The result is returned as a list of: +```javascript +{ + 'file': filename, // the file where the definition is defined + 'start': position, + 'end': position, + 'name': string, // the name of the definition + 'type': string, // the type of the definition + 'cost': int, // the cost/distance of the definition and the query + 'doc': string | null // the docstring of the definition +} +``` + ### `check-configuration`