< Summary

Class:NanoCLang.Entities.Location
Assembly:NanoCLang
File(s):C:\GitLab-Runner\builds\JxAESPd8\0\chenmichael\nanoc\src\NanoCLang\Entities\Location.cs
Covered lines:19
Uncovered lines:1
Coverable lines:20
Total lines:55
Line coverage:95% (19 of 20)
Covered branches:8
Total branches:8
Branch coverage:100% (8 of 8)

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
get_Name()100%1100%
get_Abstract()100%1100%
get_Concrete()100%1100%
Clone()100%1100%
Replace(...)100%2100%
Equals(...)100%10%
Equals(...)100%4100%
GetHashCode()100%1100%
op_Equality(...)100%1100%
op_Inequality(...)100%1100%
Tokens()100%2100%

File(s)

C:\GitLab-Runner\builds\JxAESPd8\0\chenmichael\nanoc\src\NanoCLang\Entities\Location.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4namespace NanoCLang.Entities {
 5    /// <summary>
 6    /// Provides a class for location entities.
 7    /// </summary>
 8    public class Location : Base, IEquatable<Location?>, ISubstitutable<Location>, ICloneable {
 9        /// <summary>
 10        /// Creates a new location instance with the given <paramref name="name"/>. <paramref name="isAbstract"/> specif
 11        /// </summary>
 12        /// <param name="name">Name of the location.</param>
 13        /// <param name="isAbstract"><c>true</c> iff the location is abstract, else concrete.</param>
 120814        public Location(string name, bool isAbstract) {
 60415            Name = name;
 60416            Abstract = isAbstract;
 60417        }
 18        /// <summary>
 19        /// Name of the location.
 20        /// </summary>
 441621        public string Name { get; }
 22        /// <summary>
 23        /// <c>true</c> iff the location is abstract, else <see langword="false"/>.
 24        /// </summary>
 419325        public bool Abstract { get; }
 26        /// <summary>
 27        /// <c>true</c> iff the location is concrete, else <see langword="false"/>.
 28        /// </summary>
 929        public bool Concrete => !Abstract;
 30        /// <inheritdoc/>
 15831        public object Clone() => new Location(Name, Abstract);
 32        /// <inheritdoc/>
 33        public Location Replace(Substitutor rep)
 17134            => rep.Locations.TryGetValue(Name, out var subs)
 17135            ? new Location(subs, Abstract)
 17136            : (Location)Clone();
 37        #region Equality checks
 38        /// <inheritdoc/>
 039        public override bool Equals(object? obj) => Equals(obj as Location);
 40        /// <inheritdoc/>
 89541        public bool Equals(Location? other) => !(other is null) && Name == other.Name && Abstract == other.Abstract;
 42        /// <inheritdoc/>
 166343        public override int GetHashCode() => HashCode.Combine(Name, Abstract);
 44        /// <inheritdoc/>
 5245        public static bool operator ==(Location? left, Location? right) => EqualityComparer<Location?>.Default.Equals(le
 46        /// <inheritdoc/>
 4047        public static bool operator !=(Location? left, Location? right) => !(left == right);
 48        #endregion
 49        /// <inheritdoc/>
 38950        public override IEnumerable<StringFormatterToken> Tokens(NanoCSourceFormat args) {
 68451            if (Abstract) yield return "~";
 38952            yield return Name;
 38953        }
 54    }
 55}