mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] highlights external implementations in 'provides' (IDEA-169193)
This commit is contained in:
+5
@@ -359,6 +359,11 @@ public class ModuleHighlightUtil {
|
||||
PsiClass implClass = (PsiClass)implTarget;
|
||||
PsiMethod provider;
|
||||
|
||||
if (findModule(statement) != findModule(implClass)) {
|
||||
String message = JavaErrorMessages.message("module.service.alien");
|
||||
results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).descriptionAndTooltip(message).create());
|
||||
}
|
||||
|
||||
if (InheritanceUtil.isInheritorOrSelf(implClass, (PsiClass)intTarget, true)) {
|
||||
if (implClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
String message = JavaErrorMessages.message("module.service.abstract", implClass.getName());
|
||||
|
||||
@@ -410,6 +410,7 @@ module.opens.in.weak.module='opens' is not allowed in an open module
|
||||
package.not.found=Package not found: {0}
|
||||
package.is.empty=Package is empty: {0}
|
||||
module.service.enum=The service definition is an enum: {0}
|
||||
module.service.alien=The service implementation must be defined in the same module as the provides directive
|
||||
module.service.impl=The service implementation type must be a subtype of the service interface type, or have a public static no-args 'provider' method
|
||||
module.service.abstract=The service implementation is an abstract class: {0}
|
||||
module.service.inner=The service implementation is an inner class: {0}
|
||||
|
||||
@@ -151,8 +151,12 @@ class ModuleHighlightingTest : LightJava9ModulesCodeInsightFixtureTestCase() {
|
||||
addFile("pkg/main/Impl7.java", "package pkg.main;\npublic class Impl7 {\n public static void provider();\n}")
|
||||
addFile("pkg/main/Impl8.java", "package pkg.main;\npublic class Impl8 {\n public static C provider();\n}")
|
||||
addFile("pkg/main/Impl9.java", "package pkg.main;\npublic class Impl9 {\n public class Inner implements C { }\n}")
|
||||
addFile("module-info.java", "module M2 {\n exports pkg.m2;\n}", M2)
|
||||
addFile("pkg/m2/C.java", "package pkg.m2;\npublic class C { }", M2)
|
||||
addFile("pkg/m2/Impl.java", "package pkg.m2;\npublic class Impl extends C { }", M2)
|
||||
highlight("""
|
||||
module M {
|
||||
requires M2;
|
||||
provides pkg.main.C with pkg.main.<error descr="Cannot resolve symbol 'NoImpl'">NoImpl</error>;
|
||||
provides pkg.main.C with pkg.main.<error descr="'pkg.main.Impl1' is not public in 'pkg.main'. Cannot be accessed from outside package">Impl1</error>;
|
||||
provides pkg.main.C with pkg.main.<error descr="The service implementation type must be a subtype of the service interface type, or have a public static no-args 'provider' method">Impl2</error>;
|
||||
@@ -163,6 +167,7 @@ class ModuleHighlightingTest : LightJava9ModulesCodeInsightFixtureTestCase() {
|
||||
provides pkg.main.C with pkg.main.<error descr="The 'provider' method return type must be a subtype of the service interface type: Impl7">Impl7</error>;
|
||||
provides pkg.main.C with pkg.main.Impl8;
|
||||
provides pkg.main.C with pkg.main.Impl9.<error descr="The service implementation is an inner class: Inner">Inner</error>;
|
||||
provides pkg.m2.C with pkg.m2.<error descr="The service implementation must be defined in the same module as the provides directive">Impl</error>;
|
||||
}""".trimIndent())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user