Skip to content

Bootstrapping a ReScript MCP #7566

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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions analysis/bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ let main () =
path line col
in
match args with
| [_; "mcp"; "loc-info"; path; line; col] ->
Mcp.LocInfo.locInfo ~path ~pos:(int_of_string line, int_of_string col)
|> print_endline
| [_; "mcp"; "identifier-info"; path; identifier] ->
Mcp.IdentifierInfo.identifierInfo ~identifier ~path ~maybe_line:None
~maybe_col:None
|> print_endline
| [_; "mcp"; "docs"; called_from; typ; identifier] -> (
match Mcp.Docs.docs_type_from_string typ with
| None ->
print_endline
"Not a valid type. Should be either 'ProjectFile' or 'Library'."
| Some typ -> Mcp.Docs.docs ~called_from ~typ ~identifier |> print_endline)
| [_; "cache-project"; rootPath] -> (
Cfg.readProjectConfigCache := false;
let uri = Uri.fromPath rootPath in
Expand Down
30 changes: 30 additions & 0 deletions analysis/src/Commands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,36 @@ let test ~path =
("TypeDefinition " ^ path ^ " " ^ string_of_int line ^ ":"
^ string_of_int col);
typeDefinition ~path ~pos:(line, col) ~debug:true
| "mli" ->
print_endline
("MCP loc info " ^ path ^ " " ^ string_of_int line ^ ":"
^ string_of_int col);
let currentFile = createCurrentFile () in
Mcp.LocInfo.locInfo ~path ~pos:(line, col) |> print_endline;
Sys.remove currentFile
| "mif" ->
print_endline
("MCP identifier info " ^ path ^ " " ^ string_of_int line ^ ":"
^ string_of_int col);
let currentFile = createCurrentFile () in
let identifier = String.sub rest 3 (String.length rest - 3) in
let identifier = String.trim identifier in
Mcp.IdentifierInfo.identifierInfo ~identifier ~path ~maybe_line:None
~maybe_col:None
|> print_endline;
Sys.remove currentFile
| "mdp" ->
print_endline "MCP docs for project file";
let identifier = String.sub rest 3 (String.length rest - 3) in
let identifier = String.trim identifier in
Mcp.Docs.docs ~called_from:path ~typ:ProjectFile ~identifier
|> print_endline
| "mdl" ->
print_endline "MCP docs for library";
let identifier = String.sub rest 3 (String.length rest - 3) in
let identifier = String.trim identifier in
Mcp.Docs.docs ~called_from:path ~typ:Library ~identifier
|> print_endline
| "xfm" ->
let currentFile = createCurrentFile () in
(* +2 is to ensure that the character ^ points to is what's considered the end of the selection. *)
Expand Down
Loading
Loading