public override Task <TooltipInformation> CreateTooltipInformation(MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext ctx, int currentParameter, bool smartWrap, CancellationToken cancelToken)
            {
                var sig = new SignatureMarkupCreator(ctx, editor != null ? editor.CaretOffset : 0)
                {
                    HighlightParameter = currentParameter
                };

                return(Task.FromResult(new TooltipInformation {
                    SignatureMarkup = sig.GetArrayIndexerMarkup(arrayType)
                }));
            }
Exemplo n.º 2
0
        internal static ExpandSelectionAnnotation GetSelectionAnnotation(MonoDevelop.Ide.Editor.TextEditor editor)
        {
            var result = editor.Annotation <ExpandSelectionAnnotation> ();

            if (result == null)
            {
                result = new ExpandSelectionAnnotation(editor);
                editor.AddAnnotation(result);
            }
            return(result);
        }
Exemplo n.º 3
0
 public TestSemanticHighlighting(MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext documentContext) : base(editor, documentContext)
 {
 }
Exemplo n.º 4
0
 public static ITextView GetPlatformTextView(this MonoDevelop.Ide.Editor.TextEditor textEditor)
 {
     return(textEditor.TextView);
 }
Exemplo n.º 5
0
 public static ITextBuffer GetPlatformTextBuffer(this MonoDevelop.Ide.Editor.TextEditor textEditor)
 {
     return(textEditor.TextView.TextBuffer);
 }
			public ExpandSelectionAnnotation (MonoDevelop.Ide.Editor.TextEditor editor)
			{
				this.editor = editor;
				editor.CaretPositionChanged += Editor_CaretPositionChanged;
			}
Exemplo n.º 7
0
        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 (ctx != null)
            {
                if (ctx.ParsedDocument == null || ctx.AnalysisDocument == null)
                {
                    LoggingService.LogError("Signature markup creator created with invalid context." + Environment.NewLine + Environment.StackTrace);
                }
            }

            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;
            }));
        }
Exemplo n.º 8
0
 public static ITextBuffer GetPlatformTextBuffer(this MonoDevelop.Ide.Editor.TextEditor textEditor)
 {
     return(textEditor.GetContent <Mono.TextEditor.ITextEditorDataProvider>().GetTextEditorData().Document.TextBuffer);
 }
            internal static Task <TooltipInformation> CreateTooltipInformation(MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext ctx, ISymbol sym, int currentParameter, bool smartWrap, CancellationToken cancelToken)
            {
                var tooltipInfo = new TooltipInformation();
                var sig         = new SignatureMarkupCreator(ctx, editor != null ? editor.CaretOffset : 0);

                sig.HighlightParameter       = currentParameter;
                sig.BreakLineAfterReturnType = smartWrap;

                return(Task.Run(() => {
                    if (cancelToken.IsCancellationRequested)
                    {
                        return null;
                    }
                    try {
                        tooltipInfo.SignatureMarkup = sig.GetMarkup(sym);
                    } catch (Exception e) {
                        LoggingService.LogError("Got exception while creating markup for :" + sym, e);
                        return new TooltipInformation();
                    }
                    tooltipInfo.SummaryMarkup = Ambience.GetSummaryMarkup(sym) ?? "";

                    if (cancelToken.IsCancellationRequested)
                    {
                        return null;
                    }

                    if (sym is IMethodSymbol)
                    {
                        var method = (IMethodSymbol)sym;
                        if (method.IsExtensionMethod && method.ReducedFrom != null && method.ReducedFrom.ContainingType != null)
                        {
                            tooltipInfo.AddCategory(GettextCatalog.GetString("Extension Method from"), method.ReducedFrom.ContainingType.Name);
                        }
                    }
                    int paramIndex = currentParameter;

                    //				if (Symbol is IMethodSymbol && ((IMethodSymbol)Symbol).IsExtensionMethod)
                    //					paramIndex++;
                    var list = GetParameterList(sym);
                    paramIndex = Math.Min(list.Length - 1, paramIndex);

                    var curParameter = paramIndex >= 0 && paramIndex < list.Length ? list [paramIndex] : null;
                    if (curParameter != null)
                    {
                        string docText = Ambience.GetDocumentation(sym);
                        if (!string.IsNullOrEmpty(docText))
                        {
                            string text = docText;
                            Regex paramRegex = new Regex("(\\<param\\s+name\\s*=\\s*\"" + curParameter.Name + "\"\\s*\\>.*?\\</param\\>)", RegexOptions.Compiled);
                            Match match = paramRegex.Match(docText);

                            if (match.Success)
                            {
                                text = Ambience.GetDocumentationMarkup(sym, match.Groups [1].Value);
                                if (!string.IsNullOrWhiteSpace(text))
                                {
                                    tooltipInfo.AddCategory(GettextCatalog.GetString("Parameter"), text);
                                }
                            }
                        }
                        if (curParameter.Type.TypeKind == TypeKind.Delegate)
                        {
                            tooltipInfo.AddCategory(GettextCatalog.GetString("Delegate Info"), sig.GetDelegateInfo(curParameter.Type));
                        }
                    }
                    return tooltipInfo;
                }));
            }
 public override Task <TooltipInformation> CreateTooltipInformation(MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext ctx, int currentParameter, bool smartWrap, CancellationToken cancelToken)
 {
     return(CreateTooltipInformation(editor, ctx, Symbol, currentParameter, smartWrap, cancelToken));
 }
Exemplo n.º 11
0
 public ExpandSelectionAnnotation(MonoDevelop.Ide.Editor.TextEditor editor)
 {
     this.editor = editor;
     editor.CaretPositionChanged += Editor_CaretPositionChanged;
 }
Exemplo n.º 12
0
        internal static bool IsSelected(MonoDevelop.Ide.Editor.TextEditor editor, Microsoft.CodeAnalysis.Text.TextSpan span)
        {
            var selection = editor.SelectionRange;

            return(selection.Offset == span.Start && selection.Length == span.Length);
        }