public String getReferenceName() { PsiElement nameElement = getReferenceNameElement(); if (nameElement != null) { IElementType nodeType = nameElement.getNode().getElementType(); if (TokenSets.STRING_LITERAL_SET.contains(nodeType)) { final Object value = GrLiteralImpl.getLiteralValue(nameElement); if (value instanceof String) { return (String) value; } } return nameElement.getText(); } return null; }
@NotNull public static String getName(@NotNull GrNamedElement namedElement) { PsiElement nameElement = namedElement.getNameIdentifierGroovy(); ASTNode node = nameElement.getNode(); LOG.assertTrue(node != null); if (node.getElementType() == mIDENT) { return nameElement.getText(); } if (node.getElementType() == mSTRING_LITERAL || node.getElementType() == mGSTRING_LITERAL) { final Object value = GrLiteralImpl.getLiteralValue(nameElement); if (value instanceof String) { return (String) value; } else { return GrStringUtil.removeQuotes(nameElement.getText()); } } throw new IncorrectOperationException( "incorrect name element: " + node.getElementType() + ", named element: " + namedElement); }