User: rednesto Date: 03 Dec 24 13:12 Revision: 092f5c175cf4a8c5d70b87941f93e6aebf8af46f Summary: Fix #2408 Force external annotations by default TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9793&personal=false Index: src/main/kotlin/MinecraftConfigurable.kt =================================================================== --- src/main/kotlin/MinecraftConfigurable.kt (revision 28ca789856873606a44e7e2a8d7bde4c6937b24b) +++ src/main/kotlin/MinecraftConfigurable.kt (revision 092f5c175cf4a8c5d70b87941f93e6aebf8af46f) @@ -81,6 +81,11 @@ row { checkBox(MCDevBundle("minecraft.settings.show_chat_color_underlines")) .bindSelected(settings::isShowChatColorUnderlines) + } + row { + checkBox(MCDevBundle("minecraft.settings.force_external_annotations")) + .bindSelected(settings::forceExternalAnnotations) + .comment(MCDevBundle("minecraft.settings.force_external_annotations.comment")) }.bottomGap(BottomGap.SMALL) group(indent = false) { Index: src/main/kotlin/MinecraftSettings.kt =================================================================== --- src/main/kotlin/MinecraftSettings.kt (revision 28ca789856873606a44e7e2a8d7bde4c6937b24b) +++ src/main/kotlin/MinecraftSettings.kt (revision 092f5c175cf4a8c5d70b87941f93e6aebf8af46f) @@ -39,6 +39,7 @@ var isShowChatColorGutterIcons: Boolean = true, var isShowChatColorUnderlines: Boolean = false, var underlineType: UnderlineType = UnderlineType.DOTTED, + var forceExternalAnnotations: Boolean = true, var mixinClassIcon: Boolean = true, @@ -108,6 +109,12 @@ state.underlineType = underlineType } + var forceExternalAnnotations: Boolean + get() = state.forceExternalAnnotations + set(forceExternalAnnotations) { + state.forceExternalAnnotations = forceExternalAnnotations + } + var mixinClassIcon: Boolean get() = state.mixinClassIcon set(mixinClassIcon) { Index: src/main/kotlin/platform/mcp/McpModule.kt =================================================================== --- src/main/kotlin/platform/mcp/McpModule.kt (revision 28ca789856873606a44e7e2a8d7bde4c6937b24b) +++ src/main/kotlin/platform/mcp/McpModule.kt (revision 092f5c175cf4a8c5d70b87941f93e6aebf8af46f) @@ -20,6 +20,7 @@ package com.demonwav.mcdev.platform.mcp +import com.demonwav.mcdev.MinecraftSettings import com.demonwav.mcdev.facet.MinecraftFacet import com.demonwav.mcdev.platform.AbstractModule import com.demonwav.mcdev.platform.PlatformType @@ -28,6 +29,8 @@ import com.demonwav.mcdev.translations.TranslationFileListener import com.demonwav.mcdev.util.runWriteTaskLater import com.intellij.json.JsonFileType +import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder +import com.intellij.openapi.externalSystem.util.ExternalSystemUtil import com.intellij.openapi.fileTypes.FileTypeManager import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.VirtualFileManager @@ -35,6 +38,8 @@ import com.intellij.psi.PsiMethod import com.intellij.util.messages.MessageBusConnection import javax.swing.Icon +import org.jetbrains.plugins.gradle.settings.GradleSettings +import org.jetbrains.plugins.gradle.util.GradleConstants class McpModule(facet: MinecraftFacet) : AbstractModule(facet) { @@ -54,8 +59,23 @@ runWriteTaskLater { FileTypeManager.getInstance().associatePattern(JsonFileType.INSTANCE, McpConstants.PNG_MCMETA) } + + if (MinecraftSettings.instance.forceExternalAnnotations) { + // Force enable external annotations so that ours are provided + var requiresRefresh = false + for (settings in GradleSettings.getInstance(project).linkedProjectsSettings) { + if (!settings.isResolveExternalAnnotations) { + settings.isResolveExternalAnnotations = true + requiresRefresh = true - } + } + } + if (requiresRefresh) { + ExternalSystemUtil.refreshProjects(ImportSpecBuilder(project, GradleConstants.SYSTEM_ID)) + } + } + } + private fun initSrg() { val settings = getSettings() val file = settings.mappingFile ?: return Index: src/main/resources/messages/MinecraftDevelopment.properties =================================================================== --- src/main/resources/messages/MinecraftDevelopment.properties (revision 28ca789856873606a44e7e2a8d7bde4c6937b24b) +++ src/main/resources/messages/MinecraftDevelopment.properties (revision 092f5c175cf4a8c5d70b87941f93e6aebf8af46f) @@ -271,6 +271,8 @@ minecraft.settings.creator.repo.default_name=My Repo minecraft.settings.creator.repo.builtin_name=Built In +minecraft.settings.force_external_annotations=Force external annotations in Minecraft projects +minecraft.settings.force_external_annotations.comment=The plugin uses external annotations to provide support for some features, like recognizing translation methods. minecraft.settings.lang_template.display_name=Localization Template minecraft.settings.lang_template.scheme=Scheme: minecraft.settings.lang_template.project_must_be_selected=You must have selected a project for this!