public override string GetDisplayTextMarkup()
        {
            if (factory == null)
            {
                return(Symbol.Name);
            }
            var model = ext.ParsedDocument.GetAst <SemanticModel> ();

            var result = RoslynCompletionData.SafeMinimalDisplayString(base.Symbol, model, declarationBegin, Ambience.LabelFormat) + " {...}";
            var idx    = result.IndexOf(Symbol.Name);

            if (idx >= 0)
            {
                result =
                    result.Substring(0, idx) +
                    "<b>" + Symbol.Name + "</b>" +
                    result.Substring(idx + Symbol.Name.Length);
            }

            if (!afterKeyword)
            {
                result = "override " + result;
            }

            return(ApplyDiplayFlagsFormatting(result));
        }
        protected override string GetInsertionText()
        {
            var sb = new StringBuilder();

            if (!afterKeyword)
            {
                sb.Append("new ");
            }
            sb.Append(CropGlobal(RoslynCompletionData.SafeMinimalDisplayString(insertSymbol, semanticModel, declarationBegin, HideParameters)));
            return(sb.ToString());
        }
        public override string GetDisplayTextMarkup()
        {
            var model = ext.ParsedDocument.GetAst <SemanticModel> ();

            var result = "<b>" + Ambience.EscapeText(CropGlobal(RoslynCompletionData.SafeMinimalDisplayString(symbol, model, declarationBegin, HideParameters))) + "</b>()";

            if (!afterKeyword)
            {
                result = "new " + result;
            }
            return(ApplyDiplayFlagsFormatting(result));
        }
 ISymbolCompletionData ICompletionDataFactory.CreateEnumMemberCompletionData(ICompletionDataKeyHandler keyHandler, ISymbol alias, IFieldSymbol field)
 {
     return(new RoslynSymbolCompletionData(keyHandler, this, field, RoslynCompletionData.SafeMinimalDisplayString(alias ?? field.Type, semanticModel, ext.Editor.CaretOffset, Ambience.NameFormat) + "." + field.Name));
 }
Example #5
0
        public override void InsertCompletionText(CompletionListWindow window, ref KeyActions ka, KeyDescriptor descriptor)
        {
            // insert add/remove event handler code after +=/-=
            var editor = factory.Ext.Editor;


            bool AddSemicolon = true;
            var  position     = window.CodeCompletionContext.TriggerOffset;

            editor.ReplaceText(position, editor.CaretOffset - position, this.DisplayText + (AddSemicolon ? ";" : ""));


            var document       = IdeApp.Workbench.ActiveDocument;
            var parsedDocument = document.UpdateParseDocument().Result;
            var semanticModel  = parsedDocument.GetAst <SemanticModel> ();

            var declaringType   = semanticModel.GetEnclosingSymbol <INamedTypeSymbol> (position, default(CancellationToken));
            var enclosingSymbol = semanticModel.GetEnclosingSymbol <ISymbol> (position, default(CancellationToken));

            var insertionPoints = InsertionPointService.GetInsertionPoints(
                document.Editor,
                parsedDocument,
                declaringType,
                editor.CaretOffset
                );
            var options = new InsertionModeOptions(
                GettextCatalog.GetString("Create new method"),
                insertionPoints,
                point => {
                if (!point.Success)
                {
                    return;
                }
                var indent = "\t";
                var sb     = new StringBuilder();
                if (enclosingSymbol != null && enclosingSymbol.IsStatic)
                {
                    sb.Append("static ");
                }
                sb.Append("void ");
                int pos2 = sb.Length;
                sb.Append(this.DisplayText);
                sb.Append(' ');
                sb.Append("(");

                var delegateMethod = delegateType.GetDelegateInvokeMethod();
                for (int k = 0; k < delegateMethod.Parameters.Length; k++)
                {
                    if (k > 0)
                    {
                        sb.Append(", ");
                    }
                    sb.Append(RoslynCompletionData.SafeMinimalDisplayString(delegateMethod.Parameters [k], semanticModel, position, MonoDevelop.Ide.TypeSystem.Ambience.LabelFormat));
                }
                sb.Append(")");

                sb.Append(editor.EolMarker);
                sb.Append(indent);
                sb.Append("{");
                sb.Append(editor.EolMarker);
                sb.Append(indent);
                sb.Append(editor.Options.GetIndentationString());
                //int cursorPos = pos + sb.Length;
                sb.Append(editor.EolMarker);
                sb.Append(indent);
                sb.Append("}");
                point.InsertionPoint.Insert(document.Editor, document, sb.ToString());
                //			// start text link mode after insert
                //			var links = new List<TextLink> ();
                //			var link = new TextLink ("name");
                //
                //			link.AddLink (new TextSegment (initialOffset, this.DisplayText.Length));
                //			link.AddLink (new TextSegment (initialOffset + pos + pos2, this.DisplayText.Length));
                //			links.Add (link);
                //			editor.StartTextLinkMode (new TextLinkModeOptions (links));
            }
                );

            editor.StartInsertionMode(options);
        }