forked from sbt/sbt
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sketch of abstracting over dependency details in incremental compiler
This represents a sketch of the idea that we can abstract over details of a specific dependency kind. The goal would that only a few implementations of methods in incremental would be sensitive to specific dependency kind: 1. Dependency extraction logic 2. Implementation of Relations which adds dependencies to specific relations (or abstract over specific relations) 3. Invalidation algorithm (Incremental.scala) which has different of each kind of dependency 4. TextAnalysisFormat In particular, adding a new dependency kind would not affect signatures of existing methods. What needs to be done: - finish refactoring so the code compiles again and previous semantics are preserved - introduce deprecated overloads that preserve old method signatures (this is required for preserving binary compatibility)
- Loading branch information
1 parent
066a12c
commit 62fddc2
Showing
3 changed files
with
81 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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,48 @@ | ||
package sbt.inc | ||
|
||
import java.io.File | ||
import xsbti.api.Source | ||
|
||
/** | ||
* Dependency tracked by incremental compiler consists of two parts: | ||
* - `edge` which describes an edge in dependency graph | ||
* - `context` which stores context information from a src file where the dependency got introduced | ||
* | ||
* The context is needed for incremental compiler to decide what kind of invalidation strategy to use. | ||
* It might also store some additional information useful for debugging. | ||
*/ | ||
private[inc] final case class Dependency(edge: DependencyEdge, context: DependencyContext) | ||
|
||
private[inc] sealed abstract class DependencyEdge | ||
/** | ||
* External dependency from src file to class name. External means "outside of enclosing Analysis". | ||
* Typically that means a dependency coming from another subproject in sbt. | ||
* | ||
* The classApi contains snapshot of information about the class (that `toClassName` points at) | ||
* as observed from point of view of compilation that produced this dependency edge. | ||
* | ||
* The classApi is stored so we can detect changes to external apis by comparing snapshots | ||
* of the api from two Analysis instances. | ||
*/ | ||
private[inc] final case class ExternalDepndencyEdge(fromSrc: File, toClassName: String, classApi: Source) | ||
extends DependencyEdge | ||
|
||
/** | ||
* Represents a dependency edge between two source files in the same sbt subproject. | ||
*/ | ||
private[inc] final case class InternalDependencyEdge(fromSrc: File, toSrc: File) extends DependencyEdge | ||
|
||
/** | ||
* Represents contextual information about particular depedency edge. See comments in | ||
* subtypes for examples of particular contexts. | ||
*/ | ||
private[inc] sealed abstract class DependencyContext | ||
/** | ||
* Marks dependency edge introduced by referring to a class through inheritance as in | ||
* | ||
* class A extends B | ||
* | ||
* Each dependency by inheritance introduces corresponding dependency by member reference. | ||
*/ | ||
private[inc] final case object DependencyByInheritance extends DependencyContext | ||
private[inc] final case object DependencyByMemberRef extends DependencyContext |
This file contains 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