-
Notifications
You must be signed in to change notification settings - Fork 1
/
NexGenerator.cs
43 lines (37 loc) · 1.46 KB
/
NexGenerator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis;
using System;
using StrideSourceGenerator.Core.GeneratorCreators;
using StrideSourceGenerator.Core.Roslyn;
using System.Diagnostics;
using System.Linq;
namespace StrideSourceGenerator;
[Generator]
public class NexGenerator : ISourceGenerator
{
public void Initialize(GeneratorInitializationContext context)
{
// Debugger.Launch();
context.RegisterForSyntaxNotifications(() => new NexSyntaxReceiver());
}
private GeneratorYamlClass classGenerator { get; set; } = new();
public void Execute(GeneratorExecutionContext context)
{
NexSyntaxReceiver syntaxReceiver = (NexSyntaxReceiver)context.SyntaxReceiver;
foreach (TypeDeclarationSyntax classDeclaration in syntaxReceiver.TypeDeclarations)
{
SemanticModel semanticModel = context.Compilation.GetSemanticModel(classDeclaration.SyntaxTree);
ClassInfo info = new()
{
ExecutionContext = context,
TypeSyntax = classDeclaration,
SyntaxReceiver = syntaxReceiver,
Symbol = semanticModel.GetDeclaredSymbol(classDeclaration),
};
classGenerator.StartCreation(info);
}
}
public const string CompilerServicesDiagnosticIdFormat = "STR0{0:000}";
public const string CompilerServicesDiagnosticCategory = "Stride.CompilerServices";
}