-
Notifications
You must be signed in to change notification settings - Fork 60
Add: Workspace symbols #510
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ let kindNumber = function | |
| EnumMember -> 22 | ||
| TypeParameter -> 26 | ||
|
||
let command ~path = | ||
let document ~path = | ||
let symbols = ref [] in | ||
let rec exprKind (exp : Parsetree.expression) = | ||
match exp.pexp_desc with | ||
|
@@ -134,19 +134,42 @@ let command ~path = | |
let parser = Res_driver.parsingEngine.parseInterface ~forPrinter:false in | ||
let {Res_driver.parsetree = signature} = parser ~filename:path in | ||
iterator.signature iterator signature |> ignore); | ||
let result = | ||
!symbols | ||
|> List.rev_map (fun (name, loc, kind) -> | ||
Protocol.stringifyDocumentSymbolItem | ||
{ | ||
name; | ||
location = | ||
{ | ||
uri = Uri.toString (Uri.fromPath path); | ||
range = Utils.cmtLocToRange loc; | ||
}; | ||
kind = kindNumber kind; | ||
}) | ||
|> String.concat ",\n" | ||
in | ||
print_endline ("[\n" ^ result ^ "\n]") | ||
!symbols | ||
|> List.rev_map (fun (name, loc, kind) -> | ||
let symbol : Protocol.documentSymbolItem = | ||
{ | ||
name; | ||
location = | ||
{ | ||
uri = Uri.toString (Uri.fromPath path); | ||
range = Utils.cmtLocToRange loc; | ||
}; | ||
kind = kindNumber kind; | ||
} | ||
in | ||
symbol) | ||
|
||
let workspace ~dir = | ||
let open FindFiles in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a bunch of places in the codebase with this kind of code. E.g. the functionality to read There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a separate issue to track this @cristianoc ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can be assessed now, and any follow-on work postponed.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aspeddro will you have a look at this? After that, this should be good for merging. EDIT: Sorry, this + the other comments about the tests that @cristianoc had. |
||
let bsconfig = dir /+ "bsconfig.json" in | ||
match Files.readFile bsconfig with | ||
| None -> None | ||
| Some text -> ( | ||
match Json.parse text with | ||
| None -> None | ||
| Some inner -> | ||
let sourceDirectories = | ||
getSourceDirectories ~includeDev:false ~baseDir:dir inner | ||
in | ||
let result = | ||
sourceDirectories | ||
|> List.map (fun srcDir -> | ||
Files.readDirectory (dir /+ srcDir) | ||
|> List.map (fun path -> dir /+ srcDir /+ path) | ||
|> List.filter isSourceFile |> filterDuplicates) | ||
|> List.flatten | ||
|> List.map (fun path -> | ||
document ~path |> List.map Protocol.stringifyDocumentSymbolItem) | ||
|> List.flatten |> Protocol.array | ||
in | ||
Some result) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
SHELL = /bin/bash | ||
|
||
node_modules/.bin/rescript: | ||
npm install | ||
|
||
build: node_modules/.bin/rescript | ||
node_modules/.bin/rescript | ||
|
||
clean: | ||
rm -r node_modules lib | ||
|
||
.PHONY: clean |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Hover src/Auto.res 2:13 | ||
Hover document/src/Auto.res 2:13 | ||
{"contents": "```rescript\n(Belt.List.t<'a>, 'a => 'b) => Belt.List.t<'b>\n```\n\n\n Returns a new list with `f` applied to each element of `someList`.\n\n ```res example\n list{1, 2}->Belt.List.map(x => x + 1) // list{3, 4}\n ```\n"} | ||
|
Uh oh!
There was an error while loading. Please reload this page.