List<FileHyperlinkRawData> (@NotNull String line) { if (line.length() > myMaxLineLength) { return Collections.emptyList(); } Pair<Matcher, PatternHyperlinkFormat> pair = findMatcher(line); if (pair == null) { return Collections.emptyList(); } Matcher matcher = pair.first; PatternHyperlinkFormat format = pair.second; PatternHyperlinkPart[] linkParts = format.getLinkParts(); int groupCount = matcher.groupCount(); if (groupCount > linkParts.length) { return Collections.emptyList(); } String path = null; int lineNumber = -1, columnNumber = -1; int hyperlinkStartInd = -1, hyperlinkEndInd = -1; boolean hyperlinkFreezed = false; for (int i = 1; i <= groupCount; i++) { String value = matcher.group(i); if (value == null) { continue; } PatternHyperlinkPart part = linkParts[i - 1]; if (part == PatternHyperlinkPart.HYPERLINK) { hyperlinkStartInd = matcher.start(i); hyperlinkEndInd = matcher.end(i); hyperlinkFreezed = true; } else if (part == PatternHyperlinkPart.PATH) { path = value; if (!hyperlinkFreezed) { hyperlinkStartInd = matcher.start(i); hyperlinkEndInd = matcher.end(i); } } else if (part == PatternHyperlinkPart.LINE) { value = StringUtil.trimStart(value, ":"); lineNumber = StringUtil.parseInt(value, UNKNOWN); hyperlinkEndInd = tryExtendHyperlinkEnd(hyperlinkFreezed, hyperlinkEndInd, matcher.start(i), matcher.end(i)); } else if (part == PatternHyperlinkPart.COLUMN) { value = StringUtil.trimStart(value, ":"); columnNumber = StringUtil.parseInt(value, UNKNOWN); if (columnNumber != UNKNOWN) { hyperlinkEndInd = tryExtendHyperlinkEnd(hyperlinkFreezed, hyperlinkEndInd, matcher.start(i), matcher.end(i)); } } } if (path == null || lineNumber == UNKNOWN || columnNumber == UNKNOWN || hyperlinkStartInd == -1) { return Collections.emptyList(); } if (!format.isZeroBasedLineNumbering()) { lineNumber--; } if (!format.isZeroBasedColumnNumbering()) { columnNumber--; } lineNumber = Math.max(lineNumber, -1); columnNumber = Math.max(columnNumber, -1); FileHyperlinkRawData data = new FileHyperlinkRawData(path, lineNumber, columnNumber, hyperlinkStartInd, hyperlinkEndInd); return Collections.singletonList(data); }