public static boolean containsWhiteSpacesOnly(@NotNull ASTNode node) { PsiElement psiElement = node.getPsi(); if (psiElement instanceof PsiWhiteSpace) return true; Language nodeLang = psiElement.getLanguage(); if (!nodeLang.isKindOf(XMLLanguage.INSTANCE) || isTextOnlyNode(node) || node.getElementType() == XmlElementType.XML_PROLOG) { WhiteSpaceFormattingStrategy strategy = WhiteSpaceFormattingStrategyFactory.getStrategy(nodeLang); int length = node.getTextLength(); return strategy.check(node.getChars(), 0, length) >= length; } return false; }
public static boolean containsWhiteSpacesOnly(ASTNode node) { WhiteSpaceFormattingStrategy strategy = WhiteSpaceFormattingStrategyFactory.getStrategy(node.getPsi().getLanguage()); String nodeText = node.getText(); int length = nodeText.length(); return strategy.check(nodeText, 0, length) >= length; }