Merge pull request #1013 from gkossakowski/used-names-extraction

Used names extraction logic
This commit is contained in:
Grzegorz Kossakowski 2013-12-03 03:30:21 -08:00
commit b81fc0b256
2 changed files with 10 additions and 4 deletions

View File

@ -24,12 +24,16 @@ public interface AnalysisCallback
public void generatedClass(File source, File module, String name);
/** Called when the public API of a source file is extracted. */
public void api(File sourceFile, xsbti.api.SourceAPI source);
public void usedName(File sourceFile, String names);
/** Provides problems discovered during compilation. These may be reported (logged) or unreported.
* Unreported problems are usually unreported because reporting was not enabled via a command line switch. */
public void problem(String what, Position pos, String msg, Severity severity, boolean reported);
/**
* Determines whether member reference and inheritance dependencies should be extracted in given compiler
* run.
* Determines whether method calls through this interface should be interpreted as serving
* name hashing algorithm needs in given compiler run.
*
* In particular, it indicates whether member reference and inheritance dependencies should be
* extracted.
*
* As the signature suggests, this method's implementation is meant to be side-effect free. It's added
* to AnalysisCallback because it indicates how other callback calls should be interpreted by both
@ -38,5 +42,5 @@ public interface AnalysisCallback
* NOTE: This method is an implementation detail and can be removed at any point without deprecation.
* Do not depend on it, please.
*/
public boolean memberRefAndInheritanceDeps();
public boolean nameHashing();
}

View File

@ -4,17 +4,19 @@ import java.io.File
import scala.collection.mutable.ArrayBuffer
import xsbti.api.SourceAPI
class TestCallback(override val memberRefAndInheritanceDeps: Boolean = false) extends AnalysisCallback
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 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 generatedClass(source: File, module: File, name: String) { products += ((source, module, name)) }
def usedName(source: File, name: String) { usedNames(source) += name }
def api(source: File, sourceAPI: SourceAPI): Unit = {
assert(!apis.contains(source), s"The `api` method should be called once per source file: $source")
apis(source) = sourceAPI