int (@NotNull final Document doc, @NotNull final PsiFile psiFile, int start, int end) { if (!(psiFile instanceof PropertiesFile)) return -1; final String documentText = doc.getText(); final String documentTextTillEndOfFirstLine = documentText.substring(0, start + 1); if (!PropertiesUtil.isUnescapedBackSlashAtTheEnd(documentTextTillEndOfFirstLine)) return CANNOT_JOIN; if (end < documentText.length() && startsWithEscapedWhitespace(documentText.substring(end))) { // if the second line starts with escaped whitespace (e.g. '\ '), then remove it too end ++; } // strip the continuation char '\', // the leading whitespaces on the second line and // the optional '\' if the text on the second line starts with '\ ' doc.deleteString(start, end); return start; }