List<TextContent> (@NotNull PsiElement root, @NotNull Set<TextContent.TextDomain> allowedDomains) { if (root instanceof PsiPlainText && root.getContainingFile().getName().endsWith(".txt")) { String text = root.getText(); List<TextContent> result = new ArrayList<>(); int[] ends = StreamEx.of(Text.allOccurrences(paragraphEnd, text)).mapToInt(TextRange::getStartOffset).append(text.length()).toArray(); for (int i = 0; i < ends.length; i++) { int start = i == 0 ? 0 : ends[i - 1]; int end = ends[i]; ContainerUtil.addIfNotNull(result, TextContent.builder().build(root, TextContent.TextDomain.PLAIN_TEXT, new TextRange(start, end))); } return result; } return Collections.emptyList(); }