Skip to content

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

@Cerber-Ursi

Description

@Cerber-Ursi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions