diff --git a/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java b/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java index 8db4cbedc..e318a12ca 100644 --- a/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java +++ b/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java @@ -785,19 +785,23 @@ public class Editor { return "Editor(\n"+getText()+"\n)"; } - public void assertLinkTargets(String hoverOver, Set expectedLocations) throws Exception { + public void assertLinkTargets(String hoverOver, List expectedLocations) throws Exception { int pos = getRawText().indexOf(hoverOver); if (pos>=0) { pos += hoverOver.length() / 2; } assertTrue(pos>=0, "Not found in editor: '"+hoverOver+"'"); - - DefinitionParams params = new DefinitionParams(new TextDocumentIdentifier(getUri()), doc.toPosition(pos)); - List definitions = harness.getDefinitions(params); - - assertEquals(ImmutableSet.copyOf(expectedLocations), ImmutableSet.copyOf(definitions)); + + assertLinkTargets(doc.toPosition(pos), expectedLocations); } + public void assertLinkTargets(Position pos, List expectedLocations) throws Exception { + DefinitionParams params = new DefinitionParams(new TextDocumentIdentifier(getUri()), pos); + List definitions = harness.getDefinitions(params); + assertEquals(ImmutableList.copyOf(expectedLocations), ImmutableList.copyOf(definitions)); + } + + public void assertNoLinkTargets(String hoverOver) throws Exception { int pos = getRawText().indexOf(hoverOver); if (pos>=0) { diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/configurationmetadata/ConfigurationMetadataItem.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/configurationmetadata/ConfigurationMetadataItem.java index 5005e5de0..8b3d6f94d 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/configurationmetadata/ConfigurationMetadataItem.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/configurationmetadata/ConfigurationMetadataItem.java @@ -23,7 +23,7 @@ package org.springframework.ide.vscode.boot.configurationmetadata; * @author Stephane Nicoll * @since 1.3.0 */ -class ConfigurationMetadataItem extends ConfigurationMetadataProperty { +public class ConfigurationMetadataItem extends ConfigurationMetadataProperty { private String sourceType; diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/PropertyInfo.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/PropertyInfo.java index f6455fdf7..40ad22c34 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/PropertyInfo.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/PropertyInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014-2016 Pivotal, Inc. + * Copyright (c) 2014, 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 @@ -14,13 +14,13 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataItem; import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataProperty; import org.springframework.ide.vscode.boot.configurationmetadata.ConfigurationMetadataSource; import org.springframework.ide.vscode.boot.configurationmetadata.Deprecation; import org.springframework.ide.vscode.boot.configurationmetadata.Deprecation.Level; import org.springframework.ide.vscode.boot.configurationmetadata.ValueHint; import org.springframework.ide.vscode.boot.configurationmetadata.ValueProvider; -import org.springframework.ide.vscode.boot.java.links.JavaElementLocationProvider; import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry.ValueProviderStrategy; import org.springframework.ide.vscode.boot.metadata.hints.HintProvider; import org.springframework.ide.vscode.boot.metadata.hints.HintProviders; @@ -54,6 +54,11 @@ public class PropertyInfo { this.sourceType = st!=null?st:source.getType(); this.sourceMethod = source.getSourceMethod(); } + + public PropertySource(String sourceType, String sourceMethod) { + this.sourceType = sourceType; + this.sourceMethod = sourceMethod; + } @Override public String toString() { return sourceType+"::"+sourceMethod; @@ -154,6 +159,10 @@ public class PropertyInfo { handleKeyAs(h.getParameters().get("target")); } } + if (prop instanceof ConfigurationMetadataItem) { + ConfigurationMetadataItem item = (ConfigurationMetadataItem) prop; + addSource(new PropertySource(item.getSourceType(), item.getSourceMethod())); + } } public PropertyInfo(String p) { this(p, null, null, null, null, null, null, null, null, null, null); @@ -179,6 +188,17 @@ public class PropertyInfo { public String getName() { return name; } + /** + * Gets the name of the property without the x.y.z prefix, i.e. if property is x.y.z.a then its simple name is a + * @return simple name + */ + public String getSimpleName() { + int idx = name.lastIndexOf('.'); + if (idx >= 0 && idx < name.length() - 1) { + return name.substring(idx + 1); + } + return name; + } public Object getDefaultValue() { return defaultValue; } @@ -217,14 +237,18 @@ public class PropertyInfo { return "PropertyInfo("+getId()+")"; } public PropertySource addSource(ConfigurationMetadataSource source) { - if (sources==null) { - sources = new ArrayList(); - } PropertySource s = new PropertySource(source); - sources.add(s); + addSource(s); return s; } + public void addSource(PropertySource source) { + if (sources==null) { + sources = new ArrayList(); + } + sources.add(source); + } + public PropertyInfo withId(String alias) { if (alias.equals(id)) { return this; diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/SpringPropertyIndex.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/SpringPropertyIndex.java index b7558f27b..1f5cd975f 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/SpringPropertyIndex.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/SpringPropertyIndex.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015 Pivotal, Inc. + * Copyright (c) 2015, 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 @@ -59,14 +59,18 @@ public class SpringPropertyIndex { } for (ConfigurationMetadataGroup group : metadata.getAllGroups().values()) { + ImmutableSet.Builder sources = ImmutableSet.builder(); for (ConfigurationMetadataSource source : group.getSources().values()) { - ImmutableSet.Builder sources = ImmutableSet.builder(); + PropertySource propertySource = new PropertySource(source); + sources.add(propertySource); for (ConfigurationMetadataProperty prop : source.getProperties().values()) { PropertyInfo info = properties.get(prop.getId()); - sources.add(info.addSource(source)); + if (info.getSources().isEmpty()) { + info.addSource(propertySource); + } } - groups.put(group.getId(), sources.build()); } + groups.put(group.getId(), sources.build()); } } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/hover/PropertiesDefinitionCalculator.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/hover/PropertiesDefinitionCalculator.java index 621e16f3c..a8b049032 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/hover/PropertiesDefinitionCalculator.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/properties/hover/PropertiesDefinitionCalculator.java @@ -101,10 +101,24 @@ public class PropertiesDefinitionCalculator { elements.add(type); String methodSig = source.getSourceMethod(); if (methodSig!=null) { - // the property source is a method, so actually we look for accessor in the return type. - IMethod method = getMethod(type, methodSig); - if (method!=null) { - elements.add(method); + if (type.isRecord()) { + IField field = type.getField(getMethodName(methodSig)); + if (field != null) { + // Prefer field over method for records if names are the same + elements.add(field); + } else { + // No field? Add a method if found then. + IMethod method = getMethod(type, methodSig); + if (method!=null) { + elements.add(method); + } + } + } else { + // the property source is a method, so actually we look for accessor in the return type. + IMethod method = getMethod(type, methodSig); + if (method!=null) { + elements.add(method); + } } } } @@ -140,12 +154,12 @@ public class PropertiesDefinitionCalculator { } } if (type != null && type.isRecord()) { - IField field = getPropertyField(type, property.getName()); + IField field = getPropertyField(type, property.getSimpleName()); if (field != null) { elements.add(field); } } else { - IMethod method = getPropertyMethod(typeUtil, type, property.getName()); + IMethod method = getPropertyMethod(typeUtil, type, property.getSimpleName()); if (method!=null) { elements.add(method); } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/XmlBeansHyperlinkTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/XmlBeansHyperlinkTest.java index 11bc343a7..170c9aa93 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/XmlBeansHyperlinkTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/utils/test/XmlBeansHyperlinkTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019 Pivotal, Inc. + * Copyright (c) 2019, 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 @@ -168,7 +168,7 @@ public class XmlBeansHyperlinkTest { targetRange, editor.rangeOf("name=\"simple\" ref=\"simpleObj\"", "simpleObj") ); - editor.assertLinkTargets("simpleObj", Collections.singleton(expectedLocation)); + editor.assertLinkTargets("simpleObj", Collections.singletonList(expectedLocation)); } @Test @@ -238,7 +238,7 @@ public class XmlBeansHyperlinkTest { targetRange, editor.rangeOf("name=\"simple\" ref=\"simpleObj\"", "simpleObj") ); - editor.assertLinkTargets("simpleObj", Collections.singleton(expectedLocation)); + editor.assertLinkTargets("simpleObj", Collections.singletonList(expectedLocation)); } @Test diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/value/test/PropertyValueAnnotationDefProviderTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/value/test/PropertyValueAnnotationDefProviderTest.java index 67d8470d3..fa12bcab3 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/value/test/PropertyValueAnnotationDefProviderTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/value/test/PropertyValueAnnotationDefProviderTest.java @@ -17,6 +17,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.HashSet; +import java.util.List; import java.util.Set; import org.eclipse.lsp4j.LocationLink; @@ -88,7 +89,7 @@ public class PropertyValueAnnotationDefProviderTest { new Range(new Position(0, 0), new Position(0, 11)), new Range(new Position(0, 10), new Position(0, 11)), new Range(new Position(6, 8), new Position(6, 22))); - editor.assertLinkTargets("some.prop", Set.of(expectedLocation)); + editor.assertLinkTargets("some.prop", List.of(expectedLocation)); } @Test @@ -112,7 +113,7 @@ public class PropertyValueAnnotationDefProviderTest { new Range(new Position(1, 2), new Position(1, 9)), new Range(new Position(1, 8), new Position(1, 9)), new Range(new Position(6, 8), new Position(6, 22))); - editor.assertLinkTargets("some.prop", Set.of(expectedLocation)); + editor.assertLinkTargets("some.prop", List.of(expectedLocation)); } @Test @@ -140,7 +141,7 @@ public class PropertyValueAnnotationDefProviderTest { new Range(new Position(1, 2), new Position(1, 9)), new Range(new Position(1, 8), new Position(1, 9)), new Range(new Position(6, 8), new Position(6, 22))); - editor.assertLinkTargets("some.prop", Set.of(expectedPropsLocation, expectedYamlLocation)); + editor.assertLinkTargets("some.prop", List.of(expectedYamlLocation, expectedPropsLocation)); } } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/metadata/PropertiesIndexTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/metadata/PropertiesIndexTest.java index 5fb5d9ee7..b784d3404 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/metadata/PropertiesIndexTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/metadata/PropertiesIndexTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016, 2019 Pivotal, Inc. + * Copyright (c) 2016, 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 @@ -40,7 +40,7 @@ public class PropertiesIndexTest { PropertyInfo propertyInfo = index.get("server.port"); assertNotNull(propertyInfo); assertEquals(Integer.class.getName(), propertyInfo.getType()); - assertEquals("port", propertyInfo.getName()); + assertEquals("port", propertyInfo.getSimpleName()); } @Test @@ -52,7 +52,7 @@ public class PropertiesIndexTest { PropertyInfo propertyInfo = index.get("demo.settings.user"); assertNotNull(propertyInfo); assertEquals(String.class.getName(), propertyInfo.getType()); - assertEquals("user", propertyInfo.getName()); + assertEquals("user", propertyInfo.getSimpleName()); } @Test diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java index 1226431a0..1a0f933e6 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java @@ -488,19 +488,12 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { Editor editor = newEditor( "server.port=888\n" + - "spring.datasource.login-timeout=1000\n" + "flyway.init-sqls=a,b,c\n" ); definitionLinkAsserts.assertLinkTargets(editor, "server", p, editor.rangeOf("server.port", "server.port"), method("org.springframework.boot.autoconfigure.web.ServerProperties", "setPort", "java.lang.Integer")); - definitionLinkAsserts.assertLinkTargets(editor, "data", p, editor.rangeOf("spring.datasource.login-timeout", "spring.datasource.login-timeout"), - method("org.springframework.boot.autoconfigure.jdbc.DataSourceConfigMetadata", "hikariDataSource"), - method("org.springframework.boot.autoconfigure.jdbc.DataSourceConfigMetadata", "tomcatDataSource"), - method("org.springframework.boot.autoconfigure.jdbc.DataSourceConfigMetadata", "dbcpDataSource") - ); - definitionLinkAsserts.assertLinkTargets(editor, "flyway", p, editor.rangeOf("flyway.init-sqls", "flyway.init-sqls"), method("org.springframework.boot.autoconfigure.flyway.FlywayProperties", "setInitSqls", "java.util.List")); } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java index 750c2c6c6..17ba5ccf5 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java @@ -13,6 +13,7 @@ package org.springframework.ide.vscode.boot.test; import static org.junit.jupiter.api.Assertions.*; import static org.springframework.ide.vscode.boot.test.DefinitionLinkAsserts.field; import static org.springframework.ide.vscode.boot.test.DefinitionLinkAsserts.method; +import static org.springframework.ide.vscode.boot.test.DefinitionLinkAsserts.type; import static org.springframework.ide.vscode.languageserver.testharness.Editor.INDENTED_COMPLETION; import java.io.File; @@ -1008,9 +1009,11 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest { editor.rangeOf("port", "port"), method("org.springframework.boot.autoconfigure.web.ServerProperties", "setPort", "java.lang.Integer") ); - definitionLinkAsserts.assertLinkTargets(editor, "login-", p, - editor.rangeOf("login-timeout"), + definitionLinkAsserts.assertLinkTargets(editor, "datasource", p, + editor.rangeOf("datasource"), method("org.springframework.boot.autoconfigure.jdbc.DataSourceConfigMetadata", "hikariDataSource"), + method("org.springframework.boot.autoconfigure.jdbc.XADataSourceAutoConfiguration", "dataSource"), + type("org.springframework.boot.autoconfigure.jdbc.DataSourceProperties"), method("org.springframework.boot.autoconfigure.jdbc.DataSourceConfigMetadata", "tomcatDataSource"), method("org.springframework.boot.autoconfigure.jdbc.DataSourceConfigMetadata", "dbcpDataSource") ); @@ -1018,7 +1021,101 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest { editor.rangeOf("init-sqls", "init-sqls"), method("org.springframework.boot.autoconfigure.flyway.FlywayProperties", "setInitSqls", "java.util.List")); } + + @Test + void hyperLinksForGroupsWithPrimitiveTypes() throws Exception { + IJavaProject p = createPredefinedMavenProject("gh-sts4-sample"); + useProject(p); + + Editor editor = newEditor(""" + app2: + value: true + service1: + value: false + service: + host: 1.2.3.4 + port: 5000 + """ + ); + + definitionLinkAsserts.assertLinkTargets(editor, "app2", p, editor.rangeOf("app2"), type("com.example.demo.Settings2")); + definitionLinkAsserts.assertLinkTargets(editor, "value", p, editor.rangeOf("value: true", "value"), method("com.example.demo.Settings2", "setValue", "boolean")); + definitionLinkAsserts.assertLinkTargets(editor, "service1", p, editor.rangeOf("service1"), method("com.example.demo.Settings2", "getService1")); + definitionLinkAsserts.assertLinkTargets(editor, editor.rangeOf("value: false", "value").getStart(), p, editor.rangeOf("value: false", "value"), method("com.example.demo.Settings2$Service", "setValue", "boolean")); + definitionLinkAsserts.assertLinkTargets(editor, "service:", p, editor.rangeOf("service:", "service"), method("com.example.demo.Settings2$Service", "getService")); + definitionLinkAsserts.assertLinkTargets(editor, "host", p, editor.rangeOf("host"), method("com.example.demo.Settings2$Endpoint", "setHost", "java.lang.String")); + definitionLinkAsserts.assertLinkTargets(editor, "port", p, editor.rangeOf("port"), method("com.example.demo.Settings2$Endpoint", "setPort", "int")); + } + + @Test + void hyperLinksForGroupsWithoutPrimitiveTypes_1() throws Exception { + IJavaProject p = createPredefinedMavenProject("gh-sts4-sample"); + useProject(p); + + Editor editor = newEditor(""" + app1: + service1: + service: + host: 1.2.3.4 + port: 5000 + """ + ); + + definitionLinkAsserts.assertLinkTargets(editor, "app1", p, editor.rangeOf("app1"), type("com.example.demo.Settings1")); + definitionLinkAsserts.assertLinkTargets(editor, "service1", p, editor.rangeOf("service1"), method("com.example.demo.Settings1", "getService1")); + definitionLinkAsserts.assertLinkTargets(editor, "service:", p, editor.rangeOf("service:", "service"), method("com.example.demo.Settings1$Service", "getService")); + definitionLinkAsserts.assertLinkTargets(editor, "host", p, editor.rangeOf("host"), method("com.example.demo.Settings1$Endpoint", "setHost", "java.lang.String")); + definitionLinkAsserts.assertLinkTargets(editor, "port", p, editor.rangeOf("port"), method("com.example.demo.Settings1$Endpoint", "setPort", "int")); + } + @Test + void hyperLinksForGroupsWithoutPrimitiveTypes_2() throws Exception { + IJavaProject p = createPredefinedMavenProject("gh-sts4-sample"); + useProject(p); + + Editor editor = newEditor(""" + app3: + value: true + service1: + host: 1.2.3.4 + port: 5000 + service2: + host: 5.6.7.8 + port: 6000 + """ + ); + + definitionLinkAsserts.assertLinkTargets(editor, "app3", p, editor.rangeOf("app3"), type("com.example.demo.Settings3")); + definitionLinkAsserts.assertLinkTargets(editor, "value", p, editor.rangeOf("value"), method("com.example.demo.Settings3", "setValue", "boolean")); + definitionLinkAsserts.assertLinkTargets(editor, "service1", p, editor.rangeOf("service1"), method("com.example.demo.Settings3", "getService1")); + definitionLinkAsserts.assertLinkTargets(editor, editor.rangeOf("host: 1.2.3.4", "host").getStart(), p, editor.rangeOf("host: 1.2.3.4", "host"), method("com.example.demo.Settings3$Endpoint", "setHost", "java.lang.String")); + definitionLinkAsserts.assertLinkTargets(editor, editor.rangeOf("port: 5000", "port").getStart(), p, editor.rangeOf("port: 5000", "port"), method("com.example.demo.Settings3$Endpoint", "setPort", "int")); + definitionLinkAsserts.assertLinkTargets(editor, "service2", p, editor.rangeOf("service2"), method("com.example.demo.Settings3", "getService2")); + definitionLinkAsserts.assertLinkTargets(editor, editor.rangeOf("host: 5.6.7.8", "host").getStart(), p, editor.rangeOf("host: 5.6.7.8", "host"), method("com.example.demo.Settings3$Endpoint", "setHost", "java.lang.String")); + definitionLinkAsserts.assertLinkTargets(editor, editor.rangeOf("port: 6000", "port").getStart(), p, editor.rangeOf("port: 6000", "port"), method("com.example.demo.Settings3$Endpoint", "setPort", "int")); + } + + @Test + void hyperLinksForGroupsWithRecords() throws Exception { + IJavaProject p = createPredefinedMavenProject("gh-sts4-sample"); + useProject(p); + + Editor editor = newEditor(""" + app: + service1: + service: + host: fvdfv + port: 76 + """ + ); + + definitionLinkAsserts.assertLinkTargets(editor, "app", p, editor.rangeOf("app"), type("com.example.demo.Settings")); + definitionLinkAsserts.assertLinkTargets(editor, "service1", p, editor.rangeOf("service1"), method("com.example.demo.Settings", "getService1")); + definitionLinkAsserts.assertLinkTargets(editor, "service:", p, editor.rangeOf("service:", "service"), field("com.example.demo.Settings$Service", "service")); + definitionLinkAsserts.assertLinkTargets(editor, "host", p, editor.rangeOf("host"), field("com.example.demo.Settings$Endpoint", "host")); + definitionLinkAsserts.assertLinkTargets(editor, "port", p, editor.rangeOf("port"), field("com.example.demo.Settings$Endpoint", "port")); + } + @Test void testReconcile() throws Exception { defaultTestData(); diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/DefinitionLinkAsserts.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/DefinitionLinkAsserts.java index 2d6ede4b5..e81061722 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/DefinitionLinkAsserts.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/DefinitionLinkAsserts.java @@ -12,23 +12,28 @@ package org.springframework.ide.vscode.boot.test; import java.net.URI; import java.net.URL; +import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; +import java.util.List; import java.util.Optional; -import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; +import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.ASTVisitor; import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; import org.eclipse.jdt.core.dom.EnumConstantDeclaration; import org.eclipse.jdt.core.dom.EnumDeclaration; +import org.eclipse.jdt.core.dom.FieldDeclaration; import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.RecordDeclaration; import org.eclipse.jdt.core.dom.SimpleName; import org.eclipse.jdt.core.dom.SingleVariableDeclaration; import org.eclipse.jdt.core.dom.TypeDeclaration; +import org.eclipse.jdt.core.dom.VariableDeclarationFragment; import org.eclipse.lsp4j.Location; import org.eclipse.lsp4j.LocationLink; +import org.eclipse.lsp4j.Position; import org.eclipse.lsp4j.Range; import org.springframework.ide.vscode.boot.java.links.JavaDocumentUriProvider; import org.springframework.ide.vscode.boot.java.links.SourceLinks; @@ -39,12 +44,16 @@ import org.springframework.ide.vscode.commons.util.text.LanguageId; import org.springframework.ide.vscode.commons.util.text.TextDocument; import org.springframework.ide.vscode.languageserver.testharness.Editor; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; public class DefinitionLinkAsserts { private JavaDocumentUriProvider javaDocumentUriProvider; private CompilationUnitCache cuCache; + + public interface JavaLocationProvider { + Location getLocation(CompilationUnitCache cuCache, JavaDocumentUriProvider javaDocumentUriProvider, IJavaProject project) throws Exception; + } public static JavaMethod method(String fqClassName, String methodName, String... params) { return new JavaMethod(fqClassName, methodName, params); @@ -53,8 +62,12 @@ public class DefinitionLinkAsserts { public static JavaField field(String fqClassName, String name) { return new JavaField(fqClassName, name); } + + public static JavaType type(String fqName) { + return new JavaType(fqName); + } - public static class JavaMethod { + public static class JavaMethod implements JavaLocationProvider { public final String fqName; public final String methodName; public final String[] params; @@ -68,9 +81,71 @@ public class DefinitionLinkAsserts { return "JavaMethod [fqName=" + fqName + ", methodName=" + methodName + ", params=" + Arrays.toString(params) + "]"; } + + public Location getLocation(CompilationUnitCache cuCache, JavaDocumentUriProvider javaDocumentUriProvider, IJavaProject project) throws Exception { + Location loc = new Location(); + Optional sourceUrl = SourceLinks.source(project, fqName); + if (sourceUrl.isPresent()) { + + URI docUri = javaDocumentUriProvider.docUri(project, fqName); + loc.setUri(docUri.toASCIIString()); + + URI sourceUri = sourceUrl.get().toURI(); + Range r = cuCache.withCompilationUnit(project, sourceUri, (cu) -> { + try { + AtomicReference range = new AtomicReference<>(null); + TextDocument doc = new TextDocument(sourceUrl.get().toString(), LanguageId.JAVA); + doc.setText(cuCache.fetchContent(sourceUri)); + String typeName = fqName.substring(fqName.lastIndexOf('.') + 1); + String[] nameTokens = typeName.split("\\$"); + + cu.accept(new ASTVisitor() { + + @Override + public boolean visit(MethodDeclaration node) { + SimpleName nameNode = node.getName(); + if (nameNode.getIdentifier().equals(methodName) && isType(node.getParent(), nameTokens, nameTokens.length)) { + if (node.parameters().size() != params.length) { + return false; + } + int i = 0; + for (Object _p : node.parameters()) { + if (_p instanceof SingleVariableDeclaration) { + SingleVariableDeclaration p = (SingleVariableDeclaration) _p; + String fqName = p.getType().resolveBinding().getErasure().getQualifiedName(); + if (!fqName.equals(params[i++])) { + return false; + } + } else { + return false; + } + } + try { + range.set(doc.toRange(nameNode.getStartPosition(), nameNode.getLength())); + } catch (BadLocationException e) { + throw new IllegalStateException(e); + } + } + return false; + } + + }); + return range.get(); + } catch (Exception e) { + throw new IllegalStateException(e); + } + }); + if (r == null) { + throw new IllegalStateException("Couldn't find " + toString()); + } + loc.setRange(r); + } + return loc; + } + } - public static class JavaField { + public static class JavaField implements JavaLocationProvider { public final String fqName; public final String fieldName; public JavaField(String fqName, String fieldName) { @@ -82,6 +157,172 @@ public class DefinitionLinkAsserts { public String toString() { return "JavaField [fqName=" + fqName + ", fieldName=" + fieldName + "]"; } + + public Location getLocation(CompilationUnitCache cuCache, JavaDocumentUriProvider javaDocumentUriProvider, IJavaProject project) throws Exception { + Location loc = new Location(); + + Optional sourceUrl = SourceLinks.source(project, fqName); + if (sourceUrl.isPresent()) { + + URI sourceUri = sourceUrl.get().toURI(); + + URI docUri = javaDocumentUriProvider.docUri(project, fqName); + loc.setUri(docUri.toASCIIString()); + String typeName = fqName.substring(fqName.lastIndexOf('.') + 1); + String[] nameTokens = typeName.split("\\$"); + + Range r = cuCache.withCompilationUnit(project, sourceUri, (cu) -> { + try { + AtomicReference range = new AtomicReference<>(null); + TextDocument doc = new TextDocument(sourceUrl.get().toString(), LanguageId.JAVA); + doc.setText(cuCache.fetchContent(sourceUri)); + cu.accept(new ASTVisitor() { + + @Override + public boolean visit(EnumConstantDeclaration node) { + if (isType(node.getParent(), nameTokens, nameTokens.length)) { + SimpleName nameNode = node.getName(); + if (nameNode.getIdentifier().equals(fieldName)) { + try { + range.set(doc.toRange(nameNode.getStartPosition(), nameNode.getLength())); + return false; + } catch (BadLocationException e) { + throw new IllegalStateException(e); + } + } + } + return true; + } + + @SuppressWarnings("unchecked") + @Override + public boolean visit(FieldDeclaration node) { + if (isType(node.getParent(), nameTokens, nameTokens.length)) { + for (VariableDeclarationFragment f : (List) node.fragments()) { + SimpleName nameNode = f.getName(); + if (fieldName.equals(nameNode.getIdentifier())) { + try { + range.set(doc.toRange(nameNode.getStartPosition(), nameNode.getLength())); + return false; + } catch (BadLocationException e) { + throw new IllegalStateException(e); + } + } + } + } + return super.visit(node); + } + + @Override + public boolean visit(RecordDeclaration node) { + if (isType(node, nameTokens, nameTokens.length)) { + for (Object o : node.recordComponents()) { + if (o instanceof SingleVariableDeclaration) { + SingleVariableDeclaration rc = (SingleVariableDeclaration) o; + if (fieldName.equals(new String(rc.getName().getIdentifier()))) { + try { + range.set(doc.toRange(rc.getName().getStartPosition(), rc.getName().getLength())); + return false; + } catch (BadLocationException e) { + throw new IllegalStateException(e); + } + } + } + } + } + return super.visit(node); + } + + + }); + return range.get(); + } catch (Exception e) { + throw new IllegalStateException(e); + } + }); + if (r == null) { + throw new IllegalStateException("Couldn't find " + toString()); + } + loc.setRange(r); + } + return loc; + } + + } + + public static class JavaType implements JavaLocationProvider { + private String fqName; + + public JavaType(String fqName) { + this.fqName = fqName; + } + + public Location getLocation(CompilationUnitCache cuCache, JavaDocumentUriProvider javaDocumentUriProvider, IJavaProject project) throws Exception { + Location loc = new Location(); + Optional sourceUrl = SourceLinks.source(project, fqName); + if (sourceUrl.isPresent()) { + + URI docUri = javaDocumentUriProvider.docUri(project, fqName); + loc.setUri(docUri.toASCIIString()); + + String typeName = fqName.substring(fqName.lastIndexOf('.') + 1); + URI sourceUri = sourceUrl.get().toURI(); + Range r = cuCache.withCompilationUnit(project, sourceUri, (cu) -> { + try { + TextDocument doc = new TextDocument(sourceUrl.get().toString(), LanguageId.JAVA); + doc.setText(cuCache.fetchContent(sourceUri)); + AtomicReference range = new AtomicReference<>(null); + String[] nameTokens = typeName.split("\\$"); + AtomicInteger index = new AtomicInteger(0); + cu.accept(new ASTVisitor() { + + private boolean proceessTypeNode(TextDocument doc, String typeName, + AtomicReference range, AbstractTypeDeclaration node) { + SimpleName nameNode = node.getName(); + if (nameNode.getIdentifier().equals(nameTokens[index.get()])) { + if (index.incrementAndGet() == nameTokens.length) { + try { + range.set(doc.toRange(nameNode.getStartPosition(), nameNode.getLength())); + return false; + } catch (BadLocationException e) { + throw new IllegalStateException(e); + } + } + return true; + } + return false; + } + + @Override + public boolean visit(TypeDeclaration node) { + return proceessTypeNode(doc, typeName, range, node); + } + + @Override + public boolean visit(EnumDeclaration node) { + return proceessTypeNode(doc, typeName, range, node); + } + + @Override + public boolean visit(RecordDeclaration node) { + return proceessTypeNode(doc, typeName, range, node); + } + + + }); + return range.get(); + } catch (Exception e) { + throw new IllegalStateException(e); + } + }); + if (r == null) { + throw new IllegalStateException("Couldn't find " + fqName); + } + loc.setRange(r); + } + return loc; + } + } public DefinitionLinkAsserts(JavaDocumentUriProvider javaDocumentUriProvider, CompilationUnitCache cuCache) { @@ -90,223 +331,46 @@ public class DefinitionLinkAsserts { } - public void assertLinkTargets(Editor editor, String hoverOver, IJavaProject project, Range highlightRange, JavaMethod... methods) throws Exception { - Set expectedLocations = new HashSet<>(); - for (JavaMethod method : methods) { - Location l = getLocation(project, method); + public void assertLinkTargets(Editor editor, String hoverOver, IJavaProject project, Range highlightRange, JavaLocationProvider... javaElements) throws Exception { + List expectedLocations = new ArrayList<>(); + for (JavaLocationProvider jlp : javaElements) { + Location l = jlp.getLocation(cuCache, javaDocumentUriProvider, project); expectedLocations.add(new LocationLink(l.getUri(), l.getRange(), l.getRange(), highlightRange)); } editor.assertLinkTargets(hoverOver, expectedLocations); } + + public void assertLinkTargets(Editor editor, Position pos, IJavaProject project, Range highlightRange, JavaLocationProvider... javaElements) throws Exception { + List expectedLocations = new ArrayList<>(); + for (JavaLocationProvider jlp : javaElements) { + Location l = jlp.getLocation(cuCache, javaDocumentUriProvider, project); + expectedLocations.add(new LocationLink(l.getUri(), l.getRange(), l.getRange(), highlightRange)); + } + + editor.assertLinkTargets(pos, expectedLocations); + } + public void assertLinkTargets(Editor editor, String hoverOver, IJavaProject project, Range highlightRange, String typeFqName) throws Exception { - Location l = getLocation(project, typeFqName); + Location l = type(typeFqName).getLocation(cuCache, javaDocumentUriProvider, project); LocationLink link = new LocationLink(l.getUri(), l.getRange(), l.getRange(), highlightRange); - editor.assertLinkTargets(hoverOver, ImmutableSet.of(link)); + editor.assertLinkTargets(hoverOver, ImmutableList.of(link)); } - - public void assertLinkTargets(Editor editor, String hoverOver, IJavaProject project, Range highlightRange, JavaField field) throws Exception { - - Location l = getLocation(project, field); - - LocationLink link = new LocationLink(l.getUri(), l.getRange(), l.getRange(), highlightRange); - - editor.assertLinkTargets(hoverOver, ImmutableSet.of(link)); - } - - private Location getLocation(IJavaProject project, String fqName) throws Exception { - Location loc = new Location(); - Optional sourceUrl = SourceLinks.source(project, fqName); - if (sourceUrl.isPresent()) { - - URI docUri = javaDocumentUriProvider.docUri(project, fqName); - loc.setUri(docUri.toASCIIString()); - - String typeName = fqName.substring(fqName.lastIndexOf('.') + 1); - URI sourceUri = sourceUrl.get().toURI(); - Range r = cuCache.withCompilationUnit(project, sourceUri, (cu) -> { - try { - TextDocument doc = new TextDocument(sourceUrl.get().toString(), LanguageId.JAVA); - doc.setText(cuCache.fetchContent(sourceUri)); - AtomicReference range = new AtomicReference<>(null); - cu.accept(new ASTVisitor() { - - private boolean proceessTypeNode(TextDocument doc, String typeName, - AtomicReference range, AbstractTypeDeclaration node) { - SimpleName nameNode = node.getName(); - if (nameNode.getIdentifier().equals(typeName)) { - try { - range.set(doc.toRange(nameNode.getStartPosition(), nameNode.getLength())); - return false; - } catch (BadLocationException e) { - throw new IllegalStateException(e); - } - } - return true; - } - - @Override - public boolean visit(TypeDeclaration node) { - return proceessTypeNode(doc, typeName, range, node); - } - - @Override - public boolean visit(EnumDeclaration node) { - return proceessTypeNode(doc, typeName, range, node); - } - - }); - return range.get(); - } catch (Exception e) { - throw new IllegalStateException(e); - } - }); - if (r == null) { - throw new IllegalStateException("Couldn't find " + fqName); + + private static boolean isType(ASTNode node, String[] typeTokens, int length) { + if (length <= 0) { + return !(node instanceof AbstractTypeDeclaration); + } else if (node instanceof AbstractTypeDeclaration) { + AbstractTypeDeclaration typeDeclaration = (AbstractTypeDeclaration) node; + if (typeDeclaration.getName().getIdentifier().equals(typeTokens[length - 1])) { + return isType(typeDeclaration.getParent(), typeTokens, length - 1); } - loc.setRange(r); } - return loc; - } - - private Location getLocation(IJavaProject project, JavaMethod method) throws Exception { - Location loc = new Location(); - Optional sourceUrl = SourceLinks.source(project, method.fqName); - if (sourceUrl.isPresent()) { - - URI docUri = javaDocumentUriProvider.docUri(project, method.fqName); - loc.setUri(docUri.toASCIIString()); - - URI sourceUri = sourceUrl.get().toURI(); - Range r = cuCache.withCompilationUnit(project, sourceUri, (cu) -> { - try { - AtomicReference range = new AtomicReference<>(null); - TextDocument doc = new TextDocument(sourceUrl.get().toString(), LanguageId.JAVA); - doc.setText(cuCache.fetchContent(sourceUri)); - cu.accept(new ASTVisitor() { - - @Override - public boolean visit(MethodDeclaration node) { - SimpleName nameNode = node.getName(); - if (nameNode.getIdentifier().equals(method.methodName)) { - if (node.parameters().size() != method.params.length) { - return false; - } - int i = 0; - for (Object _p : node.parameters()) { - if (_p instanceof SingleVariableDeclaration) { - SingleVariableDeclaration p = (SingleVariableDeclaration) _p; - String fqName = p.getType().resolveBinding().getErasure().getQualifiedName(); - if (!fqName.equals(method.params[i++])) { - return false; - } - } else { - return false; - } - } - try { - range.set(doc.toRange(nameNode.getStartPosition(), nameNode.getLength())); - } catch (BadLocationException e) { - throw new IllegalStateException(e); - } - } - return false; - } - - }); - return range.get(); - } catch (Exception e) { - throw new IllegalStateException(e); - } - }); - if (r == null) { - throw new IllegalStateException("Couldn't find " + method); - } - loc.setRange(r); - } - return loc; - } - - private Location getLocation(IJavaProject project, JavaField field) throws Exception { - Location loc = new Location(); - - Optional sourceUrl = SourceLinks.source(project, field.fqName); - if (sourceUrl.isPresent()) { - - URI sourceUri = sourceUrl.get().toURI(); - - URI docUri = javaDocumentUriProvider.docUri(project, field.fqName); - loc.setUri(docUri.toASCIIString()); - - Range r = cuCache.withCompilationUnit(project, sourceUri, (cu) -> { - try { - AtomicReference range = new AtomicReference<>(null); - TextDocument doc = new TextDocument(sourceUrl.get().toString(), LanguageId.JAVA); - doc.setText(cuCache.fetchContent(sourceUri)); - cu.accept(new ASTVisitor() { - - boolean foundType = false; - - @Override - public boolean visit(EnumConstantDeclaration node) { - if (foundType) { - SimpleName nameNode = node.getName(); - if (nameNode.getIdentifier().equals(field.fieldName)) { - try { - range.set(doc.toRange(nameNode.getStartPosition(), nameNode.getLength())); - } catch (BadLocationException e) { - throw new IllegalStateException(e); - } - } - } - return true; - } - - @Override - public boolean visit(EnumDeclaration node) { - if (node.getName().getIdentifier() - .equals(field.fqName.substring(field.fqName.lastIndexOf('.') + 1))) { - foundType = true; - return true; - } - return super.visit(node); - } - - @Override - public boolean visit(RecordDeclaration node) { - for (Object o : node.recordComponents()) { - if (o instanceof SingleVariableDeclaration) { - SingleVariableDeclaration rc = (SingleVariableDeclaration) o; - if (field.fieldName.equals(new String(rc.getName().getIdentifier()))) { - try { - range.set(doc.toRange(rc.getName().getStartPosition(), rc.getName().getLength())); - } catch (BadLocationException e) { - throw new IllegalStateException(e); - } - return true; - } - } - } - return super.visit(node); - } - - - }); - return range.get(); - } catch (Exception e) { - throw new IllegalStateException(e); - } - }); - if (r == null) { - throw new IllegalStateException("Couldn't find " + field); - } - loc.setRange(r); - } - return loc; + return false; } } diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/mvnw b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/mvnw new file mode 100755 index 000000000..a16b5431b --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/mvnw.cmd b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/mvnw.cmd new file mode 100644 index 000000000..c8d43372c --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/pom.xml b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/pom.xml new file mode 100644 index 000000000..c6f6227ee --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.0.6 + + + com.example + gh-sts4-sample + 0.0.1-SNAPSHOT + gh-sts4-sample + Demo project for Spring Boot + + 17 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/GhSts4SampleApplication.java b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/GhSts4SampleApplication.java new file mode 100644 index 000000000..63107f6be --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/GhSts4SampleApplication.java @@ -0,0 +1,15 @@ +package com.example.demo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; + +@SpringBootApplication +@ConfigurationPropertiesScan +public class GhSts4SampleApplication { + + public static void main(String[] args) { + SpringApplication.run(GhSts4SampleApplication.class, args); + } + +} diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/Settings.java b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/Settings.java new file mode 100644 index 000000000..666048d31 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/Settings.java @@ -0,0 +1,18 @@ +package com.example.demo; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = "app") +public class Settings { + public static record Endpoint(String host, int port) {} + public static record Service(Endpoint service) {} + + + private Service service1; + public Service getService1() { + return service1; + } + public void setService1(Service service1) { + this.service1 = service1; + } +} \ No newline at end of file diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/Settings1.java b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/Settings1.java new file mode 100644 index 000000000..bc4aeefc4 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/Settings1.java @@ -0,0 +1,49 @@ +package com.example.demo; + +import java.util.List; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = "app1") +public class Settings1 { + + public static class Endpoint { + private String host; + private int port; + public String getHost() { + return host; + } + public void setHost(String host) { + this.host = host; + } + public int getPort() { + return port; + } + public void setPort(int port) { + this.port = port; + } + + } + public static class Service { + private Endpoint service; + public Endpoint getService() { + return service; + } + public void setService(Endpoint service) { + this.service = service; + } + } + + + private Service service1; + + + public Service getService1() { + return service1; + } + + + public void setService1(Service service1) { + this.service1 = service1; + } +} diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/Settings2.java b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/Settings2.java new file mode 100644 index 000000000..725ada5a2 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/Settings2.java @@ -0,0 +1,65 @@ +package com.example.demo; + +import java.util.List; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = "app2") +public class Settings2 { + + public static class Endpoint { + private String host; + private int port; + public String getHost() { + return host; + } + public void setHost(String host) { + this.host = host; + } + public int getPort() { + return port; + } + public void setPort(int port) { + this.port = port; + } + + } + public static class Service { + private Endpoint service; + private boolean value; + public Endpoint getService() { + return service; + } + public void setService(Endpoint service) { + this.service = service; + } + public boolean isValue() { + return value; + } + public void setValue(boolean value) { + this.value = value; + } + } + + + private Service service1; + private boolean value; + + public Service getService1() { + return service1; + } + + public void setService1(Service service1) { + this.service1 = service1; + } + + + public boolean isValue() { + return value; + } + + + public void setValue(boolean value) { + this.value = value; + } +} diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/Settings3.java b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/Settings3.java new file mode 100644 index 000000000..9117ce4c7 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/java/com/example/demo/Settings3.java @@ -0,0 +1,49 @@ +package com.example.demo; + +import java.util.List; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = "app3") +public class Settings3 { + public static class Endpoint { + private String host; + private int port; + public String getHost() { + return host; + } + public void setHost(String host) { + this.host = host; + } + public int getPort() { + return port; + } + public void setPort(int port) { + this.port = port; + } + + } + + private Endpoint service1; + private Endpoint service2; + private boolean value; + + public Endpoint getService1() { + return service1; + } + public void setService1(Endpoint service1) { + this.service1 = service1; + } + public Endpoint getService2() { + return service2; + } + public void setService2(Endpoint service2) { + this.service2 = service2; + } + public boolean isValue() { + return value; + } + public void setValue(boolean value) { + this.value = value; + } +} diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/resources/application.properties b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/resources/application.properties new file mode 100644 index 000000000..6ddd5f698 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/resources/application.properties @@ -0,0 +1,17 @@ +# only app1.service1.service works +app1.service1.service.host=1.2.3.4 +app1.service1.service.port=5000 + +# everything works +app2.value=true +app2.service1.value=true +app2.service1.service.host=1.2.3.4 +app2.service1.service.port=5000 + + +# app3.service2 does not work +app3.value=true +app3.service1.host=1.2.3.4 +app3.service1.port=5000 +app3.service2.host=1.2.3.4 +app3.service2.port=5000 diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/resources/application.yml b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/resources/application.yml new file mode 100644 index 000000000..f8f991d1a --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/main/resources/application.yml @@ -0,0 +1,33 @@ +--- +# only app1.service1.service works +app1: + service1: + service: + host: 1.2.3.4 + port: 5000 + +# everything works +app2: + value: true + service1: + value: true + service: + host: 1.2.3.4 + port: 5000 + + +# app3.service2 does not work +app3: + value: true + service1: + host: 1.2.3.4 + port: 5000 + service2: + host: 1.2.3.4 + port: 5000 + +app: + service1: + service: + host: fvdfv + port: 76 diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/test/java/com/example/demo/GhSts4SampleApplicationTests.java b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/test/java/com/example/demo/GhSts4SampleApplicationTests.java new file mode 100644 index 000000000..c2e35347c --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/gh-sts4-sample/src/test/java/com/example/demo/GhSts4SampleApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.demo; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class GhSts4SampleApplicationTests { + + @Test + void contextLoads() { + } + +}