예제 #1
0
파일: CSharp.cs 프로젝트: Victov/NClass
        /// <summary>
        ///     Gets the <see cref="OperationModifier" /> as a C# string.
        /// </summary>
        /// <param name="modifier">The <see cref="OperationModifier" /> to convert.</param>
        /// <returns>The <see cref="OperationModifier" /> as a string.</returns>
        public static string Declaration(this OperationModifier modifier)
        {
            if ((modifier & OperationModifier.None) > 0)
            {
                return("");
            }
            StringBuilder result = new StringBuilder( );

            if ((modifier & OperationModifier.Hider) != 0)
            {
                result.Append("new ");
            }
            if ((modifier & OperationModifier.Static) != 0)
            {
                result.Append("static ");
            }
            if (((modifier & OperationModifier.Virtual) != 0) && ((modifier & OperationModifier.Override) == 0))
            {
                result.Append("virtual ");
            }
            if ((modifier & OperationModifier.Abstract) != 0)
            {
                result.Append("abstract ");
            }
            if ((modifier & OperationModifier.Sealed) != 0)
            {
                result.Append("sealed ");
            }
            if ((modifier & OperationModifier.Override) != 0)
            {
                result.Append("override ");
            }

            return(result.ToString( ));
        }
예제 #2
0
 public override bool IsValidModifier(OperationModifier modifier)
 {
     return(
         modifier == OperationModifier.Static ||
         modifier == OperationModifier.Abstract ||
         modifier == OperationModifier.Sealed
         );
 }
예제 #3
0
 public virtual void ClearModifiers()
 {
     if (modifier != OperationModifier.None)
     {
         modifier = OperationModifier.None;
         Changed();
     }
 }
예제 #4
0
 /// <summary>
 /// Returns a readable string containing the <see cref="OperationModifier"/>.
 /// </summary>
 /// <param name="operationModifier">The <see cref="OperationModifier"/> to convert to a string.</param>
 /// <returns>The converted <see cref="OperationModifier"/></returns>
 private static string ToString(OperationModifier operationModifier)
 {
     if (operationModifier == OperationModifier.None)
     {
         return("");
     }
     return(operationModifier.ToString().ToLower() + " ");
 }
예제 #5
0
        protected override void CopyFrom(Member member)
        {
            base.CopyFrom(member);

            Operation operation = (Operation)member;

            modifier     = operation.modifier;
            argumentList = operation.argumentList.Clone();
        }
예제 #6
0
        public override string GetOperationModifierString(OperationModifier modifier, bool forCode)
        {
            if (modifier == OperationModifier.None)
            {
                if (forCode)
                {
                    return("");
                }
                else
                {
                    return("None");
                }
            }

            StringBuilder builder = new StringBuilder(30);

            if ((modifier & OperationModifier.Hider) != 0)
            {
                builder.Append(forCode ? "new " : "New, ");
            }
            if ((modifier & OperationModifier.Static) != 0)
            {
                builder.Append(forCode ? "static " : "Static, ");
            }
            if ((modifier & OperationModifier.Virtual) != 0)
            {
                builder.Append(forCode ? "virtual " : "Virtual, ");
            }
            if ((modifier & OperationModifier.Abstract) != 0)
            {
                builder.Append(forCode ? "abstract " : "Abstract, ");
            }
            if ((modifier & OperationModifier.Sealed) != 0)
            {
                builder.Append(forCode ? "sealed " : "Sealed, ");
            }
            if ((modifier & OperationModifier.Override) != 0)
            {
                builder.Append(forCode ? "override " : "Override, ");
            }

            if (forCode)
            {
                builder.Remove(builder.Length - 1, 1);
            }
            else
            {
                builder.Remove(builder.Length - 2, 2);
            }

            return(builder.ToString());
        }
예제 #7
0
        public static string GetOperationModifier(OperationModifier modifier,
                                                  Language language, bool forCode)
        {
            if (modifier == OperationModifier.None)
            {
                if (forCode)
                {
                    return("");
                }
                else
                {
                    return("None");
                }
            }

            if (language == Language.Java && modifier == OperationModifier.Sealed)
            {
                if (forCode)
                {
                    return("final");
                }
                else
                {
                    return("Final");
                }
            }
            else if (language == Language.CSharp && modifier == OperationModifier.Sealed)
            {
                if (forCode)
                {
                    return("sealed override");
                }
                else
                {
                    return("Sealed");
                }
            }

            if (forCode)
            {
                return(modifier.ToString().ToLower());
            }
            else
            {
                return(modifier.ToString());
            }
        }
예제 #8
0
        private void ChangeModifier(OperationModifier modifier)
        {
            if (shape.ActiveMember != null && ValidateDeclarationLine())
            {
                var operation = shape.ActiveMember as Operation;
                if (operation != null)
                {
                    // Class changing to abstract
                    if ((modifier & OperationModifier.Abstract) != 0)
                    {
                        var classType = shape.CompositeType as ClassType;
                        if (classType != null && classType.Modifier != ClassModifier.Abstract)
                        {
                            var result = MessageBox.Show(
                                Strings.ChangingToAbstractConfirmation,
                                Strings.Confirmation,
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Warning);

                            if (result == DialogResult.No)
                            {
                                return;
                            }
                        }
                    }

                    try
                    {
                        // Clear other modifiers
                        operation.ClearModifiers();

                        // Set new values
                        operation.IsAbstract = (modifier & OperationModifier.Abstract) != 0;
                        operation.IsVirtual  = (modifier & OperationModifier.Virtual) != 0;
                        operation.IsOverride = (modifier & OperationModifier.Override) != 0;
                        operation.IsSealed   = (modifier & OperationModifier.Sealed) != 0;

                        RefreshValues();
                    }
                    catch (BadSyntaxException ex)
                    {
                        RefreshValues();
                        SetError(ex.Message);
                    }
                }
            }
        }
예제 #9
0
        public override string GetOperationModifierString(OperationModifier modifier, bool forCode)
        {
            if (modifier == OperationModifier.None)
            {
                if (forCode)
                {
                    return("");
                }
                else
                {
                    return("None");
                }
            }

            StringBuilder builder = new StringBuilder(20);

            if ((modifier & OperationModifier.Static) != 0)
            {
                builder.Append(forCode ? "static " : "Static, ");
            }
            if ((modifier & OperationModifier.Sealed) != 0)
            {
                builder.Append(forCode ? "final " : "Final, ");
            }
            if ((modifier & OperationModifier.Abstract) != 0)
            {
                builder.Append(forCode ? "abstract " : "Abstract, ");
            }

            if (forCode)
            {
                builder.Remove(builder.Length - 1, 1);
            }
            else
            {
                builder.Remove(builder.Length - 2, 2);
            }

            return(builder.ToString());
        }
        public void VerifyThatCreatingOverrideCreateSubscriptions()
        {
            var domain1 = new CDP4Common.SiteDirectoryData.DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache,
                                                                             this.uri);
            var domain2 = new CDP4Common.SiteDirectoryData.DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache,
                                                                             this.uri);
            var model      = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var iteration  = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var elementDef = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = domain1
            };
            var defForUsage = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = domain1
            };
            var usage = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ElementDefinition = defForUsage
            };

            var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = domain1
            };
            var parameterSubscription = new ParameterSubscription(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = domain2
            };

            parameter.ParameterSubscription.Add(parameterSubscription);

            this.assembler.Cache.TryAdd(new CacheKey(parameter.Iid, iteration.Iid), new Lazy <Thing>(() => parameter));
            this.assembler.Cache.TryAdd(new CacheKey(parameterSubscription.Iid, iteration.Iid), new Lazy <Thing>(() => parameterSubscription));
            this.assembler.Cache.TryAdd(new CacheKey(usage.Iid, iteration.Iid), new Lazy <Thing>(() => usage));

            var parameterOverride = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner     = domain1,
                Parameter = parameter
            };

            usage.ParameterOverride.Add(parameterOverride);

            model.Iteration.Add(iteration);
            iteration.Element.Add(elementDef);
            iteration.Element.Add(defForUsage);
            elementDef.ContainedElement.Add(usage);
            defForUsage.Parameter.Add(parameter);

            var transactionContext = TransactionContextResolver.ResolveContext(iteration);
            var context            = transactionContext.ContextRoute();

            var operationContainer = new OperationContainer(context, model.RevisionNumber);

            operationContainer.AddOperation(new Operation(null, parameterOverride.ToDto(), OperationKind.Create));
            operationContainer.AddOperation(new Operation(usage.ToDto(), usage.ToDto(), OperationKind.Update));

            var modifier = new OperationModifier(this.session.Object);

            modifier.ModifyOperationContainer(operationContainer);

            Assert.AreEqual(3, operationContainer.Operations.Count());
        }
예제 #11
0
 public string GetOperationModifierString(OperationModifier modifier)
 {
     return(GetOperationModifierString(modifier, false));
 }
        public void VerifyThatActualFiniteStateKindIsUpdatedOnNewDefault()
        {
            var model     = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var possibleList1 = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var possibleList2 = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var possibleList3 = new PossibleFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var ps11 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var ps12 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var ps21 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var ps22 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var ps31 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var ps32 = new PossibleFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            possibleList1.PossibleState.Add(ps11);
            possibleList1.PossibleState.Add(ps12);
            possibleList2.PossibleState.Add(ps21);
            possibleList2.PossibleState.Add(ps22);
            possibleList3.PossibleState.Add(ps31);
            possibleList3.PossibleState.Add(ps32);

            var actualList1 = new ActualFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var actualList2 = new ActualFiniteStateList(Guid.NewGuid(), this.assembler.Cache, this.uri);

            actualList1.PossibleFiniteStateList.Add(possibleList1);
            actualList1.PossibleFiniteStateList.Add(possibleList2);
            var as11 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as11.PossibleState.Add(ps11);
            as11.PossibleState.Add(ps21);
            var as12 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as12.PossibleState.Add(ps11);
            as12.PossibleState.Add(ps22);
            var as13 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as13.PossibleState.Add(ps12);
            as13.PossibleState.Add(ps21);
            var as14 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as14.PossibleState.Add(ps12);
            as14.PossibleState.Add(ps22);

            actualList1.ActualState.Add(as11);
            actualList1.ActualState.Add(as12);
            actualList1.ActualState.Add(as13);
            actualList1.ActualState.Add(as14);

            actualList2.PossibleFiniteStateList.Add(possibleList2);
            actualList2.PossibleFiniteStateList.Add(possibleList3);
            var as21 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as21.PossibleState.Add(ps21);
            as21.PossibleState.Add(ps31);
            var as22 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as22.PossibleState.Add(ps21);
            as22.PossibleState.Add(ps32);
            var as23 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as23.PossibleState.Add(ps22);
            as23.PossibleState.Add(ps31);
            var as24 = new ActualFiniteState(Guid.NewGuid(), this.assembler.Cache, this.uri);

            as24.PossibleState.Add(ps22);
            as24.PossibleState.Add(ps32);

            actualList2.ActualState.Add(as21);
            actualList2.ActualState.Add(as22);
            actualList2.ActualState.Add(as23);
            actualList2.ActualState.Add(as24);

            model.Iteration.Add(iteration);
            iteration.PossibleFiniteStateList.Add(possibleList1);
            iteration.PossibleFiniteStateList.Add(possibleList2);
            iteration.PossibleFiniteStateList.Add(possibleList3);
            iteration.ActualFiniteStateList.Add(actualList1);
            iteration.ActualFiniteStateList.Add(actualList2);

            this.assembler.Cache.TryAdd(new CacheKey(model.Iid, null), new Lazy <Thing>(() => model));
            this.assembler.Cache.TryAdd(new CacheKey(iteration.Iid, null), new Lazy <Thing>(() => iteration));
            this.assembler.Cache.TryAdd(new CacheKey(possibleList1.Iid, iteration.Iid), new Lazy <Thing>(() => possibleList1));
            this.assembler.Cache.TryAdd(new CacheKey(possibleList2.Iid, iteration.Iid), new Lazy <Thing>(() => possibleList2));
            this.assembler.Cache.TryAdd(new CacheKey(possibleList3.Iid, iteration.Iid), new Lazy <Thing>(() => possibleList3));
            this.assembler.Cache.TryAdd(new CacheKey(ps11.Iid, iteration.Iid), new Lazy <Thing>(() => ps11));
            this.assembler.Cache.TryAdd(new CacheKey(ps12.Iid, iteration.Iid), new Lazy <Thing>(() => ps12));
            this.assembler.Cache.TryAdd(new CacheKey(ps21.Iid, iteration.Iid), new Lazy <Thing>(() => ps21));
            this.assembler.Cache.TryAdd(new CacheKey(ps22.Iid, iteration.Iid), new Lazy <Thing>(() => ps22));
            this.assembler.Cache.TryAdd(new CacheKey(ps31.Iid, iteration.Iid), new Lazy <Thing>(() => ps31));
            this.assembler.Cache.TryAdd(new CacheKey(ps32.Iid, iteration.Iid), new Lazy <Thing>(() => ps32));
            this.assembler.Cache.TryAdd(new CacheKey(actualList1.Iid, iteration.Iid), new Lazy <Thing>(() => actualList1));
            this.assembler.Cache.TryAdd(new CacheKey(actualList2.Iid, iteration.Iid), new Lazy <Thing>(() => actualList2));
            this.assembler.Cache.TryAdd(new CacheKey(as11.Iid, iteration.Iid), new Lazy <Thing>(() => as11));
            this.assembler.Cache.TryAdd(new CacheKey(as12.Iid, iteration.Iid), new Lazy <Thing>(() => as12));
            this.assembler.Cache.TryAdd(new CacheKey(as13.Iid, iteration.Iid), new Lazy <Thing>(() => as13));
            this.assembler.Cache.TryAdd(new CacheKey(as14.Iid, iteration.Iid), new Lazy <Thing>(() => as14));
            this.assembler.Cache.TryAdd(new CacheKey(as21.Iid, iteration.Iid), new Lazy <Thing>(() => as21));
            this.assembler.Cache.TryAdd(new CacheKey(as22.Iid, iteration.Iid), new Lazy <Thing>(() => as22));
            this.assembler.Cache.TryAdd(new CacheKey(as23.Iid, iteration.Iid), new Lazy <Thing>(() => as23));
            this.assembler.Cache.TryAdd(new CacheKey(as24.Iid, iteration.Iid), new Lazy <Thing>(() => as24));

            possibleList1.DefaultState = ps11;
            as11.Kind = ActualFiniteStateKind.FORBIDDEN;

            var transactionContext = TransactionContextResolver.ResolveContext(iteration);
            var context            = transactionContext.ContextRoute();

            var operationContainer = new OperationContainer(context, model.RevisionNumber);

            var original = possibleList2.ToDto();
            var modify   = (CDP4Common.DTO.PossibleFiniteStateList)possibleList2.ToDto();

            modify.DefaultState = ps21.Iid;

            operationContainer.AddOperation(new Operation(original, modify, OperationKind.Update));

            Assert.AreEqual(1, operationContainer.Operations.Count());

            var modifier = new OperationModifier(this.session.Object);

            modifier.ModifyOperationContainer(operationContainer);

            Assert.AreEqual(2, operationContainer.Operations.Count());
            var addedOperation      = operationContainer.Operations.Last();
            var originalActualState = (CDP4Common.DTO.ActualFiniteState)addedOperation.OriginalThing;
            var modifiedActualState = (CDP4Common.DTO.ActualFiniteState)addedOperation.ModifiedThing;

            Assert.AreEqual(as11.Iid, originalActualState.Iid);
            Assert.AreEqual(ActualFiniteStateKind.MANDATORY, modifiedActualState.Kind);
            Assert.AreEqual(ActualFiniteStateKind.FORBIDDEN, originalActualState.Kind);
        }
예제 #13
0
파일: Language.cs 프로젝트: gbaychev/NClass
		public abstract string GetOperationModifierString(OperationModifier modifier, bool forCode);
예제 #14
0
		public virtual void ClearModifiers()
		{
			if (modifier != OperationModifier.None) {
				modifier = OperationModifier.None;
				Changed();
			}
		}
예제 #15
0
 public override string GetOperationModifierString(OperationModifier modifier, bool forCode)
 {
     throw new NotImplementedException();
 }
예제 #16
0
 public override bool IsValidModifier(OperationModifier modifier)
 {
     return(true);
 }
예제 #17
0
파일: Language.cs 프로젝트: gbaychev/NClass
		public abstract bool IsValidModifier(OperationModifier modifier);
예제 #18
0
        private void RefreshValues()
        {
            if (shape.ActiveMember != null)
            {
                Member member = shape.ActiveMember;
                SuspendLayout();
                RefreshModifiers();
                Language language = shape.CompositeType.Language;

                int cursorPosition = txtDeclaration.SelectionStart;
                txtDeclaration.Text           = member.ToString();
                txtDeclaration.SelectionStart = cursorPosition;
                txtDeclaration.ReadOnly       = (member.MemberType == MemberType.Destructor);

                SetError(null);
                needValidation = false;

                // Visibility
                RefreshVisibility();

                // Static and New modifiers
                toolStatic.Checked = member.IsStatic;
                toolStatic.Enabled = (member.MemberType != MemberType.Destructor);
                toolHider.Checked  = member.IsHider;
                toolHider.Enabled  = (member.MemberType != MemberType.Destructor);

                // Field modifiers
                Field field = member as Field;
                if (field != null)
                {
                    FieldModifier modifier = field.Modifier &
                                             (FieldModifier.Constant | FieldModifier.Readonly | FieldModifier.Volatile);

                    if (modifier == FieldModifier.None)
                    {
                        toolFieldModifiers.Text = Strings.None;
                    }
                    else
                    {
                        toolFieldModifiers.Text = language.ValidFieldModifiers[modifier];
                    }
                }

                // Operation modifiers
                Operation operation = member as Operation;
                if (operation != null)
                {
                    OperationModifier modifier = operation.Modifier &
                                                 (OperationModifier.Abstract | OperationModifier.Override |
                                                  OperationModifier.Sealed | OperationModifier.Virtual);

                    if (modifier == OperationModifier.None)
                    {
                        toolOperationModifiers.Text = Strings.None;
                    }
                    else
                    {
                        toolOperationModifiers.Text = language.ValidOperationModifiers[modifier];
                    }

                    toolOperationModifiers.Enabled = (member.MemberType != MemberType.Destructor);
                }

                // Property accessor
                Property property = member as Property;
                if (property != null)
                {
                    if (property.IsReadonly)
                    {
                        toolAccessor.Image       = Properties.Resources.PublicReadonly;
                        toolAccessor.ToolTipText = Strings.ReadOnly;
                    }
                    else if (property.IsWriteonly)
                    {
                        toolAccessor.Image       = Properties.Resources.PublicWriteonly;
                        toolAccessor.ToolTipText = Strings.WriteOnly;
                    }
                    else
                    {
                        toolAccessor.Image       = Properties.Resources.PublicProperty;
                        toolAccessor.ToolTipText = Strings.ReadWrite;
                    }
                }

                RefreshNewMembers();
                RefreshMoveUpDownTools();
                ResumeLayout();
            }
        }
예제 #19
0
        private void RefreshValues()
        {
            if (shape.ActiveMember != null)
            {
                Member member = shape.ActiveMember;

                if (member is Property)
                {
                    this.Height = pnlAdvancedOptions.Bottom + pnlAdvancedOptions.Margin.Bottom;
                }
                else
                {
                    this.Height = pnlAdvancedOptions.Location.Y;
                }
                Refresh();

                SuspendLayout();
                RefreshModifiers();
                Language language = shape.CompositeType.Language;

                int cursorPosition = txtDeclaration.SelectionStart;
                txtDeclaration.Text           = member.ToString();
                txtDeclaration.SelectionStart = cursorPosition;
                txtDeclaration.ReadOnly       = (member.MemberType == MemberType.Destructor);

                int cursorPositionNHMColumn = txtNHMColumnName.SelectionStart;
                txtNHMColumnName.Text           = member.NHMColumnName;
                txtNHMColumnName.SelectionStart = cursorPositionNHMColumn;

                chkIsIdentity.Checked     = member.IsIdentity;
                cboManyToOne.SelectedItem = string.IsNullOrEmpty(member.ManyToOne) ? "(None)" : member.ManyToOne;
                chkIsUnique.Checked       = member.IsUnique;
                chkIsNotNull.Checked      = member.IsNotNull;

                SetError(null);
                needValidation = false;

                // Visibility
                RefreshVisibility();

                // Static and New modifiers
                toolStatic.Checked = member.IsStatic;
                toolStatic.Enabled = (member.MemberType != MemberType.Destructor);
                toolHider.Checked  = member.IsHider;
                toolHider.Enabled  = (member.MemberType != MemberType.Destructor);

                // Field modifiers
                Field field = member as Field;
                if (field != null)
                {
                    FieldModifier modifier = field.Modifier &
                                             (FieldModifier.Constant | FieldModifier.Readonly | FieldModifier.Volatile);

                    if (modifier == FieldModifier.None)
                    {
                        toolFieldModifiers.Text = Strings.None;
                    }
                    else
                    {
                        toolFieldModifiers.Text = language.ValidFieldModifiers[modifier];
                    }
                }

                // Operation modifiers
                Operation operation = member as Operation;
                if (operation != null)
                {
                    OperationModifier modifier = operation.Modifier &
                                                 (OperationModifier.Abstract | OperationModifier.Override |
                                                  OperationModifier.Sealed | OperationModifier.Virtual);

                    if (modifier == OperationModifier.None)
                    {
                        toolOperationModifiers.Text = Strings.None;
                    }
                    else
                    {
                        toolOperationModifiers.Text = language.ValidOperationModifiers[modifier];
                    }

                    toolOperationModifiers.Enabled = (member.MemberType != MemberType.Destructor);
                }

                // Property accessor
                Property property = member as Property;
                if (property != null)
                {
                    if (property.IsReadonly)
                    {
                        toolAccessor.Image       = Properties.Resources.PublicReadonly;
                        toolAccessor.ToolTipText = Strings.ReadOnly;
                    }
                    else if (property.IsWriteonly)
                    {
                        toolAccessor.Image       = Properties.Resources.PublicWriteonly;
                        toolAccessor.ToolTipText = Strings.WriteOnly;
                    }
                    else
                    {
                        toolAccessor.Image       = Properties.Resources.PublicProperty;
                        toolAccessor.ToolTipText = Strings.ReadWrite;
                    }
                }

                RefreshNewMembers();
                RefreshMoveUpDownTools();
                ResumeLayout();
            }
        }
예제 #20
0
		public override string GetOperationModifierString(OperationModifier modifier, bool forCode)
		{
			if (modifier == OperationModifier.None) {
				if (forCode)
					return "";
				else
					return "None";
			}

			StringBuilder builder = new StringBuilder(20);
			if ((modifier & OperationModifier.Static) != 0)
				builder.Append(forCode ? "static " : "Static, ");
			if ((modifier & OperationModifier.Sealed) != 0)
				builder.Append(forCode ? "final " : "Final, ");
			if ((modifier & OperationModifier.Abstract) != 0)
				builder.Append(forCode ? "abstract " : "Abstract, ");

			if (forCode)
				builder.Remove(builder.Length - 1, 1);
			else
				builder.Remove(builder.Length - 2, 2);

			return builder.ToString();
		}
예제 #21
0
 public override bool IsValidModifier(OperationModifier modifier) => true;
예제 #22
0
		private void ChangeModifier(OperationModifier modifier)
		{
			if (shape.ActiveMember != null && ValidateDeclarationLine())
			{
				Operation operation = shape.ActiveMember as Operation;
				if (operation != null)
				{
					// Class changing to abstract
					if ((modifier & OperationModifier.Abstract) != 0)
					{
						ClassType classType = shape.CompositeType as ClassType;
						if (classType != null && classType.Modifier != ClassModifier.Abstract)
						{
							DialogResult result = MessageBox.Show(
								Strings.ChangingToAbstractConfirmation, Strings.Confirmation,
								MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

							if (result == DialogResult.No)
								return;
						}
					}
					
					try
					{
						// Clear other modifiers
						operation.ClearModifiers();

						// Set new values
						operation.IsAbstract = ((modifier & OperationModifier.Abstract) != 0);
						operation.IsVirtual = ((modifier & OperationModifier.Virtual) != 0);
						operation.IsOverride = ((modifier & OperationModifier.Override) != 0);
						operation.IsSealed = ((modifier & OperationModifier.Sealed) != 0);

						RefreshValues();
					}
					catch (BadSyntaxException ex)
					{
						RefreshValues();
						SetError(ex.Message);
					}
				}
			}
		}
예제 #23
0
		protected override void CopyFrom(Member member)
		{
			base.CopyFrom(member);

			Operation operation = (Operation) member;
			modifier = operation.modifier;
			argumentList = operation.argumentList.Clone();
		}
		public override bool IsValidModifier(OperationModifier modifier)
        {
            return validOperationModifiers.ContainsKey(modifier);
		}
예제 #25
0
		public override bool IsValidModifier(OperationModifier modifier)
		{
			return (
				modifier == OperationModifier.Static ||
				modifier == OperationModifier.Abstract ||
				modifier == OperationModifier.Sealed
			);
		}
		public override string GetOperationModifierString(OperationModifier modifier, bool forCode)
		{
			if (modifier == OperationModifier.None) {
				if (forCode)
					return "";
				else
					return "None";
			}

			StringBuilder builder = new StringBuilder(30);
			if ((modifier & OperationModifier.Hider) != 0)
				builder.Append(forCode ? "new " : "New, ");
			if ((modifier & OperationModifier.Static) != 0)
				builder.Append(forCode ? "static " : "Static, ");
			if ((modifier & OperationModifier.Virtual) != 0)
				builder.Append(forCode ? "virtual " : "Virtual, ");
			if ((modifier & OperationModifier.Abstract) != 0)
				builder.Append(forCode ? "abstract " : "Abstract, ");
			if ((modifier & OperationModifier.Sealed) != 0)
				builder.Append(forCode ? "sealed " : "Sealed, ");
			if ((modifier & OperationModifier.Override) != 0)
				builder.Append(forCode ? "override " : "Override, ");

			if (forCode)
				builder.Remove(builder.Length - 1, 1);
			else
				builder.Remove(builder.Length - 2, 2);

			return builder.ToString();
		}
예제 #27
0
 internal static string GetOperationModifier(OperationModifier modifier, Language language)
 {
     return(GetOperationModifier(modifier, language, true));
 }
예제 #28
0
 public override bool IsValidModifier(OperationModifier modifier)
 {
     throw new NotImplementedException();
 }
예제 #29
0
 public abstract bool IsValidModifier(OperationModifier modifier);
예제 #30
0
파일: Language.cs 프로젝트: gbaychev/NClass
		public string GetOperationModifierString(OperationModifier modifier)
		{
			return GetOperationModifierString(modifier, false);
		}
예제 #31
0
 public abstract string GetOperationModifierString(OperationModifier modifier, bool forCode);
예제 #32
0
        public override bool Parse(ItemFactory itemFactory, ITextProvider text, TokenStream tokens)
        {
            if (tokens.CurrentToken.TokenType != CssTokenType.OpenSquareBracket)
            {
                return(false);
            }

            // Collect each piece of "[ name = value ]", any of which could be missing after the '['

            OpenBracket = Children.AddCurrentAndAdvance(tokens, CssClassifierContextType.SquareBracket);

            if (ItemName.IsAtItemName(tokens))
            {
                AttributeName = itemFactory.CreateSpecific <ItemName>(this);
                AttributeName.Parse(itemFactory, text, tokens);
                AttributeName.Context = CssClassifierContextCache.FromTypeEnum(CssClassifierContextType.ElementAttribute);
                Children.Add(AttributeName);
            }
            else
            {
                OpenBracket.AddParseError(ParseErrorType.AttributeSelectorElementMissing, ParseErrorLocation.AfterItem);
            }

            switch (tokens.CurrentToken.TokenType)
            {
            case CssTokenType.BeginsWith:           // ^=
            case CssTokenType.EndsWith:             // $=
            case CssTokenType.OneOf:                // ~=
            case CssTokenType.ListBeginsWith:       // |=
            case CssTokenType.ContainsString:       // *=
            case CssTokenType.Equals:               // =
                Operation = Children.AddCurrentAndAdvance(tokens, CssClassifierContextType.SelectorOperator);
                break;
            }

            if (tokens.CurrentToken.TokenType == CssTokenType.Identifier)
            {
                AttributeValue = Children.AddCurrentAndAdvance(tokens, CssClassifierContextType.ElementAttributeValue);
            }
            else if (tokens.CurrentToken.IsString())
            {
                AttributeValue = Children.AddCurrentAndAdvance(tokens, CssClassifierContextType.ElementAttributeValue);
            }

            if (AttributeValue != null && Operation == null)
            {
                AttributeValue.AddParseError(ParseErrorType.AttributeSelectorOperationMissing, ParseErrorLocation.BeforeItem);
            }
            else if (AttributeValue == null && Operation != null)
            {
                Operation.AddParseError(ParseErrorType.AttributeSelectorValueMissing, ParseErrorLocation.AfterItem);
            }

            if (AttributeValue != null && tokens.CurrentToken.TokenType == CssTokenType.Identifier)
            {
                OperationModifier = Children.AddCurrentAndAdvance(tokens, CssClassifierContextType.SelectorOperator);

                if (OperationModifier.Length != 1 || text[OperationModifier.Start] != 'i')
                {
                    OperationModifier.AddParseError(ParseErrorType.UnexpectedToken, ParseErrorLocation.WholeItem);
                }
            }

            if (tokens.CurrentToken.TokenType == CssTokenType.CloseSquareBracket)
            {
                CloseBracket = Children.AddCurrentAndAdvance(tokens, CssClassifierContextType.SquareBracket);
            }
            else
            {
                AddParseError(ParseErrorType.AttributeSelectorCloseBracketMissing, ParseErrorLocation.AfterItem);
            }

            return(Children.Count > 0);
        }
예제 #33
0
		public override bool IsValidModifier(OperationModifier modifier)
		{
			return true;
		}