public UpperCaseSuggestedAction(ITrackingSpan span)
 {
     _mSpan     = span;
     _mSnapshot = span.TextBuffer.CurrentSnapshot;
     _mUpper    = span.GetText(_mSnapshot).ToUpper();
     _mDisplay  = $"Convert '{span.GetText(_mSnapshot)}' to upper case";
 }
Пример #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public HugSuggestedAction(ITrackingSpan trackingSpan, HugTags.Item item)
        {
            Item         = item;
            TrackingSpan = trackingSpan;
            Snapshot     = TrackingSpan.TextBuffer.CurrentSnapshot;
            Tagged       = Item.Left + TrackingSpan.GetText(Snapshot) + Item.Right;

            if (Tagged.Length < MenuItemLength)
            {
                DisplayText = string.Format("Hug as {0}", Tagged);
            }
            else
            {
                if (Item.Left.Length + Item.Right.Length >= MenuItemLength)
                {
                    // The tags alone are too large, so try to fit an ellipsis
                    DisplayText = string.Format("Hug as {0}", Item.Left + "…" + Item.Right);
                }
                else
                {
                    var text      = TrackingSpan.GetText(Snapshot).Trim('.');
                    var shortened = Item.Left + text + Item.Right;

                    if (shortened.Length > MenuItemLength)
                    {
                        shortened = Item.Left
                                    + text.Substring(0, text.Length - (shortened.Length - MenuItemLength))
                                    + "…"
                                    + Item.Right;
                    }

                    DisplayText = string.Format("Hug as {0}", shortened);
                }
            }
        }
Пример #3
0
 public LowerCaseSuggestedAction(ITrackingSpan span)
 {
     m_span     = span;
     m_snapshot = span.TextBuffer.CurrentSnapshot;
     m_lower    = span.GetText(m_snapshot).ToLower();
     m_display  = string.Format("Convert '{0}' to upper case", span.GetText(m_snapshot));
 }
 public UpperCaseSuggestedAction(ITrackingSpan span)
 {
     _span = span;
     _snapshot = span.TextBuffer.CurrentSnapshot;
     _upper = span.GetText(_snapshot).ToUpper();
     _display = string.Format("Convert '{0}' to upper case", span.GetText(_snapshot));
 }
 public UE4SpecifierCollisitionSuggestedAction(ITrackingSpan span, UE4MacroStatement ue4Statement)
 {
     _span         = span;
     _ue4Statement = ue4Statement;
     _snapshot     = span.TextBuffer.CurrentSnapshot;
     _lower        = span.GetText(_snapshot).ToLower();
     DisplayText   = $"Convert '{span.GetText(_snapshot)}' to lower case";
 }
 public UpperCaseSmartTagAction(ITrackingSpan span)
 {
     this.span = span;
     snapshot = span.TextBuffer.CurrentSnapshot;
     upper = span.GetText(snapshot).ToUpper();
     display = "Convert to upper case";
 }
 public ImplementInterfaceSuggestedAction(ITrackingSpan span, ITextView textView)
 {
     m_span     = span;
     m_snapshot = span.TextBuffer.CurrentSnapshot;
     m_display  = string.Format("Implement Interfaces", span.GetText(m_snapshot));
     m_textView = textView;
 }
        public string GetInsertionText(CssTextSource textSource, ITrackingSpan typingSpan)
        {
            string text = DisplayText;
            bool needsQuote = text.IndexOf(' ') != -1;
            if (text == "Pick from file...")
            {
                return string.Empty;
            }

            if (needsQuote)
            {
                // Prefer to use single quotes, but if the inline style uses single quotes, then use double quotes.
                char quote = (textSource == CssTextSource.InlineStyleSingleQuote) ? '"' : '\'';

                if (typingSpan != null)
                {
                    // If the user already typed a quote, then use it

                    string typingText = typingSpan.GetText(typingSpan.TextBuffer.CurrentSnapshot);

                    if (!string.IsNullOrEmpty(typingText) && (typingText[0] == '"' || typingText[0] == '\''))
                    {
                        quote = typingText[0];
                    }
                }

                if (text != null && text.IndexOf(quote) == -1)
                {
                    text = quote.ToString() + text + quote.ToString();
                }
            }

            return text;
        }
        public string GetInsertionText(CssTextSource textSource, ITrackingSpan typingSpan)
        {
            string text       = DisplayText;
            bool   needsQuote = text.IndexOf(' ') != -1;

            if (text == "Pick from file...")
            {
                return(string.Empty);
            }

            if (needsQuote)
            {
                // Prefer to use single quotes, but if the inline style uses single quotes, then use double quotes.
                char quote = (textSource == CssTextSource.InlineStyleSingleQuote) ? '"' : '\'';

                if (typingSpan != null)
                {
                    // If the user already typed a quote, then use it

                    string typingText = typingSpan.GetText(typingSpan.TextBuffer.CurrentSnapshot);

                    if (!string.IsNullOrEmpty(typingText) && (typingText[0] == '"' || typingText[0] == '\''))
                    {
                        quote = typingText[0];
                    }
                }

                if (text != null && text.IndexOf(quote) == -1)
                {
                    text = quote.ToString() + text + quote.ToString();
                }
            }

            return(text);
        }
 public UE4SpecifierNotValidSuggestedAction(ITrackingSpan span, UE4MacroStatement ue4Statement)
 {
     _span         = span;
     _ue4Statement = ue4Statement;
     _snapshot     = span.TextBuffer.CurrentSnapshot;
     DisplayText   = $"'{span.GetText(_snapshot)}' is not valid {ue4Statement.MacroConst} specifier";
 }
 public GenerateFieldSmartTagAction(ITrackingSpan span)
 {
     trackingSpan = span;
     snapShot     = span.TextBuffer.CurrentSnapshot;
     m_upper      = span.GetText(snapShot).ToUpper();
     displayText  = "生成属性";
 }
        public ISignature GetBestMatch(ISignatureHelpSession session)
        {
            if (session.Signatures.Count != 4)
            {
                return(session.Signatures.FirstOrDefault());
            }

            string text = _span.GetText(_buffer.CurrentSnapshot);

            if (text.Contains("[{"))
            {
                return(session.Signatures.ElementAt(3));
            }

            if (text.Contains("{"))
            {
                return(session.Signatures.ElementAt(1));
            }

            if (text.Contains("**"))
            {
                return(session.Signatures.ElementAt(2));
            }

            return(session.Signatures.ElementAt(0));
        }
        /// <summary>
        /// Check if the property name in the text buffer has changed.
        /// If so, then dismiss the syntax help tip.
        /// </summary>
        private void OnTextBufferChanged(object sender, TextContentChangedEventArgs eventArgs)
        {
            if (_trackingSpan != null && _session != null)
            {
                ITextSnapshot snapshot               = _trackingSpan.TextBuffer.CurrentSnapshot;
                SnapshotPoint startPoint             = _trackingSpan.GetStartPoint(snapshot);
                bool          propertyNameStillValid = false;

                if (startPoint.Position + _propertyName.Length <= snapshot.Length)
                {
                    string text = _trackingSpan.GetText(snapshot);

                    if (text.StartsWith("[", StringComparison.Ordinal))
                    {
                        // The correct property name is still in the code
                        propertyNameStillValid = true;
                        _session.Match();
                    }
                }

                if (!propertyNameStillValid)
                {
                    _session.Dismiss();
                }
            }
        }
Пример #14
0
        private int CalcCurrentParameter(SnapshotPoint triggerPt)
        {
            if (_params.Count == 0)
            {
                _currentParam = null;
                return(-1);
            }

            var source          = _applicableToSpan.GetText(triggerPt.Snapshot);
            var localTriggerPos = triggerPt.Position - _applicableToSpan.GetStartPoint(triggerPt.Snapshot);

            var parser = new CodeParser(source);

            parser.ReadExact('(');              // Skip past opening bracket
            var commaCount = 0;

            while (parser.Position < localTriggerPos && parser.ReadNestable())
            {
                if (parser.Text == ",")
                {
                    commaCount++;
                }
            }

            return(commaCount < _params.Count ? commaCount : _params.Count - 1);
        }
Пример #15
0
 public BaseSmartTagAction(ITrackingSpan span, FileCodeModel codeModel)
 {
     _span      = span;
     _snapshot  = span.TextBuffer.CurrentSnapshot;
     _display   = span.GetText(_snapshot);
     _codeModel = codeModel;
 }
 public LowerCaseSmartTagAction(ITrackingSpan span)
 {
     this.span = span;
     tsnapshot = span.TextBuffer.CurrentSnapshot;
     lower = span.GetText(tsnapshot).ToLower();
     display = "Convert to lower case";
 }
Пример #17
0
        private CompletionSet GetElementById(IList <CompletionSet> completionSets, int position, ITextSnapshotLine line, string text, int index)
        {
            int end = text.IndexOf(')', index);

            if (position <= line.Start + end)
            {
                ITrackingSpan span = _buffer.CurrentSnapshot.CreateTrackingSpan(line.Start + index, end - index, SpanTrackingMode.EdgeInclusive);

                List <Completion> list = new List <Completion>();
                if (!span.GetText(_buffer.CurrentSnapshot).Contains("\""))
                {
                    return(null);
                }

                AddExistingCompletions(completionSets, list);

                var names = _classNames.GetNames(new System.Uri(EditorExtensionsPackage.DTE.ActiveDocument.FullName), line.Start.Add(index), CssNameType.Id);

                foreach (string name in names.Select(n => n.Name).Distinct())
                {
                    list.Add(GenerateCompletion(name));
                }

                var completions = list.OrderBy(x => x.DisplayText.TrimStart('\"'));

                return(new CompletionSet("ids", "Web Essentials", span, completions, null));
            }

            return(null);
        }
 public GenerateFieldSmartTagAction(ITrackingSpan span)
 {
     trackingSpan = span;
     snapShot = span.TextBuffer.CurrentSnapshot;
     m_upper = span.GetText(snapShot).ToUpper();
     displayText = "生成属性";
 }
Пример #19
0
        public SuppressSuggestedAction(ITrackingSpan span, Rule rule, int days)
        {
            _rule     = rule;
            _span     = span;
            _snapshot = span.TextBuffer.CurrentSnapshot;
            _code     = span.GetText(_snapshot);

            if (_rule != null)
            {
                if (days > 0)
                {
                    _display  = string.Format(Resources.Messages.SuppressIssue, rule.Id, days);
                    _suppDate = DateTime.Now.AddDays(days);
                }
                else
                {
                    _display = string.Format(Resources.Messages.SuppressIssuePermanently, rule.Id);
                }
            }
            else
            {
                if (days > 0)
                {
                    _display  = string.Format(Resources.Messages.SupressAllIssues, days);
                    _suppDate = DateTime.Now.AddDays(days);
                }
                else
                {
                    _display = string.Format(Resources.Messages.SuppressAllIssuesPermanently);
                }
            }
        }
Пример #20
0
 public LowerCaseSmartTagAction(ITrackingSpan span)
 {
     m_span     = span;
     m_snapshot = span.TextBuffer.CurrentSnapshot;
     m_lower    = span.GetText(m_snapshot).ToLower();
     m_display  = "Convert to lower case";
 }
Пример #21
0
 public PutInHashicorpAction(ITrackingSpan span, string value, string language)
 {
     _span         = span;
     this.value    = value;
     this.language = language;
     _snapshot     = span.TextBuffer.CurrentSnapshot;
     _display      = string.Format("Secrecy: Put '{0}' in Hashicorp Vault", span.GetText(_snapshot));
 }
Пример #22
0
 public EncryptWithAWSKMS(ITrackingSpan span, string value, string language)
 {
     _span         = span;
     this.value    = value;
     this.language = language;
     _snapshot     = span.TextBuffer.CurrentSnapshot;
     _display      = string.Format("Secrecy: Encrypt '{0}' with AWS KMS", span.GetText(_snapshot));
 }
        private void SetCode()
        {
            var rawSelection       = span.GetText(span.TextBuffer.CurrentSnapshot);
            var property           = PropertySignature.FromRawSelection(rawSelection);
            var dependencyProperty = DependencyPropertySignature.FromRawSelection(rawSelection);

            nonIndentedCode = TextGenerator.GetNonIndentedCodeWithRegion(property, dependencyProperty);
            indentedCode    = TextGenerator.GetIndentedCodeWithRegion(property, dependencyProperty);
        }
        public FixSuggestedAction(ITrackingSpan span, CodeFix fix)
        {
            _fix      = fix;
            _span     = span;
            _snapshot = span.TextBuffer.CurrentSnapshot;
            string code = span.GetText(_snapshot);

            _fixedCode = RuleProcessor.Fix(code, _fix);
            _display   = (string.IsNullOrEmpty(_fix.Name)) ? _fixedCode : _fix.Name;
        }
Пример #25
0
 public WhenAction(ITrackingSpan span, TodoTagger tagger, string display, TimeSpan delayBy, string filePath)
 {
     m_span       = span;
     m_snapshot   = span.TextBuffer.CurrentSnapshot;
     m_upper      = span.GetText(m_snapshot).ToUpper();
     m_display    = display;
     m_delayBy    = delayBy;
     m_tagger     = tagger;
     FileLocation = filePath;
 }
Пример #26
0
 internal WordLegacyCompletionSession(ITrackingSpan wordTrackingSpan, IIntellisenseSessionStack intellisenseSessionStack, ICompletionSession completionSession, WordLegacyCompletionSet wordCompletionSet)
 {
     _textView                     = completionSession.TextView;
     _wordTrackingSpan             = wordTrackingSpan;
     _wordCompletionSet            = wordCompletionSet;
     _completionSession            = completionSession;
     _initialText                  = _wordTrackingSpan.GetText(_textView.TextSnapshot);
     _completionSession.Dismissed += delegate { OnDismissed(); };
     _intellisenseSessionStack     = intellisenseSessionStack;
 }
Пример #27
0
        /// <summary>
        /// Calculates the prefix used to filter and position the completion list
        /// </summary>
        /// <returns></returns>
        private string getPrefix()
        {
            var prefix = filterSpan.GetText(filterSpan.TextBuffer.CurrentSnapshot);

            if (prefix.Length > FilterOffset)
            {
                return(prefix.Substring(FilterOffset));
            }
            return(prefix);
        }
        /// <summary>
        /// Calculates the prefix used to filter and position the completion list
        /// </summary>
        /// <returns></returns>
        protected virtual string GetFilterPrefix()
        {
            var prefix = filterSpan.GetText(filterSpan.TextBuffer.CurrentSnapshot);

            if (prefix.Length > FilterOffset)
            {
                return(prefix.Substring(FilterOffset));
            }
            return(prefix);
        }
            public CompletionListUpdater(
                ITrackingSpan applicableToSpan,
                CompletionSessionData sessionData,
                AsyncCompletionSessionDataSnapshot snapshotData,
                RecentItemsManager recentItemsManager,
                IGlobalOptionService globalOptions)
            {
                _sessionData        = sessionData;
                _snapshotData       = snapshotData;
                _recentItemsManager = recentItemsManager;

                _applicableToSpan = applicableToSpan;
                _filterText       = applicableToSpan.GetText(_snapshotData.Snapshot);

                _hasSuggestedItemOptions = _sessionData.HasSuggestionItemOptions || _snapshotData.DisplaySuggestionItem;

                // We prefer using the original snapshot, which should always be available from items provided by Roslyn's CompletionSource.
                // Only use data.Snapshot in the theoretically possible but rare case when all items we are handling are from some non-Roslyn CompletionSource.
                var snapshotForDocument = TryGetInitialTriggerLocation(_snapshotData, out var intialTriggerLocation)
                    ? intialTriggerLocation.Snapshot
                    : _snapshotData.Snapshot;

                _document = snapshotForDocument?.TextBuffer.AsTextContainer().GetOpenDocumentInCurrentContext();
                if (_document != null)
                {
                    _completionService = _document.GetLanguageService <CompletionService>();
                    _completionRules   = _completionService?.GetRules(globalOptions.GetCompletionOptions(_document.Project.Language)) ?? CompletionRules.Default;

                    // Let us make the completion Helper used for non-Roslyn items case-sensitive.
                    // We can change this if get requests from partner teams.
                    _completionHelper = CompletionHelper.GetHelper(_document);
                    _filterMethod     = _completionService == null
                        ? ((itemsWithPatternMatches, text) => CompletionService.FilterItems(_completionHelper, itemsWithPatternMatches, text))
                        : ((itemsWithPatternMatches, text) => _completionService.FilterItems(_document, itemsWithPatternMatches, text));

                    // Nothing to highlight if user hasn't typed anything yet.
                    _highlightMatchingPortions = _filterText.Length > 0 &&
                                                 globalOptions.GetOption(CompletionViewOptions.HighlightMatchingPortionsOfCompletionListItems, _document.Project.Language);

                    _showCompletionItemFilters = globalOptions.GetOption(CompletionViewOptions.ShowCompletionItemFilters, _document.Project.Language);
                }
                else
                {
                    _completionService = null;
                    _completionRules   = CompletionRules.Default;

                    // Let us make the completion Helper used for non-Roslyn items case-sensitive.
                    // We can change this if get requests from partner teams.
                    _completionHelper = new CompletionHelper(isCaseSensitive: true);
                    _filterMethod     = (itemsWithPatternMatches, text) => CompletionService.FilterItems(_completionHelper, itemsWithPatternMatches, text);

                    _highlightMatchingPortions = false;
                    _showCompletionItemFilters = true;
                }
            }
Пример #30
0
        public CompleteDueByAction(ITrackingSpan span, TodoTagger tagger, string display, string filePath, Reminder reminder)
        {
            m_span = span;
            m_snapshot = span.TextBuffer.CurrentSnapshot;
            m_upper = span.GetText(m_snapshot).ToUpper();
            m_display = display;
            m_tagger = tagger;
            m_reminder = reminder;

            FileLocation = filePath;
        }
Пример #31
0
 /// <summary>
 /// This method is executed when action is selected in the context menu
 /// </summary>
 public void Invoke()
 {
     if (dictionary != null && Keyboard.Modifiers == ModifierKeys.Control)
     {
         dictionary.ReplaceAllOccurrences(span.GetText(span.TextBuffer.CurrentSnapshot), replaceWith);
     }
     else
     {
         span.TextBuffer.Replace(span.GetSpan(span.TextBuffer.CurrentSnapshot), replaceWith.Suggestion);
     }
 }
Пример #32
0
        public CompleteDueByAction(ITrackingSpan span, TodoTagger tagger, string display, string filePath, Reminder reminder)
        {
            m_span     = span;
            m_snapshot = span.TextBuffer.CurrentSnapshot;
            m_upper    = span.GetText(m_snapshot).ToUpper();
            m_display  = display;
            m_tagger   = tagger;
            m_reminder = reminder;

            FileLocation = filePath;
        }
Пример #33
0
 public AttachAction(ITrackingSpan span, ITextView view, TodoTagger tagger, string display, string path, string filePath)
 {
     m_span = span;
     m_snapshot = span.TextBuffer.CurrentSnapshot;
     m_upper = span.GetText(m_snapshot).ToUpper();
     m_display = display;
     m_path = path;
     m_tagger = tagger;
     m_view = view;
     this.FileLocation = filePath;
 }
Пример #34
0
        public ISignature GetBestMatch(ISignatureHelpSession session)
        {
            if (session.Signatures.Count > 0)
            {
                ITrackingSpan applicableToSpan = session.Signatures[0].ApplicableToSpan;
                string        text             = applicableToSpan.GetText(applicableToSpan.TextBuffer.CurrentSnapshot);

                return(session.Signatures[0]);
            }
            return(null);
        }
Пример #35
0
 public DueByAction(ITrackingSpan span, TodoTagger tagger, string display, DateTime dueBy, string friendly, string filePath)
 {
     m_span = span;
     m_snapshot = span.TextBuffer.CurrentSnapshot;
     m_upper = span.GetText(m_snapshot).ToUpper();
     m_display = display;
     m_dueBy = dueBy;
     m_friendly = friendly;
     m_tagger = tagger;
     FileLocation = filePath;
 }
Пример #36
0
 public DueByAction(ITrackingSpan span, TodoTagger tagger, string display, DateTime dueBy, string friendly, string filePath)
 {
     m_span       = span;
     m_snapshot   = span.TextBuffer.CurrentSnapshot;
     m_upper      = span.GetText(m_snapshot).ToUpper();
     m_display    = display;
     m_dueBy      = dueBy;
     m_friendly   = friendly;
     m_tagger     = tagger;
     FileLocation = filePath;
 }
Пример #37
0
 public AttachAction(ITrackingSpan span, ITextView view, TodoTagger tagger, string display, string path, string filePath)
 {
     m_span            = span;
     m_snapshot        = span.TextBuffer.CurrentSnapshot;
     m_upper           = span.GetText(m_snapshot).ToUpper();
     m_display         = display;
     m_path            = path;
     m_tagger          = tagger;
     m_view            = view;
     this.FileLocation = filePath;
 }
Пример #38
0
 internal PowerShellCompletionSet(string moniker, string displayName, ITrackingSpan applicableTo, IEnumerable <Completion> completions, IEnumerable <Completion> completionBuilders, ITrackingSpan filterSpan, ITrackingSpan lineStartToApplicableTo)
     : base(moniker, displayName, applicableTo, completions, completionBuilders)
 {
     if (filterSpan == null)
     {
         throw new ArgumentNullException("filterSpan");
     }
     this.completions        = new FilteredObservableCollection <Completion>(new ObservableCollection <Completion>(completions));
     FilterSpan              = filterSpan;
     LineStartToApplicableTo = lineStartToApplicableTo;
     InitialApplicableTo     = applicableTo.GetText(applicableTo.TextBuffer.CurrentSnapshot);
 }
 internal PowerShellCompletionSet(string moniker, string displayName, ITrackingSpan applicableTo, IEnumerable<Completion> completions, IEnumerable<Completion> completionBuilders, ITrackingSpan filterSpan, ITrackingSpan lineStartToApplicableTo)
     : base(moniker, displayName, applicableTo, completions, completionBuilders)
 {
     if (filterSpan == null)
     {
         throw new ArgumentNullException("filterSpan");
     }
     this.completions = new FilteredObservableCollection<Completion>(new ObservableCollection<Completion>(completions));
     FilterSpan = filterSpan;
     LineStartToApplicableTo = lineStartToApplicableTo;
     InitialApplicableTo = applicableTo.GetText(applicableTo.TextBuffer.CurrentSnapshot);
 }
Пример #40
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="span">The tracking span related to the event</param>
 public SpellingEventArgs(ITrackingSpan span)
 {
     this.Word = span.GetText(span.TextBuffer.CurrentSnapshot);
     this.Span = span;
 }