[devkit] new inspection: JComponent must use UiDataProvider (IDEA-355274)

WIP

GitOrigin-RevId: 0c8002a011a442f8cad12a001f6a2daf40e28be5
This commit is contained in:
Yann Cébron
2024-07-16 17:09:39 +02:00
committed by intellij-monorepo-bot
parent 81668ee458
commit 4817098482
9 changed files with 117 additions and 2 deletions

View File

@@ -0,0 +1,4 @@
import javax.swing.JComponent;
import com.intellij.openapi.actionSystem.DataProvider;
public class <warning descr="Use UiDataProvider instead of DataProvider">MyJComponent</warning> extends JComponent implements DataProvider {}

View File

@@ -0,0 +1,4 @@
import javax.swing.JComponent;
import com.intellij.openapi.actionSystem.UiCompatibleDataProvider;
public class MyJComponentUiCompatibleDataProvider extends JComponent implements UiCompatibleDataProvider {}

View File

@@ -0,0 +1,3 @@
import com.intellij.openapi.actionSystem.DataProvider;
public class NotJComponent implements DataProvider {}

View File

@@ -41,7 +41,7 @@ public class DevkitInspectionsRegistrationCheckTest extends BasePlatformTestCase
List<LocalInspectionEP> devkitInspections = ContainerUtil.filter(LocalInspectionEP.LOCAL_INSPECTION.getExtensionList(), ep -> {
return "DevKit".equals(ep.getPluginDescriptor().getPluginId().getIdString());
});
assertEquals("Mismatch in total inspections, check classpath in test run configuration (intellij.devkit.plugin)", 72,
assertEquals("Mismatch in total inspections, check classpath in test run configuration (intellij.devkit.plugin)", 73,
devkitInspections.size());
List<LocalInspectionEP> disabledInspections = ContainerUtil.filter(devkitInspections, ep -> !ep.enabledByDefault);

View File

@@ -0,0 +1,46 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.idea.devkit.inspections
import com.intellij.testFramework.TestDataPath
import org.jetbrains.idea.devkit.DevkitJavaTestsUtil
import org.jetbrains.idea.devkit.inspections.quickfix.LightDevKitInspectionFixTestBase
@TestDataPath("\$CONTENT_ROOT/testData/inspections/jComponentDataProvider")
class JComponentDataProviderInspectionTest : LightDevKitInspectionFixTestBase() {
override fun getBasePath() = DevkitJavaTestsUtil.TESTDATA_PATH + "inspections/jComponentDataProvider/"
override fun getFileExtension(): String = "java"
override fun setUp() {
super.setUp()
myFixture.enableInspections(JComponentDataProviderInspection())
myFixture.addClass("""
package com.intellij.openapi.actionSystem;
public interface DataProvider {}
""".trimIndent())
myFixture.addClass("""
package com.intellij.openapi.actionSystem;
public interface UiCompatibleDataProvider {}
""".trimIndent())
myFixture.addClass("""
package com.intellij.openapi.actionSystem;
public interface UiDataProvider {}
""".trimIndent())
}
fun testNotJComponent() {
doTest()
}
fun testMyJComponent() {
doTest()
}
fun testMyJComponentUiCompatibleDataProvider() {
doTest()
}
}