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>(); }
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(); } }
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); }
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>()); }
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>()); }
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); })
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>()); }
protected abstract IEnumerable <SimpleDothtmlCompletion> GetItemsCore(DothtmlCompletionContext context, List <string> tagNameHierarchy);
protected abstract void CommitCore(DothtmlCompletionContext context, Completion completion);
public abstract IEnumerable <SimpleDothtmlCompletion> GetItems(DothtmlCompletionContext context);
protected abstract IEnumerable<SimpleDothtmlCompletion> GetItemsCore(DothtmlCompletionContext context, string directiveName);