Ejemplo n.º 1
0
        public override IList <HtmlCompletion> GetEntries(HtmlCompletionContext context)
        {
            var session = context.Session;
            var cache   = ComponentsCache.GetCache();
            var list    = new List <HtmlCompletion>(cache.Count);

            foreach (var data in cache.Values)
            {
                list.Add(CreateItem(data.Name, data.Description, session));
            }

            return(list);
        }
Ejemplo n.º 2
0
        public override IList <HtmlCompletion> GetEntries(HtmlCompletionContext context)
        {
            var           session     = context.Session;
            var           elementName = context.Element.Name;
            var           cache       = ComponentsCache.GetCache();
            ComponentData component   = null;

            cache.TryGetValue(elementName, out component);
            if (component == null)
            {
                return(new List <HtmlCompletion>(0));
            }

            var prefixStart = context.Position > 10 ? context.Position - 10 : 0;
            // using text before cursor for different suggestions lists for better UX
            var cursorPrefix = context.Document.TextBuffer.CurrentSnapshot
                               .GetText(prefixStart, context.Position - prefixStart);

            //ProjectHelpers.Log("cursorPrefix = " + cursorPrefix);

            var list = new List <HtmlCompletion>();

            if (cursorPrefix.EndsWith("v-on:"))             // events only and no prefix
            {
                AddEventsToList(list, session, component, false);
            }
            else if (cursorPrefix.EndsWith("v-bind:"))             // props only and no prefix
            {
                AddPropsToList(list, session, component, false);
            }
            else
            {
                AddEventsToList(list, session, component, _addPrefixedEvents);
                AddPropsToList(list, session, component, _addPrefixedProps);
            }

            return(list);
        }