{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/58433906","id":58433906,"diff_hunk":"@@ -0,0 +1,104 @@\n+﻿using System;\n+using System.Collections.Generic;\n+using System.Collections.Immutable;\n+using System.Threading;\n+using System.Threading.Tasks;\n+using Microsoft.CodeAnalysis.CodeActions;\n+using Microsoft.CodeAnalysis.CodeFixes;\n+using Microsoft.CodeAnalysis.Diagnostics;\n+using Microsoft.CodeAnalysis.Editing;\n+using Microsoft.CodeAnalysis.Text;\n+\n+namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.PopulateSwitch\n+{\n+    internal abstract class AbstractPopulateSwitchCodeFixProvider : CodeFixProvider\n+    {\n+        public override ImmutableArray<string> FixableDiagnosticIds => ImmutableArray.Create(IDEDiagnosticIds.PopulateSwitchDiagnosticId);\n+\n+        public override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer;\n+\n+        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)\n+        {\n+            var document = context.Document;\n+            var span = context.Span;\n+            var cancellationToken = context.CancellationToken;\n+\n+            var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);\n+            var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);\n+            var node = GetSwitchStatementNode(root, span);\n+            if (node == null)\n+            {\n+                return;\n+            }\n+\n+            context.RegisterCodeFix(\n+                new MyCodeAction(\n+                    FeaturesResources.AddSwitchLabels,\n+                    c => AddMissingSwitchLabelsAsync(model, document, root, node)),\n+                context.Diagnostics);\n+        }\n+\n+        protected abstract SyntaxNode GetSwitchExpression(SyntaxNode node);\n+\n+        protected abstract List<string> GetMissingLabels(SyntaxNode node, SemanticModel model, INamedTypeSymbol enumType,\n+            out bool containsDefaultLabel);\n+\n+        protected abstract int InsertPosition(List<SyntaxNode> sections);\n+\n+        protected abstract List<SyntaxNode> GetSwitchSections(SyntaxNode node);\n+\n+        protected abstract SyntaxNode NewSwitchNode(SyntaxNode node, List<SyntaxNode> sections);\n+\n+        protected abstract SyntaxNode GetSwitchStatementNode(SyntaxNode root, TextSpan span);\n+\n+        private Task<Document> AddMissingSwitchLabelsAsync(SemanticModel model, Document document, SyntaxNode root, SyntaxNode switchNode)\n+        {\n+            var enumType = (INamedTypeSymbol)model.GetTypeInfo(GetSwitchExpression(switchNode)).Type;\n+            var fullyQualifiedEnumType = enumType.ToDisplayString();\n+\n+            bool containsDefaultLabel;\n+            var missingLabels = GetMissingLabels(switchNode, model, enumType, out containsDefaultLabel);\n+\n+            var generator = SyntaxGenerator.GetGenerator(document);\n+\n+            var switchExitStatement = generator.ExitSwitchStatement();\n+            var statements = new List<SyntaxNode> { switchExitStatement };\n+\n+            var newSections = GetSwitchSections(switchNode);\n+            foreach (var label in missingLabels)\n+            {\n+                var caseLabel = generator.DottedName($\"{fullyQualifiedEnumType}.{label}\");","path":"src/Features/Core/Portable/PopulateSwitch/AbstractPopulateSwitchCodeFixProvider.cs","position":70,"original_position":70,"commit_id":"db7676ebd7247e456b5640109fd2e84e906d9fa4","original_commit_id":"db7676ebd7247e456b5640109fd2e84e906d9fa4","user":{"login":"Hosch250","id":6299719,"avatar_url":"https://avatars.githubusercontent.com/u/6299719?v=3","gravatar_id":"","url":"https://api.github.com/users/Hosch250","html_url":"https://github.com/Hosch250","followers_url":"https://api.github.com/users/Hosch250/followers","following_url":"https://api.github.com/users/Hosch250/following{/other_user}","gists_url":"https://api.github.com/users/Hosch250/gists{/gist_id}","starred_url":"https://api.github.com/users/Hosch250/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hosch250/subscriptions","organizations_url":"https://api.github.com/users/Hosch250/orgs","repos_url":"https://api.github.com/users/Hosch250/repos","events_url":"https://api.github.com/users/Hosch250/events{/privacy}","received_events_url":"https://api.github.com/users/Hosch250/received_events","type":"User","site_admin":false},"body":"Thank you for the tip.","created_at":"2016-04-04T19:32:13Z","updated_at":"2016-04-04T19:32:13Z","html_url":"https://github.com/dotnet/roslyn/pull/10160#discussion_r58433906","pull_request_url":"https://api.github.com/repos/dotnet/roslyn/pulls/10160","_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments/58433906"},"html":{"href":"https://github.com/dotnet/roslyn/pull/10160#discussion_r58433906"},"pull_request":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/10160"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/10160","id":64416057,"html_url":"https://github.com/dotnet/roslyn/pull/10160","diff_url":"https://github.com/dotnet/roslyn/pull/10160.diff","patch_url":"https://github.com/dotnet/roslyn/pull/10160.patch","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/10160","number":10160,"state":"open","locked":false,"title":"Implement code action to complete switch statements on enums","user":{"login":"Hosch250","id":6299719,"avatar_url":"https://avatars.githubusercontent.com/u/6299719?v=3","gravatar_id":"","url":"https://api.github.com/users/Hosch250","html_url":"https://github.com/Hosch250","followers_url":"https://api.github.com/users/Hosch250/followers","following_url":"https://api.github.com/users/Hosch250/following{/other_user}","gists_url":"https://api.github.com/users/Hosch250/gists{/gist_id}","starred_url":"https://api.github.com/users/Hosch250/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hosch250/subscriptions","organizations_url":"https://api.github.com/users/Hosch250/orgs","repos_url":"https://api.github.com/users/Hosch250/repos","events_url":"https://api.github.com/users/Hosch250/events{/privacy}","received_events_url":"https://api.github.com/users/Hosch250/received_events","type":"User","site_admin":false},"body":"Close #6766. I was unable to figure out how to set the cursor to a certain position as described in the issue, and I am unsure if everything else is done the way it should be. Should it be an IDE issue, or should it be a CS and VB issue? I mostly copied the pattern from the Remove Unnecessary Cast issue, so that is why I made it an IDE issue.","created_at":"2016-03-29T05:39:48Z","updated_at":"2016-04-04T19:32:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e4ac7544a535ef8b35d535eb1ce7b179dc61073b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/roslyn/pulls/10160/commits","review_comments_url":"https://api.github.com/repos/dotnet/roslyn/pulls/10160/comments","review_comment_url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/10160/comments","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/db7676ebd7247e456b5640109fd2e84e906d9fa4","head":{"label":"Hosch250:master","ref":"master","sha":"db7676ebd7247e456b5640109fd2e84e906d9fa4","user":{"login":"Hosch250","id":6299719,"avatar_url":"https://avatars.githubusercontent.com/u/6299719?v=3","gravatar_id":"","url":"https://api.github.com/users/Hosch250","html_url":"https://github.com/Hosch250","followers_url":"https://api.github.com/users/Hosch250/followers","following_url":"https://api.github.com/users/Hosch250/following{/other_user}","gists_url":"https://api.github.com/users/Hosch250/gists{/gist_id}","starred_url":"https://api.github.com/users/Hosch250/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hosch250/subscriptions","organizations_url":"https://api.github.com/users/Hosch250/orgs","repos_url":"https://api.github.com/users/Hosch250/repos","events_url":"https://api.github.com/users/Hosch250/events{/privacy}","received_events_url":"https://api.github.com/users/Hosch250/received_events","type":"User","site_admin":false},"repo":{"id":54931234,"name":"roslyn","full_name":"Hosch250/roslyn","owner":{"login":"Hosch250","id":6299719,"avatar_url":"https://avatars.githubusercontent.com/u/6299719?v=3","gravatar_id":"","url":"https://api.github.com/users/Hosch250","html_url":"https://github.com/Hosch250","followers_url":"https://api.github.com/users/Hosch250/followers","following_url":"https://api.github.com/users/Hosch250/following{/other_user}","gists_url":"https://api.github.com/users/Hosch250/gists{/gist_id}","starred_url":"https://api.github.com/users/Hosch250/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hosch250/subscriptions","organizations_url":"https://api.github.com/users/Hosch250/orgs","repos_url":"https://api.github.com/users/Hosch250/repos","events_url":"https://api.github.com/users/Hosch250/events{/privacy}","received_events_url":"https://api.github.com/users/Hosch250/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Hosch250/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":true,"url":"https://api.github.com/repos/Hosch250/roslyn","forks_url":"https://api.github.com/repos/Hosch250/roslyn/forks","keys_url":"https://api.github.com/repos/Hosch250/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Hosch250/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Hosch250/roslyn/teams","hooks_url":"https://api.github.com/repos/Hosch250/roslyn/hooks","issue_events_url":"https://api.github.com/repos/Hosch250/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/Hosch250/roslyn/events","assignees_url":"https://api.github.com/repos/Hosch250/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/Hosch250/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/Hosch250/roslyn/tags","blobs_url":"https://api.github.com/repos/Hosch250/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Hosch250/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Hosch250/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/Hosch250/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Hosch250/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/Hosch250/roslyn/languages","stargazers_url":"https://api.github.com/repos/Hosch250/roslyn/stargazers","contributors_url":"https://api.github.com/repos/Hosch250/roslyn/contributors","subscribers_url":"https://api.github.com/repos/Hosch250/roslyn/subscribers","subscription_url":"https://api.github.com/repos/Hosch250/roslyn/subscription","commits_url":"https://api.github.com/repos/Hosch250/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/Hosch250/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/Hosch250/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/Hosch250/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/Hosch250/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/Hosch250/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Hosch250/roslyn/merges","archive_url":"https://api.github.com/repos/Hosch250/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Hosch250/roslyn/downloads","issues_url":"https://api.github.com/repos/Hosch250/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/Hosch250/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/Hosch250/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/Hosch250/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Hosch250/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/Hosch250/roslyn/releases{/id}","deployments_url":"https://api.github.com/repos/Hosch250/roslyn/deployments","created_at":"2016-03-28T23:39:50Z","updated_at":"2016-03-28T23:40:23Z","pushed_at":"2016-04-04T14:35:10Z","git_url":"git://github.com/Hosch250/roslyn.git","ssh_url":"git@github.com:Hosch250/roslyn.git","clone_url":"https://github.com/Hosch250/roslyn.git","svn_url":"https://github.com/Hosch250/roslyn","homepage":"","size":149262,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"3299f0262b40d294c5bf2da13a0f00b98f2917d4","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":29078997,"name":"roslyn","full_name":"dotnet/roslyn","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","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":false,"url":"https://api.github.com/repos/dotnet/roslyn","forks_url":"https://api.github.com/repos/dotnet/roslyn/forks","keys_url":"https://api.github.com/repos/dotnet/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/roslyn/teams","hooks_url":"https://api.github.com/repos/dotnet/roslyn/hooks","issue_events_url":"https://api.github.com/repos/dotnet/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/roslyn/events","assignees_url":"https://api.github.com/repos/dotnet/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/roslyn/tags","blobs_url":"https://api.github.com/repos/dotnet/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/roslyn/languages","stargazers_url":"https://api.github.com/repos/dotnet/roslyn/stargazers","contributors_url":"https://api.github.com/repos/dotnet/roslyn/contributors","subscribers_url":"https://api.github.com/repos/dotnet/roslyn/subscribers","subscription_url":"https://api.github.com/repos/dotnet/roslyn/subscription","commits_url":"https://api.github.com/repos/dotnet/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/roslyn/merges","archive_url":"https://api.github.com/repos/dotnet/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/roslyn/downloads","issues_url":"https://api.github.com/repos/dotnet/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/roslyn/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/roslyn/deployments","created_at":"2015-01-11T02:39:03Z","updated_at":"2016-04-04T18:44:09Z","pushed_at":"2016-04-04T19:21:32Z","git_url":"git://github.com/dotnet/roslyn.git","ssh_url":"git@github.com:dotnet/roslyn.git","clone_url":"https://github.com/dotnet/roslyn.git","svn_url":"https://github.com/dotnet/roslyn","homepage":"","size":176604,"stargazers_count":4791,"watchers_count":4791,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1202,"mirror_url":null,"open_issues_count":2598,"forks":1202,"open_issues":2598,"watchers":4791,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/10160"},"html":{"href":"https://github.com/dotnet/roslyn/pull/10160"},"issue":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/10160"},"comments":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/10160/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/10160/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/10160/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/roslyn/statuses/db7676ebd7247e456b5640109fd2e84e906d9fa4"}}}}