mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
devkit: restore references to classes in custom attributes of extensions
Class converter wasn't registered for custom attributes of extensions after b301f92a7d, breaking highlighting, completion and rename for class references in such attributes (e.g. IDEA-140250). This reverts the problematic commit and adds tests for such cases.
This commit is contained in:
@@ -153,7 +153,7 @@ public class ExtensionDomExtender extends DomExtender<Extensions> {
|
||||
final String attrName = getStringAttribute(attrAnno, "value", evalHelper, fieldName);
|
||||
if (attrName != null) {
|
||||
Class clazz = String.class;
|
||||
if (withElement != null && isClassField(fieldName)) {
|
||||
if (withElement != null || isClassField(fieldName)) {
|
||||
clazz = PsiClass.class;
|
||||
} else if (PsiType.BOOLEAN.equals(field.getType())) {
|
||||
clazz = Boolean.class;
|
||||
@@ -200,17 +200,16 @@ public class ExtensionDomExtender extends DomExtender<Extensions> {
|
||||
}
|
||||
|
||||
private static void markAsClass(DomExtension extension, String fieldName, @Nullable With withElement) {
|
||||
if (withElement == null) return;
|
||||
|
||||
final String withClassName = withElement.getImplements().getStringValue();
|
||||
extension.addCustomAnnotation(new ExtendClassImpl() {
|
||||
@Override
|
||||
public String value() {
|
||||
return withClassName;
|
||||
}
|
||||
});
|
||||
|
||||
if (isClassField(fieldName)) {
|
||||
if (withElement != null) {
|
||||
final String withClassName = withElement.getImplements().getStringValue();
|
||||
extension.addCustomAnnotation(new ExtendClassImpl() {
|
||||
@Override
|
||||
public String value() {
|
||||
return withClassName;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (withElement != null || isClassField(fieldName)) {
|
||||
extension.setConverter(CLASS_CONVERTER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
<<error descr="Deprecated EP 'com.intellij.myPlugin.deprecatedEP'">myPlugin.deprecatedEP</error> implementation="foo.MyDeprecatedEPImpl"/>
|
||||
|
||||
<myService serviceImplementation="foo.<error descr="Cannot resolve class 'MyInvalid'">MyInvalid</error>"/>
|
||||
|
||||
<myService serviceImplementation="foo.MyRunnable"/>
|
||||
<myPlugin.foo.bar implementation="java.util.ArrayList"/>
|
||||
<completion.contributor/>
|
||||
<custom.custom/>
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<idea-plugin>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<myService serviceImplementation="Fuba<caret>"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<idea-plugin>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<myService serviceImplementation="foo.Foo$Fubar<caret>"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
+22
@@ -92,6 +92,7 @@ class PluginXmlFunctionalTest extends JavaCodeInsightFixtureTestCase {
|
||||
<id>com.intellij</id>
|
||||
<extensionPoints>
|
||||
<extensionPoint name="completion.contributor"/>
|
||||
<extensionPoint name="myService" beanClass="foo.MyServiceDescriptor"/>
|
||||
</extensionPoints>
|
||||
""")
|
||||
addPluginXml("indirect", """
|
||||
@@ -110,6 +111,9 @@ class PluginXmlFunctionalTest extends JavaCodeInsightFixtureTestCase {
|
||||
myFixture.addClass("package foo; public class MyRunnable implements java.lang.Runnable {}")
|
||||
myFixture.addClass("package foo; @Deprecated public abstract class MyDeprecatedEP {}")
|
||||
myFixture.addClass("package foo; public class MyDeprecatedEPImpl extends foo.MyDeprecatedEP {}")
|
||||
myFixture.addClass("package foo;\n" +
|
||||
"import com.intellij.util.xmlb.annotations.Attribute;\n" +
|
||||
"public class MyServiceDescriptor { @Attribute public String serviceImplementation; }")
|
||||
|
||||
configureByFile()
|
||||
myFixture.checkHighlighting(true, false, false)
|
||||
@@ -181,6 +185,24 @@ class PluginXmlFunctionalTest extends JavaCodeInsightFixtureTestCase {
|
||||
myFixture.checkResultByFile(getTestName(false) + "_after.xml")
|
||||
}
|
||||
|
||||
void testInnerClassCompletionInService() {
|
||||
addPluginXml("idea_core", """
|
||||
<id>com.intellij</id>
|
||||
<extensionPoints>
|
||||
<extensionPoint name="completion.contributor"/>
|
||||
<extensionPoint name="myService" beanClass="foo.MyServiceDescriptor"/>
|
||||
</extensionPoints>
|
||||
""")
|
||||
myFixture.addClass("package foo;\n" +
|
||||
"import com.intellij.util.xmlb.annotations.Attribute;\n" +
|
||||
"public class MyServiceDescriptor { @Attribute public String serviceImplementation; }")
|
||||
myFixture.addClass("package foo; public class Foo { public static class Fubar {} }")
|
||||
myFixture.configureByFile(getTestName(false) + ".xml")
|
||||
myFixture.completeBasic()
|
||||
myFixture.type('\n')
|
||||
myFixture.checkResultByFile(getTestName(false) + "_after.xml")
|
||||
}
|
||||
|
||||
void testInnerClassSmartCompletion() {
|
||||
myFixture.addClass("package foo; public class Foo { public static class Fubar extends Foo {} }")
|
||||
myFixture.configureByFile(getTestName(false) + ".xml")
|
||||
|
||||
Reference in New Issue
Block a user