Merge branch 'master' of github.com:spring-projects/sts4

This commit is contained in:
Kris De Volder
2017-12-11 08:56:18 -08:00
50 changed files with 334 additions and 100 deletions

6
.gitignore vendored
View File

@@ -14,6 +14,12 @@
eclipse-language-servers/**/*.jar
*.war
*.ear
**/.sts4-cache/*
**/test-projects/**/*.classpath
**/test-projects/**/*.vscode
**/test-projects/**/*.project
**/test-projects/**/*.settings
**/test-projects/**/*.springBeans
# Exceptions
!**/.mvn/wrapper/maven-wrapper.jar

View File

@@ -1,6 +1,6 @@
STS4 - Dev Environment Setup
# STS4 - Dev Environment Setup
# Running the STS4 Boot Java Language Server locally
## Running the STS4 Boot Java Language Server locally
Import the headless-services modules into your workspace as existing Maven projects.
Startup the boot java language server with:
@@ -30,7 +30,7 @@ Save, then launch by pressing `F5`.
This connects the VSCode extension to the locally running language server.
It also uses port 5007
# Connect local STS4 Boot Java LS to Eclipse runtime workbench
## Connect local STS4 Boot Java LS to Eclipse runtime workbench
Startup Eclipse or STS (3). I.e something that support for RCP / plugin development.
@@ -43,7 +43,7 @@ The language server plugin is: org.springframework.tooling.boot.java.ls
Add Vmargs: -Dboot-java-ls-port=5007
This lets the Eclipse language server extension connect to the locally running language server on port 5007
# Additional Resources:
## Additional Resources:
- Generic editor source code (used by lsp4e as a dependency): https://github.com/eclipse/eclipse.platform.text
Not sure which version of this you should checkout, it probably depends on your version of Eclipse as this is part

View File

@@ -3,15 +3,15 @@ Bundle-ManifestVersion: 2
Bundle-Name: Spring Boot Java Language Server
Bundle-Vendor: Pivotal, Inc.
Bundle-SymbolicName: org.springframework.tooling.boot.java.ls;singleton:=true
Bundle-Version: 0.0.10.qualifier
Bundle-Version: 0.2.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.9.0",
org.eclipse.core.runtime;bundle-version="3.12.0",
org.eclipse.lsp4e;bundle-version="0.1.0",
org.eclipse.lsp4e;bundle-version="0.5.0",
org.eclipse.ui.genericeditor;bundle-version="1.0.0",
org.eclipse.jface.text;bundle-version="3.11.100",
org.eclipse.jdt.ui;bundle-version="3.13.0",
org.eclipse.lsp4j,
org.eclipse.lsp4j;bundle-version="0.4.0",
org.eclipse.ui.workbench,
org.eclipse.jface,
org.eclipse.xtext.xbase.lib,
@@ -20,8 +20,8 @@ Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.9.0",
org.eclipse.ui
Import-Package: com.google.gson;version="2.7.0",
org.eclipse.jface.preference,
org.eclipse.lsp4j.jsonrpc.messages;version="0.1.0.v20170117-0759",
org.eclipse.lsp4j.services;version="0.1.0.v20170117-0759",
org.eclipse.lsp4j.jsonrpc.messages;version="0.4.0",
org.eclipse.lsp4j.services;version="0.4.0",
org.osgi.framework
Bundle-Activator: org.springframework.tooling.boot.java.ls.BootJavaLanguageServerPlugin
Bundle-ActivationPolicy: lazy

View File

@@ -12,14 +12,14 @@
</parent>
<artifactId>org.springframework.tooling.boot.java.ls</artifactId>
<version>0.0.10-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>boot-java-language-server</artifactId>
<version>0.0.10-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -16,7 +16,7 @@ package org.springframework.tooling.boot.java.ls;
public class Constants {
public static final String PLUGIN_ID = "org.springframework.tooling.boot.java.ls";
public static final String LANGUAGE_SERVER_VERSION = "0.0.10-SNAPSHOT.jar";
public static final String LANGUAGE_SERVER_VERSION = "0.2.0-SNAPSHOT.jar";
public static final String PREF_BOOT_HINTS = "boot-java.boot-hints.on";

View File

@@ -3,22 +3,22 @@ Bundle-ManifestVersion: 2
Bundle-Name: BOSH Manifest Language Server
Bundle-Vendor: Pivotal, Inc.
Bundle-SymbolicName: org.springframework.tooling.bosh.ls;singleton:=true
Bundle-Version: 0.0.10.qualifier
Bundle-Version: 0.2.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.9.0",
org.eclipse.core.runtime;bundle-version="3.12.0",
org.eclipse.lsp4e;bundle-version="0.1.0",
org.eclipse.lsp4e;bundle-version="0.5.0",
org.eclipse.ui.genericeditor;bundle-version="1.0.0",
org.eclipse.jface.text;bundle-version="3.11.100",
org.eclipse.jdt.ui;bundle-version="3.13.0",
org.eclipse.tm4e.core;bundle-version="0.1.0",
org.eclipse.tm4e.ui;bundle-version="0.1.0",
org.eclipse.lsp4j,
org.eclipse.lsp4j;bundle-version="0.4.0",
org.eclipse.ui.workbench,
org.eclipse.jface,
org.springframework.tooling.ls.eclipse.commons;bundle-version="4.0.0"
Import-Package: com.google.gson;version="2.7.0",
org.eclipse.jface.preference,
org.eclipse.lsp4j.jsonrpc.messages;version="0.1.0.v20170117-0759",
org.eclipse.lsp4j.services;version="0.1.0.v20170117-0759",
org.eclipse.lsp4j.jsonrpc.messages;version="0.4.0",
org.eclipse.lsp4j.services;version="0.4.0",
org.osgi.framework

View File

@@ -12,14 +12,14 @@
</parent>
<artifactId>org.springframework.tooling.bosh.ls</artifactId>
<version>0.0.10-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>bosh-language-server</artifactId>
<version>0.0.10-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.springframework.ide.eclipse</groupId>

View File

@@ -48,7 +48,7 @@ public class BoshLanguageServer extends STS4LanguageServerProcessStreamConnector
}
protected String getLanguageServerJARLocation() {
String languageServer = "bosh-language-server-" + Constants.LANGUAGE_SERVER_VERSION + "-SNAPSHOT.jar";
String languageServer = "bosh-language-server-" + Constants.LANGUAGE_SERVER_VERSION + ".jar";
Bundle bundle = Platform.getBundle(Constants.PLUGIN_ID);
File dataFile = bundle.getDataFile(languageServer);

View File

@@ -16,6 +16,6 @@ package org.springframework.tooling.bosh.ls;
public class Constants {
public static final String PLUGIN_ID = "org.springframework.tooling.bosh.ls";
public static final String LANGUAGE_SERVER_VERSION = "0.0.10";
public static final String LANGUAGE_SERVER_VERSION = "0.2.0-SNAPSHOT";
}

View File

@@ -7,7 +7,7 @@ Bundle-Version: 4.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.9.0",
org.eclipse.core.runtime;bundle-version="3.12.0",
org.eclipse.lsp4e;bundle-version="0.1.0",
org.eclipse.lsp4e;bundle-version="0.5.0",
org.eclipse.ui.genericeditor;bundle-version="1.0.0",
org.eclipse.jface.text;bundle-version="3.11.100",
org.eclipse.jdt.ui;bundle-version="3.13.0",
@@ -15,6 +15,6 @@ Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.9.0",
org.eclipse.tm4e.ui;bundle-version="0.1.0",
org.springframework.tooling.cloudfoundry.manifest.ls;bundle-version="0.0.9"
Import-Package: org.eclipse.jface.preference,
org.eclipse.lsp4j.jsonrpc.messages;version="0.1.0.v20170117-0759",
org.eclipse.lsp4j.services;version="0.1.0.v20170117-0759",
org.eclipse.lsp4j.jsonrpc.messages;version="0.4.0",
org.eclipse.lsp4j.services;version="0.4.0",
org.osgi.framework

View File

@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: Cloud Foundry Manifest Language Server
Bundle-Vendor: Pivotal, Inc.
Bundle-SymbolicName: org.springframework.tooling.cloudfoundry.manifest.ls;singleton:=true
Bundle-Version: 0.0.10.qualifier
Bundle-Version: 0.2.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.8.0",
org.eclipse.core.runtime;bundle-version="3.12.0",

View File

@@ -12,14 +12,14 @@
</parent>
<artifactId>org.springframework.tooling.cloudfoundry.manifest.ls</artifactId>
<version>0.0.10-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>manifest-yaml-language-server</artifactId>
<version>0.0.10-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
</dependency>
</dependencies>

View File

@@ -16,6 +16,6 @@ package org.springframework.tooling.cloudfoundry.manifest.ls;
public class Constants {
public static final String PLUGIN_ID = "org.springframework.tooling.cloudfoundry.manifest.ls";
public static final String LANGUAGE_SERVER_VERSION = "0.0.10-SNAPSHOT.jar";
public static final String LANGUAGE_SERVER_VERSION = "0.2.0-SNAPSHOT.jar";
}

View File

@@ -3,22 +3,22 @@ Bundle-ManifestVersion: 2
Bundle-Name: Concourse Pipeline Language Server
Bundle-Vendor: Pivotal, Inc.
Bundle-SymbolicName: org.springframework.tooling.concourse.ls;singleton:=true
Bundle-Version: 0.0.10.qualifier
Bundle-Version: 0.2.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.9.0",
org.eclipse.core.runtime;bundle-version="3.12.0",
org.eclipse.lsp4e;bundle-version="0.1.0",
org.eclipse.lsp4e;bundle-version="0.5.0",
org.eclipse.ui.genericeditor;bundle-version="1.0.0",
org.eclipse.jface.text;bundle-version="3.11.100",
org.eclipse.jdt.ui;bundle-version="3.13.0",
org.eclipse.tm4e.core;bundle-version="0.1.0",
org.eclipse.tm4e.ui;bundle-version="0.1.0",
org.eclipse.lsp4j,
org.eclipse.lsp4j;bundle-version="0.4.0",
org.eclipse.ui.workbench,
org.eclipse.jface,
org.springframework.tooling.ls.eclipse.commons;bundle-version="4.0.0"
Import-Package: com.google.gson;version="2.7.0",
org.eclipse.jface.preference,
org.eclipse.lsp4j.jsonrpc.messages;version="0.1.0.v20170117-0759",
org.eclipse.lsp4j.services;version="0.1.0.v20170117-0759",
org.eclipse.lsp4j.jsonrpc.messages;version="0.4.0",
org.eclipse.lsp4j.services;version="0.4.0",
org.osgi.framework

View File

@@ -12,14 +12,14 @@
</parent>
<artifactId>org.springframework.tooling.concourse.ls</artifactId>
<version>0.0.10-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>concourse-language-server</artifactId>
<version>0.0.10-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.springframework.ide.eclipse</groupId>

View File

@@ -48,7 +48,7 @@ public class ConcourseLanguageServer extends STS4LanguageServerProcessStreamConn
}
protected String getLanguageServerJARLocation() {
String languageServer = "concourse-language-server-" + Constants.LANGUAGE_SERVER_VERSION + "-SNAPSHOT.jar";
String languageServer = "concourse-language-server-" + Constants.LANGUAGE_SERVER_VERSION + ".jar";
Bundle bundle = Platform.getBundle(Constants.PLUGIN_ID);
File dataFile = bundle.getDataFile(languageServer);

View File

@@ -16,6 +16,6 @@ package org.springframework.tooling.concourse.ls;
public class Constants {
public static final String PLUGIN_ID = "org.springframework.tooling.concourse.ls";
public static final String LANGUAGE_SERVER_VERSION = "0.0.10";
public static final String LANGUAGE_SERVER_VERSION = "0.2.0-SNAPSHOT";
}

View File

@@ -7,9 +7,9 @@ Bundle-Vendor: Pivotal, Inc.
Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.9.0",
org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.lsp4e;bundle-version="0.3.0",
org.eclipse.lsp4j.jsonrpc,
org.eclipse.lsp4j,
org.eclipse.lsp4e;bundle-version="0.5.0",
org.eclipse.lsp4j.jsonrpc;bundle-version="0.4.0",
org.eclipse.lsp4j;bundle-version="0.4.0",
org.eclipse.ui.workbench.texteditor,
org.eclipse.jface.text,
com.google.guava

View File

@@ -2,11 +2,11 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Goto Symbol Popup
Bundle-SymbolicName: org.springframework.tooling.ls.eclipse.gotosymbol;singleton:=true
Bundle-Version: 0.0.10.qualifier
Bundle-Version: 4.0.0.qualifier
Require-Bundle: org.eclipse.ui,
org.eclipse.ui.workbench.texteditor,
org.eclipse.lsp4e,
org.eclipse.lsp4j,
org.eclipse.lsp4e;bundle-version="0.5.0",
org.eclipse.lsp4j;bundle-version="0.4.0",
org.eclipse.jface.text;bundle-version="3.12.0",
org.eclipse.core.resources;bundle-version="3.12.0",
org.eclipse.core.filebuffers,

View File

@@ -11,6 +11,5 @@
<artifactId>org.springframework.tooling.ls.eclipse.gotosymbol</artifactId>
<packaging>eclipse-plugin</packaging>
<version>0.0.10-SNAPSHOT</version>
</project>

View File

@@ -3,22 +3,22 @@ Bundle-ManifestVersion: 2
Bundle-Name: Spring Boot Properties Language Server
Bundle-Vendor: Pivotal, Inc.
Bundle-SymbolicName: org.springframework.tooling.properties.ls;singleton:=true
Bundle-Version: 0.0.10.qualifier
Bundle-Version: 0.2.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.9.0",
org.eclipse.core.runtime;bundle-version="3.12.0",
org.eclipse.lsp4e;bundle-version="0.1.0",
org.eclipse.lsp4e;bundle-version="0.5.0",
org.eclipse.ui.genericeditor;bundle-version="1.0.0",
org.eclipse.jface.text;bundle-version="3.11.100",
org.eclipse.jdt.ui;bundle-version="3.13.0",
org.eclipse.tm4e.core;bundle-version="0.1.0",
org.eclipse.tm4e.ui;bundle-version="0.1.0",
org.eclipse.lsp4j,
org.eclipse.lsp4j;bundle-version="0.4.0",
org.eclipse.ui.workbench,
org.eclipse.jface,
org.springframework.tooling.ls.eclipse.commons;bundle-version="4.0.0"
Import-Package: com.google.gson;version="2.7.0",
org.eclipse.jface.preference,
org.eclipse.lsp4j.jsonrpc.messages;version="0.1.0.v20170117-0759",
org.eclipse.lsp4j.services;version="0.1.0.v20170117-0759",
org.eclipse.lsp4j.jsonrpc.messages;version="0.4.0",
org.eclipse.lsp4j.services;version="0.4.0",
org.osgi.framework

View File

@@ -12,14 +12,14 @@
</parent>
<artifactId>org.springframework.tooling.properties.ls</artifactId>
<version>0.0.10-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>boot-properties-language-server</artifactId>
<version>0.0.10-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.springframework.ide.eclipse</groupId>

View File

@@ -16,6 +16,6 @@ package org.springframework.tooling.properties.ls;
public class Constants {
public static final String PLUGIN_ID = "org.springframework.tooling.properties.ls";
public static final String LANGUAGE_SERVER_VERSION = "0.0.10";
public static final String LANGUAGE_SERVER_VERSION = "0.2.0-SNAPSHOT";
}

View File

@@ -48,7 +48,7 @@ public class SpringBootPropertiesLanguageServer extends STS4LanguageServerProces
}
protected String getLanguageServerJARLocation() {
String languageServer = "boot-properties-language-server-" + Constants.LANGUAGE_SERVER_VERSION + "-SNAPSHOT.jar";
String languageServer = "boot-properties-language-server-" + Constants.LANGUAGE_SERVER_VERSION + ".jar";
Bundle bundle = Platform.getBundle(Constants.PLUGIN_ID);
File dataFile = bundle.getDataFile(languageServer);

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../commons/pom.xml</relativePath>
</parent>

View File

@@ -92,6 +92,13 @@ public class ComponentInjectionsHoverProvider extends AbstractInjectedIntoHoverP
return ASTUtils.getAttribute(annotation, "value").flatMap(ASTUtils::getFirstString)
.orElseGet(() -> {
String typeName = beanType.getName();
ITypeBinding declaringClass = beanType.getDeclaringClass();
while (declaringClass != null) {
typeName = declaringClass.getName() + "." + typeName;
declaringClass = declaringClass.getDeclaringClass();
}
if (StringUtil.hasText(typeName)) {
return Character.toLowerCase(typeName.charAt(0)) + typeName.substring(1);
}

View File

@@ -23,9 +23,9 @@ public class LiveHoverUtils {
public static String showBean(LiveBean bean) {
StringBuilder buf = new StringBuilder("Bean [id: " + bean.getId());
String type = bean.getType();
if (type!=null) {
buf.append(", type: `"+type+"`");
String type = bean.getType(true);
if (type != null) {
buf.append(", type: `" + type + "`");
}
buf.append(']');
return buf.toString();
@@ -35,10 +35,10 @@ public class LiveHoverUtils {
String newline = " \n"+indentStr; //Note: the double space before newline makes markdown see it as a real line break
StringBuilder buf = new StringBuilder("Bean: ");
buf.append(bean.getId());
String type = bean.getType();
if (type!=null) {
String type = bean.getType(true);
if (type != null) {
buf.append(newline);
buf.append("Type: `"+type+"`");
buf.append("Type: `" + type + "`");
}
String resource = bean.getResource();
if (StringUtil.hasText(resource)) {

View File

@@ -119,19 +119,28 @@ public class RequestMappingHoverProvider implements HoverProvider {
private boolean methodMatchesAnnotation(Annotation annotation, RequestMapping rm) {
String rqClassName = rm.getFullyQualifiedClassName();
ASTNode parent = annotation.getParent();
if (parent instanceof MethodDeclaration) {
MethodDeclaration methodDec = (MethodDeclaration) parent;
IMethodBinding binding = methodDec.resolveBinding();
return binding.getDeclaringClass().getQualifiedName().equals(rqClassName)
&& binding.getName().equals(rm.getMethodName())
&& Arrays.equals(Arrays.stream(binding.getParameterTypes())
.map(t -> t.getTypeDeclaration().getQualifiedName())
.toArray(String[]::new),
rm.getMethodParameters());
// } else if (parent instanceof TypeDeclaration) {
// TypeDeclaration typeDec = (TypeDeclaration) parent;
// return typeDec.resolveBinding().getQualifiedName().equals(rqClassName);
if (rqClassName != null) {
int chop = rqClassName.indexOf("$$EnhancerBySpringCGLIB$$");
if (chop >= 0) {
rqClassName = rqClassName.substring(0, chop);
}
rqClassName = rqClassName.replace('$', '.');
ASTNode parent = annotation.getParent();
if (parent instanceof MethodDeclaration) {
MethodDeclaration methodDec = (MethodDeclaration) parent;
IMethodBinding binding = methodDec.resolveBinding();
return binding.getDeclaringClass().getQualifiedName().equals(rqClassName)
&& binding.getName().equals(rm.getMethodName())
&& Arrays.equals(Arrays.stream(binding.getParameterTypes())
.map(t -> t.getTypeDeclaration().getQualifiedName())
.toArray(String[]::new),
rm.getMethodParameters());
// } else if (parent instanceof TypeDeclaration) {
// TypeDeclaration typeDec = (TypeDeclaration) parent;
// return typeDec.resolveBinding().getQualifiedName().equals(rqClassName);
}
}
return false;
}

View File

@@ -219,6 +219,66 @@ public class BeanInjectedIntoHoverProviderTest {
);
}
@Test
public void beanFromInnerClassWithOneInjection() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder()
.add(LiveBean.builder()
.id("fooImplementation")
.type("hello.FooImplementation")
.build()
)
.add(LiveBean.builder()
.id("myController")
.type("hello.MyController")
.dependencies("fooImplementation")
.build()
)
.add(LiveBean.builder()
.id("irrelevantBean")
.type("com.example.IrrelevantBean")
.dependencies("myController")
.build()
)
.build();
mockAppProvider.builder()
.isSpringBootApp(true)
.processId("111")
.processName("the-app")
.beans(beans)
.build();
Editor editor = harness.newEditor(LanguageId.JAVA,
"package hello;\n" +
"\n" +
"import org.springframework.context.annotation.Bean;\n" +
"import org.springframework.context.annotation.Configuration;\n" +
"import org.springframework.context.annotation.Profile;\n" +
"\n" +
"public class OuterClass {\n" +
" \n" +
" @Configuration\n" +
" public static class InnerClass {\n" +
" \n" +
" @Bean(\"fooImplementation\")\n" +
" Foo someFoo() {\n" +
" return new FooImplementation();\n" +
" }\n" +
" }\n" +
"}"
);
editor.assertHighlights("@Bean");
editor.assertTrimmedHover("@Bean",
"**Injection report for Bean [id: fooImplementation]**\n" +
"\n" +
"Process [PID=111, name=`the-app`]:\n" +
"\n" +
"Bean [id: fooImplementation, type: `hello.FooImplementation`] injected into:\n" +
"\n" +
"- Bean: myController \n" +
" Type: `hello.MyController`\n"
);
}
@Test
public void beanWithFileResource() throws Exception {
Path of = harness.getOutputFolder();

View File

@@ -585,7 +585,8 @@ public class ComponentInjectionsHoverProviderTest {
);
}
@Test public void bug_153072942_SpringBootApplication__withCGLib_is_a_Component() throws Exception {
@Test
public void bug_153072942_SpringBootApplication__withCGLib_is_a_Component() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder()
.add(LiveBean.builder()
.id("demoApplication")
@@ -623,4 +624,88 @@ public class ComponentInjectionsHoverProviderTest {
);
}
@Test
public void componentFromInnerClass() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder()
.add(LiveBean.builder()
.id("demoApplication.InnerClass")
.type("com.example.DemoApplication$InnerClass")
.build()
)
.build();
mockAppProvider.builder()
.isSpringBootApp(true)
.processId("111")
.processName("the-app")
.beans(beans)
.build();
Editor editor = harness.newEditor(LanguageId.JAVA,
"package com.example;\n" +
"\n" +
"import org.springframework.boot.SpringApplication;\n" +
"import org.springframework.boot.autoconfigure.SpringBootApplication;\n" +
"import org.springframework.context.annotation.Bean;\n" +
"import org.springframework.web.client.RestTemplate;\n" +
"\n" +
"public class DemoApplication {\n" +
" \n" +
" @SpringBootApplication\n" +
" public static class InnerClass {\n" +
" \n" +
" public static void main(String[] args) {\n" +
" SpringApplication.run(DemoApplication.InnerClass.class, args);\n" +
" }\n" +
" }\n" +
"}\n"
);
editor.assertHighlights("@SpringBootApplication");
editor.assertHoverContains("@SpringBootApplication",
"**Injection report for Bean [id: demoApplication.InnerClass, type: `com.example.DemoApplication.InnerClass`]**"
);
}
@Test
public void componentFromInnerInnerClass() throws Exception {
LiveBeansModel beans = LiveBeansModel.builder()
.add(LiveBean.builder()
.id("demoApplication.InnerClass.InnerInnerClass")
.type("com.example.DemoApplication$InnerClass$InnerInnerClass")
.build()
)
.build();
mockAppProvider.builder()
.isSpringBootApp(true)
.processId("111")
.processName("the-app")
.beans(beans)
.build();
Editor editor = harness.newEditor(LanguageId.JAVA,
"package com.example;\n" +
"\n" +
"import org.springframework.boot.SpringApplication;\n" +
"import org.springframework.boot.autoconfigure.SpringBootApplication;\n" +
"import org.springframework.context.annotation.Bean;\n" +
"import org.springframework.web.client.RestTemplate;\n" +
"\n" +
"public class DemoApplication {\n" +
" \n" +
" public static class InnerClass {\n" +
" \n" +
" @SpringBootApplication\n" +
" public static class InnerInnerClass {\n" +
" \n" +
" public static void main(String[] args) {\n" +
" SpringApplication.run(DemoApplication.InnerClass.InnerInnerClass.class, args);\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n"
);
editor.assertHighlights("@SpringBootApplication");
editor.assertHoverContains("@SpringBootApplication",
"**Injection report for Bean [id: demoApplication.InnerClass.InnerInnerClass, type: `com.example.DemoApplication.InnerClass.InnerInnerClass`]**"
);
}
}

View File

@@ -64,6 +64,7 @@ public class RequestMappingLiveHoverTest {
harness.intialize(directory);
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
editor.assertHighlights("@RequestMapping(method=RequestMethod.GET)");
editor.assertHoverContains("@RequestMapping(method=RequestMethod.GET)", "[http://cfapps.io:1111/hello-world](http://cfapps.io:1111/hello-world)\n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
@@ -94,6 +95,8 @@ public class RequestMappingLiveHoverTest {
harness.intialize(directory);
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
editor.assertHighlights("@RequestMapping(\"/hello\")", "@RequestMapping(\"/goodbye\")");
editor.assertHoverContains("@RequestMapping(\"/hello\")", "[http://cfapps.io:999/hello](http://cfapps.io:999/hello)\n" +
"\n" +
"Process [PID=76543, name=`test-request-mapping-live-hover`]");
@@ -214,12 +217,8 @@ public class RequestMappingLiveHoverTest {
docUri);
editor.assertNoHover("@DeleteMapping(\"/greetings\")");
}
@Test
public void testNoHoverHintMethod() throws Exception {
@@ -261,7 +260,6 @@ public class RequestMappingLiveHoverTest {
docUri);
editor.assertNoHover("@PutMapping(\"/greetings\")");
}
@Test
@@ -756,4 +754,39 @@ public class RequestMappingLiveHoverTest {
}
@Test
public void testMappingHoversInInnerClasses() throws Exception {
File directory = new File(
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/InnerClassController.java";
// Build a mock running boot app
mockAppProvider.builder()
.isSpringBootApp(true)
.port("1111")
.processId("22022")
.host("cfapps.io")
.processName("test-request-mapping-live-hover")
// Ugly, but this is real JSON copied from a real live running app. We want the
// mock app to return realistic results if possible
.requestMappings(
"{\"/webjars/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**\":{\"bean\":\"resourceHandlerMapping\"},\"/**/favicon.ico\":{\"bean\":\"faviconHandlerMapping\"},\"{[/hello-world],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public example.Greeting example.HelloWorldController.sayHello(java.lang.String)\"},\"{[/inner-inner-class]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.InnerClassController$InnerController$InnerInnerController.saySomethingSuperInnerClass()\"},\"{[/inner-class]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.InnerClassController$InnerController.saySomething()\"},\"{[/person/{name}],methods=[GET]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.getMapping(java.lang.String)\"},\"{[/delete/{id}],methods=[DELETE]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.removeMe(int)\"},\"{[/goodbye]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.goodbye()\"},\"{[/hello]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.hello()\"},\"{[/postHello],methods=[POST]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.postMethod(java.lang.String)\"},\"{[/put/{id}],methods=[PUT]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public java.lang.String example.RestApi.putMethod(int,java.lang.String)\"},\"{[/error]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)\"},\"{[/error],produces=[text/html]}\":{\"bean\":\"requestMappingHandlerMapping\",\"method\":\"public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)\"}}")
.build();
harness.intialize(directory);
Editor editor = harness.newEditorFromFileUri(docUri, LanguageId.JAVA);
editor.assertHighlights("@RequestMapping(\"/inner-class\")", "@RequestMapping(\"/inner-inner-class\")");
editor.assertHoverContains("@RequestMapping(\"/inner-class\")", "[http://cfapps.io:1111/inner-class](http://cfapps.io:1111/inner-class)\n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
editor.assertHoverContains("@RequestMapping(\"/inner-inner-class\")", "[http://cfapps.io:1111/inner-inner-class](http://cfapps.io:1111/inner-inner-class)\n" +
"\n" +
"Process [PID=22022, name=`test-request-mapping-live-hover`]");
}
}

View File

@@ -0,0 +1,28 @@
package example;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
public class InnerClassController {
@RestController
public static class InnerController {
@RequestMapping("/inner-class")
public String saySomething() {
return "Hello from Inner-Class";
}
@RestController
public static class InnerInnerController {
@RequestMapping("/inner-inner-class")
public String saySomethingSuperInnerClass() {
return "Hello from Inner-Inner-Class";
}
}
}
}

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../commons/pom.xml</relativePath>
</parent>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../commons/pom.xml</relativePath>
</parent>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -95,12 +95,19 @@ public class LiveBean {
public String getType(boolean stripCGLib) {
String type = this.type;
if (stripCGLib) {
int chop = type.indexOf("$$EnhancerBySpringCGLIB$$");
if (chop>=0) {
type = type.substring(0, chop);
if (type != null) {
if (stripCGLib) {
int chop = type.indexOf("$$EnhancerBySpringCGLIB$$");
if (chop >= 0) {
type = type.substring(0, chop);
}
}
// convert inner classes from $ to . notation
type = type.replace('$', '.');
}
return type;
}

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -10,7 +10,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@@ -6,7 +6,7 @@
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<packaging>pom</packaging>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<name>commons-parent</name>
<modules>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../commons/pom.xml</relativePath>
</parent>

View File

@@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>commons-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<relativePath>../commons/pom.xml</relativePath>
</parent>

View File

@@ -6,7 +6,7 @@
<groupId>org.springframework.ide.vscode</groupId>
<artifactId>headless-services-aggregator</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
<name>aggregator</name>
<modules>

View File

@@ -8,7 +8,7 @@ VSCode extension and Language Server providing support for working with Spring B
The extension will automatically activate when you edit files with the following
name patterns:
- `application*.java` => activates support for Spring Boot properties in `.properties`format.
- `application*.properties` => activates support for Spring Boot properties in `.properties`format.
- `application*.yml` => activates support for Spring Boot properties in `.yml` format.
You can also define your own patterns and map them to the language-ids