C#: Skip documentation syntax in MustBeVariant analyzer
This commit is contained in:
parent
0a0c730805
commit
256632a07e
1 changed files with 24 additions and 0 deletions
|
@ -26,6 +26,10 @@ namespace Godot.SourceGenerators
|
||||||
|
|
||||||
private void AnalyzeNode(SyntaxNodeAnalysisContext context)
|
private void AnalyzeNode(SyntaxNodeAnalysisContext context)
|
||||||
{
|
{
|
||||||
|
// Ignore syntax inside comments
|
||||||
|
if (IsInsideDocumentation(context.Node))
|
||||||
|
return;
|
||||||
|
|
||||||
var typeArgListSyntax = (TypeArgumentListSyntax)context.Node;
|
var typeArgListSyntax = (TypeArgumentListSyntax)context.Node;
|
||||||
|
|
||||||
// Method invocation or variable declaration that contained the type arguments
|
// Method invocation or variable declaration that contained the type arguments
|
||||||
|
@ -73,6 +77,26 @@ namespace Godot.SourceGenerators
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if the syntax node is inside a documentation syntax.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="syntax">Syntax node to check.</param>
|
||||||
|
/// <returns><see langword="true"/> if the syntax node is inside a documentation syntax.</returns>
|
||||||
|
private bool IsInsideDocumentation(SyntaxNode? syntax)
|
||||||
|
{
|
||||||
|
while (syntax != null)
|
||||||
|
{
|
||||||
|
if (syntax is DocumentationCommentTriviaSyntax)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
syntax = syntax.Parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the given type argument is being used in a type parameter that contains
|
/// Check if the given type argument is being used in a type parameter that contains
|
||||||
/// the <c>MustBeVariantAttribute</c>; otherwise, we ignore the attribute.
|
/// the <c>MustBeVariantAttribute</c>; otherwise, we ignore the attribute.
|
||||||
|
|
Loading…
Reference in a new issue