コード例 #1
0
		// Cloning only params will speed up the method param renaming code
		public VariableNameState CloneParamsOnly() {
			var vns = new VariableNameState();
			vns.existingVariableNames = new ExistingNames();
			vns.variableNameCreator = new VariableNameCreator();
			vns.existingVariableNames.Merge(existingVariableNames);
			vns.variableNameCreator.Merge(variableNameCreator);
			return vns;
		}
コード例 #2
0
        // Cloning only params will speed up the method param renaming code
        public VariableNameState cloneParamsOnly()
        {
            var vns = new VariableNameState();

            vns.existingVariableNames = new ExistingNames();
            vns.variableNameCreator   = new VariableNameCreator();
            vns.existingVariableNames.merge(existingVariableNames);
            vns.variableNameCreator.merge(variableNameCreator);
            return(vns);
        }
コード例 #3
0
		public VariableNameState Merge(VariableNameState other) {
			existingVariableNames.Merge(other.existingVariableNames);
			existingMethodNames.Merge(other.existingMethodNames);
			existingPropertyNames.Merge(other.existingPropertyNames);
			existingEventNames.Merge(other.existingEventNames);
			variableNameCreator.Merge(other.variableNameCreator);
			propertyNameCreator.Merge(other.propertyNameCreator);
			eventNameCreator.Merge(other.eventNameCreator);
			genericPropertyNameCreator.Merge(other.genericPropertyNameCreator);
			staticMethodNameCreator.Merge(other.staticMethodNameCreator);
			instanceMethodNameCreator.Merge(other.instanceMethodNameCreator);
			return this;
		}
コード例 #4
0
 public VariableNameState merge(VariableNameState other)
 {
     existingVariableNames.merge(other.existingVariableNames);
     existingMethodNames.merge(other.existingMethodNames);
     existingPropertyNames.merge(other.existingPropertyNames);
     existingEventNames.merge(other.existingEventNames);
     variableNameCreator.merge(other.variableNameCreator);
     propertyNameCreator.merge(other.propertyNameCreator);
     eventNameCreator.merge(other.eventNameCreator);
     genericPropertyNameCreator.merge(other.genericPropertyNameCreator);
     staticMethodNameCreator.merge(other.staticMethodNameCreator);
     instanceMethodNameCreator.merge(other.instanceMethodNameCreator);
     return(this);
 }
コード例 #5
0
		public static VariableNameState Create() {
			var vns = new VariableNameState();
			vns.existingVariableNames = new ExistingNames();
			vns.existingMethodNames = new ExistingNames();
			vns.existingPropertyNames = new ExistingNames();
			vns.existingEventNames = new ExistingNames();
			vns.variableNameCreator = new VariableNameCreator();
			vns.propertyNameCreator = new PropertyNameCreator();
			vns.eventNameCreator = new NameCreator("Event_");
			vns.genericPropertyNameCreator = new NameCreator("Prop_");
			vns.staticMethodNameCreator = new NameCreator("smethod_");
			vns.instanceMethodNameCreator = new NameCreator("method_");
			return vns;
		}
コード例 #6
0
        public static VariableNameState create()
        {
            var vns = new VariableNameState();

            vns.existingVariableNames      = new ExistingNames();
            vns.existingMethodNames        = new ExistingNames();
            vns.existingPropertyNames      = new ExistingNames();
            vns.existingEventNames         = new ExistingNames();
            vns.variableNameCreator        = new VariableNameCreator();
            vns.propertyNameCreator        = new PropertyNameCreator();
            vns.eventNameCreator           = new NameCreator("Event_");
            vns.genericPropertyNameCreator = new NameCreator("Prop_");
            vns.staticMethodNameCreator    = new NameCreator("smethod_");
            vns.instanceMethodNameCreator  = new NameCreator("method_");
            return(vns);
        }
コード例 #7
0
        void PrepareRenameMethodArgs(MMethodDef methodDef)
        {
            VariableNameState newVariableNameState = null;
            ParamInfo         info;

            if (methodDef.VisibleParameterCount > 0)
            {
                if (IsEventHandler(methodDef))
                {
                    info = Param(methodDef.ParamDefs[methodDef.VisibleParameterBaseIndex]);
                    if (!info.GotNewName())
                    {
                        info.newName = "sender";
                    }

                    info = Param(methodDef.ParamDefs[methodDef.VisibleParameterBaseIndex + 1]);
                    if (!info.GotNewName())
                    {
                        info.newName = "e";
                    }
                }
                else
                {
                    newVariableNameState = variableNameState.CloneParamsOnly();
                    var checker = NameChecker;
                    foreach (var paramDef in methodDef.ParamDefs)
                    {
                        if (paramDef.IsHiddenThisParameter)
                        {
                            continue;
                        }
                        info = Param(paramDef);
                        if (info.GotNewName())
                        {
                            continue;
                        }
                        if (!checker.IsValidMethodArgName(info.oldName))
                        {
                            info.newName = newVariableNameState.GetNewParamName(info.oldName, paramDef.ParameterDef);
                        }
                    }
                }
            }

            info = Param(methodDef.ReturnParamDef);
            if (!info.GotNewName())
            {
                if (!NameChecker.IsValidMethodReturnArgName(info.oldName))
                {
                    if (newVariableNameState == null)
                    {
                        newVariableNameState = variableNameState.CloneParamsOnly();
                    }
                    info.newName = newVariableNameState.GetNewParamName(info.oldName, methodDef.ReturnParamDef.ParameterDef);
                }
            }

            if ((methodDef.Property != null && methodDef == methodDef.Property.SetMethod) ||
                (methodDef.Event != null && (methodDef == methodDef.Event.AddMethod || methodDef == methodDef.Event.RemoveMethod)))
            {
                if (methodDef.VisibleParameterCount > 0)
                {
                    var paramDef = methodDef.ParamDefs[methodDef.ParamDefs.Count - 1];
                    Param(paramDef).newName = "value";
                }
            }
        }
コード例 #8
0
 public void mergeProperties(VariableNameState other)
 {
     existingPropertyNames.merge(other.existingPropertyNames);
 }
コード例 #9
0
 public void mergeMethods(VariableNameState other)
 {
     existingMethodNames.merge(other.existingMethodNames);
 }
コード例 #10
0
 public void mergeEvents(VariableNameState other)
 {
     existingEventNames.merge(other.existingEventNames);
 }
コード例 #11
0
 public void mergeEvents(VariableNameState other)
 {
     existingEventNames.merge(other.existingEventNames);
 }
コード例 #12
0
 public void mergeProperties(VariableNameState other)
 {
     existingPropertyNames.merge(other.existingPropertyNames);
 }
コード例 #13
0
 public void mergeMethods(VariableNameState other)
 {
     existingMethodNames.merge(other.existingMethodNames);
 }
コード例 #14
0
 public void MergeEvents(VariableNameState other) => existingEventNames.Merge(other.existingEventNames);
コード例 #15
0
 public void MergeProperties(VariableNameState other) => existingPropertyNames.Merge(other.existingPropertyNames);
コード例 #16
0
 public void MergeMethods(VariableNameState other) => existingMethodNames.Merge(other.existingMethodNames);