Support for user-defined logging.groups
This commit is contained in:
@@ -13,6 +13,7 @@ package org.springframework.ide.vscode.boot.bootiful;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.AdHocPropertyHarness;
|
||||
import org.springframework.ide.vscode.boot.metadata.ProjectBasedPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
|
||||
@Configuration
|
||||
@@ -21,7 +22,7 @@ public class AdHocPropertyHarnessTestConf {
|
||||
return new AdHocPropertyHarness();
|
||||
}
|
||||
|
||||
@Bean SpringPropertyIndexProvider adHocProperties(AdHocPropertyHarness adHocProperties) {
|
||||
@Bean ProjectBasedPropertyIndexProvider adHocProperties(AdHocPropertyHarness adHocProperties) {
|
||||
return adHocProperties.getIndexProvider();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.editor.harness;
|
||||
|
||||
import org.springframework.ide.vscode.boot.metadata.ProjectBasedPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertyInfo;
|
||||
import org.springframework.ide.vscode.boot.metadata.SpringPropertyIndexProvider;
|
||||
import org.springframework.ide.vscode.commons.util.FuzzyMap;
|
||||
@@ -23,9 +24,9 @@ public class AdHocPropertyHarness {
|
||||
}
|
||||
};
|
||||
|
||||
protected final SpringPropertyIndexProvider adHocIndexProvider = doc -> adHocProperties;
|
||||
protected final ProjectBasedPropertyIndexProvider adHocIndexProvider = project -> adHocProperties;
|
||||
|
||||
public SpringPropertyIndexProvider getIndexProvider() {
|
||||
public ProjectBasedPropertyIndexProvider getIndexProvider() {
|
||||
return adHocIndexProvider;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,7 @@ public class AdHocSpringPropertyIndexProviderTest {
|
||||
);
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, null);
|
||||
|
||||
TextDocument doc = new TextDocument(project.uri("src/main/java/SomeClass.java"), LanguageId.JAVA);
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
//alphabetic order
|
||||
"some-adhoc-bar",
|
||||
"some-adhoc-foo"
|
||||
@@ -52,8 +51,7 @@ public class AdHocSpringPropertyIndexProviderTest {
|
||||
);
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, null);
|
||||
|
||||
TextDocument doc = new TextDocument(project.uri("src/main/java/SomeClass.java"), LanguageId.JAVA);
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
//alphabetic order
|
||||
"from-yaml.adhoc.bar",
|
||||
"from-yaml.adhoc.foo"
|
||||
@@ -68,19 +66,18 @@ public class AdHocSpringPropertyIndexProviderTest {
|
||||
);
|
||||
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, null);
|
||||
TextDocument doc = new TextDocument(project.uri("src/main/java/SomeClass.java"), LanguageId.JAVA);
|
||||
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"initial-property"
|
||||
);
|
||||
|
||||
project.ensureFile("new-sourcefolder/application.properties", "new-property=whatever");
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"initial-property"
|
||||
);
|
||||
|
||||
project.createSourceFolder("new-sourcefolder");
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"initial-property",
|
||||
"new-property"
|
||||
);
|
||||
@@ -94,19 +91,18 @@ public class AdHocSpringPropertyIndexProviderTest {
|
||||
);
|
||||
|
||||
AdHocSpringPropertyIndexProvider indexer = new AdHocSpringPropertyIndexProvider(projects.finder, projects.observer, projects.fileObserver);
|
||||
TextDocument doc = new TextDocument(project.uri("src/main/java/SomeClass.java"), LanguageId.JAVA);
|
||||
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"initial-property"
|
||||
);
|
||||
|
||||
project.ensureFile("src/main/resources/application.properties", "from-properties=whatever");
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"from-properties"
|
||||
);
|
||||
|
||||
project.ensureFile("src/main/resources/application.yml", "from-yaml: whatever");
|
||||
assertProperties(indexer.getIndex(doc),
|
||||
assertProperties(indexer.getIndex(project),
|
||||
"from-properties",
|
||||
"from-yaml"
|
||||
);
|
||||
|
||||
@@ -61,6 +61,7 @@ public class ValueCompletionTest {
|
||||
|
||||
@Autowired private BootLanguageServerHarness harness;
|
||||
@Autowired private IJavaProject testProject;
|
||||
@Autowired private JavaProjectFinder projectFinder;
|
||||
|
||||
private Editor editor;
|
||||
|
||||
@@ -121,7 +122,7 @@ public class ValueCompletionTest {
|
||||
|
||||
@Test
|
||||
public void testPrefixIdentification() {
|
||||
ValueCompletionProcessor processor = new ValueCompletionProcessor(null, null);
|
||||
ValueCompletionProcessor processor = new ValueCompletionProcessor(projectFinder, null, null);
|
||||
|
||||
assertEquals("pre", processor.identifyPropertyPrefix("pre", 3));
|
||||
assertEquals("pre", processor.identifyPropertyPrefix("prefix", 3));
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.bootiful.PropertyEditorTestConf;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.AdHocPropertyHarness;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.StyledStringMatcher;
|
||||
import org.springframework.ide.vscode.boot.metadata.CachingValueProvider;
|
||||
import org.springframework.ide.vscode.boot.metadata.PropertiesLoader;
|
||||
@@ -59,8 +60,9 @@ import com.google.common.io.Files;
|
||||
@Import(PropertyEditorTestConf.class)
|
||||
public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
|
||||
@Autowired
|
||||
private DefinitionLinkAsserts definitionLinkAsserts;
|
||||
@Autowired DefinitionLinkAsserts definitionLinkAsserts;
|
||||
@Autowired AdHocPropertyHarness adHocProperties;
|
||||
|
||||
|
||||
@Configuration static class TestConf {
|
||||
@Bean LanguageId defaultLanguageId() {
|
||||
@@ -1148,6 +1150,30 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void userDefinedLoggerGroups() throws Exception {
|
||||
useProject(createPredefinedMavenProject("empty-boot-2.1.0-app"));
|
||||
|
||||
adHocProperties.add("logging.group.foobar");
|
||||
adHocProperties.add("logging.group.user-defined");
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging.level.<*>"
|
||||
, //==============
|
||||
"user-defined",
|
||||
//=>
|
||||
"logging.level.user-defined=<*>"
|
||||
);
|
||||
|
||||
assertCompletionWithLabel(
|
||||
"logging.level.<*>"
|
||||
, //==============
|
||||
"foobar",
|
||||
//=>
|
||||
"logging.level.foobar=<*>"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test public void testPropertyMapKeyCompletions() throws Exception {
|
||||
useProject(createPredefinedMavenProject("empty-boot-2.1.0-app"));
|
||||
assertCompletionWithLabel(
|
||||
|
||||
Reference in New Issue
Block a user