public UpperCaseSuggestedAction(ITrackingSpan span) { _mSpan = span; _mSnapshot = span.TextBuffer.CurrentSnapshot; _mUpper = span.GetText(_mSnapshot).ToUpper(); _mDisplay = $"Convert '{span.GetText(_mSnapshot)}' to upper case"; }
/// <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); } } }
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(); } } }
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); }
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"; }
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 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); } } }
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"; }
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)); }
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; }
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; }
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; }
/// <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; } }
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; }
/// <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); } }
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; }
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); }
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; }
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); }
/// <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; }