Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type search custom request #1369

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open

Conversation

PizieDust
Copy link
Contributor

@PizieDust PizieDust commented Sep 4, 2024

TypeSearch Request

Description

This custom request allows clients to perform a type search at a specific position within a text document based on finding functions or types that match a specific query pattern.

Server capability

  • property name: handleTypeSearch
  • property type: boolean

Request

export interface TypeSearchParams extends TexDocumentPositionParams
{
    query: string;
    limit: int;
    with_doc: bool;
}
  • method: ocamllsp/typeSearch
  • params:
    • TextDocumentPositionParams: This is an existing interface that includes:
      - TextDocumentIdentifier: Specifies the document uri for which the request is sent.
      - Position: Specifies the cursor position.
      More details can be found in the TextDocumentPositionParams - LSP Specification.
    • query: The search pattern.
    • limit: The number of results to return
    • with_doc: If to return documentation information or not

Response

result: TypeSearch | null
export interface TypeSearch {
    type t = Query_protocol.type_search_result list
}
  • t: A list of types that match the query.
    type Query_protocol.type_search_result =
    {
        name : string; // The fully qualified name of this result.
        typ : string;  // The signature of this result.
        loc : Range.t; // The location of the definition of this result in the source code.
        doc : string option; // Optional documentation associated with this result.
        cost : int; // A numeric value representing the "cost" or distance between this result and the query.
        constructible : string; // A constructible form or template that can be used to invoke this result
    }
    
  • A response with null result is returned if no entries are found.

@PizieDust PizieDust marked this pull request as ready for review September 11, 2024 03:03
@coveralls
Copy link

coveralls commented Sep 11, 2024

Pull Request Test Coverage Report for Build 4579

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 25 of 26 (96.15%) changed or added relevant lines in 1 file are covered.
  • 27 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.07%) to 21.996%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ocaml-lsp-server/src/custom_requests/req_type_search.ml 25 26 96.15%
Files with Coverage Reduction New Missed Lines %
ocaml-lsp-server/src/inlay_hints.ml 2 86.96%
ocaml-lsp-server/src/inference.ml 4 70.45%
ocaml-lsp-server/src/signature_help.ml 21 0.0%
Totals Coverage Status
Change from base Build 4565: 0.07%
Covered Lines: 5579
Relevant Lines: 25364

💛 - Coveralls

Copy link
Collaborator

@xvw xvw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@rgrinberg
Copy link
Member

Nice. Which client is going to make use of this?

@xvw
Copy link
Collaborator

xvw commented Sep 11, 2024

Nice. Which client is going to make use of this?

We probably will implement a VScode extension for the query

@rgrinberg
Copy link
Member

Okay, I think we need to see that vscode client to evaluate this work.

@PizieDust PizieDust changed the title Polarity search custom request Type search custom request Sep 24, 2024
@PizieDust PizieDust marked this pull request as draft September 24, 2024 17:13
Copy link
Collaborator

@voodoos voodoos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good to me, thanks @PizieDust

ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md Outdated Show resolved Hide resolved
Comment on lines +50 to +52
, match res.doc with
| Some d -> `String d
| None -> `Null )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be replaced by Json.option Json.string res.doc

@voodoos
Copy link
Collaborator

voodoos commented Sep 30, 2024

@xvw, @PizieDust, Melrin 5.2-502 has been released so the CI should pass without pinning and could be un-drafted. Is the custom request ready for a last round of review ?

@PizieDust PizieDust marked this pull request as ready for review October 1, 2024 07:42

```js
result: TypeSearch | null
export interface TypeSearch {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still a little bit confuse by the syntactic choice fo expressing JSON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants