Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML Property completion: Superclass properties not detected in case of List or Map #449

Closed
beckermarc opened this issue Apr 15, 2020 · 5 comments
Milestone

Comments

@beckermarc
Copy link

Hi,

I am using Spring Boot Tools 1.16.0 in VS Code. I am observing a problem with property completion in application.yaml files, that occurs whenever a property (bar) is defined in a superclass (SuperclassProperties) of a type (NestedProperties), that can be provided as a List or Map (nested). The property (bar) is not found in that case and reported as invalid, only properties defined in the child class (foo) work correctly.

If the property nested is not defined as a list or map (private NestedProperties nested), the
bar property is explicitly listed in the spring-configuration-metadata.json file and code-completion works as expected.

Example:

package my.property.test;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties("myprops")
public class TestProperties {

	private List<NestedProperties> nested = new ArrayList<>();

	public List<NestedProperties> getNested() {
		return nested;
	}

	public void setNested(List<NestedProperties> nested) {
		this.nested = nested;
	}

	public static class NestedProperties extends SuperclassProperties {

		private String foo;

		public String getFoo() {
			return foo;
		}

		public void setFoo(String foo) {
			this.foo = foo;
		}

	}

	public static class SuperclassProperties {

		private String bar;

		public String getBar() {
			return bar;
		}

		public void setBar(String bar) {
			this.bar = bar;
		}

	}

}
{
  "groups": [
    {
      "name": "myprops",
      "type": "my.property.test.TestProperties",
      "sourceType": "my.property.test.TestProperties"
    }
  ],
  "properties": [
    {
      "name": "myprops.nested",
      "type": "java.util.List<my.property.test.TestProperties$NestedProperties>",
      "sourceType": "my.property.test.TestProperties"
    }
  ],
  "hints": []
}

As you can see, only foo is suggested, but not bar:
image

@kdvolder
Copy link
Member

Reproducible. I tried it in Eclipse but it's the same issue since uses same language server under the hood.

@kdvolder
Copy link
Member

Thanks for the nice and detailed bug report and example by the way.

@spring-projects-issues
Copy link

(comment in Pivotal Tracker added by Kris De Volder:)

Pushed a fix.

@spring-projects-issues
Copy link

(comment in Pivotal Tracker added by Kris De Volder:)

Verfied the fix with a vscode snapshot build. Delivering.

Note: Did not verify the Eclipse build, I think the change is still working it's way through the slow build pipeline.

@beckermarc
Copy link
Author

Thanks for the fast fix @kdvolder :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants