Пример #1
0
 public IncrementalBuilder.Result build(
     final BuildRequest request,
     final Function1<? super URI, ? extends IResourceServiceProvider> languages,
     final IResourceClusteringPolicy clusteringPolicy) {
   try {
     final XtextResourceSet resourceSet = request.getResourceSet();
     IndexState _state = request.getState();
     ResourceDescriptionsData _resourceDescriptions = _state.getResourceDescriptions();
     ResourceDescriptionsData _copy = _resourceDescriptions.copy();
     IndexState _state_1 = request.getState();
     Source2GeneratedMapping _fileMappings = _state_1.getFileMappings();
     Source2GeneratedMapping _copy_1 = _fileMappings.copy();
     final IndexState oldState = new IndexState(_copy, _copy_1);
     CancelIndicator _cancelIndicator = request.getCancelIndicator();
     final BuildContext context =
         new BuildContext(languages, resourceSet, oldState, clusteringPolicy, _cancelIndicator);
     final IncrementalBuilder.InternalStatefulIncrementalBuilder builder = this.provider.get();
     builder.context = context;
     builder.request = request;
     try {
       return builder.launch();
     } catch (final Throwable _t) {
       if (_t instanceof Throwable) {
         final Throwable t = (Throwable) _t;
         this._operationCanceledManager.propagateIfCancelException(t);
         throw t;
       } else {
         throw Exceptions.sneakyThrow(_t);
       }
     }
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }
Пример #2
0
 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);
 }