Merge pull request #1736 from Duhemm/dependency-kind-compile

Abstract over dependency kind in Compile
This commit is contained in:
Grzegorz Kossakowski 2014-12-02 16:00:22 +01:00
commit b61c09275c
3 changed files with 53 additions and 6 deletions

View File

@ -12,13 +12,29 @@ public interface AnalysisCallback
* passed to this method. Dependencies on classes generated by sources not in the current compilation will
* be passed as class dependencies to the classDependency method.
* If <code>publicInherited</code> is true, this dependency is a result of inheritance by a
* template accessible outside of the source file. */
* template accessible outside of the source file.
* @deprecated Use `sourceDependency(File dependsOn, File source, DependencyContext context)` instead. */
@Deprecated
public void sourceDependency(File dependsOn, File source, boolean publicInherited);
/** Called to indicate that the source file <code>source</code> depends on the source file
* <code>dependsOn</code>. Note that only source files included in the current compilation will
* passed to this method. Dependencies on classes generated by sources not in the current compilation will
* be passed as class dependencies to the classDependency method.
* <code>context</code> gives information about the context in which this dependency has been extracted.
* See xsbti.DependencyContext for the list of existing dependency contexts. */
public void sourceDependency(File dependsOn, File source, DependencyContext context);
/** Called to indicate that the source file <code>source</code> depends on the top-level
* class named <code>name</code> from class or jar file <code>binary</code>.
* If <code>publicInherited</code> is true, this dependency is a result of inheritance by a
* template accessible outside of the source file. */
* template accessible outside of the source file.
* @deprecated Use `binaryDependency(File binary, String name, File source, DependencyContext context)` instead. */
@Deprecated
public void binaryDependency(File binary, String name, File source, boolean publicInherited);
/** Called to indicate that the source file <code>source</code> depends on the top-level
* class named <code>name</code> from class or jar file <code>binary</code>.
* <code>context</code> gives information about the context in which this dependency has been extracted.
* See xsbti.DependencyContext for the list of existing dependency contexts. */
public void binaryDependency(File binary, String name, File source, DependencyContext context);
/** Called to indicate that the source file <code>source</code> produces a class file at
* <code>module</code> contain class <code>name</code>.*/
public void generatedClass(File source, File module, String name);

View File

@ -0,0 +1,22 @@
package xsbti;
/**
* Enumeration of existing dependency contexts.
* Dependency contexts represent the various kind of dependencies that
* can exist between symbols.
*/
public enum DependencyContext {
/**
* Represents a direct dependency between two symbols :
* object Foo
* object Bar { def foo = Foo }
*/
DependencyByMemberRef,
/**
* Represents an inheritance dependency between two symbols :
* class A
* class B extends A
*/
DependencyByInheritance
}

View File

@ -3,17 +3,26 @@ package xsbti
import java.io.File
import scala.collection.mutable.ArrayBuffer
import xsbti.api.SourceAPI
import xsbti.DependencyContext._
class TestCallback(override val nameHashing: Boolean = false) extends AnalysisCallback
{
val sourceDependencies = new ArrayBuffer[(File, File, Boolean)]
val binaryDependencies = new ArrayBuffer[(File, String, File, Boolean)]
val sourceDependencies = new ArrayBuffer[(File, File, DependencyContext)]
val binaryDependencies = new ArrayBuffer[(File, String, File, DependencyContext)]
val products = new ArrayBuffer[(File, File, String)]
val usedNames = scala.collection.mutable.Map.empty[File, Set[String]].withDefaultValue(Set.empty)
val apis: scala.collection.mutable.Map[File, SourceAPI] = scala.collection.mutable.Map.empty
def sourceDependency(dependsOn: File, source: File, inherited: Boolean) { sourceDependencies += ((dependsOn, source, inherited)) }
def binaryDependency(binary: File, name: String, source: File, inherited: Boolean) { binaryDependencies += ((binary, name, source, inherited)) }
def sourceDependency(dependsOn: File, source: File, inherited: Boolean) {
val context = if(inherited) DependencyByInheritance else DependencyByMemberRef
sourceDependency(dependsOn, source, context)
}
def sourceDependency(dependsOn: File, source: File, context: DependencyContext) { sourceDependencies += ((dependsOn, source, context)) }
def binaryDependency(binary: File, name: String, source: File, inherited: Boolean) {
val context = if(inherited) DependencyByInheritance else DependencyByMemberRef
binaryDependency(binary, name, source, context)
}
def binaryDependency(binary: File, name: String, source: File, context: DependencyContext) { binaryDependencies += ((binary, name, source, context)) }
def generatedClass(source: File, module: File, name: String) { products += ((source, module, name)) }
def usedName(source: File, name: String) { usedNames(source) += name }