use of com.intellij.structuralsearch.impl.matcher.MatchResultImpl in project intellij-community by JetBrains.
the class SubstitutionHandler method addResult.
public void addResult(PsiElement match, int start, int end, MatchContext context) {
if (totalMatchedOccurs == -1) {
final MatchResultImpl matchResult = context.getResult();
final MatchResultImpl substitution = matchResult.findSon(name);
if (substitution == null) {
matchResult.addSon(createMatch(match, start, end));
} else if (maxOccurs > 1) {
final MatchResultImpl result = createMatch(match, start, end);
if (!substitution.isMultipleMatch()) {
// adding intermediate node to contain all multiple matches
final MatchResultImpl sonresult = new MatchResultImpl(substitution.getName(), substitution.getMatchImage(), substitution.getMatchRef(), substitution.getStart(), substitution.getEnd(), target);
substitution.setMatchRef(new SmartPsiPointer(match == null ? null : match));
substitution.setMultipleMatch(true);
if (substitution.isScopeMatch()) {
substitution.setScopeMatch(false);
sonresult.setScopeMatch(true);
for (MatchResult r : substitution.getAllSons()) sonresult.addSon((MatchResultImpl) r);
substitution.clearMatches();
}
substitution.addSon(sonresult);
}
substitution.addSon(result);
}
}
}
Aggregations