⁠
joe: 2025
- /*
- * Minecraft Development for IntelliJ
- *
- * https://mcdev.io/
- *
- * Copyright (C) 2024 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.platform.fabric.reference
- import com.demonwav.mcdev.platform.fabric.util.FabricConstants
- import com.demonwav.mcdev.platform.mcp.fabricloom.FabricLoomData
- import com.demonwav.mcdev.util.findModule
- import com.intellij.openapi.project.DumbService
- import com.intellij.openapi.util.Computable
- import com.intellij.psi.PsiElement
- import com.intellij.psi.search.FilenameIndex
- import com.intellij.psi.search.GlobalSearchScope
- import com.intellij.psi.search.SearchScope
- import com.intellij.psi.search.UseScopeEnlarger
- import org.jetbrains.plugins.gradle.util.GradleUtil
- class FabricClientUseScopeEnlarger : UseScopeEnlarger() {
- override fun getAdditionalUseScope(element: PsiElement): SearchScope? {
- val module = element.findModule()
- ?: return null
- val loomData = GradleUtil.findGradleModuleData(module)?.children
- ?.find { it.key == FabricLoomData.KEY }?.data as? FabricLoomData
- ?: return null
- if (loomData.splitMinecraftJar) {
- return GlobalSearchScope.filesScope(element.project) {
- DumbService.getInstance(module.project).runReadActionInSmartMode(
- Computable {
- val moduleWithDeps = GlobalSearchScope.moduleWithDependenciesScope(module)
- FilenameIndex.getVirtualFilesByName(FabricConstants.FABRIC_MOD_JSON, moduleWithDeps)
- }
- )
- }
- }
- return null
- }
- }
- /*
- * 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.platform.fabric.reference
- import com.demonwav.mcdev.platform.fabric.util.FabricConstants
- import com.demonwav.mcdev.platform.mcp.fabricloom.FabricLoomData
- import com.demonwav.mcdev.util.findModule
- import com.intellij.openapi.project.DumbService
- import com.intellij.openapi.util.Computable
- import com.intellij.psi.PsiElement
- import com.intellij.psi.search.FilenameIndex
- import com.intellij.psi.search.GlobalSearchScope
- import com.intellij.psi.search.SearchScope
- import com.intellij.psi.search.UseScopeEnlarger
- import org.jetbrains.plugins.gradle.util.GradleUtil
- class FabricClientUseScopeEnlarger : UseScopeEnlarger() {
- override fun getAdditionalUseScope(element: PsiElement): SearchScope? {
- val module = element.findModule()
- ?: return null
- val loomData = GradleUtil.findGradleModuleData(module)?.children
- ?.find { it.key == FabricLoomData.KEY }?.data as? FabricLoomData
- ?: return null
- if (loomData.splitMinecraftJar) {
- return GlobalSearchScope.filesScope(element.project) {
- DumbService.getInstance(module.project).runReadActionInSmartMode(
- Computable {
- val moduleWithDeps = GlobalSearchScope.moduleWithDependenciesScope(module)
- FilenameIndex.getVirtualFilesByName(FabricConstants.FABRIC_MOD_JSON, moduleWithDeps)
- }
- )
- }
- }
- return null
- }
- }