@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 protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { ResourceSet resourceSet = getResourceSet(); Multimap<String, URI> uris = getPathTraverser().resolvePathes(pathes, new Predicate<URI>() { @Override public boolean apply(URI input) { boolean result = true; if (getUriFilter() != null) result = getUriFilter().matches(input); if (result) result = getRegistry().getResourceServiceProvider(input) != null; return result; } }); IAllContainersState containersState = containersStateFactory.getContainersState(pathes, uris); installAsAdapter(resourceSet, containersState); populateResourceSet(resourceSet, uris); getValidator().validate(resourceSet, getRegistry(), issues); addModelElementsToContext(ctx, resourceSet); }
@Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { ResourceSet resourceSet = getResourceSet(); // due to some Xcore peculiarity we have to access the IAllContainerState here // to trigger some lazy init logic IAllContainersState allContainerState = (IAllContainersState) EcoreUtil.getAdapter(resourceSet.eAdapters(), IAllContainersState.class); allContainerState.isEmpty(""); Multimap<String, URI> uris = getPathTraverser().resolvePathes(pathes, new Predicate<URI>() { @Override public boolean apply(URI input) { return input.fileExtension().equals(XCORE_FILE_EXT); } }); List<Resource> resources = new ArrayList<>(); for (URI uri : uris.values()) { LOGGER.info(uri); try { resources.add(parse(uri, resourceSet)); } catch (Exception e) { LOGGER.error("Problem during loading of resource @ " + uri, e); } } installIndex(resourceSet); for (Resource r : resources) { EcoreUtil.resolveAll(r); for (Diagnostic x : r.getErrors()) { issues.addError(x.getMessage(), x); } } ctx.set(slot, resources); }
@Override public Set<Binding> getGuiceBindingsUi(Grammar grammar) { BindFactory bindFactory = new BindFactory() .addTypeToProviderInstance( IAllContainersState.class.getName(), "org.eclipse.xtext.ui.shared.Access.getJavaProjectsState()"); if (XbaseGeneratorFragment.doesUseXbase(grammar)) { bindFactory = bindFactory.addTypeToType("org.eclipse.xtext.ui.editor.XtextEditor", "org.eclipse.xtext.xbase.ui.editor.XbaseEditor"); bindFactory = bindFactory.addTypeToType("org.eclipse.xtext.ui.editor.model.XtextDocumentProvider", "org.eclipse.xtext.xbase.ui.editor.XbaseDocumentProvider"); bindFactory = bindFactory.addTypeToType("org.eclipse.xtext.ui.generator.trace.OpenGeneratedFileHandler", "org.eclipse.xtext.xbase.ui.generator.trace.XbaseOpenGeneratedFileHandler"); } return bindFactory.getBindings(); }
public ResourceSet getInitializedResourceSet(List<String> pathes, UriFilter filter) { ResourceSet resourceSet = resourceSetProvider.get(); Multimap<String, URI> pathToUriMap = getPathToUriMap(pathes, filter); IAllContainersState containersState = factory.getContainersState(pathes, pathToUriMap); resourceSet.eAdapters().add(new DelegatingIAllContainerAdapter(containersState)); for (URI uri : pathToUriMap.values()) { resourceSet.createResource(uri); } return resourceSet; }
public Class<? extends IAllContainersState.Provider> bindIAllContainersState$Provider() { return ResourceSetBasedAllContainersStateProvider.class; }
public Provider<? extends IAllContainersState> provideIAllContainersState() { return Access.getJavaProjectsState(); }
/** * Bind a custom IAllContainerState in a testing context. See {@link N4JSTestsAllContainerState} for an explanation. */ public Class<? extends IAllContainersState.Provider> bindAllContainerState() { return N4JSTestsAllContainerState.Provider.class; }
@Override public IAllContainersState get(IResourceDescriptions context) { return new N4JSTestsAllContainerState(this.getResourceSet(context)); }
@Override public IAllContainersState get() { return instance; }
@Override public Provider<IAllContainersState> provideIAllContainersState() { return new N4JSAllContainersStateProvider(); }
public Provider<IAllContainersState> provideIAllContainersState() { return Access.getJavaProjectsState(); }