Beispiel #1
0
        public override bool VisitEnumItemDecl(Enumeration.Item item)
        {
            if (!Targets.HasFlag(RenameTargets.EnumItem))
            {
                return(false);
            }

            string newName;

            if (Rename(item, out newName))
            {
                item.Name = newName;
                return(true);
            }

            return(true);
        }
Beispiel #2
0
        public bool IsRenameableDecl(Declaration decl)
        {
            if (decl is Class)
            {
                return(Targets.HasFlag(RenameTargets.Class));
            }

            var method = decl as Method;

            if (method != null)
            {
                return(Targets.HasFlag(RenameTargets.Method) &&
                       method.Kind == CXXMethodKind.Normal);
            }

            var function = decl as Function;

            if (function != null)
            {
                // Special case the IDisposable.Dispose method.
                return(Targets.HasFlag(RenameTargets.Function) &&
                       (!function.IsOperator && function.Name != "dispose"));
            }

            if (decl is Parameter)
            {
                return(Targets.HasFlag(RenameTargets.Parameter));
            }

            if (decl is Enumeration.Item)
            {
                return(Targets.HasFlag(RenameTargets.EnumItem));
            }

            if (decl is Enumeration)
            {
                return(Targets.HasFlag(RenameTargets.Enum));
            }

            var property = decl as Property;

            if (property != null)
            {
                return(Targets.HasFlag(RenameTargets.Property) && !property.IsIndexer);
            }

            if (decl is Event)
            {
                return(Targets.HasFlag(RenameTargets.Event));
            }

            if (decl is TypedefDecl)
            {
                return(Targets.HasFlag(RenameTargets.Delegate));
            }

            if (decl is Namespace && !(decl is TranslationUnit))
            {
                return(true);
            }

            if (decl is Variable)
            {
                return(Targets.HasFlag(RenameTargets.Variable));
            }

            var field = decl as Field;

            if (field != null)
            {
                if (!Targets.HasFlag(RenameTargets.Field))
                {
                    return(false);
                }
                var fieldProperty = ((Class)field.Namespace).Properties.FirstOrDefault(
                    p => p.Field == field);
                return(fieldProperty != null &&
                       fieldProperty.IsInRefTypeAndBackedByValueClassField());
            }

            return(false);
        }