Closed agudian closed 9 years ago
@agudian Finally looking into this. Another possible fix would be to set the "unmapped target policy" in the @Mapper
annotation to IGNORE
. WDYT?
The indentation / line breaks might be improved a bit further.
E.g. that's what I have:
@Mappings({
})
And that's how it's quick fixed:
@Mappings({@Mapping(target = "color", ignore = true)
})
Or that's what I have:
@Mappings({
@Mapping(target = "age", ignore = true),
@Mapping(target = "name", ignore = true)
})
And that's how it's quick fixed:
@Mappings({
@Mapping(target = "age", ignore = true),
@Mapping(target = "name", ignore = true), @Mapping(target = "color", ignore = true)
})
@agudian, great stuff, works like a charm! I've added some comments, but nothing earth-shaking. Looks good overall!
Another possible fix would be to set the "unmapped target policy" in the @Mapper annotation to IGNORE. WDYT?
Good idea. Let's track that in a separate issue.
On your formatting remarks: as you can see in the code, I only add nodes to the AST, not the source text itself. The source should be rendered using your specific formatter-settings. Check the line-breaks for annotation members and array-initializers... That should do the trick for you :-)
Thanks for the review! I'll work in some of the suggestions, add a commit for adding checkstyle to the build and push everything to master then... Some time tonight ;-)
This PR adds some basic stuff for creating quick fixes and also adds the first quick fix:
For the error/warning message "Unmapped target properties", the quick-fix "Ignore unmapped target properties" adds
@Mapping(target = "<prop>", ignore = true)
for each of the unmapped properties.The quick fix can handle the following cases:
@Mappings
annotation present, the new@Mapping
annotations will be added there@Mapping
is used, than the new annotations are placed directly on the method@Mapping
annotation present, it will be wrapped into a new@Mappings
annotation together with the new annotations@Mapping
is added directly to the methodI used an early version of this some weeks ago while working on a large number of mappers that I switched to
unmappedTargetPolicy=ERROR
and it was really fun... :smile: