public IReadOnlyCollection <RCompletion> GetEntries(RCompletionContext context) { List <RCompletion> completions = new List <RCompletion>(); ImageSource functionGlyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic); ImageSource variableGlyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic); 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>(); ImageSource functionGlyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic); ImageSource variableGlyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic); var ast = context.AstRoot; var 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); }