public static CiWinapi AddWinapi(INamedTypeSymbol typeSym, List <CiComplItem> items, TextSpan span, int typenameStart, bool onlyTypes) { Debug.Assert(IsWinapiClassSymbol(typeSym)); //In 'new' context show only types, except interfaces. //Also should do the same in 'as' context, and partially in 'is' context. But Roslyn doesn't, so we too. var sql = "SELECT name, kind FROM api"; if (onlyTypes) { sql += " WHERE kind<=4"; //see CiItemKind } items.Capacity = items.Count + 60000; using var db = EdDatabases.OpenWinapi(); using var stat = db.Statement(sql); while (stat.Step()) { string name = stat.GetText(0); var kind = (CiItemKind)stat.GetInt(1); var ci = new CiComplItem(CiComplProvider.Winapi, span, name, kind /*, CiItemAccess.Internal*/); items.Add(ci); } return(new() { _typenameStart = typenameStart, _canInsert = typeSym.IsFromSource() }); //Now (May 2021) there are ~51000 items, and uses ~16 MB of memory while showing the popup list. // Without CompletionItem would be ~8 MB. But now it is used everywhere and need some work to remove. Never mind. }
protected override void OnSourceInitialized(EventArgs e) { _db = EdDatabases.OpenWinapi(); if (!tName.Text.NE()) { _TextChanged(); } base.OnSourceInitialized(e); }
public FormWinapi() { InitializeComponent(); _db = EdDatabases.OpenWinapi(); _eName.TextChanged += _eName_TextChanged; _bOK.Click += (unu, sed) => { string s = _code.Text; if (!s.NE()) { Clipboard.SetText(s); } }; }
static bool _GetText(CiComplItem item, out string text) { using var db = EdDatabases.OpenWinapi(); return(db.Get(out text, $"SELECT code FROM api WHERE name='{item.Text}'")); }