{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls/comments/65393900","id":65393900,"diff_hunk":"@@ -0,0 +1,145 @@\n+﻿// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.\n+using System;\n+using System.IO;\n+using System.Linq;\n+using Microsoft.CodeAnalysis;\n+using Microsoft.CodeAnalysis.CSharp;\n+using Microsoft.CodeAnalysis.Editing;\n+using Microsoft.VisualStudio.LanguageServices;\n+using Microsoft.VisualStudio.Shell;\n+using Microsoft.VisualStudio.Shell.Interop;\n+using RoslyRenamer = Microsoft.CodeAnalysis.Rename;\n+\n+namespace Microsoft.VisualStudio.ProjectSystem.VS\n+{\n+    internal class Renamer\n+    {\n+        private readonly VisualStudioWorkspace _visualStudioWorkspace;\n+        private readonly IProjectThreadingService _threadingService;\n+        private readonly SVsServiceProvider _serviceProvider;\n+        private readonly Project _project;\n+        private readonly Document _oldDocument;\n+        private readonly string _newFilePath;\n+        private bool _docAdded = false;\n+        private bool _docRemoved = false;\n+        private bool _docChanged = false;\n+\n+        internal Renamer(VisualStudioWorkspace visualStudioWorkspace,\n+                         SVsServiceProvider serviceProvider,\n+                         IProjectThreadingService threadingService,\n+                         Project project,\n+                         string newFilePath,\n+                         string oldFilePath)\n+        {\n+            _visualStudioWorkspace = visualStudioWorkspace;\n+            _serviceProvider = serviceProvider;\n+            _threadingService = threadingService;\n+            _project = project;\n+            _newFilePath = newFilePath;\n+            _oldDocument = (from d in project.Documents where d.FilePath.Equals(oldFilePath, StringComparison.OrdinalIgnoreCase) select d).FirstOrDefault();\n+        }\n+\n+        public void OnWorkspaceChanged(object sender, WorkspaceChangeEventArgs args)\n+        {\n+            if (args.Kind == WorkspaceChangeKind.DocumentAdded && args.ProjectId == _project.Id)\n+            {\n+                Project project = (from p in args.NewSolution.Projects where p.Id.Equals(_project.Id) select p).FirstOrDefault();\n+                Document addedDocument = (from d in project.Documents where d.Id.Equals(args.DocumentId) select d).FirstOrDefault();\n+                if (addedDocument.FilePath.Equals(_newFilePath, StringComparison.OrdinalIgnoreCase))\n+                {\n+                    _docAdded = true;\n+                }\n+            }\n+\n+            if (args.Kind == WorkspaceChangeKind.DocumentRemoved && args.ProjectId == _project.Id && args.DocumentId == _oldDocument.Id)\n+            {\n+                _docRemoved = true;\n+            }\n+\n+            if (args.Kind == WorkspaceChangeKind.DocumentChanged && args.ProjectId == _project.Id)\n+            {\n+                _docChanged = true;\n+            }\n+\n+            if (_docAdded && _docRemoved && _docChanged)\n+            {\n+                _visualStudioWorkspace.WorkspaceChanged -= OnWorkspaceChanged;\n+\n+                _threadingService.JoinableTaskFactory.RunAsync(async () =>\n+                {\n+                    var myNewProject = _visualStudioWorkspace.CurrentSolution.Projects.Where(p => string.Equals(p.FilePath, _project.FilePath, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();\n+                    Document newDocument = (from d in myNewProject.Documents where d.FilePath.Equals(_newFilePath, StringComparison.OrdinalIgnoreCase) select d).FirstOrDefault();\n+                    if (newDocument == null)\n+                        return;\n+\n+                    var root = await newDocument.GetSyntaxRootAsync().ConfigureAwait(false);\n+                    if (root == null)\n+                        return;\n+\n+                    string oldName = Path.GetFileNameWithoutExtension(_oldDocument.FilePath);\n+                    string newName = Path.GetFileNameWithoutExtension(newDocument.FilePath);\n+\n+                    var declaration = root.DescendantNodes().Where(n => HasMatchingSyntaxNode(newDocument, n, oldName)).FirstOrDefault();\n+                    if (declaration == null)\n+                        return;\n+\n+                    var semanticModel = await newDocument.GetSemanticModelAsync().ConfigureAwait(false);\n+                    if (semanticModel == null)\n+                        return;\n+\n+                    var symbol = semanticModel.GetDeclaredSymbol(declaration);\n+                    if (symbol == null)\n+                        return;\n+\n+                    // We're about to do a symbolic rename.If the user has asked us to prompt, We need to open a dialog and ask them  ","path":"src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Renamer.cs","position":94,"original_position":94,"commit_id":"f0c334f44efed161f7b6d1aedcaadfc9f0de3469","original_commit_id":"f0c334f44efed161f7b6d1aedcaadfc9f0de3469","user":{"login":"davkean","id":1103906,"avatar_url":"https://avatars.githubusercontent.com/u/1103906?v=3","gravatar_id":"","url":"https://api.github.com/users/davkean","html_url":"https://github.com/davkean","followers_url":"https://api.github.com/users/davkean/followers","following_url":"https://api.github.com/users/davkean/following{/other_user}","gists_url":"https://api.github.com/users/davkean/gists{/gist_id}","starred_url":"https://api.github.com/users/davkean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davkean/subscriptions","organizations_url":"https://api.github.com/users/davkean/orgs","repos_url":"https://api.github.com/users/davkean/repos","events_url":"https://api.github.com/users/davkean/events{/privacy}","received_events_url":"https://api.github.com/users/davkean/received_events","type":"User","site_admin":false},"body":"Below this line should be done on the UI thread","created_at":"2016-06-01T16:19:21Z","updated_at":"2016-06-01T16:19:21Z","html_url":"https://github.com/dotnet/roslyn-project-system/pull/207#discussion_r65393900","pull_request_url":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls/207","_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls/comments/65393900"},"html":{"href":"https://github.com/dotnet/roslyn-project-system/pull/207#discussion_r65393900"},"pull_request":{"href":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls/207"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls/207","id":72132600,"html_url":"https://github.com/dotnet/roslyn-project-system/pull/207","diff_url":"https://github.com/dotnet/roslyn-project-system/pull/207.diff","patch_url":"https://github.com/dotnet/roslyn-project-system/pull/207.patch","issue_url":"https://api.github.com/repos/dotnet/roslyn-project-system/issues/207","number":207,"state":"open","locked":false,"title":"Renaming file should rename class","user":{"login":"jinujoseph","id":12449387,"avatar_url":"https://avatars.githubusercontent.com/u/12449387?v=3","gravatar_id":"","url":"https://api.github.com/users/jinujoseph","html_url":"https://github.com/jinujoseph","followers_url":"https://api.github.com/users/jinujoseph/followers","following_url":"https://api.github.com/users/jinujoseph/following{/other_user}","gists_url":"https://api.github.com/users/jinujoseph/gists{/gist_id}","starred_url":"https://api.github.com/users/jinujoseph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jinujoseph/subscriptions","organizations_url":"https://api.github.com/users/jinujoseph/orgs","repos_url":"https://api.github.com/users/jinujoseph/repos","events_url":"https://api.github.com/users/jinujoseph/events{/privacy}","received_events_url":"https://api.github.com/users/jinujoseph/received_events","type":"User","site_admin":false},"body":"Addresses part of #109.\r\n\r\nCurrently since there isn't an event to listen which indicates a rename of file completion,  Listening to workspacechange event. Will have to come back and put the right events.\r\n\r\nThis addresses the first requirement that the namespace needn't have to follow folder structure.\r\n ","created_at":"2016-06-01T07:11:21Z","updated_at":"2016-06-01T16:19:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"62013dbef36f0210562467045d03edc26b67bef6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls/207/commits","review_comments_url":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls/207/comments","review_comment_url":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/roslyn-project-system/issues/207/comments","statuses_url":"https://api.github.com/repos/dotnet/roslyn-project-system/statuses/f0c334f44efed161f7b6d1aedcaadfc9f0de3469","head":{"label":"jinujoseph:Rename","ref":"Rename","sha":"f0c334f44efed161f7b6d1aedcaadfc9f0de3469","user":{"login":"jinujoseph","id":12449387,"avatar_url":"https://avatars.githubusercontent.com/u/12449387?v=3","gravatar_id":"","url":"https://api.github.com/users/jinujoseph","html_url":"https://github.com/jinujoseph","followers_url":"https://api.github.com/users/jinujoseph/followers","following_url":"https://api.github.com/users/jinujoseph/following{/other_user}","gists_url":"https://api.github.com/users/jinujoseph/gists{/gist_id}","starred_url":"https://api.github.com/users/jinujoseph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jinujoseph/subscriptions","organizations_url":"https://api.github.com/users/jinujoseph/orgs","repos_url":"https://api.github.com/users/jinujoseph/repos","events_url":"https://api.github.com/users/jinujoseph/events{/privacy}","received_events_url":"https://api.github.com/users/jinujoseph/received_events","type":"User","site_admin":false},"repo":{"id":58006616,"name":"roslyn-project-system","full_name":"jinujoseph/roslyn-project-system","owner":{"login":"jinujoseph","id":12449387,"avatar_url":"https://avatars.githubusercontent.com/u/12449387?v=3","gravatar_id":"","url":"https://api.github.com/users/jinujoseph","html_url":"https://github.com/jinujoseph","followers_url":"https://api.github.com/users/jinujoseph/followers","following_url":"https://api.github.com/users/jinujoseph/following{/other_user}","gists_url":"https://api.github.com/users/jinujoseph/gists{/gist_id}","starred_url":"https://api.github.com/users/jinujoseph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jinujoseph/subscriptions","organizations_url":"https://api.github.com/users/jinujoseph/orgs","repos_url":"https://api.github.com/users/jinujoseph/repos","events_url":"https://api.github.com/users/jinujoseph/events{/privacy}","received_events_url":"https://api.github.com/users/jinujoseph/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jinujoseph/roslyn-project-system","description":"The C# and Visual Basic project system for Visual Studio \"15\"","fork":true,"url":"https://api.github.com/repos/jinujoseph/roslyn-project-system","forks_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/forks","keys_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/teams","hooks_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/hooks","issue_events_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/issues/events{/number}","events_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/events","assignees_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/assignees{/user}","branches_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/branches{/branch}","tags_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/tags","blobs_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/git/refs{/sha}","trees_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/statuses/{sha}","languages_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/languages","stargazers_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/stargazers","contributors_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/contributors","subscribers_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/subscribers","subscription_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/subscription","commits_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/commits{/sha}","git_commits_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/git/commits{/sha}","comments_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/comments{/number}","issue_comment_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/issues/comments{/number}","contents_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/contents/{+path}","compare_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/merges","archive_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/downloads","issues_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/issues{/number}","pulls_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/pulls{/number}","milestones_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/milestones{/number}","notifications_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/labels{/name}","releases_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/releases{/id}","deployments_url":"https://api.github.com/repos/jinujoseph/roslyn-project-system/deployments","created_at":"2016-05-03T22:53:29Z","updated_at":"2016-05-03T22:53:31Z","pushed_at":"2016-06-01T08:58:19Z","git_url":"git://github.com/jinujoseph/roslyn-project-system.git","ssh_url":"git@github.com:jinujoseph/roslyn-project-system.git","clone_url":"https://github.com/jinujoseph/roslyn-project-system.git","svn_url":"https://github.com/jinujoseph/roslyn-project-system","homepage":null,"size":82728,"stargazers_count":0,"watchers_count":0,"language":"Batchfile","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"dcb4404831fb662830cca22c70e6591e630dc0aa","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":56740275,"name":"roslyn-project-system","full_name":"dotnet/roslyn-project-system","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/roslyn-project-system","description":"The C# and Visual Basic project system for Visual Studio \"15\"","fork":false,"url":"https://api.github.com/repos/dotnet/roslyn-project-system","forks_url":"https://api.github.com/repos/dotnet/roslyn-project-system/forks","keys_url":"https://api.github.com/repos/dotnet/roslyn-project-system/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/roslyn-project-system/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/roslyn-project-system/teams","hooks_url":"https://api.github.com/repos/dotnet/roslyn-project-system/hooks","issue_events_url":"https://api.github.com/repos/dotnet/roslyn-project-system/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/roslyn-project-system/events","assignees_url":"https://api.github.com/repos/dotnet/roslyn-project-system/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/roslyn-project-system/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/roslyn-project-system/tags","blobs_url":"https://api.github.com/repos/dotnet/roslyn-project-system/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/roslyn-project-system/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/roslyn-project-system/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/roslyn-project-system/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/roslyn-project-system/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/roslyn-project-system/languages","stargazers_url":"https://api.github.com/repos/dotnet/roslyn-project-system/stargazers","contributors_url":"https://api.github.com/repos/dotnet/roslyn-project-system/contributors","subscribers_url":"https://api.github.com/repos/dotnet/roslyn-project-system/subscribers","subscription_url":"https://api.github.com/repos/dotnet/roslyn-project-system/subscription","commits_url":"https://api.github.com/repos/dotnet/roslyn-project-system/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/roslyn-project-system/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/roslyn-project-system/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/roslyn-project-system/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/roslyn-project-system/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/roslyn-project-system/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/roslyn-project-system/merges","archive_url":"https://api.github.com/repos/dotnet/roslyn-project-system/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/roslyn-project-system/downloads","issues_url":"https://api.github.com/repos/dotnet/roslyn-project-system/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/roslyn-project-system/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/roslyn-project-system/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/roslyn-project-system/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/roslyn-project-system/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/roslyn-project-system/deployments","created_at":"2016-04-21T03:40:18Z","updated_at":"2016-06-01T03:30:59Z","pushed_at":"2016-06-01T08:58:20Z","git_url":"git://github.com/dotnet/roslyn-project-system.git","ssh_url":"git@github.com:dotnet/roslyn-project-system.git","clone_url":"https://github.com/dotnet/roslyn-project-system.git","svn_url":"https://github.com/dotnet/roslyn-project-system","homepage":null,"size":4756,"stargazers_count":96,"watchers_count":96,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":131,"forks":12,"open_issues":131,"watchers":96,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls/207"},"html":{"href":"https://github.com/dotnet/roslyn-project-system/pull/207"},"issue":{"href":"https://api.github.com/repos/dotnet/roslyn-project-system/issues/207"},"comments":{"href":"https://api.github.com/repos/dotnet/roslyn-project-system/issues/207/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls/207/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/roslyn-project-system/pulls/207/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/roslyn-project-system/statuses/f0c334f44efed161f7b6d1aedcaadfc9f0de3469"}}}}
{"actor":{"display_login":"davkean"}}