protected CopyQualifiedNameService getCopyQualifiedNameService(EObject selectedElement) { if (selectedElement == null) { return null; } IResourceServiceProvider resourceServiceProvider = registry.getResourceServiceProvider(selectedElement.eResource().getURI()); if (resourceServiceProvider == null) { return null; } return resourceServiceProvider.get(CopyQualifiedNameService.class); }
private void index(Resource resource, URI uri, ResourceDescriptionsData index) { IResourceServiceProvider serviceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(uri); if (serviceProvider != null) { IResourceDescription resourceDescription = serviceProvider.getResourceDescriptionManager().getResourceDescription(resource); if (resourceDescription != null) { index.addDescription(uri, resourceDescription); } } }
/** @since 2.3 */ protected List<IResourceDescription.Delta> getRelevantDeltas(IBuildContext context) { List<IResourceDescription.Delta> result = newArrayList(); for (IResourceDescription.Delta delta : context.getDeltas()) { if (resourceServiceProvider.canHandle(delta.getUri())) result.add(delta); } return result; }
public void configure(Resource r) { resource = r; IResourceDescriptions descriptionIndex = indexProvider.getResourceDescriptions(resource); IResourceDescription descr = descriptionIndex.getResourceDescription(resource.getURI()); manager = resourceServiceProvider.getContainerManager(); buildExportedObjectsIndex(descr, descriptionIndex); searchPath = searchPathProvider.get(r); }
protected boolean validate(final Resource resource) { URI _uRI = resource.getURI(); IResourceServiceProvider _resourceServiceProvider = this.context.getResourceServiceProvider(_uRI); final IResourceValidator resourceValidator = _resourceServiceProvider.getResourceValidator(); boolean _equals = Objects.equal(resourceValidator, null); if (_equals) { return true; } URI _uRI_1 = resource.getURI(); String _lastSegment = _uRI_1.lastSegment(); String _plus = ("Starting validation for input: \'" + _lastSegment); String _plus_1 = (_plus + "\'"); IncrementalBuilder.InternalStatefulIncrementalBuilder.LOG.info(_plus_1); final List<Issue> validationResult = resourceValidator.validate(resource, CheckMode.ALL, null); BuildRequest.IPostValidationCallback _afterValidate = this.request.getAfterValidate(); URI _uRI_2 = resource.getURI(); return _afterValidate.afterValidate(_uRI_2, validationResult); }
private ResourceSet createResourceSet(URI genModelUri) { ResourceSetImpl resourceSet; if (genModelUri.fileExtension().equals("xcore")) { IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(genModelUri); IStorage2UriMapper storage2UriMapper = resourceServiceProvider.get(IStorage2UriMapper.class); IProject project = storage2UriMapper.getStorages(genModelUri).iterator().next().getSecond(); resourceSet = (ResourceSetImpl) resourceServiceProvider.get(IResourceSetProvider.class).get(project); } else { resourceSet = new ResourceSetImpl(); } Resource ecorePackageResource = EcorePackage.eINSTANCE.eResource(); Map<URI, Resource> uriResourceMap = Maps.newHashMap(); uriResourceMap.put( URI.createPlatformResourceURI(PATH_TO_ECORE_ECORE, true), ecorePackageResource); uriResourceMap.put( URI.createPlatformPluginURI(PATH_TO_ECORE_ECORE, true), ecorePackageResource); resourceSet.setURIResourceMap(uriResourceMap); return resourceSet; }
/** @since 2.3 */ protected List<IResourceDescription.Delta> getRelevantDeltas(IBuildContext context) { List<IResourceDescription.Delta> result = newArrayList(); for (IResourceDescription.Delta delta : context.getDeltas()) { if (resourceServiceProvider.canHandle(delta.getUri()) && (resourceServiceProvider instanceof IResourceServiceProviderExtension) && !((IResourceServiceProviderExtension) resourceServiceProvider) .isReadOnly(delta.getUri())) { result.add(delta); } } return result; }
private void buildExportedObjectsIndex( IResourceDescription descr, IResourceDescriptions descriptionIndex) { // The current (possibly dirty) exported resources IResourceDescription dirty = resourceServiceProvider.getResourceDescriptionManager().getResourceDescription(resource); String pathToCurrent = resource.getURI().path(); Multimap<String, IEObjectDescription> map = ArrayListMultimap.create(); // add all (possibly dirty in global index) for (IEObjectDescription d : dirty.getExportedObjects()) map.put(d.getQualifiedName().getLastSegment(), d); // add all from global index, except those for current resource for (IEObjectDescription d : getExportedObjects(descr, descriptionIndex)) if (!d.getEObjectURI().path().equals(pathToCurrent)) map.put(d.getQualifiedName().getLastSegment(), d); exportedPerLastSegment = map; }
public IResourceDescription getDescription() { return serviceProvider.getResourceDescriptionManager().getResourceDescription(resource); }
protected URIBasedFileSystemAccess createFileSystemAccess( final IResourceServiceProvider serviceProvider, final Resource resource) { URIBasedFileSystemAccess _xblockexpression = null; { final IProjectConfigProvider projectConfigProvider = serviceProvider.<IProjectConfigProvider>get(IProjectConfigProvider.class); IProjectConfig _projectConfig = null; if (projectConfigProvider != null) { ResourceSet _resourceSet = resource.getResourceSet(); _projectConfig = projectConfigProvider.getProjectConfig(_resourceSet); } final IProjectConfig projectConfig = _projectConfig; ISourceFolder _findSourceFolderContaining = null; if (projectConfig != null) { URI _uRI = resource.getURI(); _findSourceFolderContaining = projectConfig.findSourceFolderContaining(_uRI); } final ISourceFolder sourceFolder = _findSourceFolderContaining; URIBasedFileSystemAccess _uRIBasedFileSystemAccess = new URIBasedFileSystemAccess(); final Procedure1<URIBasedFileSystemAccess> _function = new Procedure1<URIBasedFileSystemAccess>() { @Override public void apply(final URIBasedFileSystemAccess it) { final IContextualOutputConfigurationProvider outputConfigProvider = serviceProvider.<IContextualOutputConfigurationProvider>get( IContextualOutputConfigurationProvider.class); Set<OutputConfiguration> _outputConfigurations = outputConfigProvider.getOutputConfigurations(resource); final Function1<OutputConfiguration, String> _function = new Function1<OutputConfiguration, String>() { @Override public String apply(final OutputConfiguration it) { return it.getName(); } }; Map<String, OutputConfiguration> _map = IterableExtensions.<String, OutputConfiguration>toMap( _outputConfigurations, _function); it.setOutputConfigurations(_map); IFilePostProcessor _get = serviceProvider.<IFilePostProcessor>get(IFilePostProcessor.class); it.setPostProcessor(_get); final IEncodingProvider newEncodingProvider = serviceProvider.<IEncodingProvider>get(IEncodingProvider.class); boolean _notEquals = (!Objects.equal(newEncodingProvider, null)); if (_notEquals) { it.setEncodingProvider(newEncodingProvider); } TraceFileNameProvider _get_1 = serviceProvider.<TraceFileNameProvider>get(TraceFileNameProvider.class); it.setTraceFileNameProvider(_get_1); TraceRegionSerializer _get_2 = serviceProvider.<TraceRegionSerializer>get(TraceRegionSerializer.class); it.setTraceRegionSerializer(_get_2); it.setGenerateTraces(true); URI _baseDir = InternalStatefulIncrementalBuilder.this.request.getBaseDir(); it.setBaseDir(_baseDir); String _name = null; if (sourceFolder != null) { _name = sourceFolder.getName(); } it.setCurrentSource(_name); ResourceSet _resourceSet = resource.getResourceSet(); URIConverter _uRIConverter = _resourceSet.getURIConverter(); it.setConverter(_uRIConverter); } }; _xblockexpression = ObjectExtensions.<URIBasedFileSystemAccess>operator_doubleArrow( _uRIBasedFileSystemAccess, _function); } return _xblockexpression; }
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); }