### Question:
MatchCaseTreeImpl extends BaseTreeImpl implements MatchCaseTree { @Override public TextRange rangeToHighlight() { if (body == null) { return textRange(); } TextRange bodyRange = body.metaData().textRange(); List<TextRange> tokenRangesBeforeBody = metaData().tokens().stream() .map(Token::textRange) .filter(t -> t.start().compareTo(bodyRange.start()) < 0) .collect(Collectors.toList()); if (tokenRangesBeforeBody.isEmpty()) { return bodyRange; } return TextRanges.merge(tokenRangesBeforeBody); } MatchCaseTreeImpl(TreeMetaData metaData, @Nullable Tree expression, @Nullable Tree body); @CheckForNull @Override Tree expression(); @CheckForNull @Override Tree body(); @Override TextRange rangeToHighlight(); @Override List<Tree> children();  }### Answer:
@Test public void rangeToHighlight() { TreeMetaDataProvider metaDataProvider = new TreeMetaDataProvider(emptyList(), TOKENS); TreeMetaData matchCaseMetaData = metaDataProvider.metaData(range(1, 1, 1, 10)); TreeMetaData bodyMetaData = metaDataProvider.metaData(range(1, 9, 1, 10)); BlockTree body = new BlockTreeImpl(bodyMetaData, Collections.singletonList(new IdentifierTreeImpl(bodyMetaData, "a"))); assertThat(new MatchCaseTreeImpl(matchCaseMetaData, null, body).rangeToHighlight()) .isEqualTo(range(1, 1, 1, 8)); }
@Test public void rangeToHighlight_with_empty_body() { TreeMetaDataProvider metaDataProvider = new TreeMetaDataProvider(emptyList(), TOKENS); TreeMetaData matchCaseMetaData = metaDataProvider.metaData(range(1, 1, 1, 8)); TreeMetaData bodyMetaData = metaDataProvider.metaData(range(1, 1, 1, 8)); BlockTree body = new BlockTreeImpl(bodyMetaData, emptyList()); assertThat(new MatchCaseTreeImpl(matchCaseMetaData, null, body).rangeToHighlight()) .isEqualTo(range(1, 1, 1, 8)); assertThat(new MatchCaseTreeImpl(matchCaseMetaData, null, null).rangeToHighlight()) .isEqualTo(range(1, 1, 1, 8)); }