From 0a2eb7f3b55bc225d4005bbec77a3f72235cf81a Mon Sep 17 00:00:00 2001 From: GGG Date: Mon, 22 Jan 2024 11:00:13 -0300 Subject: [PATCH] Remove debug logging. --- Tsu.TreeSourceGen/sample/logs.txt | 12 ------------ Tsu.TreeSourceGen/src/GeneratorExtensions.cs | 12 ++---------- 2 files changed, 2 insertions(+), 22 deletions(-) delete mode 100644 Tsu.TreeSourceGen/sample/logs.txt diff --git a/Tsu.TreeSourceGen/sample/logs.txt b/Tsu.TreeSourceGen/sample/logs.txt deleted file mode 100644 index de6c826..0000000 --- a/Tsu.TreeSourceGen/sample/logs.txt +++ /dev/null @@ -1,12 +0,0 @@ -Processing Tsu.TreeSourceGen.Sample.Root for [TreeNode] - Added. -Processing Tsu.TreeSourceGen.Sample.Expression for [TreeNode] - Discarded. { IsNamedType = True, IsClassKind = True, IsAbstract = True, IsRoot = False } -Processing Tsu.TreeSourceGen.Sample.Binary for [TreeNode] - Added. -Processing Tsu.TreeSourceGen.Sample.Constant for [TreeNode] - Added. -Processing Tsu.TreeSourceGen.Sample.Statement for [TreeNode] - Discarded. { IsNamedType = True, IsClassKind = True, IsAbstract = True, IsRoot = False } -Processing Tsu.TreeSourceGen.Sample.FunctionCall for [TreeNode] - Added. diff --git a/Tsu.TreeSourceGen/src/GeneratorExtensions.cs b/Tsu.TreeSourceGen/src/GeneratorExtensions.cs index 6b901b9..2e92519 100644 --- a/Tsu.TreeSourceGen/src/GeneratorExtensions.cs +++ b/Tsu.TreeSourceGen/src/GeneratorExtensions.cs @@ -15,21 +15,14 @@ public static IncrementalValuesProvider GetTrees(this IncrementalGenerator (node, _) => node.IsKind(SyntaxKind.ClassDeclaration), (ctx, _) => { - Log.WriteLine($"Processing {ctx.TargetSymbol} for [TreeNode]"); var attr = ctx.Attributes.SingleOrDefault(); - var firstArg = attr?.ConstructorArguments.Single().Value as INamedTypeSymbol; var nodeSymbol = (INamedTypeSymbol) ctx.TargetSymbol; // Only accept symbol arguments - if (firstArg is null || firstArg.TypeKind != TypeKind.Class + if (attr?.ConstructorArguments.Single().Value is not INamedTypeSymbol firstArg + || firstArg.TypeKind != TypeKind.Class || (nodeSymbol.IsAbstract && !SymbolEqualityComparer.Default.Equals(firstArg, ctx.TargetSymbol))) { - var b = new StringBuilder(" Discarded. "); - b.Append($"{{ IsNamedType = {firstArg is not null}"); - b.Append($", IsClassKind = {firstArg is { TypeKind: TypeKind.Class }}"); - b.Append($", IsAbstract = {nodeSymbol is { IsAbstract: true }}"); - b.Append($", IsRoot = {SymbolEqualityComparer.Default.Equals(firstArg as INamedTypeSymbol, ctx.TargetSymbol)} }}"); - Log.WriteLine(b.ToString()); return (null!, null!, null!, null); } @@ -40,7 +33,6 @@ public static IncrementalValuesProvider GetTrees(this IncrementalGenerator name = n; } - Log.WriteLine(" Added."); return ( Root: firstArg, ParentClass: ((ClassDeclarationSyntax) ctx.TargetNode).GetContainingTypes(),