public async Task CheckDefinitionLocations(int pos, int length, params LocationInfo[] expectedLocations) { var entry = (AnalysisEntry)_view.GetAnalysisEntry(); entry.Analyzer.WaitForCompleteAnalysis(_ => true); var trackingSpan = _view.CurrentSnapshot.CreateTrackingSpan(pos, length, SpanTrackingMode.EdgeInclusive); var snapshotSpan = trackingSpan.GetSpan(_view.CurrentSnapshot); Console.WriteLine("Finding definition of \"{0}\"", snapshotSpan.GetText()); var actualLocations = await NavigableSymbolSource.GetDefinitionLocationsAsync(entry, snapshotSpan.Start); Console.WriteLine($"Actual locations for pos={pos}, length={length}:"); foreach (var actualLocation in actualLocations) { Console.WriteLine($"file={actualLocation.Location.DocumentUri},line={actualLocation.Location.StartLine},col={actualLocation.Location.StartColumn}"); } // Check that any real locations are not our test files. These may be included in debug builds, // but we don't want to be testing them. // Fake paths are from our tests, so always include them. actualLocations = actualLocations .Where(v => !File.Exists(v.Location.FilePath) || !PathUtils.IsSubpathOf(PathUtils.GetParent(typeof(IAnalysisVariable).Assembly.Location), v.Location.FilePath)) .ToArray(); if (expectedLocations != null) { Assert.IsNotNull(actualLocations); Assert.AreEqual(expectedLocations.Length, actualLocations.Length, "incorrect number of locations"); for (int i = 0; i < expectedLocations.Length; i++) { Assert.AreEqual(expectedLocations[i].StartLine, actualLocations[i].Location.StartLine, "incorrect line"); Assert.AreEqual(expectedLocations[i].StartColumn, actualLocations[i].Location.StartColumn, "incorrect column"); if (expectedLocations[i].FilePath != null) { Assert.AreEqual(expectedLocations[i].FilePath, Path.GetFileName(actualLocations[i].Location.FilePath)); } } } else { Assert.AreEqual(0, actualLocations.Length, "incorrect number of locations"); } }
private async Task <IPeekableItem> GetPeekableItemAsync(IPeekResultFactory peekResultFactory, ITextBuffer buffer, SnapshotPoint pt) { var entry = buffer.TryGetAnalysisEntry(); if (entry == null) { return(null); } var result = await NavigableSymbolSource.GetDefinitionLocationsAsync(entry, pt).ConfigureAwait(false); if (result.Length > 0) { return(new PythonPeekableItem(peekResultFactory, result)); } return(null); }
public async Task CheckDefinitionLocations(int pos, int length, params LocationInfo[] expectedLocations) { var entry = (AnalysisEntry)_view.GetAnalysisEntry(); entry.Analyzer.WaitForCompleteAnalysis(_ => true); var trackingSpan = _view.CurrentSnapshot.CreateTrackingSpan(pos, length, SpanTrackingMode.EdgeInclusive); var snapshotSpan = trackingSpan.GetSpan(_view.CurrentSnapshot); Console.WriteLine("Finding definition of \"{0}\"", snapshotSpan.GetText()); var actualLocations = await NavigableSymbolSource.GetDefinitionLocationsAsync(entry, snapshotSpan.Start); if (expectedLocations != null) { Assert.IsNotNull(actualLocations); Console.WriteLine($"Actual locations for pos={pos}, length={length}:"); foreach (var actualLocation in actualLocations) { Console.WriteLine($"file={actualLocation.Location.DocumentUri},line={actualLocation.Location.StartLine},col={actualLocation.Location.StartColumn}"); } Assert.AreEqual(expectedLocations.Length, actualLocations.Length, "incorrect number of locations"); for (int i = 0; i < expectedLocations.Length; i++) { Assert.AreEqual(expectedLocations[i].StartLine, actualLocations[i].Location.StartLine, "incorrect line"); Assert.AreEqual(expectedLocations[i].StartColumn, actualLocations[i].Location.StartColumn, "incorrect column"); if (expectedLocations[i].FilePath != null) { Assert.AreEqual(expectedLocations[i].FilePath, Path.GetFileName(actualLocations[i].Location.FilePath)); } } } else { Assert.AreEqual(0, actualLocations.Length, "incorrect number of locations"); } }
public async Task CheckDefinitionLocations(int pos, int length, params AnalysisLocation[] expectedLocations) { var entry = (AnalysisEntry)_view.GetAnalysisEntry(); entry.Analyzer.WaitForCompleteAnalysis(_ => true); var trackingSpan = _view.CurrentSnapshot.CreateTrackingSpan(pos, length, SpanTrackingMode.EdgeInclusive); var snapshotSpan = trackingSpan.GetSpan(_view.CurrentSnapshot); var actualLocations = await NavigableSymbolSource.GetDefinitionLocationsAsync(entry, snapshotSpan.Start); if (expectedLocations != null) { Assert.IsNotNull(actualLocations); Console.WriteLine($"Actual locations for pos={pos}, length={length}:"); foreach (var actualLocation in actualLocations) { Console.WriteLine($"{actualLocation.Line}, {actualLocation.Column}"); } Assert.AreEqual(expectedLocations.Length, actualLocations.Length); for (int i = 0; i < expectedLocations.Length; i++) { Assert.AreEqual(expectedLocations[i].Line, actualLocations[i].Line); Assert.AreEqual(expectedLocations[i].Column, actualLocations[i].Column); if (expectedLocations[i].FilePath != null) { Assert.AreEqual(expectedLocations[i].FilePath, Path.GetFileName(actualLocations[i].FilePath)); } } } else { Assert.AreEqual(0, actualLocations.Length); } }