Skip to content

Commit c73d3e7

Browse files
committed
Fix references to client code not being resolved in fabric.mod.json
For some obscure reasons I couldn't figure out, it did not work in some cases before
1 parent 5521181 commit c73d3e7

File tree

2 files changed

+2
-30
lines changed

2 files changed

+2
-30
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- In this case, the creator will now select the latest version available for the latest Minecraft version supported by Parchment
1717
- [#2408](https://github.com/minecraft-dev/MinecraftDev/issues/2408) External translation annotations are not attached
1818
- This happens because IntelliJ IDEA disables external annotations by default in 2024.3, which we rely on for this feature, an opt-out setting has been added to force-enable external annotations in Minecraft projects.
19+
- Cases where references to client sources in fabric.mod.json were not resolved
1920

2021
## [1.8.2] - 2024-10-05
2122

src/main/kotlin/platform/fabric/reference/FabricModJsonResolveScopeEnlarger.kt

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,11 @@
2121
package com.demonwav.mcdev.platform.fabric.reference
2222

2323
import com.demonwav.mcdev.platform.fabric.util.FabricConstants
24-
import com.demonwav.mcdev.platform.mcp.fabricloom.FabricLoomData
25-
import com.intellij.openapi.module.ModuleManager
2624
import com.intellij.openapi.module.ModuleUtilCore
2725
import com.intellij.openapi.project.Project
28-
import com.intellij.openapi.roots.ProjectRootManager
2926
import com.intellij.openapi.vfs.VirtualFile
3027
import com.intellij.psi.ResolveScopeEnlarger
31-
import com.intellij.psi.search.GlobalSearchScope
3228
import com.intellij.psi.search.SearchScope
33-
import org.jetbrains.plugins.gradle.util.GradleUtil
3429

3530
class FabricModJsonResolveScopeEnlarger : ResolveScopeEnlarger() {
3631

@@ -41,30 +36,6 @@ class FabricModJsonResolveScopeEnlarger : ResolveScopeEnlarger() {
4136

4237
val module = ModuleUtilCore.findModuleForFile(file, project)
4338
?: return null
44-
val loomData = GradleUtil.findGradleModuleData(module)?.children
45-
?.find { it.key == FabricLoomData.KEY }?.data as? FabricLoomData
46-
?: return null
47-
val modSourceSets = loomData.modSourceSets
48-
?: return null
49-
50-
val moduleScopes = mutableListOf<GlobalSearchScope>()
51-
val moduleManager = ModuleManager.getInstance(project)
52-
val parentPath = module.name.substringBeforeLast('.')
53-
val rootType = ProjectRootManager.getInstance(project).fileIndex.getContainingSourceRootType(file)
54-
?: return null
55-
for ((_, sourceSets) in modSourceSets) {
56-
for (sourceSet in sourceSets) {
57-
val childModule = moduleManager.findModuleByName("$parentPath.$sourceSet")
58-
if (childModule != null) {
59-
moduleScopes.add(childModule.getModuleScope(rootType.isForTests))
60-
}
61-
}
62-
}
63-
64-
if (moduleScopes.isEmpty()) {
65-
return null
66-
}
67-
68-
return GlobalSearchScope.union(moduleScopes)
39+
return module.moduleWithDependentsScope.union(module.moduleTestsWithDependentsScope)
6940
}
7041
}

0 commit comments

Comments
 (0)