SpaceRequirements (ASTNode left, ASTNode right) { final IElementType lType = left.getElementType(); final IElementType rType = right.getElementType(); if (rType == GroovyTokenTypes.kIMPORT && lType != TokenType.WHITE_SPACE) { return SpaceRequirements.MUST_LINE_BREAK; } else if (lType == MODIFIER_LIST && rType == MODIFIER_LIST) { return SpaceRequirements.MUST; } if (lType == GroovyTokenTypes.mSEMI) { return SpaceRequirements.MAY; } if (lType == GroovyTokenTypes.mSL_COMMENT) { return SpaceRequirements.MUST_LINE_BREAK; } if (lType == GroovyTokenTypes.mNLS || lType == GroovyDocTokenTypes.mGDOC_COMMENT_START) { return SpaceRequirements.MAY; } if (lType == GroovyTokenTypes.mGT) return SpaceRequirements.MUST; if (rType == GroovyTokenTypes.mLT) return SpaceRequirements.MUST; final ASTNode parent = TreeUtil.findCommonParent(left, right); if (parent == null || ArrayUtil.contains(parent.getElementType(), GSTRING, REGEX, GSTRING_INJECTION, GroovyTokenTypes.mREGEX_LITERAL, GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL)) { return SpaceRequirements.MUST_NOT; } return LanguageUtil.canStickTokensTogetherByLexer(left, right, new GroovyLexer()); }