Account for Boot 3 bean type CGLib suffix
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2018 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -98,15 +98,7 @@ public class LiveBean {
|
||||
|
||||
if (type != null) {
|
||||
if (stripCGLib) {
|
||||
int chop = type.indexOf("$$EnhancerBySpringCGLIB$$");
|
||||
if (chop >= 0) {
|
||||
type = type.substring(0, chop);
|
||||
}
|
||||
|
||||
chop = type.indexOf("$$Lambda$");
|
||||
if (chop >= 0) {
|
||||
type = type.substring(0, chop);
|
||||
}
|
||||
type = getTypeWithoutCGLib(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,4 +122,19 @@ public class LiveBean {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static String getTypeWithoutCGLib(String type) {
|
||||
int chop = type.indexOf("$$EnhancerBySpringCGLIB$$");
|
||||
if (chop < 0) {
|
||||
chop = type.indexOf("$$SpringCGLIB$$");
|
||||
}
|
||||
if (chop >= 0) {
|
||||
type = type.substring(0, chop);
|
||||
}
|
||||
|
||||
chop = type.indexOf("$$Lambda$");
|
||||
if (chop >= 0) {
|
||||
type = type.substring(0, chop);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2020 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -32,6 +32,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.HoverProvider;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.LiveHoverUtils;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveBean;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.LiveRequestMapping;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.RequestMappingMetrics;
|
||||
import org.springframework.ide.vscode.boot.java.livehover.v2.SpringProcessLiveData;
|
||||
@@ -213,12 +214,7 @@ public class RequestMappingHoverProvider implements HoverProvider {
|
||||
String rqClassName = rm.getFullyQualifiedClassName();
|
||||
|
||||
if (rqClassName != null) {
|
||||
int chop = rqClassName.indexOf("$$EnhancerBySpringCGLIB$$");
|
||||
if (chop >= 0) {
|
||||
rqClassName = rqClassName.substring(0, chop);
|
||||
}
|
||||
|
||||
rqClassName = rqClassName.replace('$', '.');
|
||||
rqClassName = LiveBean.getTypeWithoutCGLib(rqClassName).replace('$', '.');
|
||||
|
||||
ASTNode parent = annotation.getParent();
|
||||
if (parent instanceof MethodDeclaration) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017, 2019 Pivotal, Inc.
|
||||
* Copyright (c) 2017, 2023 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@@ -327,6 +327,61 @@ public class ComponentInjectionsHoverProviderTest {
|
||||
"Process [PID=111, name=`the-app`]\n"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void componentWithOneBoot3CGILibInjection() throws Exception {
|
||||
LiveBeansModel beans = LiveBeansModel.builder()
|
||||
.add(LiveBean.builder()
|
||||
.id("fooImplementation")
|
||||
.type("com.example.FooImplementation$$SpringCGLIB$$Blah")
|
||||
.build()
|
||||
)
|
||||
.add(LiveBean.builder()
|
||||
.id("myController")
|
||||
.type("com.example.MyController$$SpringCGLIB$$Blah")
|
||||
.dependencies("fooImplementation")
|
||||
.build()
|
||||
)
|
||||
.add(LiveBean.builder()
|
||||
.id("irrelevantBean")
|
||||
.type("com.example.IrrelevantBean$$SpringCGLIB$$Blah")
|
||||
.dependencies("myController")
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
|
||||
SpringProcessLiveData liveData = new SpringProcessLiveDataBuilder()
|
||||
.processID("111")
|
||||
.processName("the-app")
|
||||
.beans(beans)
|
||||
.build();
|
||||
liveDataProvider.add("processkey", liveData);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Component;\n" +
|
||||
"\n" +
|
||||
"@Component\n" +
|
||||
"public class FooImplementation implements Foo {\n" +
|
||||
"\n" +
|
||||
" @Override\n" +
|
||||
" public void doSomeFoo() {\n" +
|
||||
" System.out.println(\"Foo do do do!\");\n" +
|
||||
" }\n" +
|
||||
"}\n"
|
||||
);
|
||||
editor.assertHighlights("@Component");
|
||||
editor.assertTrimmedHover("@Component",
|
||||
"**→ `MyController`**\n" +
|
||||
"- Bean: `myController` \n" +
|
||||
" Type: `com.example.MyController`\n" +
|
||||
" \n" +
|
||||
"Bean id: `fooImplementation` \n" +
|
||||
"Process [PID=111, name=`the-app`]\n"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void componentWithMultipleInjections() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user