public override IEnumerable<SimpleDothtmlCompletion> GetItems(DothtmlCompletionContext context)
 {
     if (context.CurrentNode is DothtmlDirectiveNode)
     {
         var directiveName = ((DothtmlDirectiveNode)context.CurrentNode).Name;
         return GetItemsCore(context, directiveName);
     }
     return Enumerable.Empty<SimpleDothtmlCompletion>();
 }
Пример #2
0
        public CustomCommit(DothtmlCompletionContext context)
        {
            this.context = context;

            if (context.CompletionSession?.SelectedCompletionSet != null)
            {
                this.selectedCompletion = context.CompletionSession.SelectedCompletionSet.SelectionStatus.IsSelected
                    ? context.CompletionSession.SelectedCompletionSet.SelectionStatus.Completion
                    : context.CompletionSession.SelectedCompletionSet.Completions.FirstOrDefault();
            }
        }
Пример #3
0
        public static List <SyntaxTreeInfo> GetSyntaxTrees(DothtmlCompletionContext context)
        {
            var compilations = GetCompilations(context);

            var trees = compilations
                        .SelectMany(c => c.SyntaxTrees.Select(t => new SyntaxTreeInfo()
            {
                Tree = t, SemanticModel = c.GetSemanticModel(t), Compilation = c
            }))
                        .Where(t => t.Tree != null)
                        .ToList();

            return(trees);
        }
Пример #4
0
        public sealed override IEnumerable <SimpleDothtmlCompletion> GetItems(DothtmlCompletionContext context)
        {
            if (context.CurrentNode is DothtmlElementNode || context.CurrentNode is DothtmlAttributeNode)
            {
                var tagNameHierarchy = GetTagHierarchy(context);

                // if the tag has already some attributes, don't show them in the IntelliSense
                var tag = ((DothtmlElementNode)context.CurrentNode) ?? (DothtmlElementNode)context.CurrentNode.ParentNode;
                var existingAttributeNames = tag.Attributes.Select(a => a.AttributeName).ToList();

                return(GetItemsCore(context, tagNameHierarchy)
                       .Where(n => !existingAttributeNames.Contains(n.DisplayText)));
            }
            return(Enumerable.Empty <SimpleDothtmlCompletion>());
        }
Пример #5
0
        public sealed override IEnumerable <SimpleDothtmlCompletion> GetItems(DothtmlCompletionContext context)
        {
            if (context.CurrentNode is DothtmlElementNode)
            {
                var tagNameHierarchy = GetTagHierarchy(context);

                if (tagNameHierarchy.Any())
                {
                    tagNameHierarchy.RemoveAt(tagNameHierarchy.Count - 1);
                }

                return(GetItemsCore(context, tagNameHierarchy));
            }
            return(Enumerable.Empty <SimpleDothtmlCompletion>());
        }
Пример #6
0
        public static List <ITypeSymbol> GetReferencedSymbols(DothtmlCompletionContext context)
        {
            var compilations = GetCompilations(context);

            var symbols = compilations
                          .SelectMany(c => c.References.Select(r => new { Compilation = c, Reference = r }))
                          .SelectMany(r =>
            {
                var symbol = r.Compilation.GetAssemblyOrModuleSymbol(r.Reference);
                if (symbol is IModuleSymbol)
                {
                    return new[] { symbol }
                }
                .OfType <IModuleSymbol>();
                return(((IAssemblySymbol)symbol).Modules);
            })
Пример #7
0
        protected List <string> GetTagHierarchy(DothtmlCompletionContext context)
        {
            var hierarchy = new List <string>();

            var node = context.CurrentNode as DothtmlElementNode;

            if (node == null && context.CurrentNode is DothtmlAttributeNode)
            {
                node = context.CurrentNode.ParentNode as DothtmlElementNode;
            }

            while (node != null)
            {
                hierarchy.Add(node.FullTagName);
                node = node.ParentNode as DothtmlElementNode;
            }

            hierarchy.Reverse();
            return(hierarchy);
        }
        public sealed override IEnumerable <SimpleDothtmlCompletion> GetItems(DothtmlCompletionContext context)
        {
            if (context.CurrentNode is DothtmlAttributeNode)
            {
                var tagNameHierarchy = GetTagHierarchy(context);

                string attributeName = null;
                for (int i = context.CurrentTokenIndex - 1; i >= 0; i--)
                {
                    if (context.Tokens[i].Type == DothtmlTokenType.Text)
                    {
                        attributeName = context.Tokens[i].Text;
                        break;
                    }
                }
                if (attributeName != null)
                {
                    return(GetItemsCore(context, tagNameHierarchy, attributeName));
                }
            }
            return(Enumerable.Empty <SimpleDothtmlCompletion>());
        }
Пример #9
0
 protected abstract IEnumerable <SimpleDothtmlCompletion> GetItemsCore(DothtmlCompletionContext context, List <string> tagNameHierarchy);
Пример #10
0
 protected abstract void CommitCore(DothtmlCompletionContext context, Completion completion);
Пример #11
0
 public abstract IEnumerable <SimpleDothtmlCompletion> GetItems(DothtmlCompletionContext context);
 protected abstract IEnumerable<SimpleDothtmlCompletion> GetItemsCore(DothtmlCompletionContext context, string directiveName);