Efficient way of loading an EMF resource at start-up? [message #1769187] |
Thu, 27 July 2017 07:23  |
Eclipse User |
|
|
|
I want to extend the AST of my DSL with dynamically calculated content. This additional code realize some sort of "build-in" library which is created at start-up time and is used during scoping. I have found information about attaching a resource in standalone-applications but the "build-in" lib should also be loaded in the Eclipse plugin. Loading a static DSL source code file is also not an option because I want to create the lib dynamically.
Here is what I have done so far....
class Lib {
@Inject Provider<XtextResourceSet> resourceSetProvider
@Inject IResourceScopeCache cache
def Resource load() {
val XtextResourceSet resourceSet = resourceSetProvider.get
val resource = resourceSet.createResource(URI.createURI("dummy:/lib.mydsl"))
cache.get("load", resource, [
val InputStream in = new ByteArrayInputStream(" /* 'dynamic' DSL code ('build-in lib') */".getBytes("UTF8"))
resource.load(in, resourceSet.getLoadOptions())
return resource
]
)
}
// called by scope provider
def calc() {
val resource = load()
cache.get("calc", resource, [ /* calculations based on the loaded resource */ ]
)
}
}
- Is this the correct way of loading an EMF resource at runtime?
- The cache is useless. I have measured the time executing calc() with and without cache and there has been no difference. How can I cache the resource loading and the calculation?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.08799 seconds