- 
                Notifications
    
You must be signed in to change notification settings  - Fork 471
 
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 14 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,101 @@ | ||
| let loc_to_string (loc : Warnings.loc) : string = | ||
| Format.sprintf "(%03d,%03d--%03d,%03d)" loc.loc_start.pos_lnum | ||
| (loc.loc_start.pos_cnum - loc.loc_start.pos_bol) | ||
| loc.loc_end.pos_lnum | ||
| (loc.loc_end.pos_cnum - loc.loc_end.pos_bol) | ||
| 
     | 
||
| 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)); | ||
| 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 | ||
| (loc_to_string t.extentLoc) | ||
| | KValue t -> | ||
| Printf.printf "%d kvalue %s\n" stamp | ||
| (loc_to_string t.extentLoc) | ||
| | KModule t -> | ||
| Printf.printf "%d kmodule %s\n" stamp | ||
| (loc_to_string t.extentLoc) | ||
| | KConstructor t -> | ||
| Printf.printf "%d kconstructor %s\n" stamp | ||
| (loc_to_string t.extentLoc)); | ||
| 
     | 
||
| (* 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 = 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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,6 +1,20 @@ | ||
| open SharedTypes | ||
| 
     | 
||
| let modulePathFromEnv env = env.QueryEnv.file.moduleName :: List.rev env.pathRev | ||
| let modulePathFromEnv env = | ||
| 
         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. This is an orthogonal change just for namespaces right? 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. Yes, exactly, when testing this on my local project (which has a namespace), I needed this.  | 
||
| let moduleName = env.QueryEnv.file.moduleName in | ||
| let transformedModuleName = | ||
| (* Transform namespaced module names from internal format (Context-Kaplay) | ||
| to user-facing format (Kaplay.Context) *) | ||
| match String.rindex_opt moduleName '-' with | ||
| | None -> moduleName | ||
| | Some i -> | ||
| let namespace = | ||
| String.sub moduleName (i + 1) (String.length moduleName - i - 1) | ||
| in | ||
| let module_ = String.sub moduleName 0 i in | ||
| namespace ^ "." ^ module_ | ||
| in | ||
| transformedModuleName :: List.rev env.pathRev | ||
| 
     | 
||
| let fullTypeIdFromDecl ~env ~name ~modulePath = | ||
| env.QueryEnv.file.moduleName :: ModulePath.toPath modulePath name | ||
| 
          
            
          
           | 
    ||
      
      Oops, something went wrong.
        
    
  
      
      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.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how we could entirely match this.
When the scope is created in the CompletionFrontEnd we doesn't know the exact that.