mirror of https://github.com/sbt/sbt.git
Make api diff context size valuable configurable.
Add `apiDiffContextSize` option to `IncOptions` which allows one to control the size (in lines) of a context used when printing diffs for textual API representation. The default value for `apiDiffContextSize` is 5 which seems to be enough for most situations. This is verified by many debugging sessions I performed when using api diffing functionality.
This commit is contained in:
parent
025eae9103
commit
0d2dc75115
|
|
@ -23,9 +23,17 @@ final case class IncOptions(
|
|||
* Enable tools for debugging API changes. At the moment this option is unused but in the
|
||||
* future it will enable for example:
|
||||
* - disabling API hashing and API minimization (potentially very memory consuming)
|
||||
* - dumping textual API representation into files
|
||||
* - diffing textual API representation which helps understanding what kind of changes
|
||||
* to APIs are visible to the incremental compiler
|
||||
*/
|
||||
apiDebug: Boolean,
|
||||
/**
|
||||
* Controls context size (in lines) displayed when diffs are produced for textual API
|
||||
* representation.
|
||||
*
|
||||
* This option is used only when `apiDebug == true`.
|
||||
*/
|
||||
apiDiffContextSize: Int,
|
||||
/**
|
||||
* The directory where we dump textual representation of APIs. This method might be called
|
||||
* only if apiDebug returns true. This is unused option at the moment as the needed functionality
|
||||
|
|
@ -45,6 +53,7 @@ object IncOptions {
|
|||
recompileAllFraction = 0.5,
|
||||
relationsDebug = false,
|
||||
apiDebug = false,
|
||||
apiDiffContextSize = 5,
|
||||
apiDumpDirectory = None,
|
||||
newClassfileManager = ClassfileManager.deleteImmediately
|
||||
)
|
||||
|
|
@ -57,6 +66,7 @@ object IncOptions {
|
|||
val relationsDebugKey = "relationsDebug"
|
||||
val apiDebugKey = "apiDebug"
|
||||
val apiDumpDirectoryKey = "apiDumpDirectory"
|
||||
val apiDiffContextSize = "apiDiffContextSize"
|
||||
|
||||
def fromStringMap(m: java.util.Map[String, String]): IncOptions = {
|
||||
// all the code below doesn't look like idiomatic Scala for a good reason: we are working with Java API
|
||||
|
|
@ -76,6 +86,10 @@ object IncOptions {
|
|||
val k = apiDebugKey
|
||||
if (m.containsKey(k)) m.get(k).toBoolean else Default.apiDebug
|
||||
}
|
||||
def getApiDiffContextSize: Int = {
|
||||
val k = apiDiffContextSize
|
||||
if (m.containsKey(k)) m.get(k).toInt else Default.apiDiffContextSize
|
||||
}
|
||||
def getApiDumpDirectory: Option[java.io.File] = {
|
||||
val k = apiDumpDirectoryKey
|
||||
if (m.containsKey(k))
|
||||
|
|
@ -83,7 +97,8 @@ object IncOptions {
|
|||
else None
|
||||
}
|
||||
|
||||
IncOptions(getTransitiveStep, getRecompileAllFraction, getRelationsDebug, getApiDebug, getApiDumpDirectory, ClassfileManager.deleteImmediately)
|
||||
IncOptions(getTransitiveStep, getRecompileAllFraction, getRelationsDebug, getApiDebug, getApiDiffContextSize,
|
||||
getApiDumpDirectory, ClassfileManager.deleteImmediately)
|
||||
}
|
||||
|
||||
def toStringMap(o: IncOptions): java.util.Map[String, String] = {
|
||||
|
|
@ -93,6 +108,7 @@ object IncOptions {
|
|||
m.put(relationsDebugKey, o.relationsDebug.toString)
|
||||
m.put(apiDebugKey, o.apiDebug.toString)
|
||||
o.apiDumpDirectory.foreach(f => m.put(apiDumpDirectoryKey, f.toString))
|
||||
m.put(apiDiffContextSize, o.apiDiffContextSize.toString)
|
||||
m
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ object Incremental
|
|||
*/
|
||||
private def logApiChanges[T](changes: (collection.Set[T], Seq[Source], Seq[Source]), log: Logger,
|
||||
options: IncOptions): Unit = {
|
||||
val contextSize = 5
|
||||
val contextSize = options.apiDiffContextSize
|
||||
try {
|
||||
val apiDiff = new APIDiff
|
||||
changes.zipped foreach {
|
||||
|
|
|
|||
Loading…
Reference in New Issue