private IEnumerable<ModifiedFileResponse> Rename(string renameTo, params Buffer[] buffers)
        {
            RenameRequest request = null;
            var solutionBuilder = new FakeSolutionBuilder();
            foreach (var buffer in buffers)
            {
                if (buffer.Text.Contains("$"))
                {
                    var location = TestHelpers.GetLineAndColumnFromDollar(buffer.Text);
                    buffer.Text = buffer.Text.Replace("$", "");
                    request = new RenameRequest
                    {
                        Buffer = buffer.Text,
                        Column = location.Column - 1,
                        Line = location.Line,
                        RenameTo = renameTo,
                        FileName = buffer.Filename
                    };
                }
                //solutionBuilder = solutionBuilder.AddProject();
                solutionBuilder = solutionBuilder.AddFile(buffer.Text, buffer.Filename);
            }
            var solution = solutionBuilder.Build();
            var bufferParser = new BufferParser(solution);
            var renameHandler = new RenameHandler(solution, bufferParser, new OmniSharpConfiguration());

            var response = renameHandler.Rename(request);
            return response.Changes;
        }
        private string Rename(string buffer, string renameTo)
        {
            var location = TestHelpers.GetLineAndColumnFromDollar(buffer);
            buffer = buffer.Replace("$", "");
            
            var solution = new FakeSolutionBuilder()
                .AddFile(buffer)
                .Build();
            
            var bufferParser = new BufferParser(solution);
            var renameHandler = new RenameHandler(solution, bufferParser, new OmniSharpConfiguration(), new FindUsagesHandler(bufferParser, solution, new ProjectFinder(solution)));
            var request = new RenameRequest
                {
                    Buffer = buffer,
                    Column = location.Column - 1,
                    Line = location.Line,
                    RenameTo = renameTo,
                    FileName = "myfile"
                };

            var response = renameHandler.Rename(request);
            if(response.Changes.Any())
                return response.Changes.First().Buffer;
            return buffer;
        }
示例#3
0
 public RenameModule(RenameHandler renameHandler)
 {
     Post["Rename", "/rename"] = x =>
     {
         var req    = this.Bind <RenameRequest>();
         var usages = renameHandler.Rename(req);
         return(Response.AsJson(usages));
     };
 }
示例#4
0
 public RenameModule(RenameHandler renameHandler)
 {
     Post["Rename", "/rename"] = x =>
     {
         var req = this.Bind<RenameRequest>();
         var usages = renameHandler.Rename(req);
         return Response.AsJson(usages);
     };
 }