Object (PsiElement child) { IElementType elemType = child.getNode().getElementType(); String text = child.getText(); if (TokenSets.NUMBERS.contains(elemType)) { try { if (elemType == GroovyTokenTypes.mNUM_INT) { return LiteralUtilKt.parseInteger(text); } else if (elemType == GroovyTokenTypes.mNUM_LONG) { return PsiLiteralUtil.parseLong(text); } else if (elemType == GroovyTokenTypes.mNUM_FLOAT) { return PsiLiteralUtil.parseFloat(text); } else if (elemType == GroovyTokenTypes.mNUM_DOUBLE) { return PsiLiteralUtil.parseDouble(text); } else if (elemType == GroovyTokenTypes.mNUM_BIG_INT) { return new BigInteger(text.substring(0, text.length() - 1)); // g or G suffix } else if (elemType == GroovyTokenTypes.mNUM_BIG_DECIMAL) { char lastChar = text.charAt(text.length() - 1); if (lastChar == 'g' || lastChar == 'G') { return new BigDecimal(text.substring(0, text.length() - 1)); } else { return new BigDecimal(text); } } } catch (NumberFormatException ignored) { } } else if (elemType == GroovyTokenTypes.kFALSE) { return Boolean.FALSE; } else if (elemType == GroovyTokenTypes.kTRUE) { return Boolean.TRUE; } else if (elemType == STRING_SQ || elemType == STRING_TSQ) { if (!text.startsWith("'")) return null; text = GrStringUtil.removeQuotes(text); StringBuilder chars = new StringBuilder(text.length()); boolean result = GrStringUtil.parseStringCharacters(text, chars, null); return result ? chars.toString() : null; } else if (elemType == STRING_DQ || elemType == STRING_TDQ) { if (!text.startsWith("\"")) return null; text = GrStringUtil.removeQuotes(text); StringBuilder chars = new StringBuilder(text.length()); boolean result = GrStringUtil.parseStringCharacters(text, chars, null); return result ? chars.toString() : null; } else if (elemType == GroovyTokenTypes.mREGEX_LITERAL) { final PsiElement cchild = child.getFirstChild(); if (cchild == null) return null; final PsiElement sibling = cchild.getNextSibling(); if (sibling == null) return null; text = sibling.getText(); final StringBuilder chars = new StringBuilder(text.length()); boolean result = GrStringUtil.parseRegexCharacters(text, chars, null, true); return result ? chars.toString() : null; } else if (elemType == GroovyTokenTypes.mDOLLAR_SLASH_REGEX_LITERAL) { final PsiElement cchild = child.getFirstChild(); if (cchild == null) return null; final PsiElement sibling = cchild.getNextSibling(); if (sibling == null) return null; text = sibling.getText(); final StringBuilder chars = new StringBuilder(text.length()); boolean result = GrStringUtil.parseRegexCharacters(text, chars, null, false); return result ? chars.toString() : null; } else if (elemType == GroovyTokenTypes.kNULL) { return ObjectUtils.NULL; } return null; }