public void Path8_Basics() { PackageDatabase db = PackageDatabaseTests.BuildDefaultSample(); Symbol tryLog = PackageDatabaseTests.GetTryLogFromSample(db); Path8 fullName = tryLog.FullName; Assert.IsFalse(fullName.IsEmpty); Assert.IsFalse(fullName.IsRoot); Assert.AreEqual(32, fullName.Length); Assert.AreEqual("Sample.Diagnostics.Logger.TryLog", fullName.ToString()); Assert.AreEqual("Sample.Diagnostics.Logger.TryLog", Write.ToString(fullName.WriteTo)); Assert.AreEqual("TryLog", fullName.Name.ToString()); Assert.AreEqual("Logger", fullName.Parent.Name.ToString()); Path8 filePath = tryLog.FilePath; Assert.IsFalse(filePath.IsEmpty); Assert.IsFalse(filePath.IsRoot); Assert.AreEqual(PackageDatabaseTests.LOGGER_PATH_LIBNET20.Length, filePath.Length); Assert.AreEqual(PackageDatabaseTests.LOGGER_PATH_LIBNET20, filePath.ToString()); Assert.AreEqual(PackageDatabaseTests.LOGGER_PATH_LIBNET20, Write.ToString(filePath.WriteTo)); Assert.AreEqual("Logger.cs", filePath.Name.ToString()); Assert.AreEqual(PackageDatabaseTests.NS_DIAGNOSTICS, filePath.Parent.Name.ToString()); }
/// <summary> /// Debugging aid which writes each full name and the number of occurrences of it /// </summary> /// <param name="writer">TextWriter to write the tree to</param> public void WriteDuplicateWeight(TextWriter writer) { ConvertToImmutable(); // Walk and compute total weight (duplicates x members) for the tree int[] duplicateWeight = new int[this.MergedMembers.Count]; DuplicateWeight(0, duplicateWeight); // Write types/namespaces with over 1,000 weight writer.WriteLine("FullName,Count,Weight"); for (int i = 0; i < this.MergedMembers.Count; ++i) { if (duplicateWeight[i] > 1000) { Path8 fullName = new Path8(this.StringStore, this.MergedMembers, i, '.', this.MergedMembers.GetDepth(i)); fullName.WriteTo(writer); writer.Write(","); writer.Write(this.MergedMemberDuplicateCount[i]); writer.Write(","); writer.Write(duplicateWeight[i]); writer.WriteLine(); } } }
public static void WriteMatchesForToolUse(TextWriter writer, PartialArray <Symbol> results) { for (int i = 0; i < results.Count; ++i) { Symbol result = results[i]; Path8 containerName = result.ContainerName; if (!containerName.IsEmpty) { containerName.WriteTo(writer); writer.Write('.'); } result.WriteSignature(writer); writer.Write('\t'); // Write full location (local/found code) or package (package index) if (result.HasLocation) { result.FilePath.WriteTo(writer); writer.Write('('); writer.Write(result.Line); writer.Write(')'); } else { result.PackageName.WriteTo(writer); } writer.WriteLine(); } }
private static void WriteContainerHeading(TextWriter writer, Symbol result) { if (result.HasLocation) { result.FilePath.Name.WriteTo(writer); writer.Write('('); writer.Write(result.Line); writer.Write(')'); } else { result.PackageName.WriteTo(writer); } writer.Write('\t'); Path8 containerName = result.ContainerName; if (!containerName.IsEmpty) { containerName.WriteTo(writer); writer.Write('.'); } result.WriteSignature(writer); writer.WriteLine(); }
private void GetFullName(ArrayBuilder <string> nameParts, Path8 path) { if (!path.IsEmpty) { GetFullName(nameParts, path.Parent); nameParts.Add(path.Name.ToString()); } }
public void Path8_Empty() { Path8 empty = Path8.Empty; Assert.IsTrue(empty.IsEmpty); Assert.IsTrue(empty.IsRoot); Assert.AreEqual(0, empty.Length); Assert.AreEqual(String8.Empty, empty.Name); Assert.AreEqual(Path8.Empty, empty.Parent); }
/// <summary> /// Debugging aid which writes each full name and the number of occurrences of it /// </summary> /// <param name="writer">TextWriter to write the tree to</param> public void WriteDuplicateCounts(TextWriter writer) { ConvertToImmutable(); writer.WriteLine("FullName,OccurrenceCount"); for (int i = 0; i < this.MergedMembers.Count; ++i) { int duplicateCount = this.MergedMemberDuplicateCount[i]; if (duplicateCount > 1) { Path8 fullName = new Path8(this.StringStore, this.MergedMembers, i, '.', this.MergedMembers.GetDepth(i) - 1); fullName.WriteTo(writer); writer.Write(","); writer.Write(duplicateCount); writer.WriteLine(); } } }
private void GetFullName(List<string> nameParts, Path8 path) { if (!path.IsEmpty) { GetFullName(nameParts, path.Parent); nameParts.Add(path.Name.ToString()); } }
public void Path8_DisallowedDelimiter() { Path8 unconstructable = new Path8(new StringStore(), new ItemTree(), 0, '\u03B2'); }