IEnumerable <CodeAction> GetActions(Attribute attribute, AttributeSection attributeSection, FieldDeclaration fieldDeclaration) { string removeAttributeMessage = ctx.TranslateString("Remove attribute"); yield return(new CodeAction(removeAttributeMessage, script => { if (attributeSection.Attributes.Count > 1) { var newSection = new AttributeSection(); newSection.AttributeTarget = attributeSection.AttributeTarget; foreach (var attr in attributeSection.Attributes) { if (attr != attribute) { newSection.Attributes.Add((Attribute)attr.Clone()); } } script.Replace(attributeSection, newSection); } else { script.Remove(attributeSection); } })); var makeStaticMessage = ctx.TranslateString("Make the field static"); yield return(new CodeAction(makeStaticMessage, script => { var newDeclaration = (FieldDeclaration)fieldDeclaration.Clone(); newDeclaration.Modifiers |= Modifiers.Static; script.Replace(fieldDeclaration, newDeclaration); })); }
IEnumerable<CodeAction> GetActions(Attribute attribute, AttributeSection attributeSection, FieldDeclaration fieldDeclaration) { string removeAttributeMessage = ctx.TranslateString("Remove attribute"); yield return new CodeAction(removeAttributeMessage, script => { if (attributeSection.Attributes.Count > 1) { var newSection = new AttributeSection(); newSection.AttributeTarget = attributeSection.AttributeTarget; foreach (var attr in attributeSection.Attributes) { if (attr != attribute) newSection.Attributes.Add((Attribute)attr.Clone()); } script.Replace(attributeSection, newSection); } else { script.Remove(attributeSection); } }); var makeStaticMessage = ctx.TranslateString("Make the field static"); yield return new CodeAction(makeStaticMessage, script => { var newDeclaration = (FieldDeclaration)fieldDeclaration.Clone(); newDeclaration.Modifiers |= Modifiers.Static; script.Replace(fieldDeclaration, newDeclaration); }); }