Exemplo n.º 1
0
        void AddNamespaceStructContents(List <ICompletionEntry> list, NamespaceStruct ns, LanguageProperties language, bool lookInReferences)
        {
            int newCapacity = list.Count + ns.Classes.Count + ns.SubNamespaces.Count;

            if (list.Capacity < newCapacity)
            {
                list.Capacity = Math.Max(list.Count * 2, newCapacity);
            }
            foreach (IClass c in ns.Classes)
            {
                if (c is GenericClassContainer)
                {
                    foreach (IClass realClass in ((GenericClassContainer)c).RealClasses)
                    {
                        AddNamespaceContentsClass(list, realClass, language, lookInReferences);
                    }
                }
                else
                {
                    AddNamespaceContentsClass(list, c, language, lookInReferences);
                }
            }
            foreach (string subns in ns.SubNamespaces)
            {
                NamespaceEntry subnsEntry = new NamespaceEntry(subns);
                if (!list.Contains(subnsEntry))                 // PERF
                {
                    list.Add(subnsEntry);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the contents of the specified <paramref name="nameSpace"/> to the <paramref name="list"/>.
        /// </summary>
        /// <param name="lookInReferences">If true, contents of referenced projects will be added as well (not recursive - just 1 level deep).</param>
        public void AddNamespaceContents(List <ICompletionEntry> list, string nameSpace, LanguageProperties language, bool lookInReferences)
        {
            if (nameSpace == null)
            {
                return;
            }

            if (lookInReferences)
            {
                lock (referencedContents) {
                    foreach (IProjectContent content in referencedContents)
                    {
                        content.AddNamespaceContents(list, nameSpace, language, false);
                    }
                }
            }

            lock (namespaces) {
                Dictionary <string, NamespaceStruct> dict = GetNamespaces(language);
                if (dict.ContainsKey(nameSpace))
                {
                    NamespaceStruct ns = dict[nameSpace];
                    AddNamespaceStructContents(list, ns, language, lookInReferences);
                }
            }
        }
Exemplo n.º 3
0
            public NamespaceStruct MergeWith(NamespaceStruct other)
            {
                NamespaceStruct newStruct = new NamespaceStruct(null);

                newStruct.Classes.AddRange(this.Classes);
                newStruct.Classes.AddRange(other.Classes);
                newStruct.SubNamespaces.AddRange(this.SubNamespaces);
                newStruct.SubNamespaces.AddRange(other.SubNamespaces);
                return(newStruct);
            }
Exemplo n.º 4
0
        /// <summary>
        /// Adds the contents of the specified <paramref name="nameSpace"/> to the <paramref name="list"/>.
        /// </summary>
        public void AddNamespaceContents(ArrayList list, string nameSpace, LanguageProperties language, bool lookInReferences)
        {
            if (nameSpace == null)
            {
                return;
            }

            if (lookInReferences)
            {
                lock (_referencedContents)
                {
                    foreach (IProjectContent content in _referencedContents)
                    {
                        if (content != null)
                        {
                            content.AddNamespaceContents(list, nameSpace, language, false);
                        }
                    }
                }
            }

            Dictionary <string, NamespaceStruct> dict = GetNamespaces(language);

            if (dict.ContainsKey(nameSpace))
            {
                NamespaceStruct ns          = dict[nameSpace];
                int             newCapacity = list.Count + ns.Classes.Count + ns.SubNamespaces.Count;
                if (list.Capacity < newCapacity)
                {
                    list.Capacity = Math.Max(list.Count * 2, newCapacity);
                }
                foreach (IClass c in ns.Classes)
                {
                    if (c is GenericClassContainer)
                    {
                        foreach (IClass realClass in ((GenericClassContainer)c).RealClasses)
                        {
                            AddNamespaceContentsClass(list, realClass, language, lookInReferences);
                        }
                    }
                    else
                    {
                        AddNamespaceContentsClass(list, c, language, lookInReferences);
                    }
                }
                foreach (string subns in ns.SubNamespaces)
                {
                    if (!list.Contains(subns))
                    {
                        list.Add(subns);
                    }
                }
            }
        }
Exemplo n.º 5
0
        void CreateNamespace(string nSpace)
        {
            Dictionary <string, NamespaceStruct> dict = GetNamespaces(this.language);

            if (dict.ContainsKey(nSpace))
            {
                return;
            }
            NamespaceStruct namespaceStruct = new NamespaceStruct(nSpace);

            dict.Add(nSpace, namespaceStruct);
            // use the same namespaceStruct for all dictionaries
            foreach (Dictionary <string, NamespaceStruct> otherDict in namespaces)
            {
                if (otherDict == dict)
                {
                    continue;
                }
                NamespaceStruct existingNamespaceStruct;
                if (otherDict.TryGetValue(nSpace, out existingNamespaceStruct))
                {
                    otherDict[nSpace] = existingNamespaceStruct.MergeWith(namespaceStruct);
                }
                else
                {
                    otherDict.Add(nSpace, namespaceStruct);
                }
            }
            if (nSpace.Length == 0)
            {
                return;
            }
            // add to parent namespace
            int    pos = nSpace.LastIndexOf('.');
            string parent;
            string subNs;

            if (pos < 0)
            {
                parent = "";
                subNs  = nSpace;
            }
            else
            {
                parent = nSpace.Substring(0, pos);
                subNs  = nSpace.Substring(pos + 1);
            }
            CreateNamespace(parent);
            dict[parent].SubNamespaces.Add(subNs);
        }
Exemplo n.º 6
0
			public NamespaceStruct MergeWith(NamespaceStruct other)
			{
				NamespaceStruct newStruct = new NamespaceStruct(null);
				newStruct.Classes.AddRange(this.Classes);
				newStruct.Classes.AddRange(other.Classes);
				newStruct.SubNamespaces.AddRange(this.SubNamespaces);
				newStruct.SubNamespaces.AddRange(other.SubNamespaces);
				return newStruct;
			}
Exemplo n.º 7
0
		void AddNamespaceStructContents(List<ICompletionEntry> list, NamespaceStruct ns, LanguageProperties language, bool lookInReferences)
		{
			int newCapacity = list.Count + ns.Classes.Count + ns.SubNamespaces.Count;
			if (list.Capacity < newCapacity)
				list.Capacity = Math.Max(list.Count * 2, newCapacity);
			foreach (IClass c in ns.Classes) {
				if (c is GenericClassContainer) {
					foreach (IClass realClass in ((GenericClassContainer)c).RealClasses) {
						AddNamespaceContentsClass(list, realClass, language, lookInReferences);
					}
				} else {
					AddNamespaceContentsClass(list, c, language, lookInReferences);
				}
			}
			foreach (string subns in ns.SubNamespaces) {
				NamespaceEntry subnsEntry = new NamespaceEntry(subns);
				if (!list.Contains(subnsEntry))	// PERF
					list.Add(subnsEntry);
			}
		}
Exemplo n.º 8
0
		void CreateNamespace(string nSpace)
		{
			Dictionary<string, NamespaceStruct> dict = GetNamespaces(this.language);
			if (dict.ContainsKey(nSpace))
				return;
			NamespaceStruct namespaceStruct = new NamespaceStruct(nSpace);
			dict.Add(nSpace, namespaceStruct);
			// use the same namespaceStruct for all dictionaries
			foreach (Dictionary<string, NamespaceStruct> otherDict in namespaces) {
				if (otherDict == dict) continue;
				NamespaceStruct existingNamespaceStruct;
				if (otherDict.TryGetValue(nSpace, out existingNamespaceStruct))
					otherDict[nSpace] = existingNamespaceStruct.MergeWith(namespaceStruct);
				else
					otherDict.Add(nSpace, namespaceStruct);
			}
			if (nSpace.Length == 0)
				return;
			// add to parent namespace
			int pos = nSpace.LastIndexOf('.');
			string parent;
			string subNs;
			if (pos < 0) {
				parent = "";
				subNs = nSpace;
			} else {
				parent = nSpace.Substring(0, pos);
				subNs = nSpace.Substring(pos + 1);
			}
			CreateNamespace(parent);
			dict[parent].SubNamespaces.Add(subNs);
		}