@@ -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