Comments (5)
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.
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.
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.
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.
It works, thank you :)
from mapstruct-idea.
Related Issues (20)
- Code completion doesn't work with lombok @SuperBuilder annotation HOT 3
- Unmapped target properties warning is missing if source is a Java record HOT 5
- Auto completion for InheritConfiguration#name, InheritInverseConfiguration#name HOT 1
- Disable unmapped target property warnings when implicitly mapping from a map HOT 2
- Completion for properties don't work (both target and source) HOT 2
- Array and Map paramter ignored as source-parameter if used as only source
- Java expression HOT 1
- Report Non-existing target properties as errors HOT 1
- WrongUsageOfMappersFactoryInspection ignores if componentModel is defined in MapperConfig HOT 1
- IDE Support of `BeanMapping#ignoredTargets`
- Code Completion didn't work well. HOT 12
- Wrong usage of mappers factory should be able to remove static initializer
- code wraps automatically, does not recognize keywords HOT 1
- Incompatible with idea 2024.1 RC HOT 4
- Plugin reports "Can't find related attribute" warning when using `source="."` HOT 2
- Code completion: mapTo... suggestions take precedence over more useful suggestions HOT 6
- Code completion for annotation parameters like @Mapping is not working HOT 5
- False positive missing mapping warning HOT 11
- Incorrect no source property defined inspection for `@Mapping`
- Renaming a @Getter annotated field results in a getter inside the mapping definition (instead of the new field name) HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapstruct-idea.