Inner class bean id is equal to bean type

This commit is contained in:
BoykoAlex
2018-07-31 01:43:00 -04:00
parent 21e0543730
commit 92fbe9ecdd
3 changed files with 12 additions and 8 deletions

View File

@@ -74,9 +74,8 @@ public class ComponentInjectionsHoverProvider extends AbstractInjectedIntoHoverP
String typeName = beanType.getName();
ITypeBinding declaringClass = beanType.getDeclaringClass();
while (declaringClass != null) {
typeName = declaringClass.getName() + "." + typeName;
declaringClass = declaringClass.getDeclaringClass();
if (declaringClass != null) {
return getBeanType(beanType).toString();
}
if (StringUtil.hasText(typeName)) {

View File

@@ -142,7 +142,12 @@ public class LiveHoverUtils {
List<LiveBean> relevantBeans = beansModel.getBeansOfName(definedBean.getId());
String type = definedBean.getType();
if (type != null) {
relevantBeans = relevantBeans.stream().filter(bean -> type.equals(bean.getType(true))).collect(Collectors.toList());
// TODO: check if we should check for bean type rather than id that we build ourselves based on type
// if (relevantBeans.isEmpty()) {
// relevantBeans = beansModel.getBeansOfType(type);
// } else {
relevantBeans = relevantBeans.stream().filter(bean -> type.equals(bean.getType(true))).collect(Collectors.toList());
// }
}
return relevantBeans;
}

View File

@@ -595,7 +595,7 @@ public class ComponentInjectionsHoverProviderTest {
public void componentFromInnerClass() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder()
.add(LiveBean.builder()
.id("demoApplication.InnerClass")
.id("com.example.DemoApplication$InnerClass")
.type("com.example.DemoApplication$InnerClass")
.build()
)
@@ -628,7 +628,7 @@ public class ComponentInjectionsHoverProviderTest {
);
editor.assertHighlights("@SpringBootApplication");
editor.assertHoverContains("@SpringBootApplication",
"**Injected `demoApplication.InnerClass` &rarr; _not injected anywhere_** \n" +
"**Injected `com.example.DemoApplication$InnerClass` &rarr; _not injected anywhere_** \n" +
"Process [PID=111, name=`the-app`]"
);
}
@@ -637,7 +637,7 @@ public class ComponentInjectionsHoverProviderTest {
public void componentFromInnerInnerClass() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder()
.add(LiveBean.builder()
.id("demoApplication.InnerClass.InnerInnerClass")
.id("com.example.DemoApplication$InnerClass$InnerInnerClass")
.type("com.example.DemoApplication$InnerClass$InnerInnerClass")
.build()
)
@@ -673,7 +673,7 @@ public class ComponentInjectionsHoverProviderTest {
);
editor.assertHighlights("@SpringBootApplication");
editor.assertHoverContains("@SpringBootApplication",
"**Injected `demoApplication.InnerClass.InnerInnerClass` &rarr; _not injected anywhere_** \n" +
"**Injected `com.example.DemoApplication$InnerClass$InnerInnerClass` &rarr; _not injected anywhere_** \n" +
"Process [PID=111, name=`the-app`]"
);
}