-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathMinecraftTreeStructureProvider.kt
47 lines (42 loc) · 1.6 KB
/
MinecraftTreeStructureProvider.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Minecraft Development for IntelliJ
*
* https://mcdev.io/
*
* Copyright (C) 2025 minecraft-dev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, version 3.0 only.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.demonwav.mcdev
import com.demonwav.mcdev.region.RegionFileType
import com.demonwav.mcdev.region.RegionPsiFileNode
import com.intellij.ide.projectView.TreeStructureProvider
import com.intellij.ide.projectView.ViewSettings
import com.intellij.ide.projectView.impl.nodes.PsiFileNode
import com.intellij.ide.util.treeView.AbstractTreeNode
private fun mapMcaNode(node: AbstractTreeNode<*>): AbstractTreeNode<*> {
if (node is PsiFileNode) {
val value = node.value
if (value?.fileType is RegionFileType) {
return RegionPsiFileNode(node.project, value, node.settings)
}
}
return node
}
class MinecraftTreeStructureProvider : TreeStructureProvider {
override fun modify(
parent: AbstractTreeNode<*>,
children: MutableCollection<AbstractTreeNode<*>>,
settings: ViewSettings?
) = children.mapTo(ArrayList(children.size), ::mapMcaNode)
}