public IReadOnlyCollection <RCompletion> GetEntries(RCompletionContext context) { List <RCompletion> completions = new List <RCompletion>(); var start = DateTime.Now; _variablesProvider.Initialize(); var names = GetFieldProvidingVariableNames(context); foreach (var variableName in names) { int memberCount = _variablesProvider.GetMemberCount(variableName); IReadOnlyCollection <INamedItemInfo> members = _variablesProvider.GetMembers(variableName, 200); foreach (var v in members) { Debug.Assert(v != null); if (v.Name.Length > 0 && v.Name[0] != '[') { ImageSource glyph = v.ItemType == NamedItemType.Variable ? _variableGlyph : _functionGlyph; var completion = new RCompletion(v.Name, CompletionUtilities.BacktickName(v.Name), v.Description, glyph); completions.Add(completion); } } } Debug.WriteLine("Variable members fetch: " + (DateTime.Now - start).TotalMilliseconds); return(completions); }
public IReadOnlyCollection <RCompletion> GetEntries(RCompletionContext context) { List <RCompletion> completions = new List <RCompletion>(); var ast = context.AstRoot; // First try simple scope like in 'for(x in 1:10) x|' IScope scope = ast.GetNodeOfTypeFromPosition <SimpleScope>(context.Position, includeEnd: true); // If not found, look for the regular scope scope = scope ?? ast.GetNodeOfTypeFromPosition <IScope>(context.Position); var variables = scope.GetApplicableVariables(context.Position); foreach (var v in variables) { RCompletion completion; RFunction f = v.Value as RFunction; completion = new RCompletion(v.Name, CompletionUtilities.BacktickName(v.Name), string.Empty, f != null ? _functionGlyph : _variableGlyph); completions.Add(completion); } return(completions); }
public IReadOnlyCollection <RCompletion> GetEntries(RCompletionContext context) { List <RCompletion> completions = new List <RCompletion>(); var infoSource = _snippetInformationSource?.InformationSource; // TODO: this is different in the console window where // packages may have been loaded from the command line. // We need an extensibility point here. IEnumerable <IPackageInfo> packages = GetPackages(context); // Get list of functions in the package foreach (IPackageInfo pkg in packages) { Debug.Assert(pkg != null); IEnumerable <INamedItemInfo> functions = pkg.Functions; if (functions != null) { foreach (INamedItemInfo function in functions) { bool isSnippet = false; // Snippets are suppressed if user typed namespace if (!context.IsInNameSpace() && infoSource != null) { isSnippet = infoSource.IsSnippet(function.Name); } if (!isSnippet) { ImageSource glyph = function.ItemType == NamedItemType.Constant ? _constantGlyph : _functionGlyph; var completion = new RFunctionCompletion(function.Name, CompletionUtilities.BacktickName(function.Name), function.Description, glyph, _functionIndex, context.Session); completions.Add(completion); } } } } return(completions); }