/// <summary> /// Lower is better. 1 == not in list. /// </summary> public int GetIndex (CompletionData item) { lock (mruLock) { var index = lastItems.IndexOf (item.DisplayText); return -index; } }
public void CommitCompletionData (CompletionData item) { lock (mruLock) { var removed = lastItems.Remove (item.DisplayText); if (!removed && lastItems.Count == MaxItems) lastItems.RemoveAt (0); lastItems.Add (item.DisplayText); } }
public void AddOverload (CompletionData data) { var tooltipInformation = data.CreateTooltipInformation (false); if (string.IsNullOrEmpty (tooltipInformation.SignatureMarkup)) return; using (var layout = new Pango.Layout (PangoContext)) { var des = FontService.GetFontDescription ("Editor"); layout.FontDescription = des; layout.SetMarkup (tooltipInformation.SignatureMarkup); int w, h; layout.GetPixelSize (out w, out h); if (w >= Allocation.Width - 10) { tooltipInformation = data.CreateTooltipInformation (true); } } AddOverload (tooltipInformation); }
public async Task AddOverload (CompletionData data, CancellationToken cancelToken) { var tooltipInformation = await data.CreateTooltipInformation (false, cancelToken); if (tooltipInformation == null || tooltipInformation.IsEmpty || cancelToken.IsCancellationRequested) return; using (var layout = new Pango.Layout (PangoContext)) { layout.FontDescription = FontService.GetFontDescription ("Editor"); layout.SetMarkup (tooltipInformation.SignatureMarkup); int w, h; layout.GetPixelSize (out w, out h); if (w >= Allocation.Width - 10) { tooltipInformation = await data.CreateTooltipInformation (true, cancelToken); } } if (cancelToken.IsCancellationRequested) return; AddOverload (tooltipInformation); }
public async Task AddOverload (CompletionData data, CancellationToken cancelToken) { try { var tooltipInformation = await data.CreateTooltipInformation (false, cancelToken); if (tooltipInformation == null || tooltipInformation.IsEmpty || cancelToken.IsCancellationRequested) return; using (var layout = new Pango.Layout (PangoContext)) { layout.FontDescription = Theme.Font; layout.SetMarkup (tooltipInformation.SignatureMarkup); int w, h; layout.GetPixelSize (out w, out h); if (w >= Allocation.Width - 10) { tooltipInformation = await data.CreateTooltipInformation (true, cancelToken); } } if (cancelToken.IsCancellationRequested) return; AddOverload (tooltipInformation); } catch (Exception e) { LoggingService.LogError ("Error while adding overload : " + data, e); } }
void UpdateDeclarationView() { if (completionDataList == null || List.Selection >= completionDataList.Count || List.Selection == -1) { return; } if (List.GdkWindow == null) { return; } RemoveDeclarationViewTimer(); // no selection, try to find a selection if (List.SelectionIndex < 0 || List.SelectionIndex >= completionDataList.Count) { List.CompletionString = PartialWord; bool hasMismatches; List.Selection = FindMatchedEntry(List.CompletionString, out hasMismatches); } // no success, hide declaration view if (List.SelectionIndex < 0 || List.SelectionIndex >= completionDataList.Count) { HideDeclarationView(); return; } CompletionData data = completionDataList[List.SelectionIndex]; IList <CompletionData> overloads; if (data.IsOverloaded) { var filteredOverloads = data.OverloadedData; if (PropertyService.Get("HideObsoleteItems", true)) { filteredOverloads = filteredOverloads.Where(x => (DisplayFlags.Obsolete != (DisplayFlags.Obsolete & x.DisplayFlags))); } overloads = new List <CompletionData> (filteredOverloads); } else { overloads = new CompletionData[] { data }; } if (data != currentData) { HideDeclarationView(); declarationviewwindow.Clear(); declarationviewwindow.Realize(); foreach (CompletionData overload in overloads) { bool hasMarkup = (overload.DisplayFlags & DisplayFlags.DescriptionHasMarkup) != 0; declarationviewwindow.AddOverload(hasMarkup ? overload.Description : GLib.Markup.EscapeText(overload.Description)); } declarationviewwindow.Multiple = data.IsOverloaded; currentData = data; if (data.IsOverloaded) { for (int i = 0; i < overloads.Count; i++) { if ((overloads[i].DisplayFlags & DisplayFlags.Obsolete) != DisplayFlags.Obsolete) { declarationviewwindow.CurrentOverload = i; break; } } } } if (declarationviewwindow.DescriptionMarkup.Length == 0) { HideDeclarationView(); return; } if (currentData != null) { declarationViewTimer = GLib.Timeout.Add(250, DelayedTooltipShow); } }
public virtual bool IsOverload(CompletionData other) { return(true); }
/// <summary> /// Returns an array of <see cref="CompletionData"/> items. /// </summary> /// <returns></returns> public CompletionData[] ToArray() { CompletionData[] data = new CompletionData[Count]; CopyTo(data, 0); return data; }
public virtual void AddCompletionData (CompletionDataList provider) { if (action == CompletionAction.AttributeValue) { currentCollection = new List<ItemData> (); OnAddAttributeValues (attNameForValue); } else if (action == CompletionAction.ElementStart) currentCollection = ElementData; else currentCollection = AttributeData; foreach (ItemData data in currentCollection) { CompletionData cd = new CompletionData (data.Name, "md-literal", data.Description); if (data.CompletionString != null) cd.CompletionText = data.CompletionString; provider.Add (cd); } }
public override bool IsCommitCharacter (CompletionData completionItem, char ch, string textTypedSoFar) { return ch == ' ' || ch == '(' || ch == '{' || ch == '['; }
public override bool IsCommitCharacter (CompletionData completionItem, char ch, string textTypedSoFar) { // Only commit on dot. return ch == '.'; }
public void AddOverload (CompletionData data) { if (overloads == null) overloads = new List<CompletionData> (); overloads.Add ((CompletionData)data); sorted = null; }
public static int Compare (CompletionData a, CompletionData b) { var result = ((a.DisplayFlags & DisplayFlags.Obsolete) == (b.DisplayFlags & DisplayFlags.Obsolete)) ? StringComparer.OrdinalIgnoreCase.Compare (a.DisplayText, b.DisplayText) : (a.DisplayFlags & DisplayFlags.Obsolete) != 0 ? 1 : -1; if (result == 0) { var aIsImport = (a.DisplayFlags & DisplayFlags.IsImportCompletion) != 0; var bIsImport = (b.DisplayFlags & DisplayFlags.IsImportCompletion) != 0; if (!aIsImport && bIsImport) return -1; if (aIsImport && !bIsImport) return 1; if (aIsImport && bIsImport) return StringComparer.Ordinal.Compare (((CompletionData)a).Description, ((CompletionData)b).Description); var ca = a as CompletionData; var cb = b as CompletionData; if (ca != null && cb != null && !ca.Icon.IsNull && !cb.Icon.IsNull) { return string.Compare(cb.Icon.Name, ca.Icon.Name, StringComparison.Ordinal); } } return result; }
static CompletionData[] GetCompletions (Dictionary<string,HashSet<string>> map, string tagName, XmlCompletionData.DataType type) { HashSet<string> values; if (!map.TryGetValue (tagName, out values)) return new CompletionData [0]; CompletionData[] data = new CompletionData[values.Count]; int i = 0; foreach (string s in values) data[i++] = new XmlCompletionData (s, type); return data; }
public virtual bool IsOverload (CompletionData other) { return DisplayText == other.DisplayText; }
public override bool IsCommitCharacter (CompletionData ICompletionData, char ch, string textTypedSoFar) { if ((ch == '"' || ch == ' ') && ICompletionData.DisplayText.Contains(ch)) { return false; } return base.IsCommitCharacter(ICompletionData, ch, textTypedSoFar) || ch == '>' || ch == '\t'; }
public virtual bool IsOverload(CompletionData other) { return(DisplayText == other.DisplayText); }
public override bool IsOverload (CompletionData other) { var os = other as RoslynSymbolCompletionData; if (os != null) { return Symbol.Kind == os.Symbol.Kind && Symbol.Name == os.Symbol.Name; } return false; }
async void DelayedTooltipShowAsync() { var selectedItem = List.SelectedItemIndex; if (selectedItem < 0 || selectedItem >= completionDataList.Count) { return; } var data = completionDataList [selectedItem]; IEnumerable <CompletionData> filteredOverloads; if (data.HasOverloads) { filteredOverloads = data.OverloadedData; } else { filteredOverloads = new CompletionData[] { data }; } EnsureDeclarationViewWindow(); if (data != currentData) { declarationviewwindow.Clear(); currentData = data; var cs = new CancellationTokenSource(); declarationViewCancelSource = cs; var overloads = new List <CompletionData> (filteredOverloads); overloads.Sort(ListWidget.overloadComparer); foreach (var overload in overloads) { await declarationviewwindow.AddOverload((CompletionData)overload, cs.Token); } if (cs.IsCancellationRequested) { return; } if (declarationViewCancelSource == cs) { declarationViewCancelSource = null; } if (data.HasOverloads) { for (int i = 0; i < overloads.Count; i++) { if (!overloads[i].DisplayFlags.HasFlag(DisplayFlags.Obsolete)) { declarationviewwindow.CurrentOverload = i; break; } } } } if (declarationviewwindow.Overloads == 0) { HideDeclarationView(); return; } if (declarationViewHidden && Visible) { RepositionDeclarationViewWindow(); } declarationViewTimer = 0; }
public override bool SendEnterThroughToEditor (CompletionData completionItem, string textTypedSoFar) { return false; }
/// <summary> /// Copies the <see cref='XmlCompletionDataCollection'/> values to a one-dimensional <see cref='Array'/> instance at the /// specified index. /// </summary> public void CopyTo(CompletionData[] array, int index) { List.CopyTo(array, index); }
public override bool IsOverload (CompletionData other) { return false; }
public static int Compare(CompletionData a, CompletionData b) { if (a == b) { return(0); } if (a != null && b == null) { return(-1); } if (a == null && b != null) { return(1); } if (a.Rules != null && b.Rules != null) { if (a.Rules.MatchPriority != b.Rules.MatchPriority) { return(b.Rules.MatchPriority.CompareTo(a.Rules.MatchPriority)); } } bool aIsObsolete = (a.DisplayFlags & DisplayFlags.Obsolete) != 0; bool bIsObsolete = (b.DisplayFlags & DisplayFlags.Obsolete) != 0; if (!aIsObsolete && bIsObsolete) { return(-1); } if (aIsObsolete && !bIsObsolete) { return(1); } var result = StringComparer.OrdinalIgnoreCase.Compare(a.DisplayText, b.DisplayText); if (result != 0) { return(result); } var aIsImport = (a.DisplayFlags & DisplayFlags.IsImportCompletion) != 0; var bIsImport = (b.DisplayFlags & DisplayFlags.IsImportCompletion) != 0; if (!aIsImport && bIsImport) { return(-1); } if (aIsImport && !bIsImport) { return(1); } result = StringComparer.Ordinal.Compare(a.Description, b.Description); if (result != 0) { return(result); } if (!a.Icon.IsNull && !b.Icon.IsNull) { return(string.Compare(a.Icon.Name, b.Icon.Name, StringComparison.Ordinal)); } return(0); }