Now that issue #5 is closed, we can think of some optimisations.
Right now, we’re doing a pretty expensive computation whenever the scope is needed. We load all other resources from disk, parse them, and construct the global scope. This does not need to happen every time getScope() is called. We can cache the results and, if the same scope is requested again, just return the result from the cache.
There’s even more: we really only need to load the other files once when getScope() is called first. Later, we should check if any of the resources has been modified, though, to make sure we pick up on any changes.
Part of that is solved by #33 , but not this part:
for (EObject rootElement : rootElements) {
if (targetJavaClass != null) {
List candidates = (List) EcoreUtil2.getAllContentsOfType(rootElement,
targetJavaClass);
globalCandidates.addAll(candidates);
}
}
Now that issue #5 is closed, we can think of some optimisations.
Right now, we’re doing a pretty expensive computation whenever the scope is needed. We load all other resources from disk, parse them, and construct the global scope. This does not need to happen every time
getScope()
is called. We can cache the results and, if the same scope is requested again, just return the result from the cache.Xtext provides a
MapBasedScope
which uses aHashMap
as a cache: https://github.com/eclipse/xtext-core/blob/master/org.eclipse.xtext/src/org/eclipse/xtext/scoping/impl/MapBasedScope.java Maybe we can do something similar?There’s even more: we really only need to load the other files once when
getScope()
is called first. Later, we should check if any of the resources has been modified, though, to make sure we pick up on any changes.