Esempio n. 1
0
 public SimpleCompletionEntry(string text, ImageMoniker moniker, IIntellisenseSession session, int specificVersion)
     : this(text, null, WpfUtil.GetIconForImageMoniker(moniker, 16, 16), session)
 {
     _specificVersion = specificVersion;
 }
Esempio n. 2
0
 public SimpleCompletionEntry(string text, string description, ImageMoniker moniker, IIntellisenseSession session)
     : base(text, "\"" + text + "\"", description, WpfUtil.GetIconForImageMoniker(moniker, 16, 16), null, false, session as ICompletionSession)
 {
 }
        protected override IEnumerable <JSONCompletionEntry> GetEntries(JSONCompletionContext context)
        {
            var member = context.ContextItem.FindType <JSONMember>();
            var list   = new List <JSONCompletionEntry>();

            if (member == null || member.UnquotedNameText != "files")
            {
                return(list);
            }

            var parent = member.Parent as JSONObject;
            var name   = parent?.FindType <JSONMember>()?.UnquotedNameText;

            if (string.IsNullOrEmpty(name))
            {
                return(list);
            }

            var children = parent.BlockItemChildren?.OfType <JSONMember>();
            var version  = children?.SingleOrDefault(c => c.UnquotedNameText == "version");

            if (version == null)
            {
                return(list);
            }

            var package = VSPackage.Manager.Provider.GetInstallablePackageAsync(name, version.UnquotedValueText).Result;

            if (package == null)
            {
                return(list);
            }

            Telemetry.TrackEvent("Completion for files");

            JSONArray array = context.ContextItem.FindType <JSONArray>();

            if (array == null)
            {
                return(list);
            }

            HashSet <string> usedFiles = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (JSONArrayElement arrayElement in array.Elements)
            {
                JSONTokenItem token = arrayElement.Value as JSONTokenItem;

                if (token != null)
                {
                    usedFiles.Add(token.CanonicalizedText);
                }
            }

            FrameworkElement o = context.Session.Presenter as FrameworkElement;

            if (o != null)
            {
                o.SetBinding(ImageThemingUtilities.ImageBackgroundColorProperty, new Binding("Background")
                {
                    Source    = o,
                    Converter = new BrushToColorConverter()
                });
            }

            foreach (var file in package.AllFiles)
            {
                if (!usedFiles.Contains(file))
                {
                    bool        isThemeIcon;
                    ImageSource glyph = WpfUtil.GetIconForFile(o, file, out isThemeIcon);

                    list.Add(new SimpleCompletionEntry(file, glyph, context.Session));
                }
            }

            if (o != null)
            {
                BindingOperations.ClearBinding(o, ImageThemingUtilities.ImageBackgroundColorProperty);
            }

            return(list);
        }