mapstruct / mapstruct-idea

An IntelliJ IDEA plugin for working with MapStruct
Other
141 stars 38 forks source link

Target property mapped more than once inspection #200

Closed hduelme closed 4 months ago

hduelme commented 4 months ago

I added an inspection if a target property is explicitly (using @Mapping) mapped more than once. The error is directly reported on the target field: grafik

Same applies if used inside @Mappings grafik

If a own annotation containing @Mapping or @Mappings is used the error is reported on the annotation directly grafik

filiphr commented 4 months ago

Good one @hduelme.

This looks good to me. Should we perhaps offer some quick fixes for it? Perhaps:

I can't think of another quick fox for this.

thunderhook commented 4 months ago

Nice @hduelme!

If a own annotation containing @Mapping or @Mappings is used the error is reported on the annotation directly

For this scenario there might be a "remove @MyMappingAnnotation" as a quick fix. But I think this is more of an edge-case and not worth implementing.

I think the quick fix can be done in a separate issue.

hduelme commented 4 months ago

@filiphr , @thunderhook I added your suggested quick fixes. The replace (or change) target quick fix currently only selects the text to change. If you know a better way to handle this, let me know.

Another idea for a quick fix is, to allow reusing properties automatically. For example, if the other annotation doesn't have a default source, we could offer a way to use our source as a default source.

hduelme commented 4 months ago

@filiphr I resolved the merge conflicts.

filiphr commented 4 months ago

Thanks @hduelme