use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.
the class AbstractSmokeTest method createResource.
protected LazyLinkingResource createResource(final String model) throws IOException {
if (logger.isTraceEnabled()) {
logger.trace("createResource: " + model);
}
XtextResourceSet set = getResourceSet();
typeProviderFactory.findOrCreateTypeProvider(set);
LazyLinkingResource resource = (LazyLinkingResource) resourceFactory.createResource(URI.createURI("Test.xtend"));
set.getResources().add(resource);
resource.load(new StringInputStream(model), null);
resource.resolveLazyCrossReferences(CancelIndicator.NullImpl);
return resource;
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.
the class AbstractXtendTestCase method getResourceSet.
protected XtextResourceSet getResourceSet() {
XtextResourceSet set = resourceSetProvider.get();
set.setClasspathURIContext(getClass().getClassLoader());
return set;
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.
the class AbstractXtendTestCase method files.
protected Iterable<XtendFile> files(boolean validate, String... contents) throws Exception {
XtextResourceSet set = getResourceSet();
List<XtendFile> result = newArrayList();
for (String string : contents) {
String fileName = getFileName(string);
Resource resource = set.createResource(URI.createURI(fileName + ".xtend"));
resource.load(new StringInputStream(string), null);
assertEquals(resource.getErrors().toString(), 0, resource.getErrors().size());
}
for (Resource resource : new ArrayList<Resource>(set.getResources())) {
XtendFile file = (XtendFile) resource.getContents().get(0);
result.add(file);
}
if (validate) {
for (XtendFile file : result) {
List<Issue> issues = ((XtextResource) file.eResource()).getResourceServiceProvider().getResourceValidator().validate(file.eResource(), CheckMode.ALL, CancelIndicator.NullImpl);
assertTrue("Resource contained errors : " + issues.toString(), issues.isEmpty());
}
}
return result;
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.
the class ConvertToArrayBenchmark method setUp.
@Override
protected void setUp() throws Exception {
Injector injector = new XbaseStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = new XtextResourceSet();
ClassLoader loader = getClass().getClassLoader();
resourceSet.setClasspathURIContext(loader);
ClasspathTypeProvider typeProvider = new ClasspathTypeProvider(loader, resourceSet, indexedAccess, null);
CommonTypeComputationServices services = injector.getInstance(CommonTypeComputationServices.class);
StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, resourceSet);
typeReference = type.getReference(typeProvider, owner);
EcoreUtil.resolveAll(resourceSet);
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-xtend by eclipse.
the class ParameterizedTypeReferenceBenchmark method setUp.
@Override
protected void setUp() throws Exception {
Injector injector = new XbaseStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = new XtextResourceSet();
ClassLoader loader = getClass().getClassLoader();
resourceSet.setClasspathURIContext(loader);
ClasspathTypeProvider typeProvider = new ClasspathTypeProvider(loader, resourceSet, indexedAccess, null);
CommonTypeComputationServices services = injector.getInstance(CommonTypeComputationServices.class);
StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, resourceSet);
typeReference = type.getReference(typeProvider, owner);
EcoreUtil.resolveAll(resourceSet);
}
Aggregations