Exemplo n.º 1
0
    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.
    }
Exemplo n.º 2
0
    protected override void OnSourceInitialized(EventArgs e)
    {
        _db = EdDatabases.OpenWinapi();
        if (!tName.Text.NE())
        {
            _TextChanged();
        }

        base.OnSourceInitialized(e);
    }
Exemplo n.º 3
0
 public _NetDocumentationProvider()
 {
     try {
         _db = EdDatabases.OpenDoc();                     //never mind: we don't dispose it on process exit
         if (_db.Get(out string s, "SELECT xml FROM doc WHERE name='.'"))
         {
             _refs = new HashSet <string>(s.Split('\n'));
         }
     }
     catch (SLException ex) { Debug_.Print(ex.Message); }
 }
Exemplo n.º 4
0
    public FormWinapi()
    {
        InitializeComponent();

        _db = EdDatabases.OpenWinapi();

        _eName.TextChanged += _eName_TextChanged;
        _bOK.Click         += (unu, sed) => {
            string s = _code.Text;
            if (!s.NE())
            {
                Clipboard.SetText(s);
            }
        };
    }
Exemplo n.º 5
0
 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}'"));
 }