Example #1
0
 void RegisterCompletionCollectionEvents(CompletionCollection collection)
 {
     UnregisterCompletionCollectionEvents();
     Debug.Assert(currentCompletionCollection == null);
     currentCompletionCollection          = collection;
     collection.CurrentCompletionChanged += CompletionCollection_CurrentCompletionChanged;
 }
Example #2
0
        ITrackingPoint GetTrackingPoint(CompletionCollection coll)
        {
            var trackingSpan = coll.ApplicableTo;
            var snapshot     = trackingSpan.TextBuffer.CurrentSnapshot;
            var point        = trackingSpan.GetStartPoint(snapshot);

            return(snapshot.CreateTrackingPoint(point.Position, PointTrackingMode.Negative));
        }
Example #3
0
 void UnregisterCompletionCollectionEvents()
 {
     if (currentCompletionCollection != null)
     {
         currentCompletionCollection.SelectionStatusChanged -= CompletionCollection_SelectionStatusChanged;
         currentCompletionCollection = null;
     }
 }
Example #4
0
 void UnregisterCompletionCollectionEvents()
 {
     if (currentCompletionCollection != null)
     {
         currentCompletionCollection.CurrentCompletionChanged -= CompletionCollection_CurrentCompletionChanged;
         currentCompletionCollection = null;
     }
 }
        ICompletionClassifier GetCompletionClassifier(CompletionCollection collection)
        {
            ICompletionClassifier completionClassifier;

            if (!toClassifier.TryGetValue(collection, out completionClassifier))
            {
                toClassifier.Add(collection, completionClassifier = completionClassifierAggregatorService.Create(collection));
            }
            return(completionClassifier);
        }
 public FilterMatchCompletionClassifier(IThemeClassificationTypes themeClassificationTypes, CompletionCollection completionCollection)
 {
     if (themeClassificationTypes == null)
     {
         throw new ArgumentNullException(nameof(themeClassificationTypes));
     }
     if (completionCollection == null)
     {
         throw new ArgumentNullException(nameof(completionCollection));
     }
     this.findMatchHighlightMarkerClassificationType = themeClassificationTypes.GetClassificationType(TextColor.FindMatchHighlightMarker);
     this.completionCollection = completionCollection;
 }
 public FilterMatchCompletionClassifier(IThemeClassificationTypeService themeClassificationTypeService, CompletionCollection completionCollection)
 {
     if (themeClassificationTypeService == null)
     {
         throw new ArgumentNullException(nameof(themeClassificationTypeService));
     }
     if (completionCollection == null)
     {
         throw new ArgumentNullException(nameof(completionCollection));
     }
     this.completionMatchHighlightClassificationType = themeClassificationTypeService.GetClassificationType(TextColor.CompletionMatchHighlight);
     this.completionCollection = completionCollection;
 }
        public FrameworkElement Create(CompletionCollection collection, Completion completion)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (completion == null)
            {
                throw new ArgumentNullException(nameof(completion));
            }
            Debug.Assert(collection.FilteredCollection.Contains(completion));

            var classifier = GetCompletionClassifier(collection);
            var inputText  = collection.ApplicableTo.GetText(collection.ApplicableTo.TextBuffer.CurrentSnapshot);
            var context    = new CompletionClassifierContext(collection, completion, completion.DisplayText, inputText);

            return(TextBlockFactory.Create(context.DisplayText, classificationFormatMap.DefaultTextProperties,
                                           classifier.GetTags(context).Select(a => new TextRunPropertiesAndSpan(a.Span, classificationFormatMap.GetTextProperties(a.ClassificationType))), TextBlockFactory.Flags.DisableSetTextBlockFontFamily | TextBlockFactory.Flags.DisableFontSize));
        }
Example #9
0
        public FrameworkElement Create(CompletionCollection collection, Completion completion)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            if (completion == null)
            {
                throw new ArgumentNullException(nameof(completion));
            }
            Debug.Assert(collection.FilteredCollection.Contains(completion));

            var classifier = GetCompletionClassifier(collection);
            var inputText  = collection.ApplicableTo.GetText(collection.ApplicableTo.TextBuffer.CurrentSnapshot);
            var context    = new CompletionClassifierContext(completion, inputText);
            var text       = completion.DisplayText;
            var textBlock  = new TextBlock();
            int textOffset = 0;

            foreach (var tag in classifier.GetTags(context))
            {
                if (textOffset < tag.Span.Start)
                {
                    textBlock.Inlines.Add(CreateRun(text.Substring(textOffset, tag.Span.Start - textOffset), null));
                }
                textBlock.Inlines.Add(CreateRun(text.Substring(tag.Span.Start, tag.Span.Length), tag.ClassificationType));
                textOffset = tag.Span.End;
            }
            if (textOffset < text.Length)
            {
                textBlock.Inlines.Add(CreateRun(text.Substring(textOffset), null));
            }

            var defProps = classificationFormatMap.DefaultTextProperties;

            if (!defProps.ForegroundBrushEmpty)
            {
                textBlock.Foreground = classificationFormatMap.DefaultTextProperties.ForegroundBrush;
            }

            return(textBlock);
        }
Example #10
0
        //-----------------------------

        private void parseGroup(XmlNodeList node, CompletionCollection group)
        {
            CompletionItem i;

            foreach (XmlElement e in node)
            {
                i              = new CompletionItem();
                i.Type         = getType(e.Name);
                i.Text         = e.GetAttribute(VAR_NAME);
                i.Description  = e.GetAttribute(VAR_DESCRIPTION);
                i.IsDeprecated = e.GetAttribute(VAR_DEPRECATED).Equals("true");
                i.Params       = e.GetAttribute(VAR_PARAMS);
                group.Add(i);
                //
                if (e.HasChildNodes)
                {
                    parseGroup(e.ChildNodes, i.Items);
                }
            }
        }
Example #11
0
        public void Start()
        {
            if (IsStarted)
            {
                throw new InvalidOperationException();
            }
            if (IsDismissed)
            {
                throw new InvalidOperationException();
            }
            IsStarted = true;
            this.completionSources = CreateCompletionSources();

            var list = new List <CompletionCollection>();

            foreach (var source in completionSources)
            {
                source.AugmentCompletionSession(this, list);
            }
            foreach (var cc in list)
            {
                completionSets.Add(cc);
            }

            if (completionSets.Count == 0)
            {
                Dismiss();
            }
            else
            {
                SelectedCompletionSet = completionSets[0];
                completionPresenter   = intellisensePresenterFactoryService.TryCreateIntellisensePresenter(this);
                if (completionPresenter == null)
                {
                    Dismiss();
                    return;
                }
                PresenterChanged?.Invoke(this, EventArgs.Empty);
                completionSessionCommandTargetFilter = new CompletionSessionCommandTargetFilter(this);
            }
        }
Example #12
0
        public void Start()
        {
            if (IsStarted)
            {
                throw new InvalidOperationException();
            }
            if (IsDismissed)
            {
                throw new InvalidOperationException();
            }
            IsStarted = true;
            this.completionSources = CreateCompletionSources();

            var list = new List <CompletionCollection>();

            foreach (var source in completionSources)
            {
                source.AugmentCompletionSession(this, list);
            }
            foreach (var cc in list)
            {
                completionCollections.Add(cc);
            }

            if (completionCollections.Count == 0)
            {
                Dismiss();
            }
            else
            {
                SelectedCompletionCollection = completionCollections[0];
                completionPresenter          = completionPresenterService.Create(this);
                Debug.Assert(completionPresenter != null);
                sessionCommandTargetFilter = new SessionCommandTargetFilter(this);
                textViewPopup = new TextViewPopup(TextView, GetTrackingPoint(SelectedCompletionCollection), completionPresenter);
                textViewPopup.Show();
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="collection">Collection</param>
 /// <param name="completion">Completion to classify</param>
 /// <param name="displayText">Text shown in the UI</param>
 /// <param name="inputText">Current user input text</param>
 public CompletionClassifierContext(CompletionCollection collection, Completion completion, string displayText, string inputText)
 {
     if (collection == null)
     {
         throw new ArgumentNullException(nameof(collection));
     }
     if (completion == null)
     {
         throw new ArgumentNullException(nameof(completion));
     }
     if (displayText == null)
     {
         throw new ArgumentNullException(nameof(displayText));
     }
     if (inputText == null)
     {
         throw new ArgumentNullException(nameof(inputText));
     }
     Collection  = collection;
     Completion  = completion;
     DisplayText = displayText;
     InputText   = inputText;
 }
        public ICompletionClassifier Create(CompletionCollection collection)
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }
            var contentType = collection.ApplicableTo.TextBuffer.ContentType;
            var classifiers = new List <ICompletionClassifier>();

            foreach (var lz in completionClassifierProviders)
            {
                if (!contentType.IsOfAnyType(lz.Metadata.ContentTypes))
                {
                    continue;
                }
                var classifier = lz.Value.Create(collection);
                if (classifier != null)
                {
                    classifiers.Add(classifier);
                }
            }
            return(new CompletionClassifierAggregator(textClassifierAggregatorService.Value, classifiers.ToArray()));
        }
Example #15
0
        public void Start()
        {
            if (IsStarted)
            {
                throw new InvalidOperationException();
            }
            if (IsDismissed)
            {
                throw new InvalidOperationException();
            }
            IsStarted = true;
            this.completionSources = CreateCompletionSources();

            var list = new List <CompletionCollection>();

            foreach (var source in completionSources)
            {
                source.AugmentCompletionSession(this, list);
            }
            foreach (var cc in list)
            {
                completionCollections.Add(cc);
            }

            if (completionCollections.Count == 0)
            {
                Dismiss();
            }
            else
            {
                SelectedCompletionCollection = completionCollections[0];
                completionPresenter          = completionPresenterProvider.Create(this);
                Debug.Assert(completionPresenter != null);
                PresenterChanged?.Invoke(this, EventArgs.Empty);
                completionSessionCommandTargetFilter = new CompletionSessionCommandTargetFilter(this);
            }
        }
Example #16
0
 public ICompletionClassifier Create(CompletionCollection collection) => new CompletionClassifier(themeClassificationTypes);
Example #17
0
 public ICompletionClassifier Create(CompletionCollection completionSet) => new CompletionClassifier(themeClassificationTypeService);
Example #18
0
 public CompletionDocument()
 {
     document = new XmlDocument();
     Items    = new CompletionCollection();
 }
 public ICompletionClassifier Create(CompletionCollection collection) => new FilterMatchCompletionClassifier(themeClassificationTypeService, collection);
Example #20
0
 public CompletionItem()
 {
     Items = new CompletionCollection();
 }