Java Code Examples for org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions#setContext()

The following examples show how to use org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions#setContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultReferenceFinderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	with(RefactoringTestLanguageStandaloneSetup.class);
	resourceSet = get(XtextResourceSet.class);
	resource = loadResource("test.refactoringtestlanguage", "A { B { ref A } } C");
	elementA = resource.getContents().get(0).eContents().get(0);
	elementB = elementA.eContents().get(0);
	elementC = resource.getContents().get(0).eContents().get(1);
	resourceSet.getResources().add(resource);

	ResourceSetBasedResourceDescriptions resourceDescriptions = get(ResourceSetBasedResourceDescriptions.class);
	resourceDescriptions.setContext(resourceSet);
	referenceFinder = new DefaultReferenceFinder(resourceDescriptions, get(IResourceServiceProvider.Registry.class), get(TargetURIConverter.class));
	localResourceAccess = new SimpleLocalResourceAccess(resourceSet);
	acceptor = new CheckingAcceptor();
}
 
Example 2
Source File: DelegatingReferenceFinderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	with(RefactoringTestLanguageStandaloneSetup.class);
	resourceSet = get(XtextResourceSet.class);
	resource = loadResource("test.refactoringtestlanguage", "A { B { ref A } } C");
	elementA = resource.getContents().get(0).eContents().get(0);
	elementB = elementA.eContents().get(0);
	elementC = resource.getContents().get(0).eContents().get(1);
	resourceSet.getResources().add(resource);

	ResourceSetBasedResourceDescriptions resourceDescriptions = get(ResourceSetBasedResourceDescriptions.class);
	resourceDescriptions.setContext(resourceSet);
	referenceFinder = new DelegatingReferenceFinder();
	referenceFinder.setIndexData(resourceDescriptions);
	referenceFinder.setConverter(get(TargetURIConverter.class));
	referenceFinder.setDelegate(get(org.eclipse.xtext.findReferences.IReferenceFinder.class));
	referenceFinder.setResourceServiceProviderRegistry(get(IResourceServiceProvider.Registry.class));
	localResourceAccess = new SimpleLocalResourceAccess(resourceSet);
	acceptor = new CheckingAcceptor();
}
 
Example 3
Source File: LiveShadowedAllContainerStateTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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)));
}
 
Example 4
Source File: XtendBatchCompiler.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
protected ResourceSetBasedResourceDescriptions getResourceDescriptions(ResourceSet resourceSet) {
	ResourceSetBasedResourceDescriptions resourceDescriptions = resourceSetDescriptionsProvider.get();
	resourceDescriptions.setContext(resourceSet);
	resourceDescriptions.setRegistry(IResourceServiceProvider.Registry.INSTANCE);
	return resourceDescriptions;
}
 
Example 5
Source File: ResourceDescriptionsProvider.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public IResourceDescriptions get(ResourceSet resourceSet) {
	ResourceSetBasedResourceDescriptions descriptions = new ResourceSetBasedResourceDescriptions();
	descriptions.setContext(resourceSet);
	descriptions.setRegistry(IResourceServiceProvider.Registry.INSTANCE);
	return descriptions;
}