-
Notifications
You must be signed in to change notification settings - Fork 469
Complete functions from included module #7515
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1827920
WIP find answer in stamps
nojaf a9e37c0
Refactor included values
nojaf 6b80247
Fix check in processLocalValue
nojaf 43b15e8
Clean up dump logs
nojaf 5c82b2f
Include values without pipe completion as well
nojaf 8fdc591
Introduce include scope
nojaf f849598
Check if include ends with path
nojaf 7b87320
Deal with namespace in modulePathFromEnv
nojaf 88cd2bc
Simplify completions from current module
nojaf 8883bfd
Also iter includes in findLocalCompletionsForValues
nojaf 978811d
Add changelog entry
nojaf aff92c5
Merge branch 'master' into pipe-include-module-two
nojaf d17e55e
Merge branch 'master' into pipe-include-module-two
nojaf c4bdd03
Remove unused function
nojaf 6aa9d71
Dump structure
nojaf feb9b1e
Print scope
nojaf fa55ece
IncludePstr_include( Pmod_ident)
nojaf 9f66dd2
Remove path to_string
nojaf f782f32
Don't let exported override included
nojaf 4a578bf
Use Path.name
nojaf 0359c7f
Remove duplicate check
nojaf 1518f6d
Store included values in separate table
nojaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
let filter_by_cursor cursor (loc : Warnings.loc) : bool = | ||
match cursor with | ||
| None -> true | ||
| Some (line, col) -> | ||
let start = loc.loc_start and end_ = loc.loc_end in | ||
let line_in = start.pos_lnum <= line && line <= end_.pos_lnum in | ||
let col_in = | ||
if start.pos_lnum = end_.pos_lnum then | ||
start.pos_cnum - start.pos_bol <= col | ||
&& col <= end_.pos_cnum - end_.pos_bol | ||
else if line = start.pos_lnum then col >= start.pos_cnum - start.pos_bol | ||
else if line = end_.pos_lnum then col <= end_.pos_cnum - end_.pos_bol | ||
else true | ||
in | ||
line_in && col_in | ||
|
||
type filter = Cursor of (int * int) | Loc of Loc.t | ||
|
||
let dump ?filter rescript_json cmt_path = | ||
let uri = Uri.fromPath (Filename.remove_extension cmt_path ^ ".res") in | ||
let package = | ||
let uri = Uri.fromPath rescript_json in | ||
Packages.getPackage ~uri |> Option.get | ||
in | ||
let moduleName = | ||
BuildSystem.namespacedName package.namespace (FindFiles.getName cmt_path) | ||
in | ||
match Cmt.fullForCmt ~moduleName ~package ~uri cmt_path with | ||
| None -> failwith (Format.sprintf "Could not load cmt for %s" cmt_path) | ||
| Some full -> | ||
let open SharedTypes in | ||
let open SharedTypes.Stamps in | ||
let applyFilter = | ||
match filter with | ||
| None -> fun _ -> true | ||
| Some (Cursor cursor) -> Loc.hasPos ~pos:cursor | ||
| Some (Loc loc) -> Loc.isInside loc | ||
in | ||
(match filter with | ||
| None -> () | ||
| Some (Cursor (line, col)) -> | ||
Printf.printf "Filtering by cursor %d,%d\n" line col | ||
| Some (Loc loc) -> Printf.printf "Filtering by loc %s\n" (Loc.toString loc)); | ||
|
||
Printf.printf "file moduleName: %s\n\n" full.file.moduleName; | ||
|
||
let stamps = | ||
full.file.stamps |> getEntries | ||
|> List.filter (fun (_, stamp) -> applyFilter (locOfKind stamp)) | ||
in | ||
|
||
let total_stamps = List.length stamps in | ||
Printf.printf "Found %d stamps:\n%s" total_stamps | ||
(if total_stamps > 0 then "\n" else ""); | ||
|
||
stamps | ||
|> List.sort (fun (_, a) (_, b) -> | ||
let aLoc = locOfKind a in | ||
let bLoc = locOfKind b in | ||
match compare aLoc.loc_start.pos_lnum bLoc.loc_start.pos_lnum with | ||
| 0 -> compare aLoc.loc_start.pos_cnum bLoc.loc_start.pos_cnum | ||
| c -> c) | ||
|> List.iter (fun (stamp, kind) -> | ||
match kind with | ||
| KType t -> | ||
Printf.printf "%d ktype %s\n" stamp | ||
(Warnings.loc_to_string t.extentLoc) | ||
| KValue t -> | ||
Printf.printf "%d kvalue %s\n" stamp | ||
(Warnings.loc_to_string t.extentLoc) | ||
| KModule t -> | ||
Printf.printf "%d kmodule %s\n" stamp | ||
(Warnings.loc_to_string t.extentLoc) | ||
| KConstructor t -> | ||
Printf.printf "%d kconstructor %s\n" stamp | ||
(Warnings.loc_to_string t.extentLoc)); | ||
|
||
(* dump the structure *) | ||
let rec dump_structure indent (structure : Module.structure) = | ||
if indent > 0 then Printf.printf "%s" (String.make indent ' '); | ||
Printf.printf "Structure %s:\n" structure.name; | ||
structure.items |> List.iter (dump_structure_item (indent + 2)) | ||
and dump_structure_item indent item = | ||
if indent > 0 then Printf.printf "%s" (String.make indent ' '); | ||
let open Module in | ||
match item.kind with | ||
| Value _typedExpr -> | ||
Printf.printf "Value %s %s\n" item.name | ||
(Warnings.loc_to_string item.loc) | ||
| Type _ -> | ||
Printf.printf "Type %s %s\n" item.name (Warnings.loc_to_string item.loc) | ||
| Module {type_ = m} -> | ||
Printf.printf "Module %s %s\n" item.name | ||
(Warnings.loc_to_string item.loc); | ||
dump_module indent m | ||
and dump_module indent (module_ : Module.t) = | ||
match module_ with | ||
| Ident path -> Printf.printf "Module (Ident) %s\n" (Path.name path) | ||
| Structure structure -> dump_structure indent structure | ||
| Constraint (m1, m2) -> | ||
dump_module indent m1; | ||
dump_module indent m2 | ||
in | ||
|
||
print_newline (); | ||
dump_structure 0 full.file.structure; | ||
|
||
(* Dump all locItems (typed nodes) *) | ||
let locItems = | ||
match full.extra with | ||
| {locItems} -> | ||
locItems |> List.filter (fun locItem -> applyFilter locItem.loc) | ||
in | ||
|
||
Printf.printf "\nFound %d locItems (typed nodes):\n\n" | ||
(List.length locItems); | ||
|
||
locItems | ||
|> List.sort (fun a b -> | ||
let aLoc = a.loc.Location.loc_start in | ||
let bLoc = b.loc.Location.loc_start in | ||
match compare aLoc.pos_lnum bLoc.pos_lnum with | ||
| 0 -> compare aLoc.pos_cnum bLoc.pos_cnum | ||
| c -> c) | ||
|> List.iter (fun {loc; locType} -> | ||
let locStr = Warnings.loc_to_string loc in | ||
let kindStr = SharedTypes.locTypeToString locType in | ||
Printf.printf "%s %s\n" locStr kindStr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.