Beispiel #1
0
        public static void AddUsing(ArrayList result, IUsing u, IProjectContent projectContent)
        {
            if (u == null)
            {
                return;
            }
            bool importNamespaces = projectContent.Language.ImportNamespaces;
            bool importClasses    = projectContent.Language.CanImportClasses;

            foreach (string name in u.Usings)
            {
                if (importClasses)
                {
                    IClass c = projectContent.GetClass(name, 0);
                    if (c != null)
                    {
                        ArrayList   members = new ArrayList();
                        IReturnType t       = c.DefaultReturnType;
                        members.AddRange(t.GetMethods());
                        members.AddRange(t.GetFields());
                        members.AddRange(t.GetEvents());
                        members.AddRange(t.GetProperties());
                        foreach (IMember m in members)
                        {
                            if (m.IsStatic && m.IsPublic)
                            {
                                result.Add(m);
                            }
                        }
                        continue;
                    }
                }
                if (importNamespaces)
                {
                    string newName = null;
                    if (projectContent.DefaultImports != null)
                    {
                        newName = projectContent.DefaultImports.SearchNamespace(name);
                    }
                    projectContent.AddNamespaceContents(result, newName ?? name, projectContent.Language, true);
                }
                else
                {
                    foreach (object o in projectContent.GetNamespaceContents(name))
                    {
                        if (!(o is string))
                        {
                            result.Add(o);
                        }
                    }
                }
            }
            if (u.HasAliases)
            {
                foreach (string alias in u.Aliases.Keys)
                {
                    result.Add(alias);
                }
            }
        }
Beispiel #2
0
 static void AddNamespaceMembersInAssembly(IProjectContent projectContent, string xmlNamespace, ArrayList list)
 {
     foreach (IAttribute att in projectContent.GetAssemblyAttributes())
     {
         if (att.PositionalArguments.Count == 2 &&
             att.AttributeType.FullyQualifiedName == "System.Windows.Markup.XmlnsDefinitionAttribute")
         {
             string namespaceName = att.PositionalArguments[1] as string;
             if (xmlNamespace.Equals(att.PositionalArguments[0]) && namespaceName != null)
             {
                 projectContent.AddNamespaceContents(list, namespaceName, projectContent.Language, false);
             }
         }
     }
 }
        /// <summary>
        /// Adds contents of all assemblies referenced by <paramref name="cu" />'s project.
        /// Also adds contents of <paramref name="callingClass" />.
        /// </summary>
        public static void AddReferencedProjectsContents(List <ICompletionEntry> result, ICompilationUnit cu, IClass callingClass)
        {
            IProjectContent projectContent = cu.ProjectContent;

            projectContent.AddNamespaceContents(result, "", projectContent.Language, true);
            var allContents = projectContent.GetAllContents();

            result.Capacity = result.Count + allContents.Count;
            foreach (var entry in allContents.Where(e => !(e is NamespaceEntry)))
            {
                result.Add(entry);
            }
            AddUsing(result, projectContent.DefaultImports, projectContent);
            AddContentsFromCallingClass(result, projectContent, callingClass);
        }
        /// <summary>
        /// Adds contents of all namespaces that this <paramref name="callingClass" /> imports to the <paramref name="result" /> list.
        /// Also adds contents of <paramref name="callingClass" />.
        /// </summary>
        public static void AddImportedNamespaceContents(List <ICompletionEntry> result, ICompilationUnit cu, IClass callingClass)
        {
            IProjectContent projectContent = cu.ProjectContent;

            projectContent.AddNamespaceContents(result, "", projectContent.Language, true);
            IUsingScope scope = (callingClass != null) ? callingClass.UsingScope : cu.UsingScope;

            while (scope != null)
            {
                foreach (IUsing u in scope.Usings)
                {
                    AddUsing(result, u, projectContent);
                }
                scope = scope.Parent;
            }
            AddUsing(result, projectContent.DefaultImports, projectContent);
            AddContentsFromCallingClass(result, projectContent, callingClass);
        }
Beispiel #5
0
        public static void AddImportedNamespaceContents(ArrayList result, ICompilationUnit cu, IClass callingClass)
        {
            IProjectContent projectContent = cu.ProjectContent;

            projectContent.AddNamespaceContents(result, "", projectContent.Language, true);
            foreach (IUsing u in cu.Usings)
            {
                AddUsing(result, u, projectContent);
            }
            AddUsing(result, projectContent.DefaultImports, projectContent);

            if (callingClass != null)
            {
                string[] namespaceParts = callingClass.Namespace.Split('.');
                for (int i = 1; i <= namespaceParts.Length; i++)
                {
                    foreach (object member in projectContent.GetNamespaceContents(string.Join(".", namespaceParts, 0, i)))
                    {
                        if (!result.Contains(member))
                        {
                            result.Add(member);
                        }
                    }
                }
                IClass currentClass = callingClass;
                do
                {
                    foreach (IClass innerClass in currentClass.GetAccessibleTypes(currentClass))
                    {
                        if (!result.Contains(innerClass))
                        {
                            result.Add(innerClass);
                        }
                    }
                    currentClass = currentClass.DeclaringType;
                } while (currentClass != null);
            }
        }
		public static void AddUsing(List<ICompletionEntry> result, IUsing u, IProjectContent projectContent)
		{
			if (u == null) {
				return;
			}
			bool importNamespaces = projectContent.Language.ImportNamespaces;
			bool importClasses = projectContent.Language.CanImportClasses;
			foreach (string name in u.Usings) {
				if (importClasses) {
					IClass c = projectContent.GetClass(name, 0);
					if (c != null) {
						ArrayList members = new ArrayList();
						IReturnType t = c.DefaultReturnType;
						members.AddRange(t.GetMethods());
						members.AddRange(t.GetFields());
						members.AddRange(t.GetEvents());
						members.AddRange(t.GetProperties());
						foreach (IMember m in members) {
							if (m.IsStatic && m.IsPublic) {
								result.Add(m);
							}
						}
						continue;
					}
				}
				if (importNamespaces) {
					string newName = null;
					if (projectContent.DefaultImports != null) {
						newName = projectContent.DefaultImports.SearchNamespace(name);
					}
					projectContent.AddNamespaceContents(result, newName ?? name, projectContent.Language, true);
				} else {
					foreach (ICompletionEntry o in projectContent.GetNamespaceContents(name)) {
						if (!(o is NamespaceEntry))
							result.Add(o);
					}
				}
			}
			if (u.HasAliases) {
				foreach (string alias in u.Aliases.Keys) {
					result.Add(new AliasEntry(alias));
				}
			}
		}
		static void AddNamespaceMembersInAssembly(IProjectContent projectContent, string xmlNamespace, List<ICompletionEntry> list)
		{
			foreach (IAttribute att in projectContent.GetAssemblyAttributes()) {
				if (att.PositionalArguments.Count == 2
				    && att.AttributeType.FullyQualifiedName == "System.Windows.Markup.XmlnsDefinitionAttribute") {
					string namespaceName = att.PositionalArguments[1] as string;
					if (xmlNamespace.Equals(att.PositionalArguments[0]) && namespaceName != null) {
						projectContent.AddNamespaceContents(list, namespaceName, projectContent.Language, false);
					}
				}
			}
		}