From 0c616d2530e2e225fba74bc490c83bd51a9ffa92 Mon Sep 17 00:00:00 2001 From: RedNesto Date: Mon, 12 Aug 2024 16:53:26 +0200 Subject: [PATCH] Remove problematic annotation --- src/main/kotlin/yaml/PluginYmlInspection.kt | 3 +- .../kotlin/framework/BaseMinecraftTest.kt | 47 +++++++------------ 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/yaml/PluginYmlInspection.kt b/src/main/kotlin/yaml/PluginYmlInspection.kt index a48fbb1d7..0aa5ecca4 100644 --- a/src/main/kotlin/yaml/PluginYmlInspection.kt +++ b/src/main/kotlin/yaml/PluginYmlInspection.kt @@ -32,14 +32,13 @@ import com.intellij.codeInspection.ProblemsHolder import com.intellij.psi.JavaPsiFacade import com.intellij.psi.PsiClass import com.intellij.psi.PsiElementVisitor -import org.jetbrains.annotations.Nls import org.jetbrains.yaml.psi.YAMLKeyValue import org.jetbrains.yaml.psi.YAMLScalar import org.jetbrains.yaml.psi.YamlPsiElementVisitor class PluginYmlInspection : LocalInspectionTool() { - override fun getStaticDescription(): @Nls String? = "Reports issues in Bukkit-like plugin.yml files" + override fun getStaticDescription(): String? = "Reports issues in Bukkit-like plugin.yml files" override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor { val module = holder.file.findModule() ?: return PsiElementVisitor.EMPTY_VISITOR diff --git a/src/test/kotlin/framework/BaseMinecraftTest.kt b/src/test/kotlin/framework/BaseMinecraftTest.kt index 99ad6c904..39552c9cd 100644 --- a/src/test/kotlin/framework/BaseMinecraftTest.kt +++ b/src/test/kotlin/framework/BaseMinecraftTest.kt @@ -26,59 +26,34 @@ import com.demonwav.mcdev.platform.PlatformType import com.demonwav.mcdev.util.runWriteTask import com.intellij.facet.FacetManager import com.intellij.openapi.module.Module -import com.intellij.openapi.project.rootManager import com.intellij.openapi.roots.ContentEntry import com.intellij.openapi.roots.LanguageLevelModuleExtension import com.intellij.openapi.roots.ModifiableRootModel import com.intellij.openapi.roots.OrderRootType import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar import com.intellij.pom.java.LanguageLevel +import com.intellij.testFramework.IdeaTestUtil import com.intellij.testFramework.LightProjectDescriptor import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor import org.junit.jupiter.api.BeforeEach abstract class BaseMinecraftTest( platformTypes: Set = emptySet(), - private val libraries: Set = emptySet(), + libraries: Set = emptySet(), ) : ProjectBuilderTest( - getProjectDescriptor(platformTypes), + getProjectDescriptor(platformTypes, libraries), ) { protected open val testPath = "" - private var initialized = false - @BeforeEach fun setUp() { if (testPath.isNotBlank()) { fixture.testDataPath = "$BASE_DATA_PATH/$testPath" } - - if (initialized) { - return - } - - initialized = true - runWriteTask { - // TODO this can be moved into the project descriptor configureModule method below in 2023.3+ - val table = LibraryTablesRegistrar.getInstance().getLibraryTable(module.project) - val model = module.rootManager.modifiableModel - for (libraryName in libraries) { - val root = checkNotNull(findLibraryRoot(libraryName)) { "Could not find library $libraryName" } - val library = table.createLibrary(libraryName) - - val libraryModel = library.modifiableModel - libraryModel.addRoot(root, OrderRootType.CLASSES) - libraryModel.commit() - - model.addLibraryEntry(library) - } - - model.commit() - } } } -fun getProjectDescriptor(platformTypes: Set): LightProjectDescriptor { +fun getProjectDescriptor(platformTypes: Set, libraries: Set): LightProjectDescriptor { return object : DefaultLightProjectDescriptor() { override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry) { model.getModuleExtension(LanguageLevelModuleExtension::class.java).languageLevel = LanguageLevel.JDK_1_8 @@ -94,9 +69,21 @@ fun getProjectDescriptor(platformTypes: Set): LightProjectDescript val modifiableModel = facetManager.createModifiableModel() modifiableModel.addFacet(facet) modifiableModel.commit() + + val table = LibraryTablesRegistrar.getInstance().getLibraryTable(module.project) + for (libraryName in libraries) { + val root = checkNotNull(findLibraryRoot(libraryName)) { "Could not find library $libraryName" } + val library = table.createLibrary(libraryName) + + val libraryModel = library.modifiableModel + libraryModel.addRoot(root, OrderRootType.CLASSES) + libraryModel.commit() + + model.addLibraryEntry(library) + } } } - override fun getSdk() = mockJdk // TODO replace by proper JDK in IdeaTestUtil in 2023.3+? + override fun getSdk() = IdeaTestUtil.getMockJdk21() } }