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

Merged
merged 33 commits into from
Nov 14, 2024
Merged

Type search custom request #1369

merged 33 commits into from
Nov 14, 2024

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 4607

Details

  • 35 of 37 (94.59%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 22.034%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ocaml-lsp-server/src/custom_requests/req_type_search.ml 35 37 94.59%
Totals Coverage Status
Change from base Build 4597: 0.1%
Covered Lines: 5599
Relevant Lines: 25411

💛 - 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
ocaml-lsp-server/src/custom_requests/req_type_search.ml Outdated Show resolved Hide resolved
@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
@voodoos
Copy link
Collaborator

voodoos commented Oct 28, 2024

@PizieDust I think we should, similarly as for the Type enclosing custom request, provide a way to ask for different format for the documentation, like markdown, and maybe plaintext and html ?

CHANGES.md Outdated Show resolved Hide resolved
ocaml-lsp-server/src/custom_requests/req_type_search.ml Outdated Show resolved Hide resolved
ocaml-lsp-server/src/custom_requests/req_type_search.ml Outdated Show resolved Hide resolved
ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md Outdated Show resolved Hide resolved
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.

Thanks, looks good! Let's wait for the vscode plugin implementation to catch up before merging.

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!

@voodoos
Copy link
Collaborator

voodoos commented Nov 14, 2024

Client support in VScode is on the way: ocamllabs/vscode-ocaml-platform#1626

@voodoos voodoos merged commit 556da72 into ocaml:master Nov 14, 2024
6 of 7 checks passed
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