//
// Copyright (c) 2010-2018 Antmicro
//
// This file is licensed under the MIT License.
// Full license text is available in 'licenses/MIT.txt'.
//
using System;
using System.Collections.Generic;
using Antmicro.Migrant;
using Sprache;

namespace Antmicro.Renode.PlatformDescription.Syntax
{
    public class UsingEntry : IPositionAware<UsingEntry>, IWithPosition, IVisitable
    {
        public UsingEntry(StringWithPosition path, string prefix)
        {
            Path = path;
            Prefix = prefix;
        }

        public IEnumerable<object> Visit()
        {
            return new[] { Path };
        }

        public StringWithPosition Path { get; private set; }
        public string Prefix { get; private set; }

        public Position StartPosition { get; private set; }

        public int Length { get; private set; }

        public UsingEntry SetPos(Position startPos, int length)
        {
            var copy = SerializationProvider.Instance.DeepClone(this);
            copy.StartPosition = startPos;
            copy.Length = length;
            return copy;
        }
    }
}
