Search in sources :

Example 36 with LiveBeansModel

use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.

the class LiveHoverUtils method findRelevantBeans.

public static Stream<LiveBean> findRelevantBeans(SpringBootApp app, LiveBean definedBean) {
    LiveBeansModel beansModel = app.getBeans();
    if (beansModel != null) {
        Stream<LiveBean> relevantBeans = beansModel.getBeansOfName(definedBean.getId()).stream();
        String type = definedBean.getType();
        if (type != null) {
            relevantBeans = relevantBeans.filter(bean -> type.equals(bean.getType(true)));
        }
        return relevantBeans;
    }
    return Stream.empty();
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Renderables(org.springframework.ide.vscode.commons.util.Renderables) BootJavaLanguageServerComponents(org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents) StringUtil(org.springframework.ide.vscode.commons.util.StringUtil) Stream(java.util.stream.Stream) SpringResource(org.springframework.ide.vscode.boot.java.utils.SpringResource) LiveBean(org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBean) SourceLinks(org.springframework.ide.vscode.boot.java.links.SourceLinks) LiveBeansModel(org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel) SpringBootApp(org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp) Optional(java.util.Optional) SourceLinkFactory(org.springframework.ide.vscode.boot.java.links.SourceLinkFactory) SimpleLanguageServer(org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer) LiveBeansModel(org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel) LiveBean(org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBean)

Example 37 with LiveBeansModel

use of org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel in project sts4 by spring-projects.

the class LiveBeansModelTest method testEmptyModel.

@Test
public void testEmptyModel() throws Exception {
    String json = IOUtils.toString(getResourceAsStream("/live-beans-models/empty-live-beans-model.json"));
    LiveBeansModel model = LiveBeansModel.parse(json);
    List<LiveBean> bean = model.getBeansOfType("org.test.DependencyA");
    assertEquals(0, bean.size());
}
Also used : LiveBeansModel(org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel) LiveBean(org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBean) Test(org.junit.Test)

Aggregations

LiveBeansModel (org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel)37 Test (org.junit.Test)33 Editor (org.springframework.ide.vscode.languageserver.testharness.Editor)29 LiveBean (org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBean)7 SpringBootApp (org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp)4 Hover (org.eclipse.lsp4j.Hover)3 Path (java.nio.file.Path)1 Optional (java.util.Optional)1 Stream (java.util.stream.Stream)1 BootJavaLanguageServerComponents (org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents)1 SourceLinkFactory (org.springframework.ide.vscode.boot.java.links.SourceLinkFactory)1 SourceLinks (org.springframework.ide.vscode.boot.java.links.SourceLinks)1 SpringResource (org.springframework.ide.vscode.boot.java.utils.SpringResource)1 IJavaProject (org.springframework.ide.vscode.commons.java.IJavaProject)1 SimpleLanguageServer (org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer)1 Renderables (org.springframework.ide.vscode.commons.util.Renderables)1 StringUtil (org.springframework.ide.vscode.commons.util.StringUtil)1