示例#1
0
        /// <summary>
        /// Added interface
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void implementBrowse_Click(object sender, EventArgs e)
        {
            ClassBrowser browser = new ClassBrowser();
            MemberList   known   = null;

            browser.IncludeFlag = FlagType.Interface;
            IASContext context = ASContext.GetLanguageContext(PluginBase.CurrentProject.Language);

            try
            {
                known = context.GetAllProjectClasses();
                known.Merge(ASContext.Context.GetVisibleExternalElements(true));
            }
            catch (Exception error)
            {
                Debug.WriteLine(error.StackTrace);
            }

            browser.ClassList = known;

            if (browser.ShowDialog(this) == DialogResult.OK)
            {
                if (browser.SelectedClass != null)
                {
                    foreach (string item in this.implementList.Items)
                    {
                        if (item == browser.SelectedClass)
                        {
                            return;
                        }
                    }
                    this.implementList.Items.Add(browser.SelectedClass);
                }
            }
            this.implementRemove.Enabled     = this.implementList.Items.Count > 0;
            this.implementList.SelectedIndex = this.implementList.Items.Count - 1;
            this.superCheck.Enabled          = this.implementList.Items.Count > 0;
            ValidateClass();
        }
 /// <summary>
 /// Returns all members inherited from super classes of this class.
 /// Does not take static inheritance into account.
 /// </summary>
 internal MemberList GetSortedInheritedMembersList()
 {
     MemberList items = new MemberList();
     ClassModel curClass = this;
     do
     {
         curClass.ResolveExtends();
         curClass = curClass.Extends;
         MemberList newMembers = curClass.GetSortedMembersList();
         items.Merge(newMembers);
         
     } while (curClass.Extends != VoidClass);
     items.RemoveAllWithFlag(FlagType.Static);
     items.Sort();
     return items;
 }
示例#3
0
        /// <summary>
        /// Return the elements (package, types, etc) visible from the current file
        /// </summary>
        /// <param name="typesOnly">Return only packages & types</param>
        /// <returns></returns>
        public override MemberList GetVisibleExternalElements(bool typesOnly)
        {
            MemberList visibleElements = new MemberList();
            if (!IsFileValid) return visibleElements;

            // top-level elements
            if (!typesOnly && topLevel != null)
            {
                if (topLevel.OutOfDate) InitTopLevelElements();
                visibleElements.Add(topLevel.Members);
            }

            if (completionCache.IsDirty)
            {
                MemberList elements = new MemberList();
                // root types & packages
                FileModel baseElements = ResolvePackage(null, false);
                if (baseElements != null)
                {
                    elements.Add(baseElements.Imports);
                    elements.Add(baseElements.Members);
                }
                elements.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0));

                bool qualify = Settings.CompletionShowQualifiedTypes && settings.GenerateImports;

                // other classes in same package
                if (features.hasPackages && cFile.Package != "")
                {
                    FileModel packageElements = ResolvePackage(cFile.Package, false);
                    if (packageElements != null)
                    {
                        foreach (MemberModel member in packageElements.Imports)
                        {
                            if (member.Flags != FlagType.Package)
                            {
                                if (qualify) member.Name = member.Type;
                                elements.Add(member);
                            }
                        }
                        foreach (MemberModel member in packageElements.Members)
                        {
                            string pkg = member.InFile.Package;
                            if (qualify && pkg != "") member.Name = pkg + "." + member.Name;
                            elements.Add(member);
                        }
                    }
                }
                // other classes in same file
                if (cFile.PrivateSectionIndex > 0)
                {
                    if (inPrivateSection && cFile.Classes.Count > 1)
                    {
                        ClassModel mainClass = cFile.GetPublicClass();
                        if (!mainClass.IsVoid())
                        {
                            MemberModel toRemove = elements.Search(mainClass.Name, 0, 0);
                            if (toRemove != null && toRemove.Type == mainClass.QualifiedName)
                                elements.Remove(toRemove);
                        }
                    }

                    MemberModel member;
                    foreach (ClassModel aClass in cFile.Classes)
                    {
                        if (features.hasMultipleDefs || aClass.Access == Visibility.Private)
                        {
                            member = aClass.ToMemberModel();
                            elements.Add(member);
                        }
                    }
                }

                // imports
                elements.Add(ResolveImports(CurrentModel));

                // in cache
                elements.Sort();
                completionCache = new CompletionCache(this, elements);

                // known classes colorization
                if (!CommonSettings.DisableKnownTypesColoring && !settings.LazyClasspathExploration && CurSciControl != null)
                {
                    try
                    {
                        CurSciControl.KeyWords(1, completionCache.Keywords); // additional-keywords index = 1
                        CurSciControl.Colourise(0, -1); // re-colorize the editor
                    }
                    catch (AccessViolationException){} // catch memory errors
                }
            }
            visibleElements.Merge(completionCache.Elements);
            return visibleElements;
        }
示例#4
0
        /// <summary>
        /// Return the top-level elements (this, super) for the current file
        /// </summary>
        /// <returns></returns>
        public override MemberList GetTopLevelElements()
        {
            GetVisibleExternalElements(); // update cache if needed

            if (topLevel != null)
            {
                MemberList items = new MemberList();
                if (topLevel.OutOfDate) InitTopLevelElements();
                items.Merge(topLevel.Members);
                items.Merge(hxCompletionCache.OtherElements);
                return items;
            }
            else return hxCompletionCache.OtherElements;
        }
示例#5
0
        public override MemberList GetVisibleExternalElements(bool typesOnly)
        {
            MemberList visibleElements = new MemberList();
            if (!IsFileValid) return visibleElements;

            // top-level elements
            if (!typesOnly && topLevel != null)
            {
                if (topLevel.OutOfDate) InitTopLevelElements();
                visibleElements.Add(topLevel.Members);
            }

            if (completionCache.IsDirty || !typesOnly)
            {
                MemberList elements = new MemberList();
                // root types & packages
                FileModel baseElements = ResolvePackage(null, false);
                if (baseElements != null)
                {
                    elements.Add(baseElements.Imports);
                    foreach(MemberModel decl in baseElements.Members)
                        if ((decl.Flags & (FlagType.Class | FlagType.Enum | FlagType.TypeDef | FlagType.Abstract)) > 0)
                            elements.Add(decl);
                }
                elements.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0));

                bool qualify = Settings.CompletionShowQualifiedTypes && settings.GenerateImports;

                // other classes in same package
                if (features.hasPackages && cFile.Package != "")
                {
                    int pLen = cFile.Package.Length;
                    FileModel packageElements = ResolvePackage(cFile.Package, false);
                    if (packageElements != null)
                    {
                        foreach (MemberModel member in packageElements.Imports)
                        {
                            if (member.Flags != FlagType.Package && member.Type.LastIndexOf('.') == pLen)
                            {
                                if (qualify) member.Name = member.Type;
                                elements.Add(member);
                            }
                        }
                        foreach (MemberModel member in packageElements.Members)
                        {
                            string pkg = member.InFile.Package;
                            if (qualify && pkg != "") member.Name = pkg + "." + member.Name;
                            elements.Add(member);
                        }
                    }
                }
                // other types in same file
                if (cFile.Classes.Count > 1)
                {
                    ClassModel mainClass = cFile.GetPublicClass();
                    foreach (ClassModel aClass in cFile.Classes)
                    {
                        if (mainClass == aClass) continue;
                        elements.Add(aClass.ToMemberModel());
                        if (!typesOnly && aClass.IsEnum())
                            elements.Add(aClass.Members);
                    }
                }

                // imports
                MemberList imports = ResolveImports(CurrentModel);
                elements.Add(imports);
                if (!typesOnly)
                    foreach (MemberModel import in imports)
                    {
                        if (import is ClassModel)
                        {
                            ClassModel aClass = import as ClassModel;
                            if (aClass.IsEnum()) elements.Add(aClass.Members);
                        }
                    }
                elements.Sort();

                // in cache
                if (typesOnly)
                {
                    completionCache = new CompletionCache(this, elements);
                    // known classes colorization
                    if (!CommonSettings.DisableKnownTypesColoring && !settings.LazyClasspathExploration && CurSciControl != null)
                    {
                        try
                        {
                            CurSciControl.KeyWords(1, completionCache.Keywords); // additional-keywords index = 1
                            CurSciControl.Colourise(0, -1); // re-colorize the editor
                        }
                        catch (AccessViolationException) { } // catch memory errors
                    }
                }
                visibleElements.Merge(elements);
            }
            else
                visibleElements.Merge(completionCache.Elements);
            return visibleElements;
        }
示例#6
0
        public override MemberList GetVisibleExternalElements(bool typesOnly)
        {
            MemberList visibleElements = new MemberList();

            if (!IsFileValid)
            {
                return(visibleElements);
            }

            // top-level elements
            if (!typesOnly && topLevel != null)
            {
                if (topLevel.OutOfDate)
                {
                    InitTopLevelElements();
                }
                visibleElements.Add(topLevel.Members);
            }

            if (completionCache.IsDirty || !typesOnly)
            {
                MemberList elements = new MemberList();
                // root types & packages
                FileModel baseElements = ResolvePackage(null, false);
                if (baseElements != null)
                {
                    elements.Add(baseElements.Imports);
                    foreach (MemberModel decl in baseElements.Members)
                    {
                        if ((decl.Flags & (FlagType.Class | FlagType.Enum | FlagType.TypeDef)) > 0)
                        {
                            elements.Add(decl);
                        }
                    }
                }
                elements.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0));

                bool qualify = Settings.CompletionShowQualifiedTypes && settings.GenerateImports;

                // other classes in same package
                if (features.hasPackages && cFile.Package != "")
                {
                    FileModel packageElements = ResolvePackage(cFile.Package, false);
                    if (packageElements != null)
                    {
                        foreach (MemberModel member in packageElements.Imports)
                        {
                            if (member.Flags != FlagType.Package)
                            {
                                if (qualify)
                                {
                                    member.Name = member.Type;
                                }
                                elements.Add(member);
                            }
                        }
                        foreach (MemberModel member in packageElements.Members)
                        {
                            string pkg = member.InFile.Package;
                            if (qualify && pkg != "")
                            {
                                member.Name = pkg + "." + member.Name;
                            }
                            elements.Add(member);
                        }
                    }
                }
                // other types in same file
                if (cFile.Classes.Count > 1)
                {
                    ClassModel mainClass = cFile.GetPublicClass();
                    foreach (ClassModel aClass in cFile.Classes)
                    {
                        if (mainClass == aClass)
                        {
                            continue;
                        }
                        elements.Add(aClass.ToMemberModel());
                        if (!typesOnly && aClass.IsEnum())
                        {
                            elements.Add(aClass.Members);
                        }
                    }
                }

                // imports
                MemberList imports = ResolveImports(CurrentModel);
                elements.Add(imports);
                if (!typesOnly)
                {
                    foreach (ClassModel aClass in imports)
                    {
                        if (aClass.IsEnum())
                        {
                            elements.Add(aClass.Members);
                        }
                    }
                }

                // in cache
                if (typesOnly)
                {
                    elements.Sort();
                    completionCache = new CompletionCache(this, elements);
                    // known classes colorization
                    if (!CommonSettings.DisableKnownTypesColoring && !settings.LazyClasspathExploration && CurSciControl != null)
                    {
                        try
                        {
                            CurSciControl.KeyWords(1, completionCache.Keywords); // additional-keywords index = 1
                            CurSciControl.Colourise(0, -1);                      // re-colorize the editor
                        }
                        catch (AccessViolationException) { } // catch memory errors
                    }
                }
                visibleElements.Merge(elements);
            }
            else
            {
                visibleElements.Merge(completionCache.Elements);
            }
            return(visibleElements);
        }