{"action":"created","comment":{"url":"https://api.github.com/repos/square/moshi/pulls/comments/175294421","pull_request_review_id":104802585,"id":175294421,"diff_hunk":"@@ -0,0 +1,276 @@\n+/*\n+ * Copyright (C) 2018 Square, Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package com.squareup.moshi\n+\n+import com.squareup.kotlinpoet.ARRAY\n+import com.squareup.kotlinpoet.ClassName\n+import com.squareup.kotlinpoet.FileSpec\n+import com.squareup.kotlinpoet.FunSpec\n+import com.squareup.kotlinpoet.KModifier\n+import com.squareup.kotlinpoet.NameAllocator\n+import com.squareup.kotlinpoet.ParameterSpec\n+import com.squareup.kotlinpoet.ParameterizedTypeName\n+import com.squareup.kotlinpoet.PropertySpec\n+import com.squareup.kotlinpoet.TypeSpec\n+import com.squareup.kotlinpoet.TypeVariableName\n+import com.squareup.kotlinpoet.asClassName\n+import com.squareup.kotlinpoet.asTypeName\n+import org.jetbrains.kotlin.serialization.ProtoBuf\n+import java.lang.reflect.Type\n+import javax.lang.model.element.Element\n+import javax.lang.model.util.Elements\n+\n+/** Generates a JSON adapter for a target type. */\n+internal class Adapter(\n+  val fqClassName: String,\n+  val packageName: String,\n+  val propertyList: List<Property>,\n+  val originalElement: Element,\n+  name: String = fqClassName.substringAfter(packageName)\n+      .replace('.', '_')\n+      .removePrefix(\"_\"),\n+  val hasCompanionObject: Boolean,\n+  val visibility: ProtoBuf.Visibility,\n+  val elements: Elements,\n+  val genericTypeNames: List<TypeVariableName>?\n+) {\n+  val nameAllocator = NameAllocator()\n+  val adapterName = \"${name}JsonAdapter\"\n+  val originalTypeName = originalElement.asType().asTypeName()\n+\n+  val moshiParam = ParameterSpec.builder(\n+      nameAllocator.newName(\"moshi\"),\n+      Moshi::class).build()\n+  val typesParam = ParameterSpec.builder(\n+      nameAllocator.newName(\"types\"),\n+      ParameterizedTypeName.get(ARRAY,\n+          Type::class.asTypeName()))\n+      .build()\n+  val readerParam = ParameterSpec.builder(\n+      nameAllocator.newName(\"reader\"),\n+      JsonReader::class)\n+      .build()\n+  val writerParam = ParameterSpec.builder(\n+      nameAllocator.newName(\"writer\"),\n+      JsonWriter::class)\n+      .build()\n+  val valueParam = ParameterSpec.Companion.builder(\n+      nameAllocator.newName(\"value\"),\n+      originalTypeName.asNullable())\n+      .build()\n+  val jsonAdapterTypeName = ParameterizedTypeName.Companion.get(\n+      JsonAdapter::class.asClassName(), originalTypeName)\n+\n+  // selectName() API setup\n+  val optionsProperty = PropertySpec.Companion.builder(","path":"kotlin-codegen/compiler/src/main/java/com/squareup/moshi/Adapter.kt","position":78,"original_position":78,"commit_id":"56e34d8174523e9e1cee269b464636dd7513b16a","original_commit_id":"56e34d8174523e9e1cee269b464636dd7513b16a","user":{"login":"JakeWharton","id":66577,"avatar_url":"https://avatars0.githubusercontent.com/u/66577?v=4","gravatar_id":"","url":"https://api.github.com/users/JakeWharton","html_url":"https://github.com/JakeWharton","followers_url":"https://api.github.com/users/JakeWharton/followers","following_url":"https://api.github.com/users/JakeWharton/following{/other_user}","gists_url":"https://api.github.com/users/JakeWharton/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeWharton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeWharton/subscriptions","organizations_url":"https://api.github.com/users/JakeWharton/orgs","repos_url":"https://api.github.com/users/JakeWharton/repos","events_url":"https://api.github.com/users/JakeWharton/events{/privacy}","received_events_url":"https://api.github.com/users/JakeWharton/received_events","type":"User","site_admin":false},"body":"nit: drop `Companion`","created_at":"2018-03-18T16:21:48Z","updated_at":"2018-03-18T16:41:19Z","html_url":"https://github.com/square/moshi/pull/462#discussion_r175294421","pull_request_url":"https://api.github.com/repos/square/moshi/pulls/462","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/square/moshi/pulls/comments/175294421"},"html":{"href":"https://github.com/square/moshi/pull/462#discussion_r175294421"},"pull_request":{"href":"https://api.github.com/repos/square/moshi/pulls/462"}}},"pull_request":{"url":"https://api.github.com/repos/square/moshi/pulls/462","id":174272956,"html_url":"https://github.com/square/moshi/pull/462","diff_url":"https://github.com/square/moshi/pull/462.diff","patch_url":"https://github.com/square/moshi/pull/462.patch","issue_url":"https://api.github.com/repos/square/moshi/issues/462","number":462,"state":"open","locked":false,"title":"Split the MoshiKotlinCodeGenProcessor into multiple types.","user":{"login":"swankjesse","id":133019,"avatar_url":"https://avatars3.githubusercontent.com/u/133019?v=4","gravatar_id":"","url":"https://api.github.com/users/swankjesse","html_url":"https://github.com/swankjesse","followers_url":"https://api.github.com/users/swankjesse/followers","following_url":"https://api.github.com/users/swankjesse/following{/other_user}","gists_url":"https://api.github.com/users/swankjesse/gists{/gist_id}","starred_url":"https://api.github.com/users/swankjesse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swankjesse/subscriptions","organizations_url":"https://api.github.com/users/swankjesse/orgs","repos_url":"https://api.github.com/users/swankjesse/repos","events_url":"https://api.github.com/users/swankjesse/events{/privacy}","received_events_url":"https://api.github.com/users/swankjesse/received_events","type":"User","site_admin":false},"body":"Move more behavior into the types: Adapter and Property now have many\r\ninstance methods and are now mutable value classes rather than immutable\r\ndata classes.\r\n\r\nThis changes how some of the bookkeeping code works. Previously there were\r\nsome pretty tricky types: maps with pairs as keys, indexed and non-indexed\r\nlists of properties. With this change more of the logic operates directly\r\non the properties.","created_at":"2018-03-12T05:00:56Z","updated_at":"2018-03-18T16:41:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fac4a5c0d43246f7d3ab0a038de68e179fffd9a4","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/square/moshi/pulls/462/commits","review_comments_url":"https://api.github.com/repos/square/moshi/pulls/462/comments","review_comment_url":"https://api.github.com/repos/square/moshi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/moshi/issues/462/comments","statuses_url":"https://api.github.com/repos/square/moshi/statuses/56e34d8174523e9e1cee269b464636dd7513b16a","head":{"label":"square:jwilson.0312.split_and_stuff","ref":"jwilson.0312.split_and_stuff","sha":"56e34d8174523e9e1cee269b464636dd7513b16a","user":{"login":"square","id":82592,"avatar_url":"https://avatars0.githubusercontent.com/u/82592?v=4","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":22789601,"name":"moshi","full_name":"square/moshi","owner":{"login":"square","id":82592,"avatar_url":"https://avatars0.githubusercontent.com/u/82592?v=4","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/moshi","description":"A modern JSON library for Android and Java.","fork":false,"url":"https://api.github.com/repos/square/moshi","forks_url":"https://api.github.com/repos/square/moshi/forks","keys_url":"https://api.github.com/repos/square/moshi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/moshi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/moshi/teams","hooks_url":"https://api.github.com/repos/square/moshi/hooks","issue_events_url":"https://api.github.com/repos/square/moshi/issues/events{/number}","events_url":"https://api.github.com/repos/square/moshi/events","assignees_url":"https://api.github.com/repos/square/moshi/assignees{/user}","branches_url":"https://api.github.com/repos/square/moshi/branches{/branch}","tags_url":"https://api.github.com/repos/square/moshi/tags","blobs_url":"https://api.github.com/repos/square/moshi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/moshi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/moshi/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/moshi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/moshi/statuses/{sha}","languages_url":"https://api.github.com/repos/square/moshi/languages","stargazers_url":"https://api.github.com/repos/square/moshi/stargazers","contributors_url":"https://api.github.com/repos/square/moshi/contributors","subscribers_url":"https://api.github.com/repos/square/moshi/subscribers","subscription_url":"https://api.github.com/repos/square/moshi/subscription","commits_url":"https://api.github.com/repos/square/moshi/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/moshi/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/moshi/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/moshi/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/moshi/contents/{+path}","compare_url":"https://api.github.com/repos/square/moshi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/moshi/merges","archive_url":"https://api.github.com/repos/square/moshi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/moshi/downloads","issues_url":"https://api.github.com/repos/square/moshi/issues{/number}","pulls_url":"https://api.github.com/repos/square/moshi/pulls{/number}","milestones_url":"https://api.github.com/repos/square/moshi/milestones{/number}","notifications_url":"https://api.github.com/repos/square/moshi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/moshi/labels{/name}","releases_url":"https://api.github.com/repos/square/moshi/releases{/id}","deployments_url":"https://api.github.com/repos/square/moshi/deployments","created_at":"2014-08-09T15:58:42Z","updated_at":"2018-03-17T16:18:55Z","pushed_at":"2018-03-12T05:00:57Z","git_url":"git://github.com/square/moshi.git","ssh_url":"git@github.com:square/moshi.git","clone_url":"https://github.com/square/moshi.git","svn_url":"https://github.com/square/moshi","homepage":"http://square.github.io/moshi/1.x/moshi/","size":1107,"stargazers_count":3639,"watchers_count":3639,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":264,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":264,"open_issues":34,"watchers":3639,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"96e074d030a1b72e6263b93e311c4173492ec2a8","user":{"login":"square","id":82592,"avatar_url":"https://avatars0.githubusercontent.com/u/82592?v=4","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":22789601,"name":"moshi","full_name":"square/moshi","owner":{"login":"square","id":82592,"avatar_url":"https://avatars0.githubusercontent.com/u/82592?v=4","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/moshi","description":"A modern JSON library for Android and Java.","fork":false,"url":"https://api.github.com/repos/square/moshi","forks_url":"https://api.github.com/repos/square/moshi/forks","keys_url":"https://api.github.com/repos/square/moshi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/moshi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/moshi/teams","hooks_url":"https://api.github.com/repos/square/moshi/hooks","issue_events_url":"https://api.github.com/repos/square/moshi/issues/events{/number}","events_url":"https://api.github.com/repos/square/moshi/events","assignees_url":"https://api.github.com/repos/square/moshi/assignees{/user}","branches_url":"https://api.github.com/repos/square/moshi/branches{/branch}","tags_url":"https://api.github.com/repos/square/moshi/tags","blobs_url":"https://api.github.com/repos/square/moshi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/moshi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/moshi/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/moshi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/moshi/statuses/{sha}","languages_url":"https://api.github.com/repos/square/moshi/languages","stargazers_url":"https://api.github.com/repos/square/moshi/stargazers","contributors_url":"https://api.github.com/repos/square/moshi/contributors","subscribers_url":"https://api.github.com/repos/square/moshi/subscribers","subscription_url":"https://api.github.com/repos/square/moshi/subscription","commits_url":"https://api.github.com/repos/square/moshi/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/moshi/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/moshi/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/moshi/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/moshi/contents/{+path}","compare_url":"https://api.github.com/repos/square/moshi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/moshi/merges","archive_url":"https://api.github.com/repos/square/moshi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/moshi/downloads","issues_url":"https://api.github.com/repos/square/moshi/issues{/number}","pulls_url":"https://api.github.com/repos/square/moshi/pulls{/number}","milestones_url":"https://api.github.com/repos/square/moshi/milestones{/number}","notifications_url":"https://api.github.com/repos/square/moshi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/moshi/labels{/name}","releases_url":"https://api.github.com/repos/square/moshi/releases{/id}","deployments_url":"https://api.github.com/repos/square/moshi/deployments","created_at":"2014-08-09T15:58:42Z","updated_at":"2018-03-17T16:18:55Z","pushed_at":"2018-03-12T05:00:57Z","git_url":"git://github.com/square/moshi.git","ssh_url":"git@github.com:square/moshi.git","clone_url":"https://github.com/square/moshi.git","svn_url":"https://github.com/square/moshi","homepage":"http://square.github.io/moshi/1.x/moshi/","size":1107,"stargazers_count":3639,"watchers_count":3639,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":264,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":264,"open_issues":34,"watchers":3639,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/moshi/pulls/462"},"html":{"href":"https://github.com/square/moshi/pull/462"},"issue":{"href":"https://api.github.com/repos/square/moshi/issues/462"},"comments":{"href":"https://api.github.com/repos/square/moshi/issues/462/comments"},"review_comments":{"href":"https://api.github.com/repos/square/moshi/pulls/462/comments"},"review_comment":{"href":"https://api.github.com/repos/square/moshi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/moshi/pulls/462/commits"},"statuses":{"href":"https://api.github.com/repos/square/moshi/statuses/56e34d8174523e9e1cee269b464636dd7513b16a"}},"author_association":"OWNER"}}
{"actor":{"display_login":"JakeWharton"}}