use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-core by eclipse.
the class DefaultResourceDescription2Test method testValidLocalLink.
@Test
public void testValidLocalLink() throws Exception {
XtextResourceSet rs = get(XtextResourceSet.class);
Resource res1 = rs.createResource(URI.createURI("foo.langatestlanguage"));
res1.load(new StringInputStream("type Foo"), null);
XtextResource res2 = (XtextResource) rs.createResource(URI.createURI("bar.langatestlanguage"));
res2.load(new StringInputStream("import 'foo.langatestlanguage'" + "type Foo type Bar extends Foo"), null);
EcoreUtil.resolveAll(res2);
Iterable<QualifiedName> names = res2.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(res2).getImportedNames();
assertFalse(names.iterator().hasNext());
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-core by eclipse.
the class DefaultResourceDescription2Test method testNotYetLinked.
@Test
public void testNotYetLinked() throws Exception {
XtextResourceSet rs = get(XtextResourceSet.class);
Resource res1 = rs.createResource(URI.createURI("foo.langatestlanguage"));
res1.load(new StringInputStream("type Foo"), null);
XtextResource res2 = (XtextResource) rs.createResource(URI.createURI("bar.langatestlanguage"));
res2.load(new StringInputStream("import 'foo.langatestlanguage'" + "type Bar extends Foo"), null);
Iterable<QualifiedName> names = res2.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(res2).getImportedNames();
assertTrue(names.iterator().hasNext());
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-core by eclipse.
the class Bug318343Test method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
with(LangATestLanguageStandaloneSetup.class);
globalScopeProvider = get(DefaultGlobalScopeProvider.class);
XtextResourceSet xtextResourceSet = get(XtextResourceSet.class);
resource1 = xtextResourceSet.createResource(URI.createFileURI(new File("uri1.langatestlanguage").getAbsolutePath()));
resource2 = xtextResourceSet.createResource(URI.createFileURI(new File("uri2.langatestlanguage").getAbsolutePath()));
resource1.load(new StringInputStream("type t1"), null);
resource2.load(new StringInputStream("type t2"), null);
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-core by eclipse.
the class AbstractPortableURIsTest method setUp.
@Before
public void setUp() throws Exception {
globalStateMemento = GlobalRegistries.makeCopyOfGlobalState();
EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE);
resourceSet = new XtextResourceSet();
resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/"));
resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/"));
resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this);
resourceSet.setClasspathURIContext(getClasspathURIContext());
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-core by eclipse.
the class ToEcoreTrafoTest method getResource.
private XtextResource getResource(String uri) {
XtextResourceSet set = get(XtextResourceSet.class);
URI nsURI = URI.createURI(EcorePackage.eNS_URI);
URI platformURI = URI.createURI("platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore");
set.getURIConverter().getURIMap().put(platformURI, nsURI);
set.getURIResourceMap().put(platformURI, set.getResource(nsURI, true));
set.setClasspathURIContext(getClass().getClassLoader());
// if(AllTests.isPluginContext) {
// set.setClasspathUriResolver(new BundleClasspathUriResolver());
// set.setClasspathURIContext(Activator.getDefault());
// }
XtextResource r = (XtextResource) set.getResource(URI.createURI(uri), true);
return r;
}
Aggregations