public CompletionList GetCompletionList(DocumentState textDocument, Position position) { var document = textDocument.LintedDocument; var element = document.Find(position.Line + 1, position.Character); if (element == null || element.TypeCode != ElementType.Paragraph) { return(new CompletionList()); } if (element.Parent == null || element.Parent.TypeCode != ElementType.ListItem) { return(new CompletionList()); } var text = element.TextAreas[0]; if (text is InterpretedText interpreted) { if (interpreted.RoleName != "doc") { return(new CompletionList()); } } else if (!text.Content.Text.StartsWith(":doc:", StringComparison.Ordinal)) { return(new CompletionList()); } var Files = new Dictionary <string, string>(); foreach (string file in Directory.EnumerateFiles( _root, "*.rst", SearchOption.AllDirectories)) { Files.Add(GetPath(file), file); } foreach (string file in Directory.EnumerateFiles( _root, "*.rest", SearchOption.AllDirectories)) { Files.Add(GetPath(file), file); } return(new CompletionList(Files.Select(_ => new CompletionItem(_.Key, CompletionItemKind.Text, _.Value, null)), true)); }
public void Detach(DocumentState doc) { doc.DocumentChanged -= DocumentState_DocumentChanged; doc.DocumentLinted -= DocumentState_DocumentLinted; }
private void Attach(DocumentState doc) { doc.DocumentChanged += DocumentState_DocumentChanged; doc.DocumentLinted += DocumentState_DocumentLinted; }