/// <summary> /// Gets the available names at the given location. This includes /// built-in variables, global variables, and locals. /// </summary> /// <param name="location"> /// The location in the file where the available members should be /// looked up. /// </param> /// <remarks>New in 2.2</remarks> public IEnumerable <MemberResult> GetAllAvailableMembers(SourceLocation location, GetMemberOptions options = GetMemberOptions.IntersectMultipleResults) { var result = new Dictionary <string, IEnumerable <AnalysisValue> >(); // collect builtins foreach (var variable in ProjectState.BuiltinModule.GetAllMembers(ProjectState._defaultContext)) { result[variable.Key] = new List <AnalysisValue>(variable.Value); } // collect variables from user defined scopes var scope = FindScope(location); foreach (var s in scope.EnumerateTowardsGlobal) { foreach (var kvp in s.GetAllMergedVariables()) { // deliberately overwrite variables from outer scopes result[kvp.Key] = new List <AnalysisValue>(kvp.Value.TypesNoCopy); } } var res = MemberDictToResultList(GetPrivatePrefix(scope), options, result); if (options.Keywords()) { res = GetKeywordMembers(options, scope).Union(res); } return(res); }
/// <summary> /// Gets the available names at the given location. This includes built-in variables, global variables, and locals. /// </summary> /// <param name="index">The 0-based absolute index into the file where the available mebmers should be looked up.</param> public IEnumerable <MemberResult> GetAllAvailableMembersByIndex(int index, GetMemberOptions options = GetMemberOptions.None) { var result = new Dictionary <string, List <AnalysisValue> >(); // collect variables from user defined scopes var scope = FindEnvironment(index); foreach (var s in scope.EnumerateTowardsGlobal) { foreach (var kvp in s.Variables) { result[kvp.Key] = new List <AnalysisValue>(kvp.Value.GetTypesNoCopy(_unit).Select(x => x.Value)); } } foreach (var kvp in this._unit.Analyzer._globalObject.GetAllMembers(_unit.ProjectEntry)) { List <AnalysisValue> values; if (!result.TryGetValue(kvp.Key, out values)) { result[kvp.Key] = new List <AnalysisValue>(kvp.Value.Select(x => x.Value)); } else { values.AddRange(kvp.Value.Select(x => x.Value)); } } var res = MemberDictToResultList(options, result); if (options.Keywords()) { res = GetKeywordMembers(options, scope).Union(res); } return(res); }
/// <summary> /// Gets the available names at the given location. This includes /// built-in variables, global variables, and locals. /// </summary> /// <param name="location"> /// The location in the file where the available members should be /// looked up. /// </param> /// <remarks>New in 2.2</remarks> public IEnumerable<MemberResult> GetAllAvailableMembers(SourceLocation location, GetMemberOptions options = GetMemberOptions.IntersectMultipleResults) { var result = new Dictionary<string, IEnumerable<AnalysisValue>>(); // collect builtins if (!options.HasFlag(GetMemberOptions.ExcludeBuiltins)) { foreach (var variable in ProjectState.BuiltinModule.GetAllMembers(ProjectState._defaultContext)) { result[variable.Key] = new List<AnalysisValue>(variable.Value); } } // collect variables from user defined scopes var scope = FindScope(location); foreach (var s in scope.EnumerateTowardsGlobal) { foreach (var kvp in s.GetAllMergedVariables()) { // deliberately overwrite variables from outer scopes result[kvp.Key] = new List<AnalysisValue>(kvp.Value.TypesNoCopy); } } var res = MemberDictToResultList(GetPrivatePrefix(scope), options, result); if (options.Keywords()) { res = GetKeywordMembers(options, scope).Union(res); } return res; }
/// <summary> /// Gets the available names at the given location. This includes built-in variables, global variables, and locals. /// </summary> /// <param name="index">The 0-based absolute index into the file where the available mebmers should be looked up.</param> public IEnumerable<MemberResult> GetAllAvailableMembersByIndex(int index, GetMemberOptions options = GetMemberOptions.None) { var result = new Dictionary<string, List<AnalysisValue>>(); // collect variables from user defined scopes var scope = FindEnvironment(index); foreach (var s in scope.EnumerateTowardsGlobal) { foreach (var kvp in s.Variables) { result[kvp.Key] = new List<AnalysisValue>(kvp.Value.GetTypesNoCopy(_unit).Select(x => x.Value)); } } foreach (var kvp in this._unit.Analyzer._globalObject.GetAllMembers(_unit.ProjectEntry)) { List<AnalysisValue> values; if (!result.TryGetValue(kvp.Key, out values)) { result[kvp.Key] = new List<AnalysisValue>(kvp.Value.Select(x => x.Value)); } else { values.AddRange(kvp.Value.Select(x => x.Value)); } } var res = MemberDictToResultList(options, result); if (options.Keywords()) { res = GetKeywordMembers(options, scope).Union(res); } return res; }
/// <summary> /// Gets the available names at the given location. This includes built-in variables, global variables, and locals. /// </summary> /// <param name="index">The 0-based absolute index into the file where the available mebmers should be looked up.</param> public IEnumerable<MemberResult> GetAllAvailableMembersByIndex(int index, GetMemberOptions options = GetMemberOptions.IntersectMultipleResults) { var result = new Dictionary<string, List<Namespace>>(); // collect builtins foreach (var variable in ProjectState.BuiltinModule.GetAllMembers(ProjectState._defaultContext)) { result[variable.Key] = new List<Namespace>(variable.Value); } // collect variables from user defined scopes var scope = FindScope(index); foreach (var s in scope.EnumerateTowardsGlobal) { foreach (var kvp in s.GetAllMergedVariables()) { result[kvp.Key] = new List<Namespace>(kvp.Value.TypesNoCopy); } } var res = MemberDictToResultList(GetPrivatePrefix(scope), options, result); if (options.Keywords()) { res = Enumerable.Concat(res, GetKeywordMembers(options, scope)); } return res; }