private protected static async Task <LSP.SemanticTokens> RunGetSemanticTokensAsync(TestLspServer testLspServer, LSP.Location caret)
        {
            var result = await testLspServer.ExecuteRequestAsync <LSP.SemanticTokensParams, LSP.SemanticTokens>(LSP.Methods.TextDocumentSemanticTokensFullName,
                                                                                                                CreateSemanticTokensParams(caret), new LSP.VSInternalClientCapabilities(), null, CancellationToken.None);

            Contract.ThrowIfNull(result);
            return(result);
        }
        private static async Task <LSP.VSReferenceItem[]> RunFindAllReferencesAsync(Solution solution, LSP.Location caret)
        {
            var vsClientCapabilities = new LSP.VSClientCapabilities
            {
                SupportsVisualStudioExtensions = true
            };

            var queue = CreateRequestQueue(solution);

            return(await GetLanguageServer(solution).ExecuteRequestAsync <LSP.ReferenceParams, LSP.VSReferenceItem[]>(queue, LSP.Methods.TextDocumentReferencesName,
                                                                                                                      CreateReferenceParams(caret), vsClientCapabilities, null, CancellationToken.None));
        }
 private static async Task <LSP.TextEdit[]> RunFormatDocumentRangeAsync(Solution solution, LSP.Location location)
 => await GetLanguageServer(solution).FormatDocumentRangeAsync(solution, CreateDocumentRangeFormattingParams(location), new LSP.ClientCapabilities(), CancellationToken.None);
Beispiel #4
0
        private static async Task <LSP.TextEdit[]> RunFormatDocumentRangeAsync(Solution solution, LSP.Location location)
        {
            var queue = CreateRequestQueue(solution);

            return(await GetLanguageServer(solution).ExecuteRequestAsync <LSP.DocumentRangeFormattingParams, LSP.TextEdit[]>(queue, LSP.Methods.TextDocumentRangeFormattingName,
                                                                                                                             CreateDocumentRangeFormattingParams(location), new LSP.ClientCapabilities(), null, CancellationToken.None));
        }
Beispiel #5
0
        private static async Task <LSP.DocumentHighlight[]> RunGetDocumentHighlightAsync(Solution solution, LSP.Location caret)
        {
            var queue   = CreateRequestQueue(solution);
            var results = await GetLanguageServer(solution).ExecuteRequestAsync <LSP.TextDocumentPositionParams, LSP.DocumentHighlight[]>(queue, LSP.Methods.TextDocumentDocumentHighlightName,
                                                                                                                                          CreateTextDocumentPositionParams(caret), new LSP.ClientCapabilities(), null, CancellationToken.None);

            Array.Sort(results, (h1, h2) =>
            {
                var compareKind  = h1.Kind.CompareTo(h2.Kind);
                var compareRange = CompareRange(h1.Range, h2.Range);
                return(compareKind != 0 ? compareKind : compareRange);
            });

            return(results);
        }
Beispiel #6
0
 private static async Task <object> RunGetCompletionsAsync(Solution solution, LSP.Location caret, LSP.ClientCapabilities clientCapabilities = null)
 => await GetLanguageServer(solution).GetCompletionsAsync(solution, CreateCompletionParams(caret), clientCapabilities, CancellationToken.None);
 private static async Task <LSP.TextEdit[]> RunFormatDocumentOnTypeAsync(Solution solution, string characterTyped, LSP.Location locationTyped)
 => await GetLanguageServer(solution)
 .FormatDocumentOnTypeAsync(solution, CreateDocumentOnTypeFormattingParams(characterTyped, locationTyped), new LSP.ClientCapabilities(), CancellationToken.None);
 private static async Task <LSP.Location[]> RunFindImplementationAsync(Solution solution, LSP.Location caret)
 => await GetLanguageServer(solution).ExecuteRequestAsync <LSP.TextDocumentPositionParams, LSP.Location[]>(LSP.Methods.TextDocumentImplementationName,
                                                                                                           solution, CreateTextDocumentPositionParams(caret), new LSP.ClientCapabilities(), null, CancellationToken.None);
        internal static LSP.SymbolInformation CreateSymbolInformation(LSP.SymbolKind kind, string name, LSP.Location location, Glyph glyph, string?containerName = null)
        {
            var info = new LSP.VSSymbolInformation()
            {
                Kind     = kind,
                Name     = name,
                Location = location,
                Icon     = VSLspExtensionConversions.GetImageIdFromGlyph(glyph)
            };

            if (containerName != null)
            {
                info.ContainerName = containerName;
            }

            return(info);
        }
 private static async Task <LSP.TextEdit[]> RunFormatDocumentRangeAsync(TestLspServer testLspServer, LSP.Location location)
 {
     return(await testLspServer.ExecuteRequestAsync <LSP.DocumentRangeFormattingParams, LSP.TextEdit[]>(LSP.Methods.TextDocumentRangeFormattingName,
                                                                                                        CreateDocumentRangeFormattingParams(location), new LSP.ClientCapabilities(), null, CancellationToken.None));
 }
Beispiel #11
0
 private static async Task <LSP.SignatureHelp> RunGetSignatureHelpAsync(Solution solution, LSP.Location caret)
 => await GetLanguageServer(solution).ExecuteRequestAsync <LSP.TextDocumentPositionParams, LSP.SignatureHelp>(LSP.Methods.TextDocumentSignatureHelpName,
                                                                                                              CreateTextDocumentPositionParams(caret), new LSP.ClientCapabilities(), null, CancellationToken.None);
 private protected static async Task <SumType <LSP.SemanticTokens, LSP.SemanticTokensDelta> > RunGetSemanticTokensEditsAsync(TestLspServer testLspServer, LSP.Location caret, string previousResultId)
 {
     return(await testLspServer.ExecuteRequestAsync <LSP.SemanticTokensDeltaParams, SumType <LSP.SemanticTokens, LSP.SemanticTokensDelta> >(LSP.Methods.TextDocumentSemanticTokensFullDeltaName,
                                                                                                                                            CreateSemanticTokensParams(caret, previousResultId), new LSP.VSInternalClientCapabilities(), null, CancellationToken.None));
 }
 private protected static async Task <LSP.SemanticTokens> RunGetSemanticTokensRangeAsync(TestLspServer testLspServer, LSP.Location caret, LSP.Range range)
 {
     return(await testLspServer.ExecuteRequestAsync <LSP.SemanticTokensRangeParams, LSP.SemanticTokens>(LSP.Methods.TextDocumentSemanticTokensRangeName,
                                                                                                        CreateSemanticTokensRangeParams(caret, range), new LSP.VSInternalClientCapabilities(), null, CancellationToken.None));
 }
Beispiel #14
0
        internal static async Task <LSP.VSInternalReferenceItem[]> RunFindAllReferencesAsync(TestLspServer testLspServer, LSP.Location caret, IProgress <object> progress = null)
        {
            var results = await testLspServer.ExecuteRequestAsync <LSP.ReferenceParams, LSP.VSInternalReferenceItem[]>(LSP.Methods.TextDocumentReferencesName,
                                                                                                                       CreateReferenceParams(caret, progress), CancellationToken.None);

            return(results?.Cast <LSP.VSInternalReferenceItem>()?.ToArray());
        }
Beispiel #15
0
 private static async Task <LSP.Location[]> RunGotoTypeDefinitionAsync(TestLspServer testLspServer, LSP.Location caret)
 {
     return(await testLspServer.ExecuteRequestAsync <LSP.TextDocumentPositionParams, LSP.Location[]>(LSP.Methods.TextDocumentTypeDefinitionName,
                                                                                                     CreateTextDocumentPositionParams(caret), new LSP.ClientCapabilities(), null, CancellationToken.None));
 }
Beispiel #16
0
        internal static LSP.SymbolInformation CreateSymbolInformation(LSP.SymbolKind kind, string name, LSP.Location location, Glyph glyph, string?containerName = null)
        {
            var info = new LSP.VSSymbolInformation()
            {
                Kind     = kind,
                Name     = name,
                Location = location,
                Icon     = new ImageElement(glyph.GetImageId()),
            };

            if (containerName != null)
            {
                info.ContainerName = containerName;
            }

            return(info);
        }
        private static async Task <LSP.Location[]> RunGotoDefinitionAsync(Solution solution, LSP.Location caret)
        {
            var queue = CreateRequestQueue(solution);

            return(await GetLanguageServer(solution).ExecuteRequestAsync <LSP.TextDocumentPositionParams, LSP.Location[]>(queue, LSP.Methods.TextDocumentDefinitionName,
                                                                                                                          CreateTextDocumentPositionParams(caret), new LSP.ClientCapabilities(), null, CancellationToken.None));
        }
Beispiel #18
0
 protected static LSP.TextDocumentPositionParams CreateTextDocumentPositionParams(LSP.Location caret, ProjectId?projectContext = null)
 => new LSP.TextDocumentPositionParams()
 {
     TextDocument = CreateTextDocumentIdentifier(caret.Uri, projectContext),
     Position     = caret.Range.Start
 };
Beispiel #19
0
 private static async Task <LSP.Command[]> RunCodeActionsAsync(Solution solution, LSP.Location caret, LSP.ClientCapabilities clientCapabilities = null)
 => (LSP.Command[]) await GetLanguageServer(solution).GetCodeActionsAsync(solution, CreateCodeActionParams(caret), clientCapabilities, CancellationToken.None);
Beispiel #20
0
 private protected static CodeActionResolveData CreateCodeActionResolveData(string uniqueIdentifier, LSP.Location location, IEnumerable <string>?customTags = null)
 => new CodeActionResolveData(uniqueIdentifier, customTags.ToImmutableArrayOrEmpty(), location.Range, CreateTextDocumentIdentifier(location.Uri));
 private static LSP.DocumentOnTypeFormattingParams CreateDocumentOnTypeFormattingParams(string characterTyped, LSP.Location locationTyped)
 => new LSP.DocumentOnTypeFormattingParams()
 {
     Position     = locationTyped.Range.Start,
     Character    = characterTyped,
     TextDocument = CreateTextDocumentIdentifier(locationTyped.Uri),
     Options      = new LSP.FormattingOptions()
     {
         // TODO - Format should respect formatting options.
     }
 };
Beispiel #22
0
        internal static async Task <LSP.VSInternalReferenceItem[]> RunFindAllReferencesAsync(TestLspServer testLspServer, LSP.Location caret, IProgress <object> progress = null)
        {
            var vsClientCapabilities = new LSP.VSInternalClientCapabilities
            {
                SupportsVisualStudioExtensions = true
            };

            var results = await testLspServer.ExecuteRequestAsync <LSP.ReferenceParams, LSP.VSInternalReferenceItem[]>(LSP.Methods.TextDocumentReferencesName,
                                                                                                                       CreateReferenceParams(caret, progress), vsClientCapabilities, null, CancellationToken.None);

            return(results?.Cast <LSP.VSInternalReferenceItem>()?.ToArray());
        }
        private protected static async Task <LSP.SemanticTokens> RunGetSemanticTokensRangeAsync(TestLspServer testLspServer, LSP.Location caret, LSP.Range range)
        {
            var result = await testLspServer.ExecuteRequestAsync <LSP.SemanticTokensRangeParams, LSP.SemanticTokens>(LSP.Methods.TextDocumentSemanticTokensRangeName,
                                                                                                                     CreateSemanticTokensRangeParams(caret, range), CancellationToken.None);

            Contract.ThrowIfNull(result);
            return(result);
        }
Beispiel #24
0
 private static async Task <LSP.Location[]> RunGotoDefinitionAsync(Solution solution, LSP.Location caret)
 => (LSP.Location[]) await GetLanguageServer(solution).GoToDefinitionAsync(solution, CreateTextDocumentPositionParams(caret), new LSP.ClientCapabilities(), CancellationToken.None);
Beispiel #25
0
 private static LSP.DocumentHighlight CreateDocumentHighlight(LSP.DocumentHighlightKind kind, LSP.Location location)
 => new LSP.DocumentHighlight()
 {
     Kind  = kind,
     Range = location.Range
 };
Beispiel #26
0
        private static async Task <LSP.DocumentOnAutoInsertResponseItem?> RunOnAutoInsertAsync(Solution solution, string characterTyped, LSP.Location locationTyped)
        {
            var queue = CreateRequestQueue(solution);

            return(await GetLanguageServer(solution).ExecuteRequestAsync <LSP.DocumentOnAutoInsertParams, LSP.DocumentOnAutoInsertResponseItem?>(queue, MSLSPMethods.OnAutoInsertName,
                                                                                                                                                 CreateDocumentOnAutoInsertParams(characterTyped, locationTyped), new LSP.ClientCapabilities(), null, CancellationToken.None));
        }
Beispiel #27
0
        private static LSP.DocumentSymbol CreateDocumentSymbol(LSP.SymbolKind kind, string name, string detail,
                                                               LSP.Location location, LSP.Location selection, LSP.DocumentSymbol parent = null)
        {
            var documentSymbol = new LSP.DocumentSymbol()
            {
                Kind           = kind,
                Name           = name,
                Range          = location.Range,
                Children       = new LSP.DocumentSymbol[0],
                Detail         = detail,
                Deprecated     = false,
                SelectionRange = selection.Range
            };

            if (parent != null)
            {
                var children = parent.Children.ToList();
                children.Add(documentSymbol);
                parent.Children = children.ToArray();
            }

            return(documentSymbol);
        }
Beispiel #28
0
 private static LSP.DocumentOnAutoInsertParams CreateDocumentOnAutoInsertParams(string characterTyped, LSP.Location locationTyped)
 => new LSP.DocumentOnAutoInsertParams()
 {
     Position     = locationTyped.Range.Start,
     Character    = characterTyped,
     TextDocument = CreateTextDocumentIdentifier(locationTyped.Uri)
 };
 private static LSP.DocumentRangeFormattingParams CreateDocumentRangeFormattingParams(LSP.Location location)
 => new LSP.DocumentRangeFormattingParams()
 {
     Range        = location.Range,
     TextDocument = CreateTextDocumentIdentifier(location.Uri),
     Options      = new LSP.FormattingOptions()
     {
         // TODO - Format should respect formatting options.
     }
 };
Beispiel #30
0
 private static async Task <WorkspaceEdit> RunRenameAsync(Solution solution, LSP.Location renameLocation, string renamevalue)
 => await GetLanguageServer(solution).ExecuteRequestAsync <LSP.RenameParams, LSP.WorkspaceEdit>(LSP.Methods.TextDocumentRenameName,
                                                                                                solution, CreateRenameParams(renameLocation, renamevalue), new LSP.ClientCapabilities(), null, CancellationToken.None);