void (@NotNull final PsiLanguageInjectionHost host, @NotNull final InjectedLanguagePlaces injectionPlacesRegistrar) { if (host instanceof RestLine) { int start = 0; int end = host.getTextLength() - 1; final String text = host.getText(); final List<String> strings = StringUtil.split(text, "\n", false); boolean gotExample = false; int currentPosition = 0; boolean endsWithSlash = false; for (String string : strings) { final String trimmedString = string.trim(); if (!trimmedString.startsWith(">>>") && !trimmedString.startsWith("...") && gotExample && start < end) { gotExample = false; if (!endsWithSlash) injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(), TextRange.create(start, end), null, null); } if (endsWithSlash) { endsWithSlash = false; injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(), TextRange.create(start, getEndOffset(currentPosition, string)), null, null); } if (trimmedString.startsWith(">>>")) { if (trimmedString.endsWith("\\")) endsWithSlash = true; if (!gotExample) start = currentPosition; gotExample = true; end = getEndOffset(currentPosition, string); } else if (trimmedString.startsWith("...") && gotExample) { if (trimmedString.endsWith("\\")) endsWithSlash = true; end = getEndOffset(currentPosition, string); } currentPosition += string.length(); } if (gotExample && start < end) injectionPlacesRegistrar.addPlace(PyDocstringLanguageDialect.getInstance(), TextRange.create(start, end), null, null); } }