private static CompletionItem CreateCompletionItem(XamlCompletionItem xamlCompletion, DocumentId documentId, SourceText text, Position position)
        {
            var item = new VSCompletionItem
            {
                Label            = xamlCompletion.DisplayText,
                CommitCharacters = xamlCompletion.CommitCharacters,
                Detail           = xamlCompletion.Detail,
                InsertText       = xamlCompletion.InsertText,
                Preselect        = xamlCompletion.Preselect.GetValueOrDefault(),
                SortText         = xamlCompletion.SortText,
                FilterText       = xamlCompletion.FilterText,
                Kind             = GetItemKind(xamlCompletion.Kind),
                Description      = xamlCompletion.Description,
                Icon             = xamlCompletion.Icon,
                Data             = new CompletionResolveData {
                    ProjectGuid = documentId.ProjectId.Id, DocumentGuid = documentId.Id, Position = position, DisplayText = xamlCompletion.DisplayText
                }
            };

            if (xamlCompletion.Span.HasValue)
            {
                item.TextEdit = new TextEdit
                {
                    NewText = xamlCompletion.InsertText,
                    Range   = ProtocolConversions.LinePositionToRange(text.Lines.GetLinePositionSpan(xamlCompletion.Span.Value))
                };
            }

            return(item);
        }
Beispiel #2
0
        private static CompletionItem CreateCompletionItem(
            XamlCompletionItem xamlCompletion,
            DocumentId documentId,
            SourceText text,
            Position position,
            TextDocumentIdentifier textDocument
            )
        {
            var item = new VSCompletionItem
            {
                Label            = xamlCompletion.DisplayText,
                CommitCharacters = xamlCompletion.CommitCharacters,
                Detail           = xamlCompletion.Detail,
                InsertText       = xamlCompletion.InsertText,
                Preselect        = xamlCompletion.Preselect.GetValueOrDefault(),
                SortText         = xamlCompletion.SortText,
                FilterText       = xamlCompletion.FilterText,
                Kind             = GetItemKind(xamlCompletion.Kind),
                Description      = xamlCompletion.Description,
                Icon             = xamlCompletion.Icon,
                Data             = new CompletionResolveData
                {
                    ProjectGuid  = documentId.ProjectId.Id,
                    DocumentGuid = documentId.Id,
                    Position     = position,
                    DisplayText  = xamlCompletion.DisplayText
                }
            };

            if (xamlCompletion.Span.HasValue)
            {
                item.TextEdit = new TextEdit
                {
                    NewText = xamlCompletion.InsertText,
                    Range   = ProtocolConversions.LinePositionToRange(
                        text.Lines.GetLinePositionSpan(xamlCompletion.Span.Value)
                        )
                };
            }

            if (xamlCompletion.EventDescription.HasValue)
            {
                item.Command = new Command()
                {
                    CommandIdentifier = StringConstants.CreateEventHandlerCommand,
                    Arguments         = new object[] { textDocument, xamlCompletion.EventDescription },
                    Title             = CreateEventHandlerCommandTitle
                };
            }

            return(item);
        }
Beispiel #3
0
        private static CompletionItem CreateCompletionItem(XamlCompletionItem xamlCompletion, DocumentId documentId, SourceText text, Position position, TextDocumentIdentifier textDocument, Dictionary <XamlCompletionKind, ImmutableArray <CommitCharacter> > commitCharactersCach)
        {
            var item = new VSCompletionItem
            {
                Label = xamlCompletion.DisplayText,
                VsCommitCharacters = GetCommitCharacters(xamlCompletion, commitCharactersCach),
                Detail             = xamlCompletion.Detail,
                InsertText         = xamlCompletion.InsertText,
                Preselect          = xamlCompletion.Preselect.GetValueOrDefault(),
                SortText           = xamlCompletion.SortText,
                FilterText         = xamlCompletion.FilterText,
                Kind             = GetItemKind(xamlCompletion.Kind),
                Description      = xamlCompletion.Description,
                Icon             = xamlCompletion.Icon,
                InsertTextFormat = xamlCompletion.IsSnippet ? InsertTextFormat.Snippet : InsertTextFormat.Plaintext,
                Data             = new CompletionResolveData {
                    ProjectGuid = documentId.ProjectId.Id, DocumentGuid = documentId.Id, Position = position, DisplayText = xamlCompletion.DisplayText
                }
            };

            if (xamlCompletion.Span.HasValue)
            {
                item.TextEdit = new TextEdit
                {
                    NewText = xamlCompletion.InsertText,
                    Range   = ProtocolConversions.LinePositionToRange(text.Lines.GetLinePositionSpan(xamlCompletion.Span.Value))
                };
            }

            if (xamlCompletion.EventDescription.HasValue)
            {
                item.Command = new Command()
                {
                    CommandIdentifier = StringConstants.CreateEventHandlerCommand,
                    Arguments         = new object[] { textDocument, xamlCompletion.EventDescription },
                    Title             = CreateEventHandlerCommandTitle
                };
            }
            else if (xamlCompletion.RetriggerCompletion)
            {
                // Retriger completion after commit
                item.Command = s_retriggerCompletionCommand;
            }

            return(item);
        }
        private static LSP.VSCompletionItem CreateResolvedCompletionItem(
            VSCompletionItem completionItem,
            ClassifiedTextElement description,
            string detail,
            string documentation)
        {
            completionItem.Detail = detail;
            if (documentation != null)
            {
                completionItem.Documentation = new LSP.MarkupContent()
                {
                    Kind  = LSP.MarkupKind.PlainText,
                    Value = documentation
                };
            }

            completionItem.Description = description;
            return(completionItem);
        }