in src/CTA.Rules.Analysis/RulesAnalysis.cs [416:558]
private void AddActions(FileActions fileAction, NodeToken token, TextSpan textSpan, string overrideKey = "")
{
fileAction.AttributeActions.UnionWith(token.AttributeActions.Select(a => new AttributeAction()
{
Key = a.Key,
Description = a.Description,
Value = a.Value,
Name = a.Name,
Type = a.Type,
TextSpan = textSpan,
ActionValidation = a.ActionValidation,
AttributeActionFunc = a.AttributeActionFunc,
AttributeListActionFunc = a.AttributeListActionFunc
}).ToList());
fileAction.AttributeActions.UnionWith(token.AttributeListActions.Select(a => new AttributeAction()
{
Key = a.Key,
Description = a.Description,
Value = a.Value,
Name = a.Name,
Type = a.Type,
TextSpan = textSpan,
ActionValidation = a.ActionValidation,
AttributeActionFunc = a.AttributeActionFunc,
AttributeListActionFunc = a.AttributeListActionFunc
}).ToList());
fileAction.IdentifierNameActions.UnionWith(token.IdentifierNameActions.Select(a => new IdentifierNameAction()
{
Key = a.Key,
Description = a.Description,
Value = a.Value,
Name = a.Name,
Type = a.Type,
TextSpan = textSpan,
ActionValidation = a.ActionValidation,
IdentifierNameActionFunc = a.IdentifierNameActionFunc,
}).ToList());
fileAction.InvocationExpressionActions.UnionWith(token.InvocationExpressionActions.Select(a => new InvocationExpressionAction()
{
Key = !string.IsNullOrEmpty(overrideKey) ? overrideKey : a.Key,
Description = a.Description,
Value = a.Value,
Name = a.Name,
Type = a.Type,
TextSpan = textSpan,
ActionValidation = a.ActionValidation,
InvocationExpressionActionFunc = a.InvocationExpressionActionFunc
}).ToList());
fileAction.ElementAccessActions.UnionWith(token.ElementAccessActions.Select(a => new ElementAccessAction()
{
Key = (token is ElementAccessToken) ? token.FullKey : a.Key,
Description = a.Description,
Value = a.Value,
Name = a.Name,
Type = a.Type,
TextSpan = textSpan,
ActionValidation = a.ActionValidation,
ElementAccessExpressionActionFunc = a.ElementAccessExpressionActionFunc
}).ToList());
fileAction.MemberAccessActions.UnionWith(token.MemberAccessActions.Select(a => new MemberAccessAction()
{
Key = (token is MemberAccessToken) ? token.FullKey : a.Key,
Description = a.Description,
Value = a.Value,
Name = a.Name,
Type = a.Type,
TextSpan = textSpan,
ActionValidation = a.ActionValidation,
MemberAccessActionFunc = a.MemberAccessActionFunc
}).ToList());
fileAction.Usingactions.UnionWith(token.UsingActions.Select(a => new UsingAction()
{
Key = a.Key,
Description = a.Description,
Value = a.Value,
Name = a.Name,
Type = a.Type,
TextSpan = textSpan,
ActionValidation = a.ActionValidation,
UsingActionFunc = a.UsingActionFunc
}).ToList());
fileAction.NamespaceActions.UnionWith(token.NamespaceActions.Select(a => new NamespaceAction()
{
Key = a.Key,
Description = a.Description,
Value = a.Value,
Name = a.Name,
Type = a.Type,
TextSpan = textSpan,
ActionValidation = a.ActionValidation,
NamespaceActionFunc = a.NamespaceActionFunc
}).ToList());
fileAction.ObjectCreationExpressionActions.UnionWith(token.ObjectCreationExpressionActions.Select(a => new ObjectCreationExpressionAction()
{
Key = a.Key,
Description = a.Description,
Value = a.Value,
Name = a.Name,
Type = a.Type,
TextSpan = textSpan,
ActionValidation = a.ActionValidation,
ObjectCreationExpressionGenericActionFunc = a.ObjectCreationExpressionGenericActionFunc
}).ToList());
fileAction.ExpressionActions.UnionWith(token.ExpressionActions.Select(a => new ExpressionAction()
{
Key = !string.IsNullOrEmpty(overrideKey) ? overrideKey : a.Key,
Description = a.Description,
Value = a.Value,
Name = a.Name,
Type = a.Type,
TextSpan = textSpan,
ActionValidation = a.ActionValidation,
ExpressionActionFunc = a.ExpressionActionFunc
}).ToList());
if (fileAction.AttributeActions.Any()
|| fileAction.IdentifierNameActions.Any()
|| fileAction.InvocationExpressionActions.Any()
|| fileAction.ExpressionActions.Any()
|| fileAction.ElementAccessActions.Any()
|| fileAction.MemberAccessActions.Any()
|| fileAction.Usingactions.Any()
|| fileAction.NamespaceActions.Any()
|| fileAction.ObjectCreationExpressionActions.Any())
{
var nodeToken = token.Clone();
nodeToken.TextSpan = textSpan;
fileAction.NodeTokens.Add(nodeToken);
}
AddPackages(token.PackageActions, textSpan);
}