/// <summary> /// Gets the list of modules known by the current analysis. /// </summary> /// <param name="topLevelOnly">Only return top-level modules.</param> public MemberResult[] GetModules(bool topLevelOnly = false) { List <MemberResult> res = new List <MemberResult>(ProjectState.GetModules(topLevelOnly)); var children = GlobalScope.GetChildrenPackages(InterpreterContext); foreach (var child in children) { res.Add(new MemberResult(child.Key, PythonMemberType.Module)); } return(res.ToArray()); }
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()); }
/// <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()); }