protected override Action <ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
            {
                if (myIsSerialized)
                {
                    AttributeUtil.RemoveAttributeFromAllDeclarations(myFieldDeclaration, KnownTypes.SerializeField);
                    if (myFieldDeclaration.GetAccessRights() == AccessRights.PUBLIC)
                    {
                        AttributeUtil.AddAttributeToEntireDeclaration(myMultipleFieldDeclaration,
                                                                      PredefinedType.NONSERIALIZED_ATTRIBUTE_CLASS, EmptyArray <AttributeValue> .Instance, myModule,
                                                                      myElementFactory);
                    }
                }
                else
                {
                    if (myFieldDeclaration.IsStatic)
                    {
                        ModifiersUtil.SetStatic(myMultipleFieldDeclaration, false);
                    }
                    if (myFieldDeclaration.IsReadonly)
                    {
                        ModifiersUtil.SetReadonly(myMultipleFieldDeclaration, false);
                    }

                    AttributeUtil.RemoveAttributeFromAllDeclarations(myFieldDeclaration,
                                                                     PredefinedType.NONSERIALIZED_ATTRIBUTE_CLASS);
                    if (myFieldDeclaration.GetAccessRights() != AccessRights.PUBLIC)
                    {
                        AttributeUtil.AddAttributeToEntireDeclaration(myMultipleFieldDeclaration,
                                                                      KnownTypes.SerializeField, EmptyArray <AttributeValue> .Instance, myModule, myElementFactory);
                    }
                }

                return(null);
            }
            protected override Action <ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
            {
                if (myIsSerialized)
                {
                    AttributeUtil.RemoveAttributeFromSingleDeclaration(myFieldDeclaration, KnownTypes.SerializeField);
                    if (myFieldDeclaration.GetAccessRights() == AccessRights.PUBLIC)
                    {
                        AttributeUtil.AddAttributeToSingleDeclaration(myFieldDeclaration,
                                                                      PredefinedType.NONSERIALIZED_ATTRIBUTE_CLASS, myModule, myElementFactory);
                    }
                }
                else
                {
                    if (myFieldDeclaration.IsStatic)
                    {
                        myFieldDeclaration.SetStatic(false);
                    }

                    if (myFieldDeclaration.IsReadonly)
                    {
                        myFieldDeclaration.SetReadonly(false);
                    }

                    AttributeUtil.RemoveAttributeFromSingleDeclaration(myFieldDeclaration,
                                                                       PredefinedType.NONSERIALIZED_ATTRIBUTE_CLASS);
                    if (myFieldDeclaration.GetAccessRights() != AccessRights.PUBLIC)
                    {
                        AttributeUtil.AddAttributeToSingleDeclaration(myFieldDeclaration, KnownTypes.SerializeField,
                                                                      myModule, myElementFactory);
                    }
                }

                return(null);
            }
        private static (NamedElementKinds?, IReferenceName) GetKindAndDeclaration(ILocalVariableDeclaration localVarDeclaration, IFieldDeclaration fieldDeclaration,
                                                                                  IRegularParameterDeclaration regularParameterDeclaration)
        {
            NamedElementKinds?kind           = null;
            IReferenceName    scalarTypeName = null;

            if (localVarDeclaration != null)
            {
                kind           = NamedElementKinds.Locals;
                scalarTypeName = localVarDeclaration.GetScalarTypename();
            }

            else if (fieldDeclaration != null)
            {
                scalarTypeName = fieldDeclaration.GetScalarTypename();
                var isPrivate = fieldDeclaration.GetAccessRights().Has(AccessRights.PRIVATE);

                if (fieldDeclaration.IsStatic)
                {
                    if (isPrivate)
                    {
                        kind = fieldDeclaration.IsReadonly ? NamedElementKinds.PrivateStaticReadonly : NamedElementKinds.PrivateStaticFields;
                    }
                    else
                    {
                        kind = fieldDeclaration.IsReadonly ? NamedElementKinds.StaticReadonly : NamedElementKinds.PublicFields;
                    }
                }
                else
                {
                    kind = isPrivate ? NamedElementKinds.PrivateInstanceFields : NamedElementKinds.PublicFields;
                }
            }

            else if (regularParameterDeclaration != null)
            {
                kind           = NamedElementKinds.Parameters;
                scalarTypeName = regularParameterDeclaration.ScalarTypeName;
            }

            return(kind, scalarTypeName);
        }
Example #4
0
 public AccessRights GetAccessRights()
 {
     return(_fieldDeclaration.GetAccessRights());
 }