public static Task <TooltipInformation> CreateTooltipInformation(CancellationToken ctoken, MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext ctx, ISymbol entity, bool smartWrap, bool createFooter = false, SemanticModel model = null) { var tooltipInfo = new TooltipInformation(); // if (resolver == null) // resolver = file != null ? file.GetResolver (compilation, textEditorData.Caret.Location) : new CSharpResolver (compilation); var sig = new SignatureMarkupCreator(ctx, editor != null ? editor.CaretOffset : 0); sig.SemanticModel = model; sig.BreakLineAfterReturnType = smartWrap; return(Task.Run(() => { if (ctoken.IsCancellationRequested) { return null; } try { tooltipInfo.SignatureMarkup = sig.GetMarkup(entity); } catch (Exception e) { LoggingService.LogError("Got exception while creating markup for :" + entity, e); return new TooltipInformation(); } if (ctoken.IsCancellationRequested) { return null; } tooltipInfo.SummaryMarkup = Ambience.GetSummaryMarkup(entity) ?? ""; // if (entity is IMember) { // var evt = (IMember)entity; // if (evt.ReturnType.Kind == TypeKind.Delegate) { // tooltipInfo.AddCategory (GettextCatalog.GetString ("Delegate Info"), sig.GetDelegateInfo (evt.ReturnType)); // } // } if (entity is IMethodSymbol) { var method = (IMethodSymbol)entity; if (method.IsExtensionMethod) { tooltipInfo.AddCategory(GettextCatalog.GetString("Extension Method from"), method.ContainingType.Name); } } if (createFooter) { tooltipInfo.FooterMarkup = sig.CreateFooter(entity); } return tooltipInfo; })); }
internal void InsertTemplate(CodeTemplate template, MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext context) { using (var undo = editor.OpenUndoGroup()) { var result = template.InsertTemplateContents(editor, context); var links = result.TextLinks.Select(l => new Mono.TextEditor.TextLink(l.Name) { Links = l.Links.Select(s => new TextSegment(s.Offset, s.Length)).ToList(), IsEditable = l.IsEditable, IsIdentifier = l.IsIdentifier }).ToList(); var tle = new TextLinkEditMode(this, result.InsertPosition, links); tle.TextLinkMode = TextLinkMode.General; if (tle.ShouldStartTextLinkMode) { tle.OldMode = CurrentMode; tle.StartMode(); CurrentMode = tle; } } }
internal void InsertTemplate(CodeTemplate template, MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext context) { using (var undo = editor.OpenUndoGroup()) { var result = template.InsertTemplateContents(editor, context); var links = result.TextLinks.Select(l => new Mono.TextEditor.TextLink(l.Name) { Links = l.Links.Select(s => (ISegment) new TextSegment(s.Offset, s.Length)).ToList(), IsEditable = l.IsEditable, IsIdentifier = l.IsIdentifier, GetStringFunc = l.GetStringFunc != null ? (Func <Func <string, string>, Mono.TextEditor.PopupWindow.IListDataProvider <string> >)(arg => new ListDataProviderWrapper(l.GetStringFunc(arg))) : null }).ToList(); var tle = new TextLinkEditMode(this, result.InsertPosition, links); tle.TextLinkMode = TextLinkMode.General; if (tle.ShouldStartTextLinkMode) { tle.OldMode = CurrentMode; tle.StartMode(); CurrentMode = tle; GLib.Timeout.Add(10, delegate { tle.UpdateTextLinks(); return(false); }); } } }
public static Task <TooltipInformation> CreateTooltipInformation(CancellationToken ctoken, MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext ctx, ISymbol entity, bool smartWrap, bool createFooter = false, SemanticModel model = null) { if (entity == null) { return(TaskUtil.Default <TooltipInformation> ()); } var tooltipInfo = new TooltipInformation(); var sig = new SignatureMarkupCreator(ctx, editor != null ? editor.CaretOffset : 0); sig.SemanticModel = model; sig.BreakLineAfterReturnType = smartWrap; return(Task.Run(() => { if (ctoken.IsCancellationRequested) { return null; } try { tooltipInfo.SignatureMarkup = sig.GetMarkup(entity); } catch (Exception e) { LoggingService.LogError("Got exception while creating markup for :" + entity, e); return new TooltipInformation(); } if (ctoken.IsCancellationRequested) { return null; } tooltipInfo.SummaryMarkup = Ambience.GetSummaryMarkup(entity) ?? ""; if (entity is IMethodSymbol) { var method = (IMethodSymbol)entity; if (method.IsExtensionMethod) { tooltipInfo.AddCategory(GettextCatalog.GetString("Extension Method from"), method.ContainingType.Name); } } if (createFooter) { tooltipInfo.FooterMarkup = sig.CreateFooter(entity); } return tooltipInfo; })); }