Skip to content

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

Closed

Description

@beckermarc

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

Activity

  1. kdvolder commented on Apr 17, 2020

    @kdvolder
    Member

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

  2. kdvolder commented on Apr 17, 2020

    @kdvolder
    Member

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

  3. spring-projects-issues commented on Apr 17, 2020

    @spring-projects-issues

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

    Pushed a fix.

  4. added this to the 4.6.1.RELEASE milestone on Apr 17, 2020
  5. spring-projects-issues commented on Apr 17, 2020

    @spring-projects-issues

    (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.

  6. beckermarc commented on Apr 20, 2020

    @beckermarc
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions