Skip to content

Type search custom request#1369

Merged
voodoos merged 33 commits intoocaml:masterfrom
PizieDust:polarity_search
Nov 14, 2024
Merged

Type search custom request#1369
voodoos merged 33 commits intoocaml:masterfrom
PizieDust:polarity_search

Conversation

@PizieDust
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Member

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

@xvw
Copy link
Copy Markdown
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
Copy Markdown
Member

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

@PizieDust PizieDust requested review from voodoos and xvw September 11, 2024 17:05
Copy link
Copy Markdown
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

@voodoos
Copy link
Copy Markdown
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
Copy Markdown
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 ?

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
voodoos added a commit to voodoos/opam-repository that referenced this pull request Nov 29, 2024
CHANGES:

## Features

- Add custom
  [`ocamllsp/typeSearch`](/ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md) request (ocaml/ocaml-lsp#1369)

- Make MerlinJump code action configurable (ocaml/ocaml-lsp#1376)

- Add custom [`ocamllsp/jump`](/ocaml-lsp-server/docs/ocamllsp/merlinJump-spec.md) request (ocaml/ocaml-lsp#1374)

## Fixes

- Fix fd leak in running external processes for preprocessing (ocaml/ocaml-lsp#1349)

- Fix prefix parsing for completion of object methods (ocaml/ocaml-lsp#1363, fixes ocaml/ocaml-lsp#1358)

- Remove some duplicates in the `selectionRange` answers (ocaml/ocaml-lsp#1368)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Nov 29, 2024
CHANGES:

## Features

- Add custom
  [`ocamllsp/typeSearch`](/ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md) request (ocaml/ocaml-lsp#1369)

- Make MerlinJump code action configurable (ocaml/ocaml-lsp#1376)

- Add custom [`ocamllsp/jump`](/ocaml-lsp-server/docs/ocamllsp/merlinJump-spec.md) request (ocaml/ocaml-lsp#1374)

## Fixes

- Fix fd leak in running external processes for preprocessing (ocaml/ocaml-lsp#1349)

- Fix prefix parsing for completion of object methods (ocaml/ocaml-lsp#1363, fixes ocaml/ocaml-lsp#1358)

- Remove some duplicates in the `selectionRange` answers (ocaml/ocaml-lsp#1368)
voodoos added a commit to voodoos/opam-repository that referenced this pull request Nov 29, 2024
CHANGES:

## Features

- Add custom
  [`ocamllsp/typeSearch`](/ocaml-lsp-server/docs/ocamllsp/typeSearch-spec.md) request (ocaml/ocaml-lsp#1369)

- Make MerlinJump code action configurable (ocaml/ocaml-lsp#1376)

- Add custom [`ocamllsp/jump`](/ocaml-lsp-server/docs/ocamllsp/merlinJump-spec.md) request (ocaml/ocaml-lsp#1374)

## Fixes

- Fix fd leak in running external processes for preprocessing (ocaml/ocaml-lsp#1349)

- Fix prefix parsing for completion of object methods (ocaml/ocaml-lsp#1363, fixes ocaml/ocaml-lsp#1358)

- Remove some duplicates in the `selectionRange` answers (ocaml/ocaml-lsp#1368)
@PizieDust PizieDust deleted the polarity_search branch March 31, 2026 09:27
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