Skip to content

Commit

Permalink
Remove problematic annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNesto committed Aug 12, 2024
1 parent df9f0b4 commit 0c616d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 32 deletions.
3 changes: 1 addition & 2 deletions src/main/kotlin/yaml/PluginYmlInspection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 17 additions & 30 deletions src/test/kotlin/framework/BaseMinecraftTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlatformType> = emptySet(),
private val libraries: Set<String> = emptySet(),
libraries: Set<String> = 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<PlatformType>): LightProjectDescriptor {
fun getProjectDescriptor(platformTypes: Set<PlatformType>, libraries: Set<String>): LightProjectDescriptor {
return object : DefaultLightProjectDescriptor() {
override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry) {
model.getModuleExtension(LanguageLevelModuleExtension::class.java).languageLevel = LanguageLevel.JDK_1_8
Expand All @@ -94,9 +69,21 @@ fun getProjectDescriptor(platformTypes: Set<PlatformType>): 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()
}
}

0 comments on commit 0c616d2

Please sign in to comment.