public static async Task <NavigateResponse> TranslateAsync(this NavigateResponse response, OmniSharpWorkspace workspace, Request request)
        {
            var(line, _) = await LineIndexHelper.TranslateFromGenerated(request.FileName, response.Line, workspace, true);

            response.Line = line;

            return(response);
        }
Exemple #2
0
        public async Task TranslateFromGenerated_Should_Translate_Index_In_Single_File(int index, int expected)
        {
            var fileName  = SingleCakePath;
            var workspace = CreateSimpleWorkspace(fileName, GetGeneratedFileContent(fileName));

            var(actualIndex, actualFileName) = await LineIndexHelper.TranslateFromGenerated(fileName, index, workspace, true);

            Assert.Equal(expected, actualIndex);
            Assert.Equal(GetGeneratedFileContent(fileName).Split('\n')[index],
                         GetFileContent(actualFileName).Split('\n')[actualIndex]);
        }
Exemple #3
0
        public async Task TranslateFromGenerated_Should_Translate_To_Negative_If_Outside_Bounds()
        {
            const int index     = 8207;
            const int expected  = -1;
            var       fileName  = SingleCakePath;
            var       workspace = CreateSimpleWorkspace(fileName, GetGeneratedFileContent(fileName));

            var(actualIndex, _) = await LineIndexHelper.TranslateFromGenerated(fileName, index, workspace, true);

            Assert.Equal(expected, actualIndex);
        }
        private static async Task <(string, LinePositionSpanTextChange)> TranslateAsync(this LinePositionSpanTextChange change, OmniSharpWorkspace workspace, string fileName)
        {
            var(line, newFileName) = await LineIndexHelper.TranslateFromGenerated(fileName, change.StartLine, workspace, false);

            change.StartLine = line;

            (line, _) = await LineIndexHelper.TranslateFromGenerated(fileName, change.EndLine, workspace, false);

            change.EndLine = line;

            return(newFileName, change);
        }
        private static async Task <Range> TranslateAsync(this Range range, OmniSharpWorkspace workspace, SimpleFileRequest request)
        {
            var(line, _) = await LineIndexHelper.TranslateFromGenerated(request.FileName, range.Start.Line, workspace, true);

            if (range.Start.Line == range.End.Line)
            {
                return(range with
                {
                    Start = range.Start with {
                        Line = line
                    },
                    End = range.End with {
                        Line = line
                    }
                });
        private static async Task <QuickFix> TranslateAsync(this QuickFix quickFix, OmniSharpWorkspace workspace, Request request)
        {
            var sameFile = string.IsNullOrEmpty(quickFix.FileName);
            var fileName = !sameFile ? quickFix.FileName : request.FileName;

            if (string.IsNullOrEmpty(fileName))
            {
                return(quickFix);
            }

            var(line, newFileName) = await LineIndexHelper.TranslateFromGenerated(fileName, quickFix.Line, workspace, sameFile);

            quickFix.Line     = line;
            quickFix.FileName = newFileName;

            (line, _) = await LineIndexHelper.TranslateFromGenerated(fileName, quickFix.EndLine, workspace, sameFile);

            quickFix.EndLine = line;

            return(quickFix);
        }