boolean (PsiElement match, int start, int end, @NotNull MatchContext context) { if (match == null || predicate != null && !predicate.match(match, start, end, context)) { return false; } MatchResult result = context.hasResult() ? context.getResult().findChild(name) : null; if (result == null && myNestedResult != null) { result = myNestedResult.findChild(name); } if (result == null) { final MatchResultImpl previous = context.getPreviousResult(); if (previous != null) { result = previous.findChild(name); } } if (result != null) { if (minOccurs == 1 && maxOccurs == 1) { // check if they are the same return validateOneMatch(match, start, end, result, context); } if (maxOccurs > 1 && totalMatchedOccurs != -1) { if (result.isMultipleMatch()) { final List<MatchResult> children = result.getChildren(); final int size = children.size(); if (matchedOccurs >= size) { return false; } if (size != 0) { result = children.get(matchedOccurs); } } // check if they are the same return validateOneMatch(match, start, end, result, context); } } return true; }