Example #1
0
        public MemberResult[] GetModuleMembers(string[] names, bool includeMembers = false)
        {
            var res      = new List <MemberResult>(ProjectState.GetModuleMembers(names, includeMembers));
            var children = GlobalScope.GetChildrenPackages();

            foreach (var child in children)
            {
                var mod       = (ModuleInfo)child.Value;
                var childName = mod.Name.Substring(this.GlobalScope.Name.Length + 1);

                if (childName.StartsWith(names[0]))
                {
                    res.AddRange(JsAnalyzer.GetModuleMembers(names, includeMembers, mod as IModule));
                }
            }

            return(res.ToArray());
        }
Example #2
0
        /// <summary>
        /// Gets the list of modules and members matching the provided names.
        /// </summary>
        /// <param name="names">The dotted name parts to match</param>
        /// <param name="includeMembers">Include module members that match as
        /// well as just modules.</param>
        public MemberResult[] GetModuleMembers(string[] names, bool includeMembers = false)
        {
            var res      = new List <MemberResult>(ProjectState.GetModuleMembers(InterpreterContext, names, includeMembers));
            var children = GlobalScope.GetChildrenPackages(InterpreterContext);

            foreach (var child in children)
            {
                var mod = (ModuleInfo)child.Value;

                if (string.IsNullOrEmpty(mod.Name))
                {
                    // Module does not have an importable name
                    continue;
                }

                var childName = mod.Name.Split('.');
                if (childName.Length >= 2 && childName[0] == GlobalScope.Name && childName[1] == names[0])
                {
                    res.AddRange(PythonAnalyzer.GetModuleMembers(InterpreterContext, names, includeMembers, mod as IModule));
                }
            }

            return(res.ToArray());
        }