private void addTypeCastToImplicitReceiver(
     XFeatureCall featureCall, IModificationContext context, JvmType declaringType)
     throws BadLocationException {
   String receiver;
   if (featureCall.getImplicitReceiver() instanceof XAbstractFeatureCall)
     receiver =
         ((XAbstractFeatureCall) featureCall.getImplicitReceiver()).getFeature().getSimpleName();
   else return;
   List<INode> nodes =
       NodeModelUtils.findNodesForFeature(
           featureCall, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE);
   if (nodes.isEmpty()) return;
   INode firstNode = IterableExtensions.head(nodes);
   int offset = firstNode.getOffset();
   ReplacingAppendable appendable =
       appendableFactory.create(
           context.getXtextDocument(), (XtextResource) featureCall.eResource(), offset, 0);
   appendable.append("(");
   appendable.append(receiver);
   appendable.append(" as ");
   appendable.append(declaringType);
   appendable.append(").");
   appendable.commitChanges();
 }