boolean (PsiElement element, boolean next, PsiElement sibling) { if (sibling instanceof RegExpChar) { final int value = ((RegExpChar)sibling).getValue(); if (value == ' ') { ShredManager shredManager = new ShredManager(element); ShredInfo shredInfo = shredManager.getShredInfo(element.getParent().getText()); if (shredInfo == null || shredInfo.getHost() == null) return true; if (RegExpLanguageHosts.getInstance().belongsToConditionalExpression(element, shredInfo.getHost())) { return shredManager.containsCloseRealWhiteSpace(shredInfo, next); } } return value != '\n' && value != '\r'; } else if (sibling instanceof RegExpSimpleClass) { final RegExpSimpleClass.Kind kind = ((RegExpSimpleClass)sibling).getKind(); return switch (kind) { case ANY, NON_DIGIT, NON_WORD, SPACE, NON_HORIZONTAL_SPACE, NON_VERTICAL_SPACE, NON_XML_NAME_START, NON_XML_NAME_PART, UNICODE_LINEBREAK -> false; default -> true; }; } else if (sibling instanceof RegExpClosure closure) { return isUnexpectedSibling(element, next, closure.getAtom()); } else if (sibling instanceof RegExpGroup group) { return isUnexpectedSibling(element, next, group.getPattern()); } else if (sibling instanceof RegExpPattern pattern) { for (RegExpBranch branch : pattern.getBranches()) { if (isUnexpectedSibling(element, next, branch)) { return true; } } return false; } else if (sibling instanceof RegExpBranch) { final RegExpBranch branch = (RegExpBranch)sibling; for (RegExpAtom atom : branch.getAtoms()) { if (isUnexpectedSibling(element, next, atom)) { return true; } } return false; } return sibling instanceof RegExpBoundary; }