mapstruct / mapstruct-eclipse

An Eclipse plug-in for working with MapStruct
Other
13 stars 8 forks source link

Property code completion fixes #20

Closed agudian closed 9 years ago

agudian commented 9 years ago

Property name completion: handle multiple sources, handle @MappingTarget/@TargetType parameters, support enum constants

I've put the commit ontop of PR #18- mainly so I could use the MapStructAPIConstants class that I introduced there... hope it's ok... :wink:

agudian commented 9 years ago

Rebased to master and fixed a checkstyle issue... :)

gunnarmorling commented 9 years ago

@agudian: wrt. "@TargetType parameters and support enum constants": How does this look exactly? I can't seem to trigger that functionality in manual tests.

Which makes me think that we should document the list of supported quick fixes and auto-completions in some help document (not at least for the reason that we don't have any tests, so to at least keep track of the functionality we expect to work).

agudian commented 9 years ago

@agudian: wrt. "@TargetType parameters and support enum constants": How does this look exactly? I can't seem to trigger that functionality in manual tests.

The proposals didn't work on enum-mapping methods or on methods that had @TargetType or @MappingTarget parameters. They should now, including giving proposals for enum instances.

The missing tests are really starting out to be annoying... we need to do something there... :smirk:

gunnarmorling commented 9 years ago

I can confirm it works with @MappingTarget. But what should it do for @TargetType? That's used on manually implemented methods, right? So I am not sure what a completion would look like?

For some reason it doesn't suggest enum constants as source() or target(). Not sure why...

agudian commented 9 years ago

But what should it do for @TargetType?

Ehm.. right... strange... don't know what I was thinking...

For some reason it doesn't suggest enum constants as source() or target(). Not sure why...

Just tried it again - it works for me... The caret needs to be within the "... Damn we need some tests...

gunnarmorling commented 9 years ago

Just tried it again - it works for me...

Could you share your enum and mapper type definitions you use for testing?

agudian commented 9 years ago

Could you share your enum and mapper type definitions you use for testing?

I tried with a mapper from my day-work project, with enums and mapper in different eclipse projects.

But I also tried it with this one, and the completions a and b were provided by the plugin:

@Mapper
public interface SourceTargetMapper {
    @Mapping(target = "a", source = "b")
    B toB(A a);

    public enum A {
        a, b;
    }

    public enum B {
        a, c;
    }
}
gunnarmorling commented 9 years ago

Merged and added one more commit to change the method return types. Thanks, @agudian! Re-tested it and it also works with enum types now. Not sure why it didn't last time I tried.