public boolean isInScope(Symbol symbol, Symbol scope) {
        if (scope == null) return true; // lets say every symbol is in the empty scope
        if (scope.getType() == SymbolType.RANK_PROFILE) {
            return !rankProfileInheritanceGraph.findFirstMatches(scope, 
                    rankProfileDefinitionSymbol -> {
                        if (rankProfileDefinitionSymbol.equals(symbol.getScope())) {
                            return Boolean.valueOf(true);
                        }
                        return null;
            }).isEmpty();
        } else if (scope.getType() == SymbolType.STRUCT) {
            return !structInheritanceGraph.findFirstMatches(scope, 
                    structDefinitionSymbol -> {
                        if (structDefinitionSymbol.equals(symbol.getScope())) {
                            return Boolean.valueOf(true);
                        }
                        return null;
            }).isEmpty();
        } else if ((symbol.getScope() == null || symbol.getScope().getType() == SymbolType.SCHEMA || symbol.getScope().getType() == SymbolType.DOCUMENT) && 
                (scope.getType() == SymbolType.SCHEMA || scope.getType() == SymbolType.DOCUMENT)) {
            return !documentInheritanceGraph.findFirstMatches(scope.getFileURI(), 
                ancestorURI -> {
                    if (symbol.getFileURI().equals(ancestorURI)) {
                        return Boolean.valueOf(true);
                    }
                    return null;
                }
            ).isEmpty();
        }

        return scope.equals(symbol.getScope());
    }
Searches for symbols in the schema index that match the given symbol.

@return A list of symbols that match the given symbol.
integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/index/SchemaIndex.java