Giter Site home page Giter Site logo

Comments (5)

thunderhook avatar thunderhook commented on July 1, 2024 1

Thank you for the reproducal. The PR #137 handles references inside a @MapperConfig now.

Oh... I see - we identify named methods from methods of referenced mappers (uses = ...) of a shared configuration. But we ignore the methods inside the shared configuration itself, like:

@MapperConfig(uses = OptionalMapper.class)
public class MapperConfigUsingOptionalMapper {

    @Named("thisIsCurrentlyNotCovered")
    public int doSomething(long value) {
        return 0;
    }

}

@Named methods inside a shared configuration itself are not supported by MapStruct itself, therefore I did not handle this case. I don't know if this is by design or a not-yet implemented feature (or bug).

from mapstruct-idea.

thunderhook avatar thunderhook commented on July 1, 2024

This is already supported and covered with the following test (unwrapOptional is referenced in a used mapper from a shared configuration):
https://github.com/thunderhook/mapstruct-idea/blob/b55c1e12fad45b90abb88fa3b0740b3c3a75b4ba/src/test/java/org/mapstruct/intellij/completion/MappingQualifiedByNameCompletionTestCase.java#L54-L54

If it doesn't work for you, would you mind making a minimal reproducible example?

Oh... I see - we identify named methods from methods of referenced mappers (uses = ...) of a shared configuration. But we ignore the methods inside the shared configuration itself, like:

@MapperConfig(uses = OptionalMapper.class)
public class MapperConfigUsingOptionalMapper {

    @Named("thisIsCurrentlyNotCovered")
    public int doSomething(long value) {
        return 0;
    }

}

I will take care of it, thanks for pointing this out.
If your use case is something else, feel free to provide your code.

from mapstruct-idea.

therealppa avatar therealppa commented on July 1, 2024

In my case it looks like this:

@Mapper
public interface MyOptionalMapper {

  @Named("stringLength")
  default int stringLength(String str) {
    return str.length();
  }
}
@MapperConfig(uses = MyOptionalMapper.class)
public interface MyMapperConfig {

  @Mapping(target = "targetInt", source = "sourceString", qualifiedByName = "stringLength")
  TargetBean doSomething(SourceBean value);
}
@Mapper(config = MyMapperConfig.class)
public interface MyMapperUsingConfig {

  @InheritConfiguration
  TargetBean doSomething(SourceBean value);
}

I can't navigate to "qualifiedByName = "stringLength"" in the IDE.

I have mapstruct 1.5.4, Intellij 2023.1, MapStruct Support 1.5.0

from mapstruct-idea.

filiphr avatar filiphr commented on July 1, 2024

Thanks for working on this @thunderhook.

@Named methods inside a shared configuration itself are not supported by MapStruct itself, therefore I did not handle this case. I don't know if this is by design or a not-yet implemented feature (or bug).

This is by design. Methods in a @MapperConfig are only template methods, we are not using them to invoke any code.

from mapstruct-idea.

therealppa avatar therealppa commented on July 1, 2024

It works, thank you :)

from mapstruct-idea.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.