private static @Nullable LookupElementBuilder buildEntityLookupItem(final @NotNull XmlEntityDecl decl) {
    final String name = decl.getName();
    if (name == null) {
      return null;
    }

    final LookupElementBuilder result = LookupElementBuilder.create(name).withInsertHandler(ENTITY_INSERT_HANDLER);
    final XmlAttributeValue value = decl.getValueElement();
    final ASTNode node = value.getNode();
    if (node != null) {
      final ASTNode[] nodes = node.getChildren(TokenSet.create(XmlTokenType.XML_CHAR_ENTITY_REF));
      if (nodes.length == 1) {
        final String valueText = nodes[0].getText();
        final int i = valueText.indexOf('#');
        if (i > 0) {
          String s = valueText.substring(i + 1);
          s = StringUtil.trimEnd(s, ";");

          try {
            final char unicodeChar = (char)Integer.valueOf(s).intValue();
            return result.withTypeText(String.valueOf(unicodeChar)).withLookupString(String.valueOf(unicodeChar));
          }
          catch (NumberFormatException e) {
            return result;
          }
        }
      }
    }

    return result;
  }
private static @Nullable LookupElementBuilder buildEntityLookupItem(final @NotNull XmlEntityDecl decl)