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(),