예제 #1
0
        /// <summary>
        /// Add tree nodes following the user defined members presentation
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="members"></param>
        static public void AddMembers(TreeNodeCollection tree, MemberList members)
        {
            TreeNodeCollection nodes      = tree;
            MemberTreeNode     node       = null;
            MemberModel        prevMember = null;
            int img;

            foreach (MemberModel member in members)
            {
                if ((member.Flags & FlagType.Constant) > 0)
                {
                    img = ((member.Access & Visibility.Private) > 0) ? ICON_PRIVATE_CONST :
                          ((member.Access & Visibility.Protected) > 0) ? ICON_PROTECTED_CONST : ICON_CONST;
                    node = new MemberTreeNode(member, img);
                    nodes.Add(node);
                }
                else if ((member.Flags & FlagType.Variable) > 0)
                {
                    img = ((member.Access & Visibility.Private) > 0) ? ICON_PRIVATE_VAR :
                          ((member.Access & Visibility.Protected) > 0) ? ICON_PROTECTED_VAR : ICON_VAR;
                    node = new MemberTreeNode(member, img);
                    nodes.Add(node);
                }
                else if ((member.Flags & (FlagType.Getter | FlagType.Setter)) > 0)
                {
                    if (prevMember != null && prevMember.Name == member.Name) // "collapse" properties
                    {
                        continue;
                    }
                    img = ((member.Access & Visibility.Private) > 0) ? ICON_PRIVATE_PROPERTY :
                          ((member.Access & Visibility.Protected) > 0) ? ICON_PROTECTED_PROPERTY : ICON_PROPERTY;
                    node = new MemberTreeNode(member, img);
                    nodes.Add(node);
                }
                else if ((member.Flags & FlagType.Function) > 0)
                {
                    img = ((member.Access & Visibility.Private) > 0) ? ICON_PRIVATE_FUNCTION :
                          ((member.Access & Visibility.Protected) > 0) ? ICON_PROTECTED_FUNCTION : ICON_FUNCTION;
                    node = new MemberTreeNode(member, img);
                    nodes.Add(node);
                }
                prevMember = member;
            }
        }
예제 #2
0
        public static List<MemberModel> getMatchedItems(MemberList source, string searchText, int limit)
        {
            int i = 0;
            List<MemberModel> matchedItems = new List<MemberModel>();
            char firstChar = searchText[0];
            Comparer searchMatch = char.IsUpper(firstChar) ? new Comparer(AdvancedSearchMatch) : new Comparer(SimpleSearchMatch);
            foreach (MemberModel item in source)
            {
                int index = item.Name.LastIndexOf('.');
                string name = item.Name.Substring(index + 1);

                if ((item.Flags & FlagType.Access) > 0 && searchMatch(name, searchText))
                {
                    matchedItems.Add(item);
                    if (limit > 0 && i++ > limit) break;
                }
            }
            return matchedItems;
        }
예제 #3
0
        private void AddMembersSorted(TreeNodeCollection tree, MemberList members)
        {
            if (settings.SortingMode == OutlineSorting.None)
            {
                AddMembers(tree, members);
            }
            else if (settings.SortingMode == OutlineSorting.SortedGroup)
            {
                AddMembersGrouped(tree, members);
            }
            else
            {
                IComparer <MemberModel> comparer = null;
                if (settings.SortingMode == OutlineSorting.Sorted)
                {
                    comparer = null;
                }
                else if (settings.SortingMode == OutlineSorting.SortedByKind)
                {
                    comparer = new ByKindMemberComparer();
                }
                else if (settings.SortingMode == OutlineSorting.SortedSmart)
                {
                    comparer = new SmartMemberComparer();
                }
                else if (settings.SortingMode == OutlineSorting.SortedGroup)
                {
                    comparer = new ByKindMemberComparer();
                }

                MemberList copy = new MemberList();
                copy.Add(members);
                copy.Sort(comparer);
                AddMembers(tree, copy);
            }
        }
예제 #4
0
		/// <summary>
		/// Merge selected items from the SORTED lists without duplicate values
		/// </summary>
		/// <param name="list">Items to merge</param>
		public void Merge(MemberList list, FlagType mask)
		{
			int index = 0;
			bool added;
			foreach (MemberModel m in list)
			if ((m.Flags & mask) == mask) 
			{
				added = false;
				while (index < items.Count)
				{
					if (m.CompareTo(items[index]) <= 0)
					{
						if (!m.Equals(items[index]))
							items.Insert(index, m);
						added = true;
						break;
					}
					index++;
				}
				if (!added) items.Add(m);
			}
		}
예제 #5
0
		/// <summary>
		/// Merge SORTED lists without duplicate values
		/// </summary>
		/// <param name="list">Items to merge</param>
		public void Merge(MemberList list)
		{
			Merge(list, 0);
		}
예제 #6
0
		/// <summary>
		/// Merge one item into the list
		/// </summary>
		/// <param name="item">Item to merge</param>
		public void Merge(MemberModel item)
		{
			MemberList list = new MemberList();
			list.Add(item);
			Merge(list, 0);
		}
예제 #7
0
		public MemberList MultipleSearch(string name, FlagType mask) {
			MemberList result = new MemberList();
			foreach (MemberModel m in items)
				if ((m.Name.Equals(name)) && ((m.Flags & mask) == mask)) result.Add(m);
			return result;
		}
예제 #8
0
 private void AddRegions(TreeNodeCollection tree, MemberList members)
 {
     foreach (MemberModel member in members)
     {
         MemberTreeNode node = new MemberTreeNode(member, ICON_PACKAGE);
         tree.Add(node);
     }
 }
예제 #9
0
        public static void AddMembersGrouped(TreeNodeCollection tree, MemberList members)
        {
            FlagType[] typePriority = new FlagType[] { FlagType.Constructor, FlagType.Function, FlagType.Getter | FlagType.Setter, FlagType.Variable, FlagType.Constant };
            Visibility[] visibilityPriority = new Visibility[] { Visibility.Internal, Visibility.Private, Visibility.Protected, Visibility.Public };
            Dictionary<FlagType, List<MemberModel>> typeGroups = new Dictionary<FlagType, List<MemberModel>>();

            FlagType type;
            List<MemberModel> groupList;
            MemberTreeNode node = null;
            foreach (MemberModel member in members)
            {
                if (node != null && node.Text == member.ToString())
                    continue;

                // member type
                if ((member.Flags & FlagType.Constant) > 0)
                    type = FlagType.Constant;
                else if ((member.Flags & FlagType.Variable) > 0)
                    type = FlagType.Variable;
                else if ((member.Flags & (FlagType.Getter | FlagType.Setter)) > 0)
                    type = (FlagType.Getter | FlagType.Setter);
                else if ((member.Flags & FlagType.Constructor) > 0)
                    type = FlagType.Constructor;
                else type = FlagType.Function;

                // group
                if (!typeGroups.ContainsKey(type))
                {
                    groupList = new List<MemberModel>();
                    typeGroups.Add(type, groupList);
                }
                else groupList = typeGroups[type];

                groupList.Add(member);
            }

            MemberModel prevMember = null;
            for (int i = 0; i < typePriority.Length; i++)
            {
                if (typeGroups.ContainsKey(typePriority[i]))
                {
                    groupList = typeGroups[typePriority[i]];
                    if (groupList.Count == 0)
                        continue;
                    groupList.Sort();

                    TreeNode groupNode = new TreeNode(typePriority[i].ToString(), ICON_FOLDER_CLOSED, ICON_FOLDER_OPEN);
                    int img;
                    node = null;
                    foreach (MemberModel member in groupList)
                    {
                        if (prevMember != null && prevMember.Name == member.Name)
                            continue;
                        img = GetIcon(member.Flags, member.Access);
                        node = new MemberTreeNode(member, img);
                        groupNode.Nodes.Add(node);
                    }
                    if (typePriority[i] != FlagType.Constructor) groupNode.Expand();
                    tree.Add(groupNode);
                }
            }
        }
예제 #10
0
		/// <summary>
		/// Add tree nodes following the user defined members presentation
		/// </summary>
		/// <param name="tree"></param>
		/// <param name="members"></param>
		private void AddMembers(TreeNodeCollection tree, MemberList members)
		{
			TreeNode node;
			//node = new TreeNode("Members", 1,1);
			//tree.Add(node);
			TreeNodeCollection nodes = tree; //node.Nodes;
			int img;					
			foreach(MemberModel member in members)
			if ((member.Flags & FlagType.Variable) > 0) 
			{
				img = ((member.Flags & FlagType.Private) > 0) ? 14 : 5;
				node = new TreeNode(member.ToString(),img,img);
				node.Tag = member.Name;
				nodes.Add(node);
			}
			else if ((member.Flags & FlagType.Function) > 0)
			{
				img = ((member.Flags & FlagType.Private) > 0) ? 12 : 3;
				node = new TreeNode(member.ToString(), img,img);
				node.Tag = member.Name;
				nodes.Add(node);
			}
			else if ((member.Flags & (FlagType.Getter|FlagType.Setter)) > 0)
			{
				img = ((member.Flags & FlagType.Private) > 0) ? 13 : 4;
				node = new TreeNode(member.ToString(), img,img);
				node.Tag = member.Name;
				nodes.Add(node);
			}
		}
예제 #11
0
 /// <summary>
 /// Merge SORTED lists without duplicate values
 /// </summary>
 /// <param name="list">Items to merge</param>
 public void Merge(MemberList list)
 {
     Merge(list, 0);
 }
예제 #12
0
 /// <summary>
 /// Add tree nodes following the user defined members presentation
 /// </summary>
 /// <param name="tree"></param>
 /// <param name="members"></param>
 static public void AddMembers(TreeNodeCollection tree, MemberList members)
 {
     TreeNodeCollection nodes = tree;
     MemberTreeNode node = null;
     MemberModel prevMember = null;
     int img;
     foreach (MemberModel member in members)
     {
         if ((member.Flags & FlagType.Constant) > 0)
         {
             img = ((member.Access & Visibility.Private) > 0) ? ICON_PRIVATE_CONST :
                 ((member.Access & Visibility.Protected) > 0) ? ICON_PROTECTED_CONST : ICON_CONST;
             node = new MemberTreeNode(member, img);
             nodes.Add(node);
         }
         else if ((member.Flags & FlagType.Variable) > 0)
         {
             img = ((member.Access & Visibility.Private) > 0) ? ICON_PRIVATE_VAR :
                 ((member.Access & Visibility.Protected) > 0) ? ICON_PROTECTED_VAR : ICON_VAR;
             node = new MemberTreeNode(member, img);
             nodes.Add(node);
         }
         else if ((member.Flags & (FlagType.Getter | FlagType.Setter)) > 0)
         {
             if (prevMember != null && prevMember.Name == member.Name) // "collapse" properties
                 continue;
             img = ((member.Access & Visibility.Private) > 0) ? ICON_PRIVATE_PROPERTY :
                 ((member.Access & Visibility.Protected) > 0) ? ICON_PROTECTED_PROPERTY : ICON_PROPERTY;
             node = new MemberTreeNode(member, img);
             nodes.Add(node);
         }
         else if ((member.Flags & FlagType.Function) > 0)
         {
             img = ((member.Access & Visibility.Private) > 0) ? ICON_PRIVATE_FUNCTION :
                 ((member.Access & Visibility.Protected) > 0) ? ICON_PROTECTED_FUNCTION : ICON_FUNCTION;
             node = new MemberTreeNode(member, img);
             nodes.Add(node);
         }
         prevMember = member;
     }
 }
        static private void CompleteTemplate(string Context)
        {
            // get indentation
            ScintillaNet.ScintillaControl Sci = ASContext.MainForm.CurSciControl;
            if (Sci == null)
            {
                return;
            }
            int    position = Sci.CurrentPos;
            int    line     = Sci.LineFromPosition(position);
            int    indent   = Sci.LineIndentPosition(line) - Sci.PositionFromLine(line);
            string tab      = Sci.GetLine(line).Substring(0, indent);
            // get EOL
            int    eolMode = Sci.EOLMode;
            string newline;

            if (eolMode == 0)
            {
                newline = "\r\n";
            }
            else if (eolMode == 1)
            {
                newline = "\r";
            }
            else
            {
                newline = "\n";
            }

            // empty box
            if (Context == null)
            {
                Sci.ReplaceSel(newline + tab + "* " + newline + tab + "*/");
                position += newline.Length + tab.Length + 2;
                Sci.SetSel(position, position);
            }

            // method details
            else
            {
                string box  = newline + tab + "* ";
                Match  mFun = ASFileParser.re_splitFunction.Match(Context);
                if (mFun.Success)
                {
                    // parameters
                    MemberList list = ASComplete.ParseMethodParameters(mFun.Groups["params"].Value);
                    foreach (MemberModel param in list)
                    {
                        box += newline + tab + "* @param\t" + param.Name;
                    }
                    // return type
                    Match mType = ASFileParser.re_variableType.Match(mFun.Groups["type"].Value);
                    if (mType.Success && (mType.Groups["type"].Value != "Void"))
                    {
                        box += newline + tab + "* @return";                     //+mType.Groups["type"].Value;
                    }
                }
                box += newline + tab + "*/";
                Sci.ReplaceSel(box);
                position += newline.Length + tab.Length + 2;
                Sci.SetSel(position, position);
            }
        }
예제 #14
0
        static public void AddMembersGrouped(TreeNodeCollection tree, MemberList members)
        {
            FlagType[]   typePriority       = new FlagType[] { FlagType.Constructor, FlagType.Function, FlagType.Getter | FlagType.Setter, FlagType.Variable, FlagType.Constant };
            Visibility[] visibilityPriority = new Visibility[] { Visibility.Internal, Visibility.Private, Visibility.Protected, Visibility.Public };
            Dictionary <FlagType, List <MemberModel> > typeGroups = new Dictionary <FlagType, List <MemberModel> >();

            FlagType           type;
            List <MemberModel> groupList;
            MemberTreeNode     node = null;

            foreach (MemberModel member in members)
            {
                if (node != null && node.Text == member.ToString())
                {
                    continue;
                }

                // member type
                if ((member.Flags & FlagType.Constant) > 0)
                {
                    type = FlagType.Constant;
                }
                else if ((member.Flags & FlagType.Variable) > 0)
                {
                    type = FlagType.Variable;
                }
                else if ((member.Flags & (FlagType.Getter | FlagType.Setter)) > 0)
                {
                    type = (FlagType.Getter | FlagType.Setter);
                }
                else if ((member.Flags & FlagType.Constructor) > 0)
                {
                    type = FlagType.Constructor;
                }
                else
                {
                    type = FlagType.Function;
                }

                // group
                if (!typeGroups.ContainsKey(type))
                {
                    groupList = new List <MemberModel>();
                    typeGroups.Add(type, groupList);
                }
                else
                {
                    groupList = typeGroups[type];
                }

                groupList.Add(member);
            }

            MemberModel prevMember = null;

            for (int i = 0; i < typePriority.Length; i++)
            {
                if (typeGroups.ContainsKey(typePriority[i]))
                {
                    groupList = typeGroups[typePriority[i]];
                    if (groupList.Count == 0)
                    {
                        continue;
                    }
                    groupList.Sort();

                    TreeNode groupNode = new TreeNode(typePriority[i].ToString(), ICON_FOLDER_CLOSED, ICON_FOLDER_OPEN);
                    int      img;
                    node = null;
                    foreach (MemberModel member in groupList)
                    {
                        if (prevMember != null && prevMember.Name == member.Name)
                        {
                            continue;
                        }
                        img  = GetMemberIcon(member.Flags, member.Access);
                        node = new MemberTreeNode(member, img);
                        groupNode.Nodes.Add(node);
                    }
                    if (typePriority[i] != FlagType.Constructor)
                    {
                        groupNode.Expand();
                    }
                    tree.Add(groupNode);
                }
            }
        }
예제 #15
0
 private MemberList SelectMembers(MemberList list, FlagType mask)
 {
     MemberList filtered = new MemberList();
     Visibility acc = Visibility.Public | Visibility.Internal;
     //MemberModel lastAdded = null;
     foreach (MemberModel item in list)
         if ((item.Access & acc) > 0 && (item.Flags & mask) > 0)
         {
             //if (lastAdded != null && lastAdded.Name == item.Name) continue;
             //lastAdded = item;
             filtered.Add(item);
         }
     filtered.Sort();
     return filtered;
 }
예제 #16
0
 /// <summary>
 /// Add tree nodes following the user defined members presentation
 /// </summary>
 /// <param name="tree"></param>
 /// <param name="members"></param>
 public static void AddMembers(TreeNodeCollection tree, MemberList members)
 {
     TreeNodeCollection nodes = tree;
     MemberTreeNode node = null;
     MemberModel prevMember = null;
     int img;
     foreach (MemberModel member in members)
     {
         img = GetIcon(member.Flags, member.Access);
         node = new MemberTreeNode(member, img);
         nodes.Add(node);
         prevMember = member;
     }
 }
예제 #17
0
        static public void AddMembersGrouped(TreeNodeCollection tree, MemberList members)
        {
            FlagType[] typePriority = new FlagType[] { FlagType.Constructor, FlagType.Function, FlagType.Getter | FlagType.Setter, FlagType.Variable, FlagType.Constant };
            Dictionary<FlagType, List<MemberModel>> typeGroups = new Dictionary<FlagType, List<MemberModel>>();

            FlagType type;
            List<MemberModel> groupList;
            MemberTreeNode node = null;
            foreach (MemberModel member in members)
            {
                // member type
                if ((member.Flags & FlagType.Constant) > 0)
                    type = FlagType.Constant;
                else if ((member.Flags & FlagType.Variable) > 0)
                    type = FlagType.Variable;
                else if ((member.Flags & (FlagType.Getter | FlagType.Setter)) > 0)
                    type = (FlagType.Getter | FlagType.Setter);
                else if ((member.Flags & FlagType.Constructor) > 0)
                    type = FlagType.Constructor;
                else type = FlagType.Function;

                // group
                if (!typeGroups.TryGetValue(type, out groupList))
                {
                    groupList = new List<MemberModel>();
                    typeGroups.Add(type, groupList);
                }

                groupList.Add(member);
            }

            for (int i = 0, count = typePriority.Length; i < count; i++)
            {
                type = typePriority[i];
                if (typeGroups.TryGetValue(type, out groupList))
                {
                    if (groupList.Count == 0)
                        continue;
                    groupList.Sort();

                    TreeNode groupNode = new TreeNode(type.ToString(), ICON_FOLDER_CLOSED, ICON_FOLDER_OPEN);
                    int img;
                    foreach (MemberModel member in groupList)
                    {
                        img = GetIcon(member.Flags, member.Access);
                        node = new MemberTreeNode(member, img);
                        groupNode.Nodes.Add(node);
                    }
                    if (type != FlagType.Constructor) groupNode.Expand();
                    tree.Add(groupNode);
                }
            }
        }
예제 #18
0
        private void AddMembersSorted(TreeNodeCollection tree, MemberList members)
        {
            if (settings.SortingMode == OutlineSorting.None)
            {
                AddMembers(tree, members);
            }
            else if (settings.SortingMode == OutlineSorting.SortedGroup)
            {
                AddMembersGrouped(tree, members);
            }
            else
            {
                IComparer<MemberModel> comparer = null;
                if (settings.SortingMode == OutlineSorting.Sorted)
                    comparer = null;
                else if (settings.SortingMode == OutlineSorting.SortedByKind)
                    comparer = new ByKindMemberComparer();
                else if (settings.SortingMode == OutlineSorting.SortedSmart)
                    comparer = new SmartMemberComparer();
                else if (settings.SortingMode == OutlineSorting.SortedGroup)
                    comparer = new ByKindMemberComparer();

                MemberList copy = new MemberList();
                copy.Add(members);
                copy.Sort(comparer);
                AddMembers(tree, copy);
            }
        }
예제 #19
0
		private void init(string fileName)
		{
			FileName = fileName;
			Package = "";
			haXe = fileName.EndsWith(".hx");
			//
			Namespaces = new ArrayList();
			Namespaces.Add("public");
			Namespaces.Add("private");
			//
			Imports = new MemberList();
			if (haXe) Enums = new ArrayList();
			Classes = new ArrayList();
			Members = new MemberList();
		}
예제 #20
0
        private void AddRegionsExtended(TreeNodeCollection tree, FileModel aFile)
        {
            int endRegion = 0;
            int index = 0;
            MemberModel region = null;
            MemberList regions = aFile.Regions;
            int count = regions.Count;
            for (index = 0; index < count; ++index)
            {
                region = regions[index];
                MemberTreeNode node = new MemberTreeNode(region, ICON_PACKAGE);
                tree.Add(node);

                endRegion = (index + 1 < count) ? regions[index + 1].LineFrom : int.MaxValue;

                MemberList regionMembers = new MemberList();
                foreach (MemberModel import in aFile.Imports)
                {
                    if (import.LineFrom >= region.LineFrom &&
                        import.LineTo <= endRegion)
                    {
                        regionMembers.Add(import);
                    }
                }

                foreach (MemberModel fileMember in aFile.Members)
                {
                    if (fileMember.LineFrom >= region.LineFrom &&
                        fileMember.LineTo <= endRegion)
                    {
                        regionMembers.Add(fileMember);
                    }
                }

                foreach (ClassModel cls in aFile.Classes)
                {
                    if (cls.LineFrom <= region.LineFrom)
                    {
                        foreach (MemberModel clsMember in cls.Members)
                        {
                            if (clsMember.LineFrom >= region.LineFrom &&
                                clsMember.LineTo <= endRegion)
                            {
                                regionMembers.Add(clsMember);
                            }
                        }
                    }
                    else if (cls.LineFrom >= region.LineFrom &&
                             cls.LineTo <= endRegion)
                    {
                        regionMembers.Add(cls);
                    }
                }
                AddMembers(node.Nodes, regionMembers);
            }
        }
예제 #21
0
		public ClassModel() 
		{
			ClassName = null;
			Members = new MemberList();
			//Methods = new MemberList();
			//Vars = new MemberList();
			//Properties = new MemberList();
		}