public static boolean isWellEndedString(PsiElement element) {
    final String text = element.getText();

    if (!(text.endsWith("'") ||
          text.endsWith("\"") ||
          text.endsWith("'''") ||
          text.endsWith("\"\"\"") ||
          text.endsWith("/") ||
          text.endsWith("/$"))) {
      return false;
    }


    final IElementType type = element.getNode().getElementType();
    if (TokenSets.STRING_LITERAL_SET.contains(type)) return true;

    final PsiElement lastChild = element.getLastChild();
    if (lastChild == null) return false;

    final IElementType lastType = lastChild.getNode().getElementType();
    if (type == GroovyElementTypes.GSTRING) return lastType == GroovyTokenTypes.mGSTRING_END;
    if (type == GroovyElementTypes.REGEX) return lastType == GroovyTokenTypes.mREGEX_END || lastType ==
                                                                                            GroovyTokenTypes.mDOLLAR_SLASH_REGEX_END;

    return false;
  }
public static boolean isWellEndedString(PsiElement element)