Get the corresponding scope, if none exists, make new one.

@param conn
@return wsScope
511132
private WebSocketScope getScope(WebSocketConnection conn) {
        if (log.isTraceEnabled()) {
            log.trace("Scopes: {}", scopes);
        }
        log.debug("getScope: {}", conn);
        WebSocketScope wsScope;
        String path = conn.getPath();
        if (!scopes.containsKey(path)) {
            // check for default scope
            if (!scopes.containsKey("default")) {
                wsScope = new WebSocketScope();
                wsScope.setPath(path);
                notifyListeners(WebSocketEvent.SCOPE_CREATED, wsScope);
                addWebSocketScope(wsScope);
                //log.debug("Use the IWebSocketScopeListener interface to be notified of new scopes");
            } else {
                path = "default";
            }
        }
        wsScope = scopes.get(path);
        log.debug("Returning: {}", wsScope);
        return wsScope;
    }
882900
public static NClob createNClob(final Connection conn) {
		try {
			return conn.createNClob();
		} catch (SQLException e) {
			throw new UroborosqlRuntimeException(e);
		}
	}
94322
def _scope_lookup(self, node, name, offset=0):
        """"""
        try:
            stmts = node._filter_stmts(self.locals[name], self, offset)
        except KeyError:
            stmts = ()
        if stmts:
            return self, stmts
        if self.parent:  # i.e. not Module
            # nested scope: if parent scope is a function, that's fine
            # else jump to the module
            pscope = self.parent.scope()
            if not pscope.is_function:
                pscope = pscope.root()
            return pscope.scope_lookup(node, name)
        return builtin_lookup(name)
1229776
public static Clob createClob(final Connection conn) {
		try {
			return conn.createClob();
		} catch (SQLException e) {
			throw new UroborosqlRuntimeException(e);
		}
	}
460651
public TypeUsage.Builder nullableScope(QualifiedName scope) {
    if (scope != null) {
      return scope(scope);
    } else {
      return clearScope();
    }
  }
895467
protected void register(IConnection conn) {
        if (log.isDebugEnabled()) {
            if (conn == null) {
                log.debug("Register null connection, client id: {}", id);
            } else {
                log.debug("Register connection ({}:{}) client id: {}", conn.getRemoteAddress(), conn.getRemotePort(), id);
            }
        }
        if (conn != null) {
            IScope scope = conn.getScope();
            if (scope != null) {
                log.debug("Registering for scope: {}", scope);
                connections.add(conn);
            } else {
                log.warn("Clients scope is null. Id: {}", id);
            }
        } else {
            log.warn("Clients connection is null. Id: {}", id);
        }
    }
567534
public static function scope(ScopeContract $scope = null)
    {
        if (! is_null($scope)) {
            return static::$scope = $scope;
        }

        if (is_null(static::$scope)) {
            static::$scope = new Scope;
        }

        return static::$scope;
    }
1120155
@Override
    public NGScope scope() {
        NGScope isolateScope = NGScope.create();
        isolateScope.put(getName(), "=");
        return isolateScope;
    }
857863
def scopes(self):
        
        if not self.__scopes:
            self.__scopes = Scopes(self.__connection)
        return self.__scopes
940527
@SuppressWarnings(value = "unchecked")
  <T, K extends SharedResourceKey> T getScoped(final SharedResourceFactory<T, K, S> factory, @Nonnull final K key,
      @Nonnull final ScopeWrapper<S> scope, final SharedResourcesBrokerImpl<S> broker)
      throws ExecutionException {
    SharedResourceFactory<T, K, S> currentFactory = factory;
    K currentKey = key;
    ScopeWrapper<S> currentScope = scope;

    Object obj = getScopedFromCache(currentFactory, currentKey, currentScope, broker);

    // this loop is to continue looking up objects through redirection or reloading until a valid resource is found
    while (true) {
      if (obj instanceof ResourceCoordinate) {
        ResourceCoordinate<T, K, S> resourceCoordinate = (ResourceCoordinate<T, K, S>) obj;
        if (!SharedResourcesBrokerUtils.isScopeTypeAncestor((ScopeType) currentScope.getType(), ((ResourceCoordinate) obj).getScope())) {
          throw new RuntimeException(String
              .format("%s returned an invalid coordinate: scope %s is not an ancestor of %s.", currentFactory.getName(),
                  ((ResourceCoordinate) obj).getScope(), currentScope.getType()));
        }
        try {
          obj = getScopedFromCache(resourceCoordinate.getFactory(), resourceCoordinate.getKey(),
              broker.getWrappedScope(resourceCoordinate.getScope()), broker);
        } catch (NoSuchScopeException nsse) {
          throw new RuntimeException(String
              .format("%s returned an invalid coordinate: scope %s is not available.", factory.getName(),
                  resourceCoordinate.getScope().name()), nsse);
        }
      } else if (obj instanceof ResourceEntry) {
        T resource = ((ResourceEntry<T>) obj).getResourceIfValid();

        // valid resource found
        if (resource != null) {
          return resource;
        }

        // resource is invalid. The lock in this block is to reduce the chance of starvation where a thread keeps
        // getting objects that are invalidated by another thread.
        Lock lock = this.invalidationLock.get(key);
        try {
          lock.lock();
          RawJobBrokerKey fullKey = new RawJobBrokerKey(currentScope, currentFactory.getName(), currentKey);
          safeInvalidate(fullKey);
          obj = getScopedFromCache(currentFactory, currentKey, currentScope, broker);
        } finally {
          lock.unlock();
        }
      } else {
        throw new RuntimeException(String.format("Invalid response from %s: %s.", factory.getName(), obj.getClass()));
      }
    }
  }
1044363
public void makeScope(IScope scope) {
        log.debug("makeScope: {}", scope);
        String path = scope.getContextPath();
        WebSocketScope wsScope = null;
        if (!scopes.containsKey(path)) {
            // add the name to the collection (no '/' prefix)
            activeRooms.add(scope.getName());
            // new websocket scope for the server scope
            wsScope = new WebSocketScope();
            wsScope.setPath(path);
            wsScope.setScope(scope);
            notifyListeners(WebSocketEvent.SCOPE_CREATED, wsScope);
            addWebSocketScope(wsScope);
            log.debug("Use the IWebSocketScopeListener interface to be notified of new scopes");
        } else {
            log.debug("Scope already exists: {}", path);
        }
    }
340566
public void makeScope(String path) {
        log.debug("makeScope: {}", path);
        WebSocketScope wsScope = null;
        if (!scopes.containsKey(path)) {
            // new websocket scope
            wsScope = new WebSocketScope();
            wsScope.setPath(path);
            notifyListeners(WebSocketEvent.SCOPE_CREATED, wsScope);
            addWebSocketScope(wsScope);
            log.debug("Use the IWebSocketScopeListener interface to be notified of new scopes");
        } else {
            log.debug("Scope already exists: {}", path);
        }
    }
819537
public static Scopes from(String... scopes)
    {
        if (scopes == null || scopes.length == 0) return NONE;
        return new Scopes(scopes, true);
    }
288256
function getScope(identifier) {
            for (let currentNode = identifier; currentNode; currentNode = currentNode.parent) {
                const scope = sourceCode.scopeManager.acquire(currentNode, true);

                if (scope) {
                    return scope;
                }
            }
            return null;
        }
60375
BraveSpan currentSpan() {
    BraveScope scope = currentScopes.get().peekFirst();
    if (scope != null) {
      return scope.span();
    } else {
      brave.Span braveSpan = tracer.currentSpan();
      if (braveSpan != null) {
        return new BraveSpan(tracer, braveSpan);
      }
    }
    return null;
  }
828915
private SymbolScope createScopeFrom(StaticScope otherScope) {
    Node otherScopeRoot = otherScope.getRootNode();

    SymbolScope myScope = scopes.get(otherScopeRoot);
    if (myScope == null) {
      StaticScope otherScopeParent = otherScope.getParentScope();

      // If otherScope is a global scope, and we already have a global scope,
      // then something has gone seriously wrong.
      //
      // Not all symbol tables are rooted at the same global node, and
      // we do not want to mix and match symbol tables that are rooted
      // differently.

      if (otherScopeParent == null) {
        // The global scope must be created before any local scopes.
        checkState(globalScope == null, "Global scopes found at different roots");
      }

      myScope =
          new SymbolScope(
              otherScopeRoot,
              otherScopeParent == null ? null : createScopeFrom(otherScopeParent),
              getTypeOfThis(otherScope),
              null);
      scopes.put(otherScopeRoot, myScope);
      if (myScope.isGlobalScope()) {
        globalScope = myScope;
      }
    }
    return myScope;
  }
956963
public static Blob createBlob(final Connection conn) {
		try {
			return conn.createBlob();
		} catch (SQLException e) {
			throw new UroborosqlRuntimeException(e);
		}
	}