mapstruct-idea
mapstruct-idea copied to clipboard
No language injection for expressions when target is a field
Consider the following code:
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
class Target {
public String value;
}
class Source {
}
@Mapper
abstract class SourceToScratchMapper {
@Mapping(target = "value", expression = "java(new Source().toString())")
public abstract Target map(Source source);
}
In this case, code inside expression parameter is treated as a plain string, i.e. no code highlighting and no navigation assistance. However, if we add a setter to the Target class -
class Target {
public String value;
public void setValue(String value) {
this.value = value;
}
}
...leaving mapper and source the same, the language is injected correctly - code inside java(...) is treated as Java fragment.
In fact, the fix seems to be easy, so sent the #96 with patch.