public IReadOnlyCollection <RCompletion> GetEntries(RCompletionContext context)
        {
            List <RCompletion> completions   = new List <RCompletion>();
            ImageSource        functionGlyph = _glyphService.GetGlyphThreadSafe(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic);
            ImageSource        variableGlyph = _glyphService.GetGlyphThreadSafe(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic);

            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>();
            ImageSource functionGlyph = _glyphService.GetGlyphThreadSafe(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic);
            ImageSource variableGlyph = _glyphService.GetGlyphThreadSafe(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic);

            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>();
            ImageSource functionGlyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic);
            ImageSource constantGlyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupConstant, StandardGlyphItem.GlyphItemPublic);

            // 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) {
                        ImageSource glyph = function.ItemType == NamedItemType.Constant ? constantGlyph : functionGlyph;

                        var completion = new RCompletion(function.Name, CompletionUtilities.BacktickName(function.Name), function.Description, glyph);
                        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);

            string variableName = context.Session.TextView.GetVariableNameBeforeCaret();

            VariablesProvider.Initialize();
            int memberCount = VariablesProvider.GetMemberCount(variableName);
            IReadOnlyCollection <INamedItemInfo> members = VariablesProvider.GetMembers(variableName, 200);

            // Get list of functions in the package
            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);
                }
            }

            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);
            Selector selector = Selector.Dollar;

            string variableName = RCompletionContext.GetVariableName(context.Session.TextView, context.TextBuffer.CurrentSnapshot);
            if (variableName.IndexOfAny(new char[] { '$', '@' }) < 0) {
                variableName = string.Empty;
                selector = Selector.None;
            } else if (variableName.EndsWith("@", StringComparison.Ordinal)) {
                selector = Selector.At;
            }

            VariablesProvider.Initialize();
            int memberCount = VariablesProvider.GetMemberCount(variableName);
            IReadOnlyCollection<INamedItemInfo> members = VariablesProvider.GetMembers(variableName, 200);
            var filteredList = FilterList(members, selector);

            // Get list of functions in the package
            foreach (INamedItemInfo v in filteredList) {
                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);
                }
            }

            return completions;
        }
Exemplo n.º 6
0
        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>();

            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;
        }
Exemplo n.º 8
0
        public IReadOnlyCollection <RCompletion> GetEntries(RCompletionContext context)
        {
            List <RCompletion> completions   = new List <RCompletion>();
            ImageSource        functionGlyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic);
            ImageSource        constantGlyph = GlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupConstant, StandardGlyphItem.GlyphItemPublic);
            ImageSource        snippetGlyph  = GlyphService.GetGlyph(StandardGlyphGroup.GlyphCSharpExpansion, StandardGlyphItem.GlyphItemPublic);
            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 RCompletion(function.Name, CompletionUtilities.BacktickName(function.Name), function.Description, glyph);
                            completions.Add(completion);
                        }
                    }
                }
            }

            return(completions);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
            Selector           selector      = Selector.Dollar;

            string variableName = RCompletionContext.GetVariableName(context.Session.TextView, context.TextBuffer.CurrentSnapshot);

            if (variableName.IndexOfAny(new char[] { '$', '@' }) < 0)
            {
                variableName = string.Empty;
                selector     = Selector.None;
            }
            else if (variableName.EndsWith("@", StringComparison.Ordinal))
            {
                selector = Selector.At;
            }

            VariablesProvider.Initialize();
            int memberCount = VariablesProvider.GetMemberCount(variableName);
            IReadOnlyCollection <INamedItemInfo> members = VariablesProvider.GetMembers(variableName, 200);
            var filteredList = FilterList(members, selector);

            // Get list of functions in the package
            foreach (INamedItemInfo v in filteredList)
            {
                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);
                }
            }

            return(completions);
        }