Skip to content

Instantly share code, notes, and snippets.

@nbhusare
Last active August 18, 2016 03:52
Show Gist options
  • Save nbhusare/2d12524aa3d862a0bd4806999600e519 to your computer and use it in GitHub Desktop.
Save nbhusare/2d12524aa3d862a0bd4806999600e519 to your computer and use it in GitHub Desktop.
val resolver = new BundleClasspathUriResolver()
val classpathUri = URI.createURI('''«ClasspathUriUtil.CLASSPATH_SCHEME»:/models/yourmodel.xcore''')
val normalizedUri = resolver.resolve(Platform.getBundle("org.ne.emf.xcore.models"), classpathUri) /*resolver.resolve(null, classpathURI)*/
val resource = new ResourceSetImpl().getResource(normalizedUri.trimFragment(), true)
if (resource.diagnostic != Diagnostic.OK_INSTANCE) {
throw new IllegalStateException("Problem parsing '" + uri + "':\n" +
Joiner.on('\n').join(resource.getErrors()));
}
resource
def private Diagnostic getDiagnostic(Resource resource) {
val boolean INCLUDE_WARNINGS = true
return EcoreUtil.computeDiagnostic(resource, INCLUDE_WARNINGS)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment