Skip to content

Commit ddfa38e

Browse files
committed
fix(intellij): project graph or project graph nodes may be null if project is misconfigured
1 parent a92b965 commit ddfa38e

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

apps/intellij/src/main/kotlin/dev/nx/console/angular/NxAngularConfigService.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class NxAngularConfigService(private val project: Project, private val cs: Corou
7676
return
7777
}
7878
val projectFiles =
79-
workspace.projectGraph.nodes.values
79+
(workspace.projectGraph?.nodes ?: return)
80+
.values
8081
.asSequence()
8182
// TODO: use framework metadata in the future, for now just register all projects
8283
// .filter { project ->

apps/intellij/src/main/kotlin/dev/nx/console/nx_toolwindow/NxToolWindowPanel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class NxToolWindowPanel(private val project: Project) : SimpleToolWindowPanel(tr
115115
it.second
116116
}
117117
}
118-
} else if (workspace == null || workspace.projectGraph.nodes.isEmpty()) {
118+
} else if (workspace == null || workspace.projectGraph?.nodes.isNullOrEmpty()) {
119119
noProjectsComponent
120120
} else {
121121
projectTreeComponent

apps/intellij/src/main/kotlin/dev/nx/console/nx_toolwindow/tree/builder/NxTreeBuilderBase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ abstract class NxTreeBuilderBase(private val nxWorkspace: NxWorkspace?) {
178178
if (nxWorkspace == null) {
179179
return emptyArray()
180180
}
181-
return nxWorkspace.projectGraph.nodes
181+
return (nxWorkspace.projectGraph?.nodes ?: return emptyArray())
182182
.filter { it.value.data.targets?.contains(targetsListNode.targetName) ?: false }
183183
.map {
184184
NxSimpleNode.Target(

libs/intellij/models/src/main/kotlin/dev/nx/console/models/NxWorkspace.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import kotlinx.serialization.*
44

55
data class NxWorkspace(
66
val validWorkspaceJson: Boolean,
7-
val projectGraph: NxProjectGraph,
7+
val projectGraph: NxProjectGraph?,
88
val daemonEnabled: Boolean?,
99
val workspacePath: String,
1010
val errors: Array<NxError>?,
@@ -53,7 +53,7 @@ data class NxWorkspace(
5353

5454
data class WorkspaceLayout(val appsDir: String?, val libsDir: String?)
5555

56-
data class NxProjectGraph(val nodes: Map<String, NxProjectGraphProjectNode>)
56+
data class NxProjectGraph(val nodes: Map<String, NxProjectGraphProjectNode>?)
5757

5858
data class NxProjectGraphProjectNode(val name: String, val type: String, val data: NxProject)
5959

0 commit comments

Comments
 (0)