@Override public Set<Binding> getGuiceBindingsRt(Grammar grammar) { return new BindFactory() .addTypeToType(IContainer.Manager.class.getName(), StateBasedContainerManager.class.getName()) .addTypeToType(IAllContainersState.Provider.class.getName(), org.eclipse.xtext.resource.containers.ResourceSetBasedAllContainersStateProvider.class.getName()) .addConfiguredBinding( IResourceDescriptions.class.getName(), "binder.bind(" + IResourceDescriptions.class.getName() + ".class" + ").to(" + ResourceSetBasedResourceDescriptions.class.getName() + ".class)") .addConfiguredBinding( IResourceDescriptions.class.getName() + "Persisted", "binder.bind("+ IResourceDescriptions.class.getName() + ".class" + ").annotatedWith(com.google.inject.name.Names.named(" + "org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(" + ResourceSetBasedResourceDescriptions.class.getName() + ".class)") .getBindings(); }
@Override public void setContext(final Notifier ctx) { IResourceDescriptions _localDescriptions = this.getLocalDescriptions(); final Procedure1<ResourceSetBasedResourceDescriptions> _function = (ResourceSetBasedResourceDescriptions it) -> { it.setContext(ctx); it.setData(null); }; ObjectExtensions.<ResourceSetBasedResourceDescriptions>operator_doubleArrow(((ResourceSetBasedResourceDescriptions) _localDescriptions), _function); final ResourceSet resourceSet = EcoreUtil2.getResourceSet(ctx); this.setGlobalDescriptions(ChunkedResourceDescriptions.findInEmfObject(resourceSet)); IProjectConfig _projectConfig = null; if (this.projectConfigProvider!=null) { _projectConfig=this.projectConfigProvider.getProjectConfig(resourceSet); } IWorkspaceConfig _workspaceConfig = null; if (_projectConfig!=null) { _workspaceConfig=_projectConfig.getWorkspaceConfig(); } this.workspaceConfig = _workspaceConfig; }
@Test public void testContainsURI() { String fileExtension = fep.getPrimaryFileExtension(); XtextResourceSet xtextResourceSet1 = rsp.get(); xtextResourceSet1.createResource(URI.createURI("/a/x." + fileExtension)); xtextResourceSet1.createResource(URI.createURI("/b/x1." + fileExtension)); ResourceSetBasedResourceDescriptions liveState = new ResourceSetBasedResourceDescriptions(); liveState.setContext(xtextResourceSet1); liveState.setRegistry(registry); Multimap<String, URI> container2Uris = ArrayListMultimap.create(); container2Uris.put("a", URI.createURI("/a/x." + fileExtension)); container2Uris.put("a", URI.createURI("/a/y." + fileExtension)); container2Uris.put("b", URI.createURI("/b/x1." + fileExtension)); container2Uris.put("b", URI.createURI("/b/x2." + fileExtension)); IAllContainersState containersState = containerStateProvider.get(liveState, new FakeAllContainerState(container2Uris)); assertTrue(containersState.containsURI("a", URI.createURI("/a/x." + fileExtension))); assertTrue(containersState.containsURI("a", URI.createURI("/a/y." + fileExtension))); assertFalse(containersState.containsURI("b", URI.createURI("/a/x." + fileExtension))); assertFalse(containersState.containsURI("b", URI.createURI("/a/y." + fileExtension))); assertTrue(containersState.containsURI("b", URI.createURI("/b/x1." + fileExtension))); assertTrue(containersState.containsURI("b", URI.createURI("/b/x2." + fileExtension))); assertFalse(containersState.containsURI("a", URI.createURI("/b/x1." + fileExtension))); assertFalse(containersState.containsURI("a", URI.createURI("/b/x2." + fileExtension))); }
@Override protected void configure() { this.<IResourceDescriptions>bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE)).to(ResourceSetBasedResourceDescriptions.class); this.<IResourceDescriptions>bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.LIVE_SCOPE)).to(ResourceSetBasedResourceDescriptions.class); this.<IResourceDescriptions>bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class); this.<IResourceDescriptions>bind(IResourceDescriptions.class).to(ResourceSetBasedResourceDescriptions.class); this.<IIssueHandler>bind(IIssueHandler.class).to(this.bindIIssueHandler()); this.<AbstractFileSystemAccess>bind(AbstractFileSystemAccess.class).to(this.bindJavaIoFileSystemAccess()); this.<IJavaCompiler>bind(IJavaCompiler.class).to(this.bindIJavaCompiler()); this.<IEncodingProvider>bind(IEncodingProvider.class).to(this.bindIEncodingProvider()); }
/** * @since 2.4 */ protected ResourceSet getResourceSet(IResourceDescriptions context) { if (context instanceof ResourceSetBasedResourceDescriptions) return ((ResourceSetBasedResourceDescriptions) context).getResourceSet(); else if (context instanceof EagerResourceSetBasedResourceDescriptions) return ((EagerResourceSetBasedResourceDescriptions) context).getResourceSet(); String contextType = context == null ? "null" : context.getClass().getName(); throw new IllegalStateException("Passed " + contextType + " is not based on a resource set"); }
@Before public void setup() { Module m = new Module(){ @Override public void configure(Binder binder) { binder.bind(INamingService.class).to(DefaultNamingService.class); binder.bind(IQualifiedNameProvider.class).to(SGraphNameProvider.class); binder.bind(ITypeSystem.class).toInstance(GenericTypeSystem.getInstance()); binder.bind(IResourceDescriptions.class).to(ResourceSetBasedResourceDescriptions.class); } }; Injector injector = Guice.createInjector(m); injector.injectMembers(this); }
public void configureIResourceDescriptions(Binder binder) { binder.bind(IResourceDescriptions.class).to(ResourceSetBasedResourceDescriptions.class); }
public void configureIResourceDescriptionsPersisted(Binder binder) { binder.bind(IResourceDescriptions.class).annotatedWith(Names.named(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS)).to(ResourceSetBasedResourceDescriptions.class); }