/** @since 2.8 */
 protected void saveResourceStorage(Resource resource, IFileSystemAccess access) {
   if (resource instanceof StorageAwareResource && access instanceof IFileSystemAccessExtension3) {
     IResourceStorageFacade storageFacade =
         ((StorageAwareResource) resource).getResourceStorageFacade();
     if (storageFacade != null) {
       storageFacade.saveResource(
           (StorageAwareResource) resource, (IFileSystemAccessExtension3) access);
     }
   }
 }
 protected void generate(
     final Resource resource,
     final BuildRequest request,
     final Source2GeneratedMapping newMappings) {
   URI _uRI = resource.getURI();
   final IResourceServiceProvider serviceProvider =
       this.context.getResourceServiceProvider(_uRI);
   final GeneratorDelegate generator =
       serviceProvider.<GeneratorDelegate>get(GeneratorDelegate.class);
   boolean _equals = Objects.equal(generator, null);
   if (_equals) {
     return;
   }
   URI _uRI_1 = resource.getURI();
   final Set<URI> previous = newMappings.deleteSource(_uRI_1);
   URIBasedFileSystemAccess _createFileSystemAccess =
       this.createFileSystemAccess(serviceProvider, resource);
   final Procedure1<URIBasedFileSystemAccess> _function =
       new Procedure1<URIBasedFileSystemAccess>() {
         @Override
         public void apply(final URIBasedFileSystemAccess it) {
           final URIBasedFileSystemAccess.BeforeWrite _function =
               new URIBasedFileSystemAccess.BeforeWrite() {
                 @Override
                 public InputStream beforeWrite(
                     final URI uri, final String outputCfgName, final InputStream contents) {
                   URI _uRI = resource.getURI();
                   newMappings.addSource2Generated(_uRI, uri, outputCfgName);
                   previous.remove(uri);
                   Procedure2<? super URI, ? super URI> _afterGenerateFile =
                       request.getAfterGenerateFile();
                   URI _uRI_1 = resource.getURI();
                   _afterGenerateFile.apply(_uRI_1, uri);
                   return contents;
                 }
               };
           it.setBeforeWrite(_function);
           final URIBasedFileSystemAccess.BeforeDelete _function_1 =
               new URIBasedFileSystemAccess.BeforeDelete() {
                 @Override
                 public boolean beforeDelete(final URI uri) {
                   newMappings.deleteGenerated(uri);
                   Procedure1<? super URI> _afterDeleteFile = request.getAfterDeleteFile();
                   _afterDeleteFile.apply(uri);
                   return true;
                 }
               };
           it.setBeforeDelete(_function_1);
         }
       };
   final URIBasedFileSystemAccess fileSystemAccess =
       ObjectExtensions.<URIBasedFileSystemAccess>operator_doubleArrow(
           _createFileSystemAccess, _function);
   fileSystemAccess.setContext(resource);
   boolean _isWriteStorageResources = request.isWriteStorageResources();
   if (_isWriteStorageResources) {
     boolean _matched = false;
     if (resource instanceof StorageAwareResource) {
       IResourceStorageFacade _resourceStorageFacade =
           ((StorageAwareResource) resource).getResourceStorageFacade();
       boolean _notEquals = (!Objects.equal(_resourceStorageFacade, null));
       if (_notEquals) {
         _matched = true;
         IResourceStorageFacade _resourceStorageFacade_1 =
             ((StorageAwareResource) resource).getResourceStorageFacade();
         _resourceStorageFacade_1.saveResource(
             ((StorageAwareResource) resource), fileSystemAccess);
       }
     }
   }
   final GeneratorContext generatorContext = new GeneratorContext();
   CancelIndicator _cancelIndicator = request.getCancelIndicator();
   generatorContext.setCancelIndicator(_cancelIndicator);
   generator.generate(resource, fileSystemAccess, generatorContext);
   final Procedure1<URI> _function_1 =
       new Procedure1<URI>() {
         @Override
         public void apply(final URI it) {
           try {
             IncrementalBuilder.InternalStatefulIncrementalBuilder.LOG.info(
                 ("Deleting stale generated file " + it));
             XtextResourceSet _resourceSet =
                 InternalStatefulIncrementalBuilder.this.context.getResourceSet();
             URIConverter _uRIConverter = _resourceSet.getURIConverter();
             Map<Object, Object> _emptyMap = CollectionLiterals.<Object, Object>emptyMap();
             _uRIConverter.delete(it, _emptyMap);
             Procedure1<? super URI> _afterDeleteFile = request.getAfterDeleteFile();
             _afterDeleteFile.apply(it);
           } catch (Throwable _e) {
             throw Exceptions.sneakyThrow(_e);
           }
         }
       };
   IterableExtensions.<URI>forEach(previous, _function_1);
 }