forked from autonomousapps/dependency-analysis-gradle-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge main into branch and fix merge conflicts
- Loading branch information
Showing
103 changed files
with
1,428 additions
and
606 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
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
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
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
40 changes: 40 additions & 0 deletions
40
graph-support/src/main/kotlin/com/autonomousapps/graph/DominanceTreeDataWriter.kt
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,40 @@ | ||
// Copyright (c) 2024. Tony Robalik. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.autonomousapps.graph | ||
|
||
import com.autonomousapps.graph.DominanceTreeWriter.NodeWriter | ||
|
||
public class DominanceTreeDataWriter<N : Any>( | ||
private val root: N, | ||
private val tree: DominanceTree<N>, | ||
private val nodeWriter: NodeWriter<N>, | ||
) { | ||
|
||
public val sizeTree: DependencySizeTree<N> by lazy { dfs(root) } | ||
|
||
private fun dfs(node: N): DependencySizeTree<N> { | ||
return DependencySizeTree( | ||
self = node, | ||
size = nodeWriter.getSize(node), | ||
totalSize = nodeWriter.getTreeSize(node), | ||
dependencies = tree.dominanceGraph.successors(node) | ||
.run { nodeWriter.comparator()?.let { sortedWith(it) } ?: this } | ||
.map { dfs(it) } | ||
) | ||
} | ||
} | ||
|
||
public data class DependencySizeTree<N>( | ||
val self: N, | ||
val size: Long?, | ||
val totalSize: Long?, | ||
val dependencies: List<DependencySizeTree<N>> | ||
) { | ||
public fun <M> map(f: (N) -> M): DependencySizeTree<M> = DependencySizeTree( | ||
self = f(self), | ||
size = size, | ||
totalSize = totalSize, | ||
dependencies = dependencies.map { it.map(f) } | ||
) | ||
} | ||
|
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
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
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
Oops, something went wrong.