public async Task TestGotoDefinitionAsync_MappedFile() { var markup = @"class A { string aString = 'hello'; void M() { var len = aString.Length; } }"; using var testLspServer = await CreateTestLspServerAsync(string.Empty); AddMappedDocument(testLspServer.TestWorkspace, markup); var position = new LSP.Position { Line = 5, Character = 18 }; var results = await RunGotoDefinitionAsync(testLspServer, new LSP.Location { Uri = new Uri($"C:\\{TestSpanMapper.GeneratedFileName}"), Range = new LSP.Range { Start = position, End = position } }); AssertLocationsEqual(ImmutableArray.Create(TestSpanMapper.MappedFileLocation), results); }
public async Task TestFindImplementationAsync_MappedFile() { var markup = @"interface IA { void M(); } class A : IA { void IA.M() { } }"; using var testLspServer = await CreateTestLspServerAsync(string.Empty); AddMappedDocument(testLspServer.TestWorkspace, markup); var position = new LSP.Position { Line = 2, Character = 9 }; var results = await RunFindImplementationAsync(testLspServer, new LSP.Location { Uri = new Uri($"C:\\{TestSpanMapper.GeneratedFileName}"), Range = new LSP.Range { Start = position, End = position } }); AssertLocationsEqual(ImmutableArray.Create(TestSpanMapper.MappedFileLocation), results); }
public LSP.Position GetDocumentPosition(LSP.Position currentCellPos) { return(new LSP.Position { Line = currentCellPos.Line + _previousCellsLineCount, Character = currentCellPos.Character, }); }
public async Task TestRename_WithMappedFileAsync() { var markup = @"class A { void M() { } void M2() { M() } }"; using var testLspServer = CreateTestLspServer(string.Empty, out _); AddMappedDocument(testLspServer.TestWorkspace, markup); var startPosition = new LSP.Position { Line = 2, Character = 9 }; var endPosition = new LSP.Position { Line = 2, Character = 10 }; var renameText = "RENAME"; var renameParams = CreateRenameParams( new LSP.Location { Uri = new Uri($"C:\\{TestSpanMapper.GeneratedFileName}"), Range = new LSP.Range { Start = startPosition, End = endPosition } }, "RENAME" ); var results = await RunRenameAsync(testLspServer, renameParams); // There are two rename locations, so we expect two mapped locations. var expectedMappedRanges = ImmutableArray.Create( TestSpanMapper.MappedFileLocation.Range, TestSpanMapper.MappedFileLocation.Range ); var expectedMappedDocument = TestSpanMapper.MappedFileLocation.Uri; var documentEdit = results.DocumentChanges.Value.First.Single(); Assert.Equal(expectedMappedDocument, documentEdit.TextDocument.Uri); Assert.Equal(expectedMappedRanges, documentEdit.Edits.Select(edit => edit.Range)); Assert.True(documentEdit.Edits.All(edit => edit.NewText == renameText)); }
static LSP.Location GetLocationPlusOne(LSP.Location originalLocation) { var newPosition = new LSP.Position { Character = originalLocation.Range.Start.Character + 1, Line = originalLocation.Range.Start.Line }; return(new LSP.Location { Uri = originalLocation.Uri, Range = new LSP.Range { Start = newPosition, End = newPosition } }); }
public async Task <object> GetCompletions(LSP.Position position, LSP.CompletionContext context, CancellationToken token) { var completionParams = new LSP.CompletionParams() { TextDocument = new LSP.TextDocumentIdentifier() { Uri = DocumentUri, }, Position = GetDocumentPosition(position), Context = context, }; var res = await _client.InvokeTextDocumentCompletionAsync(completionParams, token); return(res); }
public async Task <object> GetAnalysisCompletions(LSP.Position position, LSP.CompletionContext context, CancellationToken token) { return((await(_evaluator as IPythonInteractiveIntellisense)?.GetAnalysisCompletions(position, context, token)) ?? Array.Empty <LSP.CompletionItem>()); }
public static LinePosition PositionToLinePosition(LSP.Position position) { return(new LinePosition(position.Line, position.Character)); }
public static LinePosition PositionToLinePosition(LSP.Position position) => new LinePosition(position.Line, position.Character);
public Task <object> GetAnalysisCompletions(LSP.Position triggerPoint, LSP.CompletionContext context, CancellationToken token) { // No analysis completions for debug repl return(Task.FromResult <object>(null)); }
internal static SnapshotPoint GetSnapshotPositionFromProtocolPosition(this ITextSnapshot textSnapshot, LSP.Position position) { var snapshotPosition = textSnapshot.GetLineFromLineNumber(position.Line).Start + position.Character; return(new SnapshotPoint(textSnapshot, snapshotPosition)); }