Ejemplo n.º 1
0
 protected override void FreezeInternal()
 {
     base.FreezeInternal();
     baseTypeParameter.Freeze();
     owningMethod.Freeze();
     owningClass.Freeze();
 }
Ejemplo n.º 2
0
        protected void AddClassToNamespaceListInternal(IClass addClass)
        {
            // Freeze the class when adding it to the project content
            addClass.Freeze();

            Debug.Assert(!(addClass is CompoundClass));
            Debug.Assert(!addClass.HasCompoundClass);

            string fullyQualifiedName = addClass.FullyQualifiedName;
            IClass existingClass      = GetClassInternal(fullyQualifiedName, addClass.TypeParameters.Count, language);

            if (existingClass != null && existingClass.TypeParameters.Count == addClass.TypeParameters.Count)
            {
                LoggingService.Debug("Adding existing class " + addClass.Name + " from " + Path.GetFileName(addClass.CompilationUnit.FileName));
                CompoundClass compound = existingClass as CompoundClass;
                if (compound != null)
                {
                    // mark the class as partial
                    // (VB allows specifying the 'partial' modifier only on one part)
                    addClass.HasCompoundClass = true;

                    // add the new class to the compound class
                    List <IClass> newParts = new List <IClass>(compound.Parts);
                    newParts.Add(addClass);
                    // construct a replacement CompoundClass with the new part list
                    addClass = CompoundClass.Create(newParts);
                    LoggingService.Debug("Added new part (old part count=" + compound.Parts.Count + ", new part count=" + newParts.Count + ")");
                }
                else
                {
                    // Instead of overwriting a class with another, treat both parts as partial.
                    // This fixes SD2-1217.

                    if (!(addClass.IsPartial || language.ImplicitPartialClasses))
                    {
                        LoggingService.Info("Duplicate class " + fullyQualifiedName + ", creating compound");
                    }
                    else
                    {
                        LoggingService.Debug("Creating compound for " + fullyQualifiedName);
                    }

                    // Merge existing non-partial class with addClass
                    addClass.HasCompoundClass      = true;
                    existingClass.HasCompoundClass = true;

                    addClass = CompoundClass.Create(new[] { addClass, existingClass });
                }
            }
            AddClassToNamespaceListInternal2(addClass);
        }
Ejemplo n.º 3
0
		protected void AddClassToNamespaceListInternal(IClass addClass)
		{
			// Freeze the class when adding it to the project content
			addClass.Freeze();
			
			Debug.Assert(!(addClass is CompoundClass));
			Debug.Assert(!addClass.HasCompoundClass);
			
			string fullyQualifiedName = addClass.FullyQualifiedName;
			IClass existingClass = GetClassInternal(fullyQualifiedName, addClass.TypeParameters.Count, language);
			if (existingClass != null && existingClass.TypeParameters.Count == addClass.TypeParameters.Count) {
				LoggingService.Debug("Adding existing class " + addClass.Name + " from " + Path.GetFileName(addClass.CompilationUnit.FileName));
				CompoundClass compound = existingClass as CompoundClass;
				if (compound != null) {
					// mark the class as partial
					// (VB allows specifying the 'partial' modifier only on one part)
					addClass.HasCompoundClass = true;
					
					// add the new class to the compound class
					List<IClass> newParts = new List<IClass>(compound.Parts);
					newParts.Add(addClass);
					// construct a replacement CompoundClass with the new part list
					addClass = CompoundClass.Create(newParts);
					LoggingService.Debug("Added new part (old part count=" + compound.Parts.Count +", new part count=" + newParts.Count + ")");
				} else {
					// Instead of overwriting a class with another, treat both parts as partial.
					// This fixes SD2-1217.
					
					if (!(addClass.IsPartial || language.ImplicitPartialClasses)) {
						LoggingService.Info("Duplicate class " + fullyQualifiedName + ", creating compound");
					} else {
						LoggingService.Debug("Creating compound for " + fullyQualifiedName);
					}
					
					// Merge existing non-partial class with addClass
					addClass.HasCompoundClass = true;
					existingClass.HasCompoundClass = true;
					
					addClass = CompoundClass.Create(new[] { addClass, existingClass });
				}
			}
			AddClassToNamespaceListInternal2(addClass);
		}
Ejemplo n.º 4
0
 public DynamicModelElement(IClass @class, IClass implemented)
 {
     _class = @class;
     _class.Freeze();
     LoadProperties(@class, new HashSet <IClass>((implemented ?? ClassInstance).Closure(c => c.BaseTypes)));
 }