blended-modeling / eatxt

Eclipse Public License 2.0
1 stars 1 forks source link

Cache scope calculation #23

Open steghoja opened 2 years ago

steghoja commented 2 years ago

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 a HashMap 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.

joerg-holtmann commented 2 years ago

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); } }