Exemple #1
0
        #pragma warning restore 0414

        public CompletionProvider(
            RoslynCompilationWorkspace compilationWorkspace,
            XCB.ScriptContext context,
            Func <string, SourceText> getSourceTextByModelId)
        {
            this.context = context
                           ?? throw new ArgumentNullException(nameof(context));

            this.getSourceTextByModelId = getSourceTextByModelId
                                          ?? throw new ArgumentNullException(nameof(getSourceTextByModelId));

            controller = new CompletionController(compilationWorkspace);

            providerTicket = context.GlobalObject.xiexports.monaco.RegisterWorkbookCompletionItemProvider(
                "csharp",
                (XCB.ScriptFunc)ProvideCompletionItems);
        }
        static dynamic ToMonacoCompletionItems(XCB.ScriptContext context, CompletionModel model)
        {
            dynamic arr = context.CreateArray();

            var filteredCompletions = model?.FilteredItems;

            if (filteredCompletions == null || filteredCompletions.Count == 0)
            {
                return(arr);
            }

            foreach (var completion in filteredCompletions)
            {
                if (completion.Span.End > model.Text.Length)
                {
                    continue;
                }

                var displayText = completion.ToString();

                // Check for the property added by the internal SymbolCompletionItem helper
                string insertionText;
                completion.Properties.TryGetValue("InsertionText", out insertionText);

                // Check for the property added by us during filtering
                string itemDetail;
                completion.Properties.TryGetValue(itemDetailPropertyName, out itemDetail);

                arr.push(context.CreateObject(o => {
                    o.label = displayText;
                    if (itemDetail != null)
                    {
                        o.detail = itemDetail;
                    }
                    if (insertionText != null)
                    {
                        o.insertText = insertionText;
                    }
                    o.kind = MonacoExtensions.ToMonacoCompletionItemKind(completion.Tags);
                }));
            }

            return(arr);
        }
Exemple #3
0
        static dynamic ToMonacoCompletionItems(XCB.ScriptContext context, IEnumerable <CompletionItemViewModel> items)
        {
            dynamic arr = context.CreateArray();

            foreach (var item in items)
            {
                arr.push(context.CreateObject(o => {
                    o.label = item.DisplayText;
                    if (item.ItemDetail != null)
                    {
                        o.detail = item.ItemDetail;
                    }
                    if (item.InsertionText != null)
                    {
                        o.insertText = item.InsertionText;
                    }
                    o.kind = Client.Monaco.MonacoExtensions.ToMonacoCompletionItemKind(item.CompletionItem.Tags);
                }));
            }

            return(arr);
        }
 internal CssStyleDeclaration(ScriptContext context, IHTMLCSSStyleDeclaration comObject) : base(context, (Object)comObject)
 {
 }