Exemplo n.º 1
0
        // Completion
        public IEnumerable <Identifier> GetIdentifiers(int position)
        {
            var contextSpan = contextSpans.GetContextSpan(position);

            if (contextSpan != null)
            {
                if (contextSpan.Type == ContextType.Template)
                {
                    var contextIdentifiers = contextSpan.Context.Identifiers;
                    var customIdentifiers  = this.tempIdentifiers.GetTempIdentifiers(contextSpan.Context);
                    // Todo: Optimize performance
                    var extensionIdentifiers = shadowClass.Snippets.Where(s => s.Type == SnippetType.Using && s.Code.StartsWith("using"))
                                               .SelectMany(s => contextSpan.Context.GetExtensionIdentifiers(s.Code.Remove(0, 5).Trim().TrimEnd(';')));

                    return(contextIdentifiers.Concat(customIdentifiers).Concat(extensionIdentifiers).OrderBy(i => i.Name));
                }

                var identifiers = shadowClass.GetRecommendedSymbols(position).GroupBy(s => s.Name).Select(g => Identifier.FromSymbol(g.First())).ToList();

                // Add common keywords to the statement completion list. (Roslyn 1.1 might provide this funtionality)
                if (identifiers.Any(i => i.Name == "Boolean") && identifiers.Any(i => i.Name == "Class"))
                {
                    identifiers.AddRange(keywords);
                }

                return(identifiers.OrderBy(i => i.Name));
            }

            return(new Identifier[0]);
        }
Exemplo n.º 2
0
        // Completion
        public IEnumerable <Identifier> GetIdentifiers(int position)
        {
            var contextSpan = contextSpans.GetContextSpan(position);

            if (contextSpan != null)
            {
                if (contextSpan.Type == ContextType.Template)
                {
                    var contextIdentifiers = contextSpan.Context.Identifiers;
                    return(contextIdentifiers.Concat(this.tempIdentifiers.GetTempIdentifiers(contextSpan.Context)).OrderBy(i => i.Name));
                }

                var identifiers = shadowClass.GetRecommendedSymbols(position).GroupBy(s => s.Name).Select(g => Identifier.FromSymbol(g.First())).ToList();

                // Add common keywords to the statement completion list. (Roslyn 1.1 might provide this funtionality)
                if (identifiers.Any(i => i.Name == "Boolean") && identifiers.Any(i => i.Name == "Class"))
                {
                    identifiers.AddRange(keywords);
                }

                return(identifiers.OrderBy(i => i.Name));
            }

            return(new Identifier[0]);
        }