From 63fe1e1a1ff11beb2afdaad5e5ca1b6c15a48c76 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Thu, 3 Dec 2026 20:04:39 +0000 Subject: [PATCH] Treat included members as copies of their declarations in editor analysis Why: An `include` copies the members of a module under new stamps, at the positions of the original declarations. Analysis registers each copy as a declaration of the including file, so Find References on a member splits into the declaration with its direct uses and the uses of the copy (`fv` below). Constructors and record fields keep their identifiers through an include. When they come from another file's compilation, their stamps can equal stamps of values in the including file (`Dot` and `Box` below have the stamps of `v0` and `v1`). Find References on such a value then lists wrong and `0:-1` locations and misses its uses in other files. References modified (include): Example: // Lib.res module type T = { type t } module Make = (X: T) => { type shape = Dot | Box(X.t) } // Main.res include Lib.Make({ type t = int }) let v0 = 0 let v1 = 1 let v2 = 2 module type T = { type t } module F = (X: T) => { let fv = 1 } include F({ type t = int }) let u = fv // Other.res let w = Main.v0 + Main.v1 Before (text): line:column, from 0 v0 in Main Main 3:4, Main 0:-1, Main 3:4 fv in F Main 10:6 fv after include Main 10:6, Main 15:8 After (text): v0 in Main Main 3:4, Other 0:13 fv in F Main 10:6, Main 15:8 fv after include Main 10:6, Main 15:8 References modified (constructor of an included type): Example: // Main.res, with Lib.res as above include Lib.Make({ type t = int }) let v0 = 0 let v1 = 1 let dot = Dot let box = Box(1) Before (text): line:column, from 0 Dot in Main Main 3:4, Main 0:-1, Main 3:4, Main 5:10 definition of Box null After (text): Dot in Main Main 5:10, Lib 4:15 definition of Box Lib 4:21 References modified (include with a shadowed member): Example: module Base = { type t = A | B type r = {f: int} let bv = 1 let other = 2 } module Over = { include Base let other = 3 } let a = Over.A let f = (x: Over.r) => x.f let b = Over.bv + Base.bv let o = Over.other Before (text): line:column, from 0 Over.A 1:11, 0:-1, 0:-1, 10:13 x.f 2:12, 0:-1, 0:-1, 11:25 Over.bv 3:6, 3:6, 3:6, 12:13 Over.other 8:6, 8:6, 8:6, 13:13 After (text): Over.A 1:11, 10:13 x.f 2:12, 11:25 Over.bv 3:6, 12:13, 12:23 Over.other 8:6, 13:13 References modified (include module type of): Example: // M.res module Base = { let bv = 1 } include Base // M.resi module Base: { let bv: int } include module type of Base Before (text): bv in Base, line:column, from 0 M.resi 1:2 (all of `let bv: int`), M.res 1:6 After (text): M.resi 1:6, M.res 1:6 A copy whose original member is found is not a declaration of the including file: it has no definition item and no declaration reference. The original is found from the copy's module path, which names the included module `source` and the modules a nested copy sits in: the copy of `x` in a nested `Inner` resolves to `source.Inner.x`. Other files reach that copy under its full path, such as `Main.Inner.x`. Find References on a value, type or module gathers the original member and all its copies in the file and in the other file of a .res/.resi pair, and the original's references in its own file when it is in another one. Constructors and fields go through their type. The uses that other files record for all of them are collected in one pass over the project. Go to definition on a constructor or field of a copied type goes to the one it copies. A module that shadows a member it includes gets an implicit constraint to its own signature. Its members, read again from that signature, keep what the structure gave them, so its copies stay copies, and each member is declared once. `include module type of M` in a signature is an include of `M`. Constructors and record fields read from a signature (an include, a module type, a functor parameter) get stamps of their own. References at ghost locations, such as those of members read from a signature, are dropped, so there are no `0:-1` entries. Review: Why fresh stamps for constructors and fields of signatures? An include or a module type keeps their identifiers, and a signature from another file brings that compilation's stamps, which can equal stamps of this one. Fresh stamps avoid that wherever the signature comes from, also for `include unpack(...)` and for a functor parameter, where no original can be resolved. They count down from -2, because 0 marks a persistent identifier and -1 a hidden one. The numbering restarts for each file, so reading a file twice gives the same stamps. Review: What does the project scan cost? Find References reads each file of the project, and the other file of a .res/.resi pair, once per query, whatever the number of copies. Review: Why does the Hover snapshot change? `@react.component` adds a second `make`, so the module was read twice and `x` was declared twice. With one declaration, the JSX heuristic no longer runs; the hover text is the same. Review: What is not found? From the declaration in another file, uses through the including file's copy, such as `Main.Dot` or `Main.made`, are not found, as on master. Constructors and fields of a module type `S` used through another module type that includes it, as with `module type S2 = { include S }`, `module M: S` and a parameter `X: S2`, are not connected. On master they were, only through shared stamps and with `0:-1` entries. Values already behave this way. Fixes: #9323 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Kbf3gGbYDy2DBe5YmGdHTL Claude-Session: https://claude.ai/code/session_01Kbf3gGgQuXy1xmZbjATZsB Signed-off-by: Christoph Knittel --- analysis/src/process_cmt.ml | 90 ++-- analysis/src/process_extra.ml | 132 ++++-- analysis/src/references.ml | 374 +++++++++------ analysis/src/shared_types.ml | 27 +- changes/editor-include-declarations.fix.md | 1 + .../tests/src/IncludeDeclarations.res | 109 +++++ .../tests/src/IncludeDeclarationsIntf.res | 8 + .../tests/src/IncludeDeclarationsIntf.resi | 3 + .../tests/src/IncludeDeclarationsIntfUse.res | 8 + .../tests/src/IncludeDeclarationsLib.res | 12 + .../tests/src/IncludeDeclarationsOverride.res | 32 ++ .../tests/src/IncludeDeclarationsParam.res | 24 + .../tests/src/IncludeDeclarationsSig.res | 13 + .../tests/src/IncludeDeclarationsTypeOf.res | 7 + .../tests/src/IncludeDeclarationsTypeOf.resi | 4 + .../tests/src/IncludeDeclarationsUnpack.res | 18 + .../tests/src/IncludeDeclarationsUse.res | 15 + .../tests/src/expected/Hover.res.txt | 2 - .../src/expected/IncludeDeclarations.res.txt | 436 ++++++++++++++++++ .../expected/IncludeDeclarationsIntf.res.txt | 0 .../expected/IncludeDeclarationsIntf.resi.txt | 0 .../IncludeDeclarationsIntfUse.res.txt | 166 +++++++ .../expected/IncludeDeclarationsLib.res.txt | 0 .../IncludeDeclarationsOverride.res.txt | 137 ++++++ .../expected/IncludeDeclarationsParam.res.txt | 112 +++++ .../expected/IncludeDeclarationsSig.res.txt | 0 .../IncludeDeclarationsTypeOf.res.txt | 50 ++ .../IncludeDeclarationsTypeOf.resi.txt | 0 .../IncludeDeclarationsUnpack.res.txt | 47 ++ .../expected/IncludeDeclarationsUse.res.txt | 157 +++++++ 30 files changed, 1754 insertions(+), 230 deletions(-) create mode 100644 changes/editor-include-declarations.fix.md create mode 100644 tests/analysis_tests/tests/src/IncludeDeclarations.res create mode 100644 tests/analysis_tests/tests/src/IncludeDeclarationsIntf.res create mode 100644 tests/analysis_tests/tests/src/IncludeDeclarationsIntf.resi create mode 100644 tests/analysis_tests/tests/src/IncludeDeclarationsIntfUse.res create mode 100644 tests/analysis_tests/tests/src/IncludeDeclarationsLib.res create mode 100644 tests/analysis_tests/tests/src/IncludeDeclarationsOverride.res create mode 100644 tests/analysis_tests/tests/src/IncludeDeclarationsParam.res create mode 100644 tests/analysis_tests/tests/src/IncludeDeclarationsSig.res create mode 100644 tests/analysis_tests/tests/src/IncludeDeclarationsTypeOf.res create mode 100644 tests/analysis_tests/tests/src/IncludeDeclarationsTypeOf.resi create mode 100644 tests/analysis_tests/tests/src/IncludeDeclarationsUnpack.res create mode 100644 tests/analysis_tests/tests/src/IncludeDeclarationsUse.res create mode 100644 tests/analysis_tests/tests/src/expected/IncludeDeclarations.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/IncludeDeclarationsIntf.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/IncludeDeclarationsIntf.resi.txt create mode 100644 tests/analysis_tests/tests/src/expected/IncludeDeclarationsIntfUse.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/IncludeDeclarationsLib.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/IncludeDeclarationsOverride.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/IncludeDeclarationsParam.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/IncludeDeclarationsSig.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/IncludeDeclarationsTypeOf.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/IncludeDeclarationsTypeOf.resi.txt create mode 100644 tests/analysis_tests/tests/src/expected/IncludeDeclarationsUnpack.res.txt create mode 100644 tests/analysis_tests/tests/src/expected/IncludeDeclarationsUse.res.txt diff --git a/analysis/src/process_cmt.ml b/analysis/src/process_cmt.ml index 5a7d45e99ef..74aa211fedf 100644 --- a/analysis/src/process_cmt.ml +++ b/analysis/src/process_cmt.ml @@ -20,8 +20,8 @@ let attrs_to_docstring attrs = | None -> [] | Some docstring -> [docstring] -let map_record_field {Types.ld_id; ld_type; ld_attributes; ld_optional} = - let astamp = Ident.binding_time ld_id in +let map_record_field ~env {Types.ld_id; ld_type; ld_attributes; ld_optional} = + let astamp = Env.fresh_label_stamp env in let name = Ident.name ld_id in { stamp = astamp; @@ -35,29 +35,33 @@ let map_record_field {Types.ld_id; ld_type; ld_attributes; ld_optional} = deprecated = Process_attributes.find_deprecated_attribute ld_attributes; } +(* A member read from a signature, unless this file already has it: a + structure that shadows one of its members gets an implicit constraint to its + signature, which lists the remaining members of the structure again. Keep + what the structure gave them, in particular the path of an included copy, + and only export them. *) +let add_signature_declared ~(name : string Location.loc) ~extent ~stamp + ~(env : Env.t) ~item attributes add_exported find_stamp add_stamp = + match find_stamp env.stamps stamp with + | Some declared -> + ignore (add_exported name.txt stamp : bool); + declared + | None -> + add_declared ~name ~extent ~stamp ~env ~item:(item ()) attributes + add_exported add_stamp + let rec for_type_signature_item ~(env : Shared_types.Env.t) ~(exported : Exported.t) (item : Types.signature_item) = match item with | Sig_value (ident, {val_type; val_attributes; val_loc = loc}) -> - let item = val_type in - let stamp = Ident.binding_time ident in - let old_declared = Stamps.find_value env.stamps stamp in let declared = - add_declared + add_signature_declared ~name:(Location.mkloc (Ident.name ident) loc) - ~extent:loc ~stamp ~env ~item val_attributes + ~extent:loc ~stamp:(Ident.binding_time ident) ~env + ~item:(fun () -> val_type) + val_attributes (Exported.add exported Exported.Value) - Stamps.add_value - in - let declared = - (* When an id is shadowed, a module constraint without the doc comment is created. - Here the existing doc comment is restored. See https://github.com/rescript-lang/rescript-vscode/issues/621 *) - match old_declared with - | Some old_declared when declared.docstring = [] -> - let new_declared = {declared with docstring = old_declared.docstring} in - Stamps.add_value env.stamps stamp new_declared; - new_declared - | _ -> declared + Stamps.find_value Stamps.add_value in [ { @@ -74,8 +78,8 @@ let rec for_type_signature_item ~(env : Shared_types.Env.t) rec_status ) -> let declared = let name = Location.mknoloc (Ident.name ident) in - add_declared ~extent:type_loc - ~item: + add_signature_declared ~extent:type_loc + ~item:(fun () -> { Type.decl; attributes = type_attributes; @@ -98,7 +102,7 @@ let rec for_type_signature_item ~(env : Shared_types.Env.t) {Types.cd_loc; cd_id; cd_args; cd_res; cd_attributes} -> let name = Ident.name cd_id in - let stamp = Ident.binding_time cd_id in + let stamp = Env.fresh_label_stamp env in let item = { Constructor.stamp; @@ -111,7 +115,7 @@ let rec for_type_signature_item ~(env : Shared_types.Env.t) |> List.map (fun t -> (t, Location.none))) | Cstr_record fields -> InlineRecord - (fields |> List.map map_record_field)); + (fields |> List.map (map_record_field ~env))); res = cd_res; type_decl = (name, decl); docstring = attrs_to_docstring cd_attributes; @@ -129,11 +133,11 @@ let rec for_type_signature_item ~(env : Shared_types.Env.t) Stamps.add_constructor env.stamps stamp declared; item)) | Type_record (fields, _) -> - Record (fields |> List.map map_record_field)); - } + Record (fields |> List.map (map_record_field ~env))); + }) ~name ~stamp:(Ident.binding_time ident) ~env type_attributes (Exported.add exported Exported.Type) - Stamps.add_type + Stamps.find_type Stamps.add_type in [ { @@ -147,12 +151,13 @@ let rec for_type_signature_item ~(env : Shared_types.Env.t) | Sig_module (ident, {md_type; md_attributes; md_loc}, _) -> let name = Ident.name ident in let declared = - add_declared ~extent:md_loc - ~item:(for_type_module ~name ~env:(env |> Env.add_module ~name) md_type) + add_signature_declared ~extent:md_loc + ~item:(fun () -> + for_type_module ~name ~env:(env |> Env.add_module ~name) md_type) ~name:(Location.mkloc name md_loc) ~stamp:(Ident.binding_time ident) ~env md_attributes (Exported.add exported Exported.Module) - Stamps.add_module + Stamps.find_module Stamps.add_module in [ { @@ -185,10 +190,21 @@ and for_type_module ~name ~env module_type = | Mty_functor (_argIdent, _argType, result_type) -> for_type_module ~name ~env result_type +let rec get_module_path mod_desc = + match mod_desc with + | Typedtree.Tmod_ident (path, _lident) -> Some path + | Tmod_structure _ -> None + | Tmod_functor (_ident, _argName, _maybeType, _resultExpr) -> None + | Tmod_apply (functor_, _arg, _coercion) -> get_module_path functor_.mod_desc + | Tmod_unpack (_expr, _moduleType) -> None + | Tmod_constraint (expr, _typ, _constraint, _coercion) -> + get_module_path expr.mod_desc + let get_module_type_path mod_desc = match mod_desc with | Typedtree.Tmty_ident (path, _) | Tmty_alias (path, _) -> Some path - | Tmty_signature _ | Tmty_functor _ | Tmty_with _ | Tmty_typeof _ -> None + | Tmty_typeof module_expr -> get_module_path module_expr.mod_desc + | Tmty_signature _ | Tmty_functor _ | Tmty_with _ -> None let for_type_declaration ~env ~(exported : Exported.t) { @@ -466,16 +482,6 @@ let for_signature ~name ~env sig_items = let deprecated = Process_attributes.find_deprecated_attribute attributes in {Module.name; docstring; exported; items; deprecated} -let rec get_module_path mod_desc = - match mod_desc with - | Typedtree.Tmod_ident (path, _lident) -> Some path - | Tmod_structure _ -> None - | Tmod_functor (_ident, _argName, _maybeType, _resultExpr) -> None - | Tmod_apply (functor_, _arg, _coercion) -> get_module_path functor_.mod_desc - | Tmod_unpack (_expr, _moduleType) -> None - | Tmod_constraint (expr, _typ, _constraint, _coercion) -> - get_module_path expr.mod_desc - let rec for_structure_item ~(env : Shared_types.Env.t) ~(exported : Exported.t) item = match item.Typedtree.str_desc with @@ -758,7 +764,11 @@ and for_structure ~name ~env str_items = let file_for_cmt_infos ~module_name ~uri ({cmt_modname; cmt_annots} : Cmt_format.cmt_infos) = let env = - {Env.stamps = Stamps.init (); module_path = File (uri, module_name)} + { + Env.stamps = Stamps.init (); + module_path = File (uri, module_name); + last_label_stamp = ref (-1); + } in match cmt_annots with | Partial_implementation parts -> diff --git a/analysis/src/process_extra.ml b/analysis/src/process_extra.ml index a5401a98380..5961f47a0e1 100644 --- a/analysis/src/process_extra.ml +++ b/analysis/src/process_extra.ml @@ -4,55 +4,107 @@ let add_loc_item extra loc loc_type = if not loc.Warnings.loc_ghost then extra.loc_items <- {loc; loc_type} :: extra.loc_items -let add_reference ~extra stamp loc = - Hashtbl.replace extra.internal_references stamp - (loc - :: - (if Hashtbl.mem extra.internal_references stamp then - Hashtbl.find extra.internal_references stamp - else [])) +(* Ghost locations, such as those of members read from a signature, point + nowhere in the source. *) +let add_reference ~extra stamp (loc : Location.t) = + if not loc.loc_ghost then + Hashtbl.replace extra.internal_references stamp + (loc + :: + (if Hashtbl.mem extra.internal_references stamp then + Hashtbl.find extra.internal_references stamp + else [])) + +type include_origin = + | Origin of int + | Other_file of string * string list (** module name and path *) + +(* An `include` copies the members of a module under fresh stamps, with module + path [IncludedModule (source, _)] (for a nested member, under its modules) + and the location of the member they copy. Follow a copy back to that + member. When the path leads into another file, the result is + [Other_file] with the member's path there, without loading that file: if + the member is missing, the copy still is no declaration of this file and + lookups in the other file find nothing. Otherwise the result is the + member's stamp, or the copy itself when the member can't be found. *) +let rec include_origin ~(file : File.t) stamp (tip : Tip.t) = + let source_path (d : _ Declared.t) = + Module_path.included_path d.module_path d.name.txt + in + let source, kind = + match tip with + | Value -> + ( Option.bind (Stamps.find_value file.stamps stamp) source_path, + Exported.Value ) + | Module -> + ( Option.bind (Stamps.find_module file.stamps stamp) source_path, + Exported.Module ) + | Type | Field _ | Constructor _ -> + ( Option.bind (Stamps.find_type file.stamps stamp) source_path, + Exported.Type ) + in + match source with + | Some source -> ( + let env = Query_env.from_file file in + match Resolve_path.from_compiler_path ~env source with + | Exported (env, name) -> ( + match Exported.find env.exported kind name with + | Some source_stamp when source_stamp <> stamp -> + include_origin ~file source_stamp tip + | Some _ | None -> Origin stamp) + | Global (module_name, path) -> Other_file (module_name, path) + | Stamp _ | GlobalMod _ | NotFound -> Origin stamp) + | None -> Origin stamp + +(* A copy whose member is found elsewhere is not a declaration of this file. *) +let is_declaration ~file stamp tip = + include_origin ~file stamp tip = Origin stamp let extra_for_file ~(file : File.t) = let extra = init_extra () in file.stamps |> Stamps.iter_modules (fun stamp (d : Module.t Declared.t) -> - add_loc_item extra d.name.loc (LModule (Definition (stamp, Module))); - add_reference ~extra stamp d.name.loc); + if is_declaration ~file stamp Module then ( + add_loc_item extra d.name.loc (LModule (Definition (stamp, Module))); + add_reference ~extra stamp d.name.loc)); file.stamps |> Stamps.iter_values (fun stamp (d : Types.type_expr Declared.t) -> - add_loc_item extra d.name.loc - (Typed (d.name.txt, d.item, Definition (stamp, Value))); - add_reference ~extra stamp d.name.loc); + if is_declaration ~file stamp Value then ( + add_loc_item extra d.name.loc + (Typed (d.name.txt, d.item, Definition (stamp, Value))); + add_reference ~extra stamp d.name.loc)); file.stamps |> Stamps.iter_types (fun stamp (d : Type.t Declared.t) -> - add_loc_item extra d.name.loc - (TypeDefinition (d.name.txt, d.item.Type.decl, stamp)); - add_reference ~extra stamp d.name.loc; - match d.item.Type.kind with - | Record labels -> - labels - |> List.iter (fun {stamp; fname; typ} -> - add_reference ~extra stamp fname.loc; - add_loc_item extra fname.loc - (Typed (d.name.txt, typ, Definition (d.stamp, Field fname.txt)))) - | Variant constructors -> - constructors - |> List.iter (fun {Constructor.stamp; cname} -> - add_reference ~extra stamp cname.loc; - let t = - { - Types.id = 0; - level = 0; - desc = - Tconstr - ( Path.Pident {Ident.stamp; name = d.name.txt; flags = 0}, - [], - ref Types.Mnil ); - } - in - add_loc_item extra cname.loc - (Typed (d.name.txt, t, Definition (d.stamp, Constructor cname.txt)))) - | _ -> ()); + if is_declaration ~file stamp Type then ( + add_loc_item extra d.name.loc + (TypeDefinition (d.name.txt, d.item.Type.decl, stamp)); + add_reference ~extra stamp d.name.loc; + match d.item.Type.kind with + | Record labels -> + labels + |> List.iter (fun {stamp; fname; typ} -> + add_reference ~extra stamp fname.loc; + add_loc_item extra fname.loc + (Typed (d.name.txt, typ, Definition (d.stamp, Field fname.txt)))) + | Variant constructors -> + constructors + |> List.iter (fun {Constructor.stamp; cname} -> + add_reference ~extra stamp cname.loc; + let t = + { + Types.id = 0; + level = 0; + desc = + Tconstr + ( Path.Pident {Ident.stamp; name = d.name.txt; flags = 0}, + [], + ref Types.Mnil ); + } + in + add_loc_item extra cname.loc + (Typed + (d.name.txt, t, Definition (d.stamp, Constructor cname.txt)))) + | _ -> ())); extra let add_external_reference ~extra module_name path tip loc = diff --git a/analysis/src/references.ml b/analysis/src/references.ml index 7d238853e3a..c75a07520ff 100644 --- a/analysis/src/references.ml +++ b/analysis/src/references.ml @@ -187,36 +187,36 @@ let defined_for_loc ~state ~file ~package loc_kind = maybe_log "Yes!! got it"; Some res))) -(** Find alternative declaration: from res in case of interface, or from resi in case of implementation *) -let alternate_declared ~state ~(file : File.t) ~package - (declared : _ Declared.t) tip = +(* The other file of the same module: the .res of a .resi, or the .resi of a + .res, if there is one. *) +let alternate_full ~state ~(file : File.t) ~package = match Hashtbl.find_opt package.paths_for_module file.module_name with + | Some (IntfAndImpl {resi; res}) -> + maybe_log + ("alternate_declared for " ^ file.module_name ^ " has both resi and res"); + let alternate_uri = if Uri.is_interface file.uri then res else resi in + Cmt.full_from_uri ~state ~uri:(Uri.from_path alternate_uri) + | Some _ | None -> + maybe_log ("alternate_declared for " ^ file.module_name ^ " not found"); + None + +(* The member of [alternate] at the path of [declared]. *) +let alternate_member ~state ~package ~(alternate : full) + (declared : _ Declared.t) tip = + let env = Query_env.from_file alternate.file in + let path = Module_path.to_path declared.module_path declared.name.txt in + maybe_log ("find declared for path " ^ path_to_string path); + match exported_for_tip ~state ~env ~path ~package ~tip with | None -> None - | Some paths -> ( - match paths with - | IntfAndImpl {resi; res} -> ( - maybe_log - ("alternate_declared for " ^ file.module_name ^ " has both resi and res"); - let alternate_uri = if Uri.is_interface file.uri then res else resi in - match Cmt.full_from_uri ~state ~uri:(Uri.from_path alternate_uri) with - | None -> None - | Some {file; extra} -> ( - let env = Query_env.from_file file in - let path = Module_path.to_path declared.module_path declared.name.txt in - maybe_log ("find declared for path " ^ path_to_string path); - let declared_opt = - match exported_for_tip ~state ~env ~path ~package ~tip with - | None -> None - | Some (_env, _name, stamp) -> - declared_for_tip ~stamps:file.stamps stamp tip - in - match declared_opt with - | None -> None - | Some declared -> Some (file, extra, declared))) - | _ -> - maybe_log ("alternate_declared for " ^ file.module_name ^ " not found"); + | Some (_env, _name, stamp) -> + declared_for_tip ~stamps:alternate.file.stamps stamp tip - None) +(** Find alternative declaration: from res in case of interface, or from resi in case of implementation *) +let alternate_declared ~state ~file ~package declared tip = + Option.bind (alternate_full ~state ~file ~package) (fun alternate -> + alternate_member ~state ~package ~alternate declared tip + |> Option.map (fun declared -> + (alternate.file, alternate.extra, declared))) let rec resolve_module_reference ?(paths_seen = []) ~state ~file ~package (declared : Module.t Declared.t) = @@ -288,16 +288,17 @@ let resolve_module_definition ~state ~(file : File.t) ~package stamp = in Some (file.uri, loc)) -let definition ~state ~file ~package stamp (tip : Tip.t) = +let rec definition ~state ~(file : File.t) ~package stamp (tip : Tip.t) = match tip with - | Constructor name -> ( - match get_constructor file stamp name with - | None -> None - | Some constructor -> Some (file.uri, constructor.cname.loc)) - | Field name -> ( - match get_field file stamp name with - | None -> None - | Some field -> Some (file.uri, field.fname.loc)) + | Constructor name -> + label_definition ~state ~file ~package stamp tip ~own:(fun () -> + get_constructor file stamp name + |> Option.map (fun (constructor : Constructor.t) -> + (file.uri, constructor.cname.loc))) + | Field name -> + label_definition ~state ~file ~package stamp tip ~own:(fun () -> + get_field file stamp name + |> Option.map (fun field -> (file.uri, field.fname.loc))) | Module -> resolve_module_definition ~state ~file ~package stamp | _ -> ( match declared_for_tip ~stamps:file.stamps stamp tip with @@ -319,6 +320,28 @@ let definition ~state ~file ~package stamp (tip : Tip.t) = maybe_log ("Inner uri " ^ Uri.to_string uri); Some (uri, loc)) +(* The constructors and fields of an included type have no location: use + those of the type it copies, and [own] for any other type. *) +and label_definition ~state ~file ~package stamp tip ~own = + match Process_extra.include_origin ~file stamp tip with + | Origin origin when origin <> stamp -> + definition ~state ~file ~package origin tip + | Other_file (module_name, path) -> + global_definition ~state ~package module_name path tip + | Origin _ -> own () + +and global_definition ~state ~package module_name path tip = + match Process_cmt.file_for_module ~state ~package module_name with + | None -> None + | Some file -> ( + let env = Query_env.from_file file in + match exported_for_tip ~state ~env ~path ~package ~tip with + | None -> None + | Some (env, _name, stamp) -> + (* oooh wht do I do if the stamp is inside a pseudo-file? *) + maybe_log ("Got stamp " ^ string_of_int stamp); + definition ~state ~file:env.file ~package stamp tip) + let definition_for_loc_item ~state ~full:{file; package} loc_item = match loc_item.loc_type with | Typed (_, _, Definition (stamp, tip)) -> ( @@ -354,20 +377,11 @@ let definition_for_loc_item ~state ~full:{file; package} loc_item = maybe_log ("Local defn " ^ Tip.to_string tip); definition ~state ~file ~package stamp tip | LModule (GlobalReference (module_name, path, tip)) - | Typed (_, _, GlobalReference (module_name, path, tip)) -> ( + | Typed (_, _, GlobalReference (module_name, path, tip)) -> maybe_log ("Typed GlobalReference module_name:" ^ module_name ^ " path:" ^ path_to_string path ^ " tip:" ^ Tip.to_string tip); - match Process_cmt.file_for_module ~state ~package module_name with - | None -> None - | Some file -> ( - let env = Query_env.from_file file in - match exported_for_tip ~state ~env ~path ~package ~tip with - | None -> None - | Some (env, _name, stamp) -> - (* oooh wht do I do if the stamp is inside a pseudo-file? *) - maybe_log ("Got stamp " ^ string_of_int stamp); - definition ~state ~file:env.file ~package stamp tip)) + global_definition ~state ~package module_name path tip let dig_constructor ~state ~env ~package path = match Resolve_path.resolve_from_compiler_path ~state ~env ~package path with @@ -419,93 +433,173 @@ type references = { loc_opt: Location.t option; (* None: reference to a toplevel module *) } -let for_local_stamp ~state ~full:{file; extra; package} stamp (tip : Tip.t) = - let env = Query_env.from_file file in - match - match tip with - | Constructor name -> - get_constructor file stamp name - |> Option.map (fun x -> x.Constructor.stamp) - | Field name -> get_field file stamp name |> Option.map (fun x -> x.stamp) - | _ -> Some stamp - with - | None -> [] +(* The stamps that stand for the same declaration as [stamp]: the member it + was included from, when that is in this file, and all included copies of + that member. For a constructor or field, these are stamps of its type. The + origin of an origin is itself, so these are the stamps with the origin of + [stamp]. *) +let include_family ~(file : File.t) stamp (tip : Tip.t) = + let origin = Process_extra.include_origin ~file stamp tip in + let family = ref [stamp] in + let add stamp _ = + if Process_extra.include_origin ~file stamp tip = origin then + family := stamp :: !family + in + (match tip with + | Value -> Stamps.iter_values add file.stamps + | Module -> Stamps.iter_modules add file.stamps + | Type | Field _ | Constructor _ -> Stamps.iter_types add file.stamps); + (origin, List.sort_uniq compare !family) + +(* A module and path under which other files record their uses of a member, + and the module whose own file is not searched. *) +type external_key = {owner: string; module_name: string; path: path} + +(* The stamp under which [file] records the references to [tip]: for a + constructor or field, [stamp] is the stamp of its type. *) +let tip_stamp ~(file : File.t) stamp (tip : Tip.t) = + match tip with + | Constructor name -> + get_constructor file stamp name |> Option.map (fun x -> x.Constructor.stamp) + | Field name -> get_field file stamp name |> Option.map (fun x -> x.stamp) + | Value | Type | Module -> Some stamp + +(* The references to [stamp] in its file, and the key of its uses in other + files. *) +let references_in_file ~full:{file; extra; package} stamp (tip : Tip.t) = + match tip_stamp ~file stamp tip with + | None -> ([], []) | Some local_stamp -> ( - match Hashtbl.find_opt extra.internal_references local_stamp with - | None -> [] - | Some locs -> - maybe_log ("Checking externals: " ^ string_of_int stamp); - let externals = - match declared_for_tip ~stamps:env.file.stamps stamp tip with - | None -> [] - | Some declared -> - if is_visible declared then ( - let alternative_references = - match alternate_declared ~state ~package ~file declared tip with - | None -> [] - | Some (file, extra, {stamp}) -> ( + let locs = + Hashtbl.find_opt extra.internal_references local_stamp + |> Option.value ~default:[] + |> List.map (fun loc -> {uri = file.uri; loc_opt = Some loc}) + in + match declared_for_tip ~stamps:file.stamps stamp tip with + | Some declared when is_visible declared -> + let path = Module_path.to_path declared.module_path declared.name.txt in + maybe_log ("Now checking path " ^ path_to_string path); + let module_name, path = + normalize_external_reference_key ~namespace:package.namespace + ~module_name:file.module_name ~path + in + (locs, [{owner = file.module_name; module_name; path}]) + | Some _ | None -> + maybe_log "Not visible"; + (locs, [])) + +(* The uses of [tip] that other files record under [keys], found in one pass + over the project. *) +let external_references ~package keys tip = + package.project_files |> File_set.elements + |> List.concat_map (fun module_name -> + match List.filter (fun key -> key.owner <> module_name) keys with + | [] -> [] + | keys -> + Cmt.fulls_from_module ~package ~module_name + |> List.concat_map (fun {file; extra} -> + keys + |> List.concat_map (fun key -> match - match tip with - | Constructor name -> - get_constructor file stamp name - |> Option.map (fun x -> x.Constructor.stamp) - | Field name -> - get_field file stamp name |> Option.map (fun x -> x.stamp) - | _ -> Some stamp + Hashtbl.find_opt extra.external_references key.module_name with | None -> [] - | Some local_stamp -> ( - match - Hashtbl.find_opt extra.internal_references local_stamp - with - | None -> [] - | Some locs -> - locs - |> List.map (fun loc -> - {uri = file.uri; loc_opt = Some loc}))) - (* if this file has a corresponding interface or implementation file - also find the references in that file *) - in - let path = - Module_path.to_path declared.module_path declared.name.txt - in - maybe_log ("Now checking path " ^ path_to_string path); - let this_module_name = file.module_name in - let normalized_module_name, normalized_path = - normalize_external_reference_key ~namespace:package.namespace - ~module_name:this_module_name ~path - in - let externals = - package.project_files |> File_set.elements - |> List.filter (fun name -> name <> file.module_name) - |> List.map (fun module_name -> - Cmt.fulls_from_module ~package ~module_name - |> List.map (fun {file; extra} -> - match - Hashtbl.find_opt extra.external_references - normalized_module_name - with - | None -> [] - | Some refs -> - let locs = - refs - |> List.filter_map (fun (p, t, locs) -> - if p = normalized_path && t = tip then Some locs - else None) - in - locs - |> List.map (fun loc -> - {uri = file.uri; loc_opt = Some loc}))) - |> List.concat |> List.concat - in - alternative_references @ externals) - else ( - maybe_log "Not visible"; - []) + | Some refs -> + refs + |> List.filter_map (fun (p, t, loc) -> + if p = key.path && t = tip then Some loc else None) + |> List.map (fun loc -> {uri = file.uri; loc_opt = Some loc})))) + +(* The families of [stamps] in [full]: their stamps, their references in this + file, the keys of their uses in other files, and the members of other files + they copy. *) +let families_in_file ~full stamps tip = + let families = + stamps |> List.map (fun stamp -> include_family ~file:full.file stamp tip) + in + let stamps = families |> List.concat_map snd |> List.sort_uniq compare in + let locs, keys = + stamps + |> List.map (fun stamp -> references_in_file ~full stamp tip) + |> List.split + in + let sources = + families + |> List.filter_map (fun (origin, _) -> + match origin with + | Process_extra.Other_file (module_name, path) -> + Some (module_name, path) + | Origin _ -> None) + in + (stamps, List.concat locs, List.concat keys, sources) + +(* The visible members among [stamps] of [full], in the other file of the same + module (.res or .resi). *) +let alternate_stamps ~state ~(full : full) stamps tip = + match alternate_full ~state ~file:full.file ~package:full.package with + | None -> None + | Some alternate -> + let alternate_stamps = + stamps + |> List.filter_map (fun stamp -> + match declared_for_tip ~stamps:full.file.stamps stamp tip with + | Some declared when is_visible declared -> + alternate_member ~state ~package:full.package ~alternate declared + tip + |> Option.map (fun (declared : _ Declared.t) -> declared.stamp) + | Some _ | None -> None) + in + Some (alternate, alternate_stamps) + +(* The references to [stamp], its included copies and the member they copy + that are found in their own files, and the keys of their uses in other + files. The same family is gathered in the other file of the module (.res or + .resi), and a member copied from another file is looked up there. *) +let rec family_references ~state ~full stamp tip = + let stamps, locs, keys, sources = families_in_file ~full [stamp] tip in + let alternate_locs, alternate_keys, alternate_sources = + match alternate_stamps ~state ~full stamps tip with + | None -> ([], [], []) + | Some (alternate, alternate_stamps) -> + let _, locs, keys, sources = + families_in_file ~full:alternate alternate_stamps tip in - List.append - (locs |> List.map (fun loc -> {uri = file.uri; loc_opt = Some loc})) - externals) + (locs, keys, sources) + in + let source_locs, source_keys = + List.sort_uniq compare (sources @ alternate_sources) + |> List.map (fun (module_name, path) -> + global_family_references ~state ~package:full.package module_name path + tip) + |> List.split + in + ( locs @ alternate_locs @ List.concat source_locs, + keys @ alternate_keys @ List.concat source_keys ) + +and global_family_references ~state ~package module_name path tip = + match Process_cmt.file_for_module ~state ~package module_name with + | None -> ([], []) + | Some file -> ( + let env = Query_env.from_file file in + match exported_for_tip ~state ~env ~path ~package ~tip with + | None -> ([], []) + | Some (env, _name, stamp) -> ( + match Cmt.full_from_module ~package ~module_name:env.file.module_name with + | None -> ([], []) + | Some full -> + maybe_log + ("Finding references for (global) " ^ Uri.to_string env.file.uri + ^ " and stamp " ^ string_of_int stamp ^ " and tip " ^ Tip.to_string tip + ); + family_references ~state ~full stamp tip)) + +let references_with_keys ~package (locs, keys) tip = + locs @ external_references ~package (List.sort_uniq compare keys) tip + +let for_local_stamp ~state ~full stamp tip = + references_with_keys ~package:full.package + (family_references ~state ~full stamp tip) + tip let all_references_for_loc_item ~state ~full:({file; package} as full) loc_item = @@ -544,21 +638,7 @@ let all_references_for_loc_item ~state ~full:({file; package} as full) loc_item ^ string_of_int stamp ^ " and tip " ^ Tip.to_string tip); for_local_stamp ~state ~full stamp tip | LModule (GlobalReference (module_name, path, tip)) - | Typed (_, _, GlobalReference (module_name, path, tip)) -> ( - match Process_cmt.file_for_module ~state ~package module_name with - | None -> [] - | Some file -> ( - let env = Query_env.from_file file in - match exported_for_tip ~state ~env ~path ~package ~tip with - | None -> [] - | Some (env, _name, stamp) -> ( - match - Cmt.full_from_module ~package ~module_name:env.file.module_name - with - | None -> [] - | Some full -> - maybe_log - ("Finding references for (global) " ^ Uri.to_string env.file.uri - ^ " and stamp " ^ string_of_int stamp ^ " and tip " - ^ Tip.to_string tip); - for_local_stamp ~state ~full stamp tip))) + | Typed (_, _, GlobalReference (module_name, path, tip)) -> + references_with_keys ~package + (global_family_references ~state ~package module_name path tip) + tip diff --git a/analysis/src/shared_types.ml b/analysis/src/shared_types.ml index 4378978a54b..4d93e70f2f3 100644 --- a/analysis/src/shared_types.ml +++ b/analysis/src/shared_types.ml @@ -25,6 +25,16 @@ module Module_path = struct | NotVisible -> current in loop module_path [tip_name] + + (* For a member of an included module, the path of the member it copies, + inside the module the include names. *) + let rec included_path module_path name = + match module_path with + | IncludedModule (source, _) -> Some (Path.Pdot (source, name, 0)) + | ExportedModule {name = parent; module_path} -> + included_path module_path parent + |> Option.map (fun path -> Path.Pdot (path, name, 0)) + | File _ | NotVisible -> None end type field = { @@ -374,7 +384,22 @@ and completion_type = } module Env = struct - type t = {stamps: Stamps.t; module_path: Module_path.t} + type t = { + stamps: Stamps.t; + module_path: Module_path.t; + last_label_stamp: int ref; + (** Constructors and record fields read from a signature get stamps of + their own. Their identifiers are those of the declarations they + come from: an include or a module type does not rename them, and a + signature from another file brings that compilation's stamps, which + can equal stamps of this one. The compiler's stamps are positive, 0 + marks a persistent identifier and -1 a hidden one, so stamps from -2 + down can't collide. Each file starts at -1, so reading a file again + gives the same stamps. *) + } + let fresh_label_stamp env = + decr env.last_label_stamp; + !(env.last_label_stamp) let add_exported_module ~name ~is_type env = { env with diff --git a/changes/editor-include-declarations.fix.md b/changes/editor-include-declarations.fix.md new file mode 100644 index 00000000000..ae5da0d33d6 --- /dev/null +++ b/changes/editor-include-declarations.fix.md @@ -0,0 +1 @@ +- Editor: find references, definition and rename handle members brought in by `include` correctly, without duplicate or wrong locations. diff --git a/tests/analysis_tests/tests/src/IncludeDeclarations.res b/tests/analysis_tests/tests/src/IncludeDeclarations.res new file mode 100644 index 00000000000..153cc50078e --- /dev/null +++ b/tests/analysis_tests/tests/src/IncludeDeclarations.res @@ -0,0 +1,109 @@ +include IncludeDeclarationsLib.Make({ + type t = int +}) + +// Dot and Box keep their stamps from IncludeDeclarationsLib, which are the +// stamps of v0 and v1 here. +let v0 = 0 +// ^ref +let v1 = 1 +// ^ref +let v2 = 2 + +module type T = { + type t +} +module F = (X: T) => { + let fv = 1 + // ^ref +} +include F({ + type t = int +}) +let u = fv +// ^ref + +let dot = Dot +// ^ref +let box = Box(1) +// ^def +include IncludeDeclarationsLib.MakeMore({ + type t = int +}) +let lv = {lf: 1} +// ^ref +let m = made +// ^ref + +module G = (X: T) => { + type local = L1 | L2 + type r = {rf: int} +} +include G({ + type t = int +}) +let l = L1 +// ^ref +let l2 = L2 +// ^def +let rv = {rf: 1} +// ^ref + +module Base = { + let bv = 1 + // ^ref + module Inner = { + let deep = 1 + } +} +module Inc = { + include Base +} +include Base +let b = Inc.bv + bv +let deep = Inner.deep + Inc.Inner.deep +// ^ref + +// Nested members of an included module copy the nested members, not the +// members of the same name one level up. +module H = (X: T) => { + let x = 1 + module Nested = { + let x = 2 + type t = B + module Deep = { + let x = 3 + } + } +} +include H({ + type t = int +}) +let hx = x +// ^ref +let hNested = Nested.x +// ^ref +let hB = Nested.B +// ^ref +let hDeep = Nested.Deep.x +// ^ref + +// Several copies of one member, one of them a copy of a copy. +module Copy1 = { + include Base +} +module Copy2 = { + include Copy1 +} +let copies = Copy1.bv + Copy2.bv +// ^ref + +// A type read from a module type points at the module type's declaration. +module type WithType = { + type wt +} +module WithTypeImpl: WithType = { + type wt = int +} +let withType = (x: WithTypeImpl.wt) => x +// ^ref diff --git a/tests/analysis_tests/tests/src/IncludeDeclarationsIntf.res b/tests/analysis_tests/tests/src/IncludeDeclarationsIntf.res new file mode 100644 index 00000000000..e0ffc8f1b70 --- /dev/null +++ b/tests/analysis_tests/tests/src/IncludeDeclarationsIntf.res @@ -0,0 +1,8 @@ +module Base = { + type t = A | B + type r = {f: int} + let bv = 1 +} +include Base +let k = Base.A +let k2 = A diff --git a/tests/analysis_tests/tests/src/IncludeDeclarationsIntf.resi b/tests/analysis_tests/tests/src/IncludeDeclarationsIntf.resi new file mode 100644 index 00000000000..0993bfd4abf --- /dev/null +++ b/tests/analysis_tests/tests/src/IncludeDeclarationsIntf.resi @@ -0,0 +1,3 @@ +type t = A | B +type r = {f: int} +let bv: int diff --git a/tests/analysis_tests/tests/src/IncludeDeclarationsIntfUse.res b/tests/analysis_tests/tests/src/IncludeDeclarationsIntfUse.res new file mode 100644 index 00000000000..838c78265ba --- /dev/null +++ b/tests/analysis_tests/tests/src/IncludeDeclarationsIntfUse.res @@ -0,0 +1,8 @@ +let c = IncludeDeclarationsIntf.A +// ^ref +let v = IncludeDeclarationsIntf.bv +// ^ref +let f = (x: IncludeDeclarationsIntf.r) => x.f +// ^ref +let r = IncludeDeclarationsIntf.A +// ^ren Q diff --git a/tests/analysis_tests/tests/src/IncludeDeclarationsLib.res b/tests/analysis_tests/tests/src/IncludeDeclarationsLib.res new file mode 100644 index 00000000000..268351b4256 --- /dev/null +++ b/tests/analysis_tests/tests/src/IncludeDeclarationsLib.res @@ -0,0 +1,12 @@ +module type T = { + type t +} + +module Make = (X: T) => { + type shape = Dot | Box(X.t) +} + +module MakeMore = (X: T) => { + type lr = {lf: int} + let made = 1 +} diff --git a/tests/analysis_tests/tests/src/IncludeDeclarationsOverride.res b/tests/analysis_tests/tests/src/IncludeDeclarationsOverride.res new file mode 100644 index 00000000000..68028b1ecec --- /dev/null +++ b/tests/analysis_tests/tests/src/IncludeDeclarationsOverride.res @@ -0,0 +1,32 @@ +// An override makes the type checker constrain the module to its signature +// without the shadowed member. The copies keep the link to their origin. +module Base = { + type t = A | B + type r = {f: int} + let bv = 1 + let other = 2 +} +module Over = { + include Base + let other = 3 +} +let a = Over.A +// ^ref +let f = (x: Over.r) => x.f +// ^ref +let b = Over.bv + Base.bv +// ^ref +let o = Over.other +// ^ref +let r = Over.A +// ^ren Q + +// The same for members included from another file. +module OverLib = { + include IncludeDeclarationsLib.MakeMore({ + type t = int + }) + let made = 2 +} +let lv = {OverLib.lf: 1} +// ^ref diff --git a/tests/analysis_tests/tests/src/IncludeDeclarationsParam.res b/tests/analysis_tests/tests/src/IncludeDeclarationsParam.res new file mode 100644 index 00000000000..a1667fa938d --- /dev/null +++ b/tests/analysis_tests/tests/src/IncludeDeclarationsParam.res @@ -0,0 +1,24 @@ +// The same for an include of a functor parameter. +module F = (X: IncludeDeclarationsSig.S) => { + include X + let u0 = 0 + let u1 = 1 + let u2 = 2 + let u3 = 3 + let u4 = 4 + let u5 = 5 + let u6 = 6 + let u7 = 7 + let u8 = 8 + let u9 = 9 + let k = Ja +// ^ref + let k = Ja + let k = Ja + let k = Ja +// ^ren Jx + let s = sv + let s = sv + let fld = {ga: 1, gb: 2} +// ^ref +} diff --git a/tests/analysis_tests/tests/src/IncludeDeclarationsSig.res b/tests/analysis_tests/tests/src/IncludeDeclarationsSig.res new file mode 100644 index 00000000000..8e8e22ca72b --- /dev/null +++ b/tests/analysis_tests/tests/src/IncludeDeclarationsSig.res @@ -0,0 +1,13 @@ +type kind = Ka | Kb | Kc | Kd +type rk = {fa: int, fb: int, fc: int} +module type S = { + type kind2 = Ja | Jb | Jc | Jd + type rj = {ga: int, gb: int} + let sv: int +} +module Impl: S = { + type kind2 = Ja | Jb | Jc | Jd + type rj = {ga: int, gb: int} + let sv = 1 +} +let packed: module(S) = module(Impl) diff --git a/tests/analysis_tests/tests/src/IncludeDeclarationsTypeOf.res b/tests/analysis_tests/tests/src/IncludeDeclarationsTypeOf.res new file mode 100644 index 00000000000..616d04a23c6 --- /dev/null +++ b/tests/analysis_tests/tests/src/IncludeDeclarationsTypeOf.res @@ -0,0 +1,7 @@ +module Base = { + let bv = 1 + // ^ref +} +include Base +let u = bv +// ^ref diff --git a/tests/analysis_tests/tests/src/IncludeDeclarationsTypeOf.resi b/tests/analysis_tests/tests/src/IncludeDeclarationsTypeOf.resi new file mode 100644 index 00000000000..be8b63316b5 --- /dev/null +++ b/tests/analysis_tests/tests/src/IncludeDeclarationsTypeOf.resi @@ -0,0 +1,4 @@ +module Base: { + let bv: int +} +include module type of Base diff --git a/tests/analysis_tests/tests/src/IncludeDeclarationsUnpack.res b/tests/analysis_tests/tests/src/IncludeDeclarationsUnpack.res new file mode 100644 index 00000000000..3a39f96efb9 --- /dev/null +++ b/tests/analysis_tests/tests/src/IncludeDeclarationsUnpack.res @@ -0,0 +1,18 @@ +// Constructors and fields of an include without a module path have stamps +// of their own, not IncludeDeclarationsSig's, which equal stamps here. +include unpack(IncludeDeclarationsSig.packed) +let u0 = 0 +let u1 = 1 +let u2 = 2 +let u3 = 3 +let u4 = 4 +// ^ref +let u5 = 5 +let u6 = 6 +let u7 = 7 +let u8 = 8 +let u9 = 9 +let k = Ja +// ^ref +let fld = {ga: 1, gb: 2} +// ^ref diff --git a/tests/analysis_tests/tests/src/IncludeDeclarationsUse.res b/tests/analysis_tests/tests/src/IncludeDeclarationsUse.res new file mode 100644 index 00000000000..5aa8e1d0ad3 --- /dev/null +++ b/tests/analysis_tests/tests/src/IncludeDeclarationsUse.res @@ -0,0 +1,15 @@ +let w = IncludeDeclarations.v0 + IncludeDeclarations.v1 + IncludeDeclarations.fv +let b = IncludeDeclarations.bv +// ^ref +let l = IncludeDeclarations.L1 +let rf = (r: IncludeDeclarations.r) => r.rf +let externalDot = IncludeDeclarations.Dot +// ^ref +let externalLf = (r: IncludeDeclarations.lr) => r.lf +// ^ref +let externalMade = IncludeDeclarations.made +// ^ref +let upJa = IncludeDeclarationsUnpack.Ja +// ^ref +let upGa = (r: IncludeDeclarationsUnpack.rj) => r.ga +// ^ref diff --git a/tests/analysis_tests/tests/src/expected/Hover.res.txt b/tests/analysis_tests/tests/src/expected/Hover.res.txt index 14ff310ef13..bbacc8049c2 100644 --- a/tests/analysis_tests/tests/src/expected/Hover.res.txt +++ b/tests/analysis_tests/tests/src/expected/Hover.res.txt @@ -34,8 +34,6 @@ Hover src/Hover.res 22:11 } Hover src/Hover.res 26:6 -get_loc_item #8: heuristic for JSX with at most one child -heuristic for: [makeProps, make, createElement], give the loc of `make` { "contents": { "kind": "markdown", "value": "```rescript\nint\n```" } } Hover src/Hover.res 33:4 diff --git a/tests/analysis_tests/tests/src/expected/IncludeDeclarations.res.txt b/tests/analysis_tests/tests/src/expected/IncludeDeclarations.res.txt new file mode 100644 index 00000000000..621076a86c4 --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/IncludeDeclarations.res.txt @@ -0,0 +1,436 @@ +References src/IncludeDeclarations.res 6:4 +[ + { + "range": { + "end": { "character": 30, "line": 0 }, + "start": { "character": 28, "line": 0 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 6, "line": 6 }, + "start": { "character": 4, "line": 6 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 8:4 +[ + { + "range": { + "end": { "character": 55, "line": 0 }, + "start": { "character": 53, "line": 0 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 6, "line": 8 }, + "start": { "character": 4, "line": 8 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 16:6 +[ + { + "range": { + "end": { "character": 80, "line": 0 }, + "start": { "character": 78, "line": 0 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 10, "line": 22 }, + "start": { "character": 8, "line": 22 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 8, "line": 16 }, + "start": { "character": 6, "line": 16 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 22:8 +[ + { + "range": { + "end": { "character": 80, "line": 0 }, + "start": { "character": 78, "line": 0 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 10, "line": 22 }, + "start": { "character": 8, "line": 22 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 8, "line": 16 }, + "start": { "character": 6, "line": 16 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 25:10 +[ + { + "range": { + "end": { "character": 41, "line": 5 }, + "start": { "character": 38, "line": 5 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 18, "line": 5 }, + "start": { "character": 15, "line": 5 } + }, + "uri": "file:///IncludeDeclarationsLib.res" + }, + { + "range": { + "end": { "character": 13, "line": 25 }, + "start": { "character": 10, "line": 25 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +Definition src/IncludeDeclarations.res 27:10 +{ + "range": { + "end": { "character": 24, "line": 5 }, + "start": { "character": 21, "line": 5 } + }, + "uri": "file:///IncludeDeclarationsLib.res" +} + +References src/IncludeDeclarations.res 32:10 +[ + { + "range": { + "end": { "character": 52, "line": 7 }, + "start": { "character": 50, "line": 7 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 15, "line": 9 }, + "start": { "character": 13, "line": 9 } + }, + "uri": "file:///IncludeDeclarationsLib.res" + }, + { + "range": { + "end": { "character": 12, "line": 32 }, + "start": { "character": 10, "line": 32 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 34:8 +[ + { + "range": { + "end": { "character": 43, "line": 9 }, + "start": { "character": 39, "line": 9 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 10, "line": 10 }, + "start": { "character": 6, "line": 10 } + }, + "uri": "file:///IncludeDeclarationsLib.res" + }, + { + "range": { + "end": { "character": 12, "line": 34 }, + "start": { "character": 8, "line": 34 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 44:8 +[ + { + "range": { + "end": { "character": 30, "line": 3 }, + "start": { "character": 28, "line": 3 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 10, "line": 44 }, + "start": { "character": 8, "line": 44 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 17, "line": 38 }, + "start": { "character": 15, "line": 38 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +Definition src/IncludeDeclarations.res 46:9 +{ + "range": { + "end": { "character": 22, "line": 38 }, + "start": { "character": 20, "line": 38 } + }, + "uri": "file:///IncludeDeclarations.res" +} + +References src/IncludeDeclarations.res 48:10 +[ + { + "range": { + "end": { "character": 43, "line": 4 }, + "start": { "character": 41, "line": 4 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 12, "line": 48 }, + "start": { "character": 10, "line": 48 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 14, "line": 39 }, + "start": { "character": 12, "line": 39 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 52:6 +[ + { + "range": { + "end": { "character": 30, "line": 1 }, + "start": { "character": 28, "line": 1 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 32, "line": 97 }, + "start": { "character": 30, "line": 97 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 21, "line": 97 }, + "start": { "character": 19, "line": 97 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 19, "line": 62 }, + "start": { "character": 17, "line": 62 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 14, "line": 62 }, + "start": { "character": 12, "line": 62 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 8, "line": 52 }, + "start": { "character": 6, "line": 52 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 63:11 +[ + { + "range": { + "end": { "character": 16, "line": 63 }, + "start": { "character": 11, "line": 63 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 33, "line": 63 }, + "start": { "character": 28, "line": 63 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 14, "line": 54 }, + "start": { "character": 9, "line": 54 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 81:9 +[ + { + "range": { + "end": { "character": 10, "line": 81 }, + "start": { "character": 9, "line": 81 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 7, "line": 69 }, + "start": { "character": 6, "line": 69 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 83:21 +[ + { + "range": { + "end": { "character": 22, "line": 83 }, + "start": { "character": 21, "line": 83 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 9, "line": 71 }, + "start": { "character": 8, "line": 71 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 85:16 +[ + { + "range": { + "end": { "character": 17, "line": 85 }, + "start": { "character": 16, "line": 85 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 14, "line": 72 }, + "start": { "character": 13, "line": 72 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 87:24 +[ + { + "range": { + "end": { "character": 25, "line": 87 }, + "start": { "character": 24, "line": 87 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 11, "line": 74 }, + "start": { "character": 10, "line": 74 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 97:30 +[ + { + "range": { + "end": { "character": 30, "line": 1 }, + "start": { "character": 28, "line": 1 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 32, "line": 97 }, + "start": { "character": 30, "line": 97 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 21, "line": 97 }, + "start": { "character": 19, "line": 97 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 19, "line": 62 }, + "start": { "character": 17, "line": 62 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 14, "line": 62 }, + "start": { "character": 12, "line": 62 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 8, "line": 52 }, + "start": { "character": 6, "line": 52 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarations.res 107:32 +[ + { + "range": { + "end": { "character": 9, "line": 102 }, + "start": { "character": 7, "line": 102 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 34, "line": 107 }, + "start": { "character": 32, "line": 107 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + diff --git a/tests/analysis_tests/tests/src/expected/IncludeDeclarationsIntf.res.txt b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsIntf.res.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/analysis_tests/tests/src/expected/IncludeDeclarationsIntf.resi.txt b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsIntf.resi.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/analysis_tests/tests/src/expected/IncludeDeclarationsIntfUse.res.txt b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsIntfUse.res.txt new file mode 100644 index 00000000000..ee2711c2f34 --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsIntfUse.res.txt @@ -0,0 +1,166 @@ +References src/IncludeDeclarationsIntfUse.res 0:32 +[ + { + "range": { + "end": { "character": 33, "line": 0 }, + "start": { "character": 32, "line": 0 } + }, + "uri": "file:///IncludeDeclarationsIntfUse.res" + }, + { + "range": { + "end": { "character": 33, "line": 6 }, + "start": { "character": 32, "line": 6 } + }, + "uri": "file:///IncludeDeclarationsIntfUse.res" + }, + { + "range": { + "end": { "character": 10, "line": 7 }, + "start": { "character": 9, "line": 7 } + }, + "uri": "file:///IncludeDeclarationsIntf.res" + }, + { + "range": { + "end": { "character": 12, "line": 1 }, + "start": { "character": 11, "line": 1 } + }, + "uri": "file:///IncludeDeclarationsIntf.res" + }, + { + "range": { + "end": { "character": 14, "line": 6 }, + "start": { "character": 13, "line": 6 } + }, + "uri": "file:///IncludeDeclarationsIntf.res" + }, + { + "range": { + "end": { "character": 10, "line": 0 }, + "start": { "character": 9, "line": 0 } + }, + "uri": "file:///IncludeDeclarationsIntf.resi" + } +] + +References src/IncludeDeclarationsIntfUse.res 2:32 +[ + { + "range": { + "end": { "character": 34, "line": 2 }, + "start": { "character": 32, "line": 2 } + }, + "uri": "file:///IncludeDeclarationsIntfUse.res" + }, + { + "range": { + "end": { "character": 8, "line": 3 }, + "start": { "character": 6, "line": 3 } + }, + "uri": "file:///IncludeDeclarationsIntf.res" + }, + { + "range": { + "end": { "character": 6, "line": 2 }, + "start": { "character": 4, "line": 2 } + }, + "uri": "file:///IncludeDeclarationsIntf.resi" + } +] + +References src/IncludeDeclarationsIntfUse.res 4:44 +[ + { + "range": { + "end": { "character": 45, "line": 4 }, + "start": { "character": 44, "line": 4 } + }, + "uri": "file:///IncludeDeclarationsIntfUse.res" + }, + { + "range": { + "end": { "character": 13, "line": 2 }, + "start": { "character": 12, "line": 2 } + }, + "uri": "file:///IncludeDeclarationsIntf.res" + }, + { + "range": { + "end": { "character": 11, "line": 1 }, + "start": { "character": 10, "line": 1 } + }, + "uri": "file:///IncludeDeclarationsIntf.resi" + } +] + +Rename src/IncludeDeclarationsIntfUse.res 6:32 Q +[ + { + "edits": [ + { + "newText": "Q", + "range": { + "end": { "character": 33, "line": 0 }, + "start": { "character": 32, "line": 0 } + } + }, + { + "newText": "Q", + "range": { + "end": { "character": 33, "line": 6 }, + "start": { "character": 32, "line": 6 } + } + } + ], + "textDocument": { + "uri": "file:///IncludeDeclarationsIntfUse.res", + "version": 0 + } + }, + { + "edits": [ + { + "newText": "Q", + "range": { + "end": { "character": 10, "line": 0 }, + "start": { "character": 9, "line": 0 } + } + } + ], + "textDocument": { + "uri": "file:///IncludeDeclarationsIntf.resi", + "version": 0 + } + }, + { + "edits": [ + { + "newText": "Q", + "range": { + "end": { "character": 10, "line": 7 }, + "start": { "character": 9, "line": 7 } + } + }, + { + "newText": "Q", + "range": { + "end": { "character": 12, "line": 1 }, + "start": { "character": 11, "line": 1 } + } + }, + { + "newText": "Q", + "range": { + "end": { "character": 14, "line": 6 }, + "start": { "character": 13, "line": 6 } + } + } + ], + "textDocument": { + "uri": "file:///IncludeDeclarationsIntf.res", + "version": 0 + } + } +] + diff --git a/tests/analysis_tests/tests/src/expected/IncludeDeclarationsLib.res.txt b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsLib.res.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/analysis_tests/tests/src/expected/IncludeDeclarationsOverride.res.txt b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsOverride.res.txt new file mode 100644 index 00000000000..7fa582d7cc5 --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsOverride.res.txt @@ -0,0 +1,137 @@ +References src/IncludeDeclarationsOverride.res 12:13 +[ + { + "range": { + "end": { "character": 14, "line": 12 }, + "start": { "character": 13, "line": 12 } + }, + "uri": "file:///IncludeDeclarationsOverride.res" + }, + { + "range": { + "end": { "character": 14, "line": 20 }, + "start": { "character": 13, "line": 20 } + }, + "uri": "file:///IncludeDeclarationsOverride.res" + }, + { + "range": { + "end": { "character": 12, "line": 3 }, + "start": { "character": 11, "line": 3 } + }, + "uri": "file:///IncludeDeclarationsOverride.res" + } +] + +References src/IncludeDeclarationsOverride.res 14:25 +[ + { + "range": { + "end": { "character": 26, "line": 14 }, + "start": { "character": 25, "line": 14 } + }, + "uri": "file:///IncludeDeclarationsOverride.res" + }, + { + "range": { + "end": { "character": 13, "line": 4 }, + "start": { "character": 12, "line": 4 } + }, + "uri": "file:///IncludeDeclarationsOverride.res" + } +] + +References src/IncludeDeclarationsOverride.res 16:13 +[ + { + "range": { + "end": { "character": 15, "line": 16 }, + "start": { "character": 13, "line": 16 } + }, + "uri": "file:///IncludeDeclarationsOverride.res" + }, + { + "range": { + "end": { "character": 8, "line": 5 }, + "start": { "character": 6, "line": 5 } + }, + "uri": "file:///IncludeDeclarationsOverride.res" + }, + { + "range": { + "end": { "character": 25, "line": 16 }, + "start": { "character": 23, "line": 16 } + }, + "uri": "file:///IncludeDeclarationsOverride.res" + } +] + +References src/IncludeDeclarationsOverride.res 18:13 +[ + { + "range": { + "end": { "character": 11, "line": 10 }, + "start": { "character": 6, "line": 10 } + }, + "uri": "file:///IncludeDeclarationsOverride.res" + }, + { + "range": { + "end": { "character": 18, "line": 18 }, + "start": { "character": 13, "line": 18 } + }, + "uri": "file:///IncludeDeclarationsOverride.res" + } +] + +Rename src/IncludeDeclarationsOverride.res 20:13 Q +[ + { + "edits": [ + { + "newText": "Q", + "range": { + "end": { "character": 14, "line": 12 }, + "start": { "character": 13, "line": 12 } + } + }, + { + "newText": "Q", + "range": { + "end": { "character": 14, "line": 20 }, + "start": { "character": 13, "line": 20 } + } + }, + { + "newText": "Q", + "range": { + "end": { "character": 12, "line": 3 }, + "start": { "character": 11, "line": 3 } + } + } + ], + "textDocument": { + "uri": "file:///IncludeDeclarationsOverride.res", + "version": 0 + } + } +] + +References src/IncludeDeclarationsOverride.res 30:18 +[ + { + "range": { + "end": { "character": 15, "line": 9 }, + "start": { "character": 13, "line": 9 } + }, + "uri": "file:///IncludeDeclarationsLib.res" + }, + { + "range": { + "end": { "character": 20, "line": 30 }, + "start": { "character": 18, "line": 30 } + }, + "uri": "file:///IncludeDeclarationsOverride.res" + } +] + diff --git a/tests/analysis_tests/tests/src/expected/IncludeDeclarationsParam.res.txt b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsParam.res.txt new file mode 100644 index 00000000000..ac3a116b747 --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsParam.res.txt @@ -0,0 +1,112 @@ +References src/IncludeDeclarationsParam.res 13:10 +[ + { + "range": { + "end": { "character": 17, "line": 3 }, + "start": { "character": 15, "line": 3 } + }, + "uri": "file:///IncludeDeclarationsSig.res" + }, + { + "range": { + "end": { "character": 12, "line": 13 }, + "start": { "character": 10, "line": 13 } + }, + "uri": "file:///IncludeDeclarationsParam.res" + }, + { + "range": { + "end": { "character": 12, "line": 15 }, + "start": { "character": 10, "line": 15 } + }, + "uri": "file:///IncludeDeclarationsParam.res" + }, + { + "range": { + "end": { "character": 12, "line": 16 }, + "start": { "character": 10, "line": 16 } + }, + "uri": "file:///IncludeDeclarationsParam.res" + }, + { + "range": { + "end": { "character": 12, "line": 17 }, + "start": { "character": 10, "line": 17 } + }, + "uri": "file:///IncludeDeclarationsParam.res" + } +] + +Rename src/IncludeDeclarationsParam.res 17:10 Jx +[ + { + "edits": [ + { + "newText": "Jx", + "range": { + "end": { "character": 17, "line": 3 }, + "start": { "character": 15, "line": 3 } + } + } + ], + "textDocument": { + "uri": "file:///IncludeDeclarationsSig.res", + "version": 0 + } + }, + { + "edits": [ + { + "newText": "Jx", + "range": { + "end": { "character": 12, "line": 13 }, + "start": { "character": 10, "line": 13 } + } + }, + { + "newText": "Jx", + "range": { + "end": { "character": 12, "line": 15 }, + "start": { "character": 10, "line": 15 } + } + }, + { + "newText": "Jx", + "range": { + "end": { "character": 12, "line": 16 }, + "start": { "character": 10, "line": 16 } + } + }, + { + "newText": "Jx", + "range": { + "end": { "character": 12, "line": 17 }, + "start": { "character": 10, "line": 17 } + } + } + ], + "textDocument": { + "uri": "file:///IncludeDeclarationsParam.res", + "version": 0 + } + } +] + +References src/IncludeDeclarationsParam.res 21:13 +[ + { + "range": { + "end": { "character": 15, "line": 4 }, + "start": { "character": 13, "line": 4 } + }, + "uri": "file:///IncludeDeclarationsSig.res" + }, + { + "range": { + "end": { "character": 15, "line": 21 }, + "start": { "character": 13, "line": 21 } + }, + "uri": "file:///IncludeDeclarationsParam.res" + } +] + diff --git a/tests/analysis_tests/tests/src/expected/IncludeDeclarationsSig.res.txt b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsSig.res.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/analysis_tests/tests/src/expected/IncludeDeclarationsTypeOf.res.txt b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsTypeOf.res.txt new file mode 100644 index 00000000000..719db56234d --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsTypeOf.res.txt @@ -0,0 +1,50 @@ +References src/IncludeDeclarationsTypeOf.res 1:6 +[ + { + "range": { + "end": { "character": 8, "line": 1 }, + "start": { "character": 6, "line": 1 } + }, + "uri": "file:///IncludeDeclarationsTypeOf.resi" + }, + { + "range": { + "end": { "character": 10, "line": 5 }, + "start": { "character": 8, "line": 5 } + }, + "uri": "file:///IncludeDeclarationsTypeOf.res" + }, + { + "range": { + "end": { "character": 8, "line": 1 }, + "start": { "character": 6, "line": 1 } + }, + "uri": "file:///IncludeDeclarationsTypeOf.res" + } +] + +References src/IncludeDeclarationsTypeOf.res 5:8 +[ + { + "range": { + "end": { "character": 8, "line": 1 }, + "start": { "character": 6, "line": 1 } + }, + "uri": "file:///IncludeDeclarationsTypeOf.resi" + }, + { + "range": { + "end": { "character": 10, "line": 5 }, + "start": { "character": 8, "line": 5 } + }, + "uri": "file:///IncludeDeclarationsTypeOf.res" + }, + { + "range": { + "end": { "character": 8, "line": 1 }, + "start": { "character": 6, "line": 1 } + }, + "uri": "file:///IncludeDeclarationsTypeOf.res" + } +] + diff --git a/tests/analysis_tests/tests/src/expected/IncludeDeclarationsTypeOf.resi.txt b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsTypeOf.resi.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/analysis_tests/tests/src/expected/IncludeDeclarationsUnpack.res.txt b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsUnpack.res.txt new file mode 100644 index 00000000000..6e5da3b30a6 --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsUnpack.res.txt @@ -0,0 +1,47 @@ +References src/IncludeDeclarationsUnpack.res 7:4 +[ + { + "range": { + "end": { "character": 6, "line": 7 }, + "start": { "character": 4, "line": 7 } + }, + "uri": "file:///IncludeDeclarationsUnpack.res" + } +] + +References src/IncludeDeclarationsUnpack.res 14:8 +[ + { + "range": { + "end": { "character": 39, "line": 11 }, + "start": { "character": 37, "line": 11 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 10, "line": 14 }, + "start": { "character": 8, "line": 14 } + }, + "uri": "file:///IncludeDeclarationsUnpack.res" + } +] + +References src/IncludeDeclarationsUnpack.res 16:11 +[ + { + "range": { + "end": { "character": 52, "line": 13 }, + "start": { "character": 50, "line": 13 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 13, "line": 16 }, + "start": { "character": 11, "line": 16 } + }, + "uri": "file:///IncludeDeclarationsUnpack.res" + } +] + diff --git a/tests/analysis_tests/tests/src/expected/IncludeDeclarationsUse.res.txt b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsUse.res.txt new file mode 100644 index 00000000000..f696be72c41 --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/IncludeDeclarationsUse.res.txt @@ -0,0 +1,157 @@ +References src/IncludeDeclarationsUse.res 1:28 +[ + { + "range": { + "end": { "character": 30, "line": 1 }, + "start": { "character": 28, "line": 1 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 32, "line": 97 }, + "start": { "character": 30, "line": 97 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 21, "line": 97 }, + "start": { "character": 19, "line": 97 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 19, "line": 62 }, + "start": { "character": 17, "line": 62 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 14, "line": 62 }, + "start": { "character": 12, "line": 62 } + }, + "uri": "file:///IncludeDeclarations.res" + }, + { + "range": { + "end": { "character": 8, "line": 52 }, + "start": { "character": 6, "line": 52 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarationsUse.res 5:38 +[ + { + "range": { + "end": { "character": 41, "line": 5 }, + "start": { "character": 38, "line": 5 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 18, "line": 5 }, + "start": { "character": 15, "line": 5 } + }, + "uri": "file:///IncludeDeclarationsLib.res" + }, + { + "range": { + "end": { "character": 13, "line": 25 }, + "start": { "character": 10, "line": 25 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarationsUse.res 7:50 +[ + { + "range": { + "end": { "character": 52, "line": 7 }, + "start": { "character": 50, "line": 7 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 15, "line": 9 }, + "start": { "character": 13, "line": 9 } + }, + "uri": "file:///IncludeDeclarationsLib.res" + }, + { + "range": { + "end": { "character": 12, "line": 32 }, + "start": { "character": 10, "line": 32 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarationsUse.res 9:39 +[ + { + "range": { + "end": { "character": 43, "line": 9 }, + "start": { "character": 39, "line": 9 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 10, "line": 10 }, + "start": { "character": 6, "line": 10 } + }, + "uri": "file:///IncludeDeclarationsLib.res" + }, + { + "range": { + "end": { "character": 12, "line": 34 }, + "start": { "character": 8, "line": 34 } + }, + "uri": "file:///IncludeDeclarations.res" + } +] + +References src/IncludeDeclarationsUse.res 11:37 +[ + { + "range": { + "end": { "character": 39, "line": 11 }, + "start": { "character": 37, "line": 11 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 10, "line": 14 }, + "start": { "character": 8, "line": 14 } + }, + "uri": "file:///IncludeDeclarationsUnpack.res" + } +] + +References src/IncludeDeclarationsUse.res 13:50 +[ + { + "range": { + "end": { "character": 52, "line": 13 }, + "start": { "character": 50, "line": 13 } + }, + "uri": "file:///IncludeDeclarationsUse.res" + }, + { + "range": { + "end": { "character": 13, "line": 16 }, + "start": { "character": 11, "line": 16 } + }, + "uri": "file:///IncludeDeclarationsUnpack.res" + } +] +