@@ -12,7 +12,6 @@ class SceneNodesParser {
1212
1313private class ScenesParser {
1414 fun parse (sceneData : SceneData ): Map <String , String > {
15- Log .parsingScenePaths()
1615 return splitToEntries(sceneData.content, " ext_resource" )
1716 .map(::parseEntryParams)
1817 .mapNotNull(::extractSceneIdToPath)
@@ -24,7 +23,6 @@ private class ScenesParser {
2423 val path = params[" path" ]
2524
2625 if (id == null || path == null ) {
27- Log .skippingSceneResource(params)
2826 return null
2927 }
3028
@@ -36,17 +34,12 @@ private class ScenesParser {
3634 .groupBy({ it.first }, { it.second })
3735 .filter { it.value.size > 1 }
3836
39- if (duplicates.isNotEmpty()) {
40- Log .duplicatedSceneResources(duplicates)
41- }
42-
4337 return sceneIdsToPaths.toMap()
4438 }
4539}
4640
4741private class NodesParser (val scenePathsById : Map <String , String >) {
4842 fun parse (sceneData : SceneData ): Node {
49- Log .parsingSceneNodes()
5043 return splitToEntries(sceneData.content, " node" )
5144 .map(::parseEntryParams)
5245 .mapNotNull(::extractNodeParams)
@@ -61,15 +54,13 @@ private class NodesParser(val scenePathsById: Map<String, String>) {
6154 val parent = params[" parent" ]
6255
6356 if (name == null || (type == null && instance == null ) || (type != null && instance != null )) {
64- Log .skippingNode(params)
6557 return null
6658 }
6759
6860 return NodeParams (name = name, type = type, instance = instance, parent = parent)
6961 }
7062
7163 private fun createRootNode (sceneName : String , params : List <NodeParams >): Node {
72- Log .creatingRootNode()
7364 val childrenByParent = params.groupBy { it.parent }
7465 val rootParams = params.firstOrNull { it.parent == null } ? : throw ParentNodeNotFound (sceneName)
7566 return rootParams.toNode(childrenByParent, scenePathsById)
@@ -114,13 +105,11 @@ data class NodeParams(
114105}
115106
116107private fun splitToEntries (data : String , entryType : String ): List <String > {
117- Log .splittingEntries(entryType)
118108 val pattern = """ \[${entryType} .*]""" .toRegex()
119109 return pattern.findAll(data).mapNotNull { it.groupValues.firstOrNull() }.toList()
120110}
121111
122112private fun parseEntryParams (entry : String ): Map <String , String > {
123- Log .parsingEntryParams(entry)
124113 val pattern = """ (?:(\w+)=(?:\w+\("(.+)"\)|"(.+?)"))+""" .toRegex()
125114 return pattern.findAll(entry).associate { match ->
126115 val (key, argumentValue, plainValue) = match.destructured
@@ -130,7 +119,6 @@ private fun parseEntryParams(entry: String): Map<String, String> {
130119}
131120
132121private fun parseSceneName (scenePath : String ): String? {
133- Log .parsingEntryParams(scenePath)
134122 val pattern = """ ^res://(.*).tscn$""" .toRegex()
135123 return pattern.find(scenePath)?.groupValues?.getOrNull(1 )
136124}
0 commit comments