ParseException (@InspectionMessage String message, String text, int clauseNumber, int constraintNumber) { TextRange range = findClauseRange(text, clauseNumber); if (range == null) { return new ParseException(message); } int start = range.getStartOffset(); while (constraintNumber > 0) { start = text.indexOf(',', start); if (start == -1) return new ParseException(message, range); start++; constraintNumber--; } int end = text.indexOf(',', start); if (end == -1 || end > range.getEndOffset()) { end = text.indexOf("->", start); if (end == -1 || end > range.getEndOffset()) { end = range.getEndOffset(); } } if (!text.substring(start, end).trim().isEmpty()) { while (text.charAt(start) == ' ') start++; while (end > start && text.charAt(end - 1) == ' ') end--; } return new ParseException(message, new TextRange(start, end)); }