// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Bicep.Core.Diagnostics;
using Bicep.Core.Navigation;
using Bicep.Core.SourceGraph;
using Bicep.Core.Syntax;
using Bicep.Core.TypeSystem;
using Bicep.Core.Utils;

namespace Bicep.Core.Semantics;

public static class SemanticModelExtensions
{
    public static ResultWithDiagnostic<ISemanticModel> TryGetReferencedModel(this SemanticModel model, IArtifactReferenceSyntax referenceSyntax)
        => referenceSyntax.TryGetReferencedModel(model.SourceFileGrouping, model.ModelLookup);

    public static bool HasAzureTargetScope(this SemanticModel model)
        => model.TargetScope is ResourceScope.Tenant or ResourceScope.ManagementGroup or ResourceScope.Subscription or ResourceScope.ResourceGroup;
}
