GH-1499: do not check bean registrar imports when it is not a bean registrar implementation
This commit is contained in:
@@ -16,6 +16,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -26,6 +27,7 @@ import org.eclipse.jdt.core.dom.TypeDeclaration;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.Boot4JavaProblemType;
|
||||
import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
import org.springframework.ide.vscode.commons.Version;
|
||||
import org.springframework.ide.vscode.commons.java.IClasspathUtil;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
@@ -73,6 +75,10 @@ public class BeanRegistrarDeclarationReconciler implements JdtAstReconciler {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ASTUtils.findInTypeHierarchy(type, Set.of(Annotations.BEAN_REGISTRAR_INTERFACE)) == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
List<Bean> configBeans = new ArrayList<>();
|
||||
Path p = Path.of(docURI);
|
||||
List<Path> sourceFolders = IClasspathUtil.getSourceFolders(project.getClasspath()).map(f -> f.toPath()).filter(f -> p.startsWith(f)).collect(Collectors.toList());
|
||||
|
||||
@@ -58,6 +58,33 @@ public class BeanRegistrarDeclarationReconcilerTest extends BaseReconcilerTest {
|
||||
return new BeanRegistrarDeclarationReconciler(new QuickfixRegistry(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void noValidationIfNoBeanRegistrar() throws Throwable {
|
||||
String source = """
|
||||
package com.example.demo;
|
||||
|
||||
import org.springframework.beans.factory.BeanRegistrar;
|
||||
import org.springframework.beans.factory.BeanRegistry;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
public class MyBeanRegistrar {
|
||||
|
||||
public void register(BeanRegistry registry, Environment env) {
|
||||
}
|
||||
|
||||
}
|
||||
""";
|
||||
List<ReconcileProblem> problems = reconcile(() -> {
|
||||
SpringMetamodelIndex springIndex = new SpringMetamodelIndex();
|
||||
|
||||
BeanRegistrarDeclarationReconciler r = new BeanRegistrarDeclarationReconciler(new QuickfixRegistry(), springIndex);
|
||||
|
||||
return r;
|
||||
}, "A.java", source, false);
|
||||
|
||||
assertEquals(0, problems.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void noConfigBeans() throws Throwable {
|
||||
String source = """
|
||||
|
||||
Reference in New Issue
Block a user