Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No language injection for expressions when target is a field #95

Closed
Cerber-Ursi opened this issue Apr 15, 2022 · 1 comment · Fixed by #116
Closed

No language injection for expressions when target is a field #95

Cerber-Ursi opened this issue Apr 15, 2022 · 1 comment · Fixed by #116
Milestone

Comments

@Cerber-Ursi
Copy link
Contributor

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.

@Cerber-Ursi
Copy link
Contributor Author

In fact, the fix seems to be easy, so sent the #96 with patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants