- 
                Notifications
    You must be signed in to change notification settings 
- Fork 726
Persistently cached declaration maps #1871
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
          
     Open
      
      
            gabritto
  wants to merge
  29
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
gabritto/cachedsourcemaps
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            29 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      c920059
              
                source maps + go to def
              
              
                gabritto 8423ecf
              
                refactor, fix and update tests
              
              
                gabritto ca93817
              
                refactor
              
              
                gabritto 672434a
              
                Merge branch 'main' into gabritto/def1
              
              
                gabritto bb7a5b3
              
                fix typo
              
              
                gabritto cef9f67
              
                refactor LS host
              
              
                gabritto c80e7a3
              
                rename line maps with ECMA/LSP
              
              
                gabritto 4a6c6ea
              
                Merge remote-tracking branch 'origin/gabritto/renamelinemaps' into ga…
              
              
                gabritto 8debdea
              
                add type alias for line starts
              
              
                gabritto bd07e42
              
                Merge branch 'main' into gabritto/def1
              
              
                gabritto 75267d1
              
                remove fileExists from LS host
              
              
                gabritto c26faa9
              
                source maps for disk files
              
              
                gabritto 459ebfe
              
                WIP: overlays
              
              
                gabritto e2fb018
              
                fix bundled and update LS
              
              
                gabritto 4eab0b7
              
                Revert "WIP: overlays"
              
              
                gabritto 166b687
              
                refactors/fixes
              
              
                gabritto b285539
              
                Merge branch 'main' into gabritto/cachedsourcemaps
              
              
                gabritto 78e4e23
              
                fix merge
              
              
                gabritto bb1f175
              
                fix submodule
              
              
                gabritto 1a4114a
              
                file watching
              
              
                gabritto dd76d55
              
                ignore file watching messages on fourslash
              
              
                gabritto 5d37720
              
                remove ability for snapshot to read files
              
              
                gabritto a66fe91
              
                add test with declaration map changes
              
              
                gabritto a68e5e1
              
                cleanup, logging
              
              
                gabritto 32f5cb5
              
                remove unused function
              
              
                gabritto c6cf35f
              
                Merge branch 'main' into gabritto/cachedsourcemaps
              
              
                gabritto c07dad5
              
                code review
              
              
                gabritto 48c1ff1
              
                Merge branch 'main' into gabritto/cachedsourcemaps
              
              
                gabritto 064ddf5
              
                don't clone snapshot if we don't have to
              
              
                gabritto 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
    
  
  
    
              
        
          
          
            66 changes: 66 additions & 0 deletions
          
          66 
        
  internal/fourslash/tests/declarationMapGoToDefinitionChanges_test.go
  
  
      
      
   
        
      
      
    
  
    
      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,66 @@ | ||
| package fourslash_test | ||
|  | ||
| import ( | ||
| "testing" | ||
|  | ||
| "github.com/microsoft/typescript-go/internal/fourslash" | ||
| "github.com/microsoft/typescript-go/internal/testutil" | ||
| ) | ||
|  | ||
| func TestDeclarationMapGoToDefinitionChanges(t *testing.T) { | ||
| t.Parallel() | ||
|  | ||
| defer testutil.RecoverAndFail(t, "Panic on fourslash test") | ||
| const content = `// @Filename: index.ts | ||
| export class Foo { | ||
| member: string; | ||
| methodName(propName: SomeType): void {} | ||
| otherMethod() { | ||
| if (Math.random() > 0.5) { | ||
| return {x: 42}; | ||
| } | ||
| return {y: "yes"}; | ||
| } | ||
| } | ||
|  | ||
| export interface SomeType { | ||
| member: number; | ||
| } | ||
| // @Filename: index.d.ts.map | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACV,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAC5C;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"} | ||
| // @Filename: index.d.ts | ||
| export declare class Foo { | ||
| member: string; | ||
| methodName(propName: SomeType): void; | ||
| } | ||
| export interface SomeType { | ||
| member: number; | ||
| } | ||
| //# sourceMappingURL=index.d.ts.map | ||
| // @Filename: mymodule.ts | ||
| import * as mod from "./index"; | ||
| const instance = new mod.Foo(); | ||
| instance.[|/*1*/methodName|]({member: 12}); | ||
| instance.[|/*2*/otherMethod|]();` | ||
| f := fourslash.NewFourslash(t, nil /*capabilities*/, content) | ||
| f.VerifyBaselineGoToDefinition(t, "1") | ||
| f.GoToFile(t, "index.d.ts") | ||
| f.ReplaceAll(t, `export declare class Foo { | ||
| member: string; | ||
| methodName(propName: SomeType): void; | ||
| otherMethod(): { | ||
| x: number; | ||
| y?: undefined; | ||
| } | { | ||
| y: string; | ||
| x?: undefined; | ||
| }; | ||
| } | ||
| export interface SomeType { | ||
| member: number; | ||
| } | ||
| //# sourceMappingURL=index.d.ts.map`) | ||
| f.GoToFile(t, "index.d.ts.map") | ||
| f.ReplaceAll(t, `{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACZ,MAAM,EAAE,MAAM,CAAC;IACV,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IACzC,WAAW;;;;;;;CAMd;AAED,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAC;CAClB"}`) | ||
| f.VerifyBaselineGoToDefinition(t, "2") | ||
| } | 
  
    
      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.
  
    
  
    
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.
This is needed to avoid crashes in the tests, since a file name for a bundled file doesn't round trip with the current implementations of
FileNameToDocumentURIanddocumentUri.FileName().