mapstruct-idea icon indicating copy to clipboard operation
mapstruct-idea copied to clipboard

Inspection to highlight incorrect @Mapping values

Open eekboom opened this issue 8 years ago • 2 comments

It would be great if the plugin could highlight incorrect mappings with an error directly in the editor.

An inspection would be a good way to implement that I think. (For example the user can then enable/disable it, configure the severity and supress it at specific occurrences if needed.)

eekboom avatar Sep 28 '17 07:09 eekboom

By incorrect you mean when the target / source do not exist. For example:

class Target {
    private String target;
    private Nested nested;
}

class Nested {
    private String something;
}

and the mapper:

@Mapper
public interface MyMapper {

    @Mapping(target = "test", source = "...")
    @Mapping(target = "nested.test2", source = "...")
    Target map(Source source);
}

The warning / error will be on test and on test2 saying: "Property test does not exist in class Target"

filiphr avatar Sep 28 '17 18:09 filiphr

Yes, exactly.

eekboom avatar Sep 28 '17 18:09 eekboom