- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.1k
          Support for multi-project find all references
          #5209
        
          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
  
    Support for multi-project find all references
  
  #5209
              Conversation
73cf3e0    to
    d48548e      
    Compare
  
    d48548e    to
    0f8853a      
    Compare
  
            
          
                language-server/src/dotty/tools/languageserver/config/ProjectConfig.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | symbol.ownersIterator.toList.reverse.map(_.name) | ||
| } | ||
| in(targetDriver) { implicit ctx => | ||
| val base: Symbol = ctx.definitions.RootClass | 
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.
Does this work for symbols in the empty package ? Definition#staticRef has a special case to handle that.
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 think it works, see this test for instance:
        
          
                compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala
              
                Outdated
          
            Show resolved
            Hide resolved
        
      This field will be used to restrict which projects to inspect when doing workspace-wide rename or finding all references. The code that extracts dependency information from sbt has been ported from scalacenter/bloop: https://github.com/scalacenter/bloop/blob/v1.0.0/integrations/sbt-bloop/src/main/scala/bloop/integrations/sbt/SbtBloop.scala
This commit adapts the `find all references` feature so that it is able to find references to given symbols across projects. For symbols that come from the classpath, all the projects in the build will be inspected. If we're able to find a source for the symbol, only the projects that depend on the projects where we found the definition need to be inspected.
(This commit contains no functional change)
This is necessary because we may be using this InteractiveDriver before asking it to compile anything (which would have initialized it). This happens, for instance, if we use this Driver to resolve a symbol coming from a different Driver. Drivers are not meant to be used before being initialized and can crash.
It appears that the `TreeUnpickler` is not able to be run in parallel.
0f8853a    to
    d5280a6      
    Compare
  
    | @smarter I've addressed your comments | 
This commit adapts the
find all referencesfeature so that it is ableto find references to given symbols across projects. For symbols that
come from the classpath, all the projects in the build will be
inspected. If we're able to find a source for the symbol, only the
projects that depend on the projects where we found the definition need
to be inspected.