package jetbrains.mps.lang.scopes.runtime; /*Generated by MPS */ import jetbrains.mps.baseLanguage.closures.runtime._FunctionTypes; import jetbrains.mps.scope.Scope; import jetbrains.mps.scope.EmptyScope; public class LazyScope extends DelegatingScope { private final _FunctionTypes._return_P0_E0<? extends Scope> scopePromise; private Scope scope; private boolean isCalculated = false; public LazyScope(_FunctionTypes._return_P0_E0<? extends Scope> scopePromise) { this.scopePromise = scopePromise; } @Override protected Scope getScope() { if (!(isCalculated)) { scope = scopePromise.invoke(); // todo: think about this case... if (scope == null) { scope = new EmptyScope(); } isCalculated = true; } return scope; } }