Skip to content

Commit 313eb1a

Browse files
committed
Cleanup
1 parent ce6ab5f commit 313eb1a

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleDetector.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,9 @@ class AffectedModuleDetectorImpl(
589589
* original changedProjects. Always build is still here to ensure at least 1 thing is built
590590
*/
591591
private fun findDependentProjects(): Set<ProjectPath> {
592-
return changedProjects.flatMap { dependencyTracker.findAllDependents(it) }.toSet()
592+
return changedProjects.flatMap { path ->
593+
dependencyTracker.findAllDependents(path)
594+
}.toSet()
593595
}
594596

595597
/**

affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/DependencyTracker.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ class DependencyTracker(private val rootProject: Project, private val logger: Lo
5555
fun findAllDependents(projectPath: ProjectPath): Set<ProjectPath> {
5656
logger?.info("finding dependents of $projectPath")
5757
val result = mutableSetOf<ProjectPath>()
58-
fun addAllDependents(path: ProjectPath) {
59-
if (result.add(path)) {
60-
dependentList[path]?.forEach(::addAllDependents)
58+
fun addAllDependents(projectPath: ProjectPath) {
59+
if (result.add(projectPath)) {
60+
dependentList[projectPath]?.forEach(::addAllDependents)
6161
}
6262
}
6363
addAllDependents(projectPath)

affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/ProjectGraph.kt

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ class ProjectGraph(project: Project, logger: Logger? = null) : Serializable {
5454
val realSections = sections.filter { section -> section != ".." }
5555

5656
logger?.info("relative path: $relativePath , sections: $realSections")
57-
val leaf = realSections.fold(rootNode) { left, right ->
58-
left.getOrCreateNode(right)
59-
}
60-
leaf.projectPath = it.path
57+
val leaf = realSections.fold(rootNode) { left, right -> left.getOrCreateNode(right) }
58+
leaf.projectPath = it.projectPath
6159
}
6260
logger?.info("finished creating ProjectGraph")
6361
}
@@ -69,24 +67,24 @@ class ProjectGraph(project: Project, logger: Logger? = null) : Serializable {
6967
fun findContainingProject(filePath: String, logger: Logger? = null): ProjectPath? {
7068
val sections = filePath.split(File.separatorChar)
7169
logger?.info("finding containing project for $filePath , sections: $sections")
72-
return rootNode.find(sections, 0, logger)?.let { ProjectPath(it) }
70+
return rootNode.find(sections, 0, logger)
7371
}
7472

7573
val allProjects by lazy {
76-
val result = mutableSetOf<String>()
74+
val result = mutableSetOf<ProjectPath>()
7775
rootNode.addAllProjectPaths(result)
78-
result.map { ProjectPath(it) }.toSet()
76+
result
7977
}
8078

8179
private class Node() : Serializable {
82-
var projectPath: String? = null
80+
var projectPath: ProjectPath? = null
8381
private val children = mutableMapOf<String, Node>()
8482

8583
fun getOrCreateNode(key: String): Node {
8684
return children.getOrPut(key) { Node() }
8785
}
8886

89-
fun find(sections: List<String>, index: Int, logger: Logger?): String? {
87+
fun find(sections: List<String>, index: Int, logger: Logger?): ProjectPath? {
9088
if (sections.size <= index) {
9189
logger?.info("nothing")
9290
return projectPath
@@ -100,7 +98,7 @@ class ProjectGraph(project: Project, logger: Logger? = null) : Serializable {
10098
}
10199
}
102100

103-
fun addAllProjectPaths(collection: MutableSet<String>) {
101+
fun addAllProjectPaths(collection: MutableSet<ProjectPath>) {
104102
projectPath?.let { path -> collection.add(path) }
105103
for (child in children.values) {
106104
child.addAllProjectPaths(collection)
@@ -109,7 +107,7 @@ class ProjectGraph(project: Project, logger: Logger? = null) : Serializable {
109107
}
110108

111109
fun getRootProjectPath(): ProjectPath? {
112-
return rootNode.projectPath?.let { ProjectPath(it) }
110+
return rootNode.projectPath
113111
}
114112
}
115113

0 commit comments

Comments
 (0)