Пример #1
0
        /// <summary>
        /// Auto-complete completion provider request callback
        /// </summary>
        /// <param name="textDocumentPosition"></param>
        /// <param name="requestContext"></param>
        /// <returns></returns>
        internal async Task HandleCompletionRequest(TextDocumentPosition textDocumentPosition, RequestContext <CompletionList> requestContext)
        {
            CompletionList completionList = new CompletionList();

            completionList.IsIncomplete = false;

            Text text = this.CreateXmlTextFromTextDocumentUri(textDocumentPosition.TextDocument.Uri);

            TextPosition textPosition = PositionUtils.CreateTextPosition(text.Content, textDocumentPosition.Position);

            XmlCodeCompletionProvider   xmlCodeCompletion           = this.CreateCodeCompletionProvider(text, textPosition);
            XmlCompletionItemCollection xmlCompletionItemCollection = xmlCodeCompletion.RetrieveCompletionItemCollection();

            if (xmlCompletionItemCollection != null)
            {
                foreach (XmlCompletionItem xmlCompletionItem in xmlCompletionItemCollection)
                {
                    completionList.Items.Add(new CompletionItem()
                    {
                        Detail        = null, //"This is the documentation. Not Implemented",
                        Documentation = xmlCompletionItem.Documentation,
                        Kind          = CompletionItemKind.Text,
                        Label         = xmlCompletionItem.Text,
                    });
                }
            }
            await requestContext.SendResult(completionList);
        }
        public static TextPosition CreateTextPosition(string text, Position position)
        {
            TextPosition textPosition = new TextPosition();

            textPosition.Column = position.Character;
            textPosition.Line   = position.Line;
            textPosition.Offset = PositionUtils.FindOffset(text, textPosition.Line, textPosition.Column);
            return(textPosition);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="textDocumentPosition"></param>
        /// <param name="requestContext"></param>
        /// <returns></returns>
        internal async Task HandleDefinitionRequest(TextDocumentPosition textDocumentPosition, RequestContext <Location[]> requestContext)
        {
            List <Location> locations = new List <Location>();

            Text text = this.CreateXmlTextFromTextDocumentUri(textDocumentPosition.TextDocument.Uri);

            TextPosition textPosition = PositionUtils.CreateTextPosition(text.Content, textDocumentPosition.Position);

            XmlSymbolDefinitionProvider xmlSymbolDefinition         = this.CreateSymbolDefinitionProvider(text, textPosition);
            XmlObjectLocationCollection xmlObjectLocationCollection = xmlSymbolDefinition.RetrieveSymbolLocation();

            if (xmlObjectLocationCollection != null)
            {
                foreach (XmlObjectLocation xmlObjectLocation in xmlObjectLocationCollection)
                {
                    locations.Add(new Location()
                    {
                        Range = new Range()
                        {
                            Start = new Position()
                            {
                                Line      = xmlObjectLocation.LineNumber - 1,
                                Character = xmlObjectLocation.LinePosition - 1
                            },
                            End = new Position()
                            {
                                Line      = xmlObjectLocation.LineNumber - 1,
                                Character = xmlObjectLocation.LinePosition - 1
                            }
                        },
                        Uri = xmlObjectLocation.Uri.ToString(),
                    });
                }
            }
            await requestContext.SendResult(locations.ToArray());
        }