Clean diagnostic rules
Move the following diagnostics into static readonly fields: GD0101, GD0102, GD0103, GD0104, GD0105, GD0106, GD0107, GD0201, GD0202, GD0203, GD0301, GD0302, GD0303, GD0401, GD0402. To be more consistent, the titles for the following diagnostics were modified: GD0101, GD0105, GD0106, GD0302, GD0303, GD0401, GD0402. A subsequent update of the documentation repo is needed. Tests for the following diagnostics were created: GD0201, GD0202, GD0203.
This commit is contained in:
@@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Diagnostics;
|
||||
namespace Godot.SourceGenerators
|
||||
{
|
||||
[DiagnosticAnalyzer(LanguageNames.CSharp)]
|
||||
public class GlobalClassAnalyzer : DiagnosticAnalyzer
|
||||
public sealed class GlobalClassAnalyzer : DiagnosticAnalyzer
|
||||
{
|
||||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
|
||||
=> ImmutableArray.Create(
|
||||
@@ -33,10 +33,22 @@ namespace Godot.SourceGenerators
|
||||
return;
|
||||
|
||||
if (typeSymbol.IsGenericType)
|
||||
Common.ReportGlobalClassMustNotBeGeneric(context, typeClassDecl, typeSymbol);
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(
|
||||
Common.GlobalClassMustNotBeGenericRule,
|
||||
typeSymbol.Locations.FirstLocationWithSourceTreeOrDefault(),
|
||||
typeSymbol.ToDisplayString()
|
||||
));
|
||||
}
|
||||
|
||||
if (!typeSymbol.InheritsFrom("GodotSharp", GodotClasses.GodotObject))
|
||||
Common.ReportGlobalClassMustDeriveFromGodotObject(context, typeClassDecl, typeSymbol);
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(
|
||||
Common.GlobalClassMustDeriveFromGodotObjectRule,
|
||||
typeSymbol.Locations.FirstLocationWithSourceTreeOrDefault(),
|
||||
typeSymbol.ToDisplayString()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user