{"action":"closed","number":323,"pull_request":{"url":"https://api.github.com/repos/square/javapoet/pulls/323","id":43906923,"html_url":"https://github.com/square/javapoet/pull/323","diff_url":"https://github.com/square/javapoet/pull/323.diff","patch_url":"https://github.com/square/javapoet/pull/323.patch","issue_url":"https://api.github.com/repos/square/javapoet/issues/323","number":323,"state":"closed","locked":false,"title":"Use least-qualified names for conflicting class names","user":{"login":"auke-","id":7162870,"avatar_url":"https://avatars.githubusercontent.com/u/7162870?v=3","gravatar_id":"","url":"https://api.github.com/users/auke-","html_url":"https://github.com/auke-","followers_url":"https://api.github.com/users/auke-/followers","following_url":"https://api.github.com/users/auke-/following{/other_user}","gists_url":"https://api.github.com/users/auke-/gists{/gist_id}","starred_url":"https://api.github.com/users/auke-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auke-/subscriptions","organizations_url":"https://api.github.com/users/auke-/orgs","repos_url":"https://api.github.com/users/auke-/repos","events_url":"https://api.github.com/users/auke-/events{/privacy}","received_events_url":"https://api.github.com/users/auke-/received_events","type":"User","site_admin":false},"body":"After the quick fix for conflicting names (#320) this is my first shot at making name resolution more straight forward.\r\n\r\nThere are a couple of simple scenarios:\r\n- same class\r\nAlways use the simple name, e.g. x.y.A referenced from x.y.A resolves to A and x.y.A.B referenced from x.y.A.B resolves to B.\r\n\r\n- parent class\r\nAlways use the simple name, e.g. x.y.A.B referenced from x.y.A.B.C resolves to B and  x.y.A referenced from x.y.A.B.C resolves to A.\r\n\r\n- nested class\r\nAlways use the qualified name starting at the nesting, e.g. x.y.A.B referenced from x.y.A resolves to B and x.y.A.B.C referenced from x.y.A resolves to B.C.\r\n\r\nAnd some complex scenarios:\r\n- nested class of a parent class\r\nUse the qualified name starting at the nesting, e.g. x.y.A.D referenced from x.y.A.B.C resolves to D.\r\n\r\n- other class in the same package\r\nUse the qualified name, e.g. x.y.B.C referenced from x.y.A. resolves to B.C.\r\n\r\n- other class in another package\r\nUse the qualified name and import top-level name, e.g. x.y.z.B.C referenced from x.y.A. resolves to B.C and imports x.y.z.B.\r\n\r\nIf (in the complex scenarios) the top-level name of the resolved name conflicts with another name (same class, parent, member, member of a parent, imported class or referenced class) the name of the enclosing class is used. If the top-level class conflicts, the fully qualified name is used (package and class names).\r\n\r\nThere are some issues with my current approach:\r\n- Information about inherited classes and interfaces isn't available (see #77).\r\n- Type information of annotated classes and classes implementing or extending classes isn't available on the type stack (should this be changed in TypeSpec.emit?).\r\n- I'm not sure if the methods nestedName and isNestedClass should be methods of ClassName or CodeWriter.\r\n- Not all scenarios are covered by tests.\r\n- Scenarios with anonymous nested classes aren't covered by tests.","created_at":"2015-09-01T18:02:48Z","updated_at":"2015-10-22T10:29:07Z","closed_at":"2015-10-22T10:29:07Z","merged_at":null,"merge_commit_sha":"3825c9e5ec830e05035533e0c27d9471c59bfe95","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/javapoet/pulls/323/commits","review_comments_url":"https://api.github.com/repos/square/javapoet/pulls/323/comments","review_comment_url":"https://api.github.com/repos/square/javapoet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/javapoet/issues/323/comments","statuses_url":"https://api.github.com/repos/square/javapoet/statuses/0d926aa0e9dac7a479227d577a2e3cc722bf8f67","head":{"label":"auke-:master","ref":"master","sha":"0d926aa0e9dac7a479227d577a2e3cc722bf8f67","user":{"login":"auke-","id":7162870,"avatar_url":"https://avatars.githubusercontent.com/u/7162870?v=3","gravatar_id":"","url":"https://api.github.com/users/auke-","html_url":"https://github.com/auke-","followers_url":"https://api.github.com/users/auke-/followers","following_url":"https://api.github.com/users/auke-/following{/other_user}","gists_url":"https://api.github.com/users/auke-/gists{/gist_id}","starred_url":"https://api.github.com/users/auke-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auke-/subscriptions","organizations_url":"https://api.github.com/users/auke-/orgs","repos_url":"https://api.github.com/users/auke-/repos","events_url":"https://api.github.com/users/auke-/events{/privacy}","received_events_url":"https://api.github.com/users/auke-/received_events","type":"User","site_admin":false},"repo":{"id":18435256,"name":"javawriter","full_name":"auke-/javawriter","owner":{"login":"auke-","id":7162870,"avatar_url":"https://avatars.githubusercontent.com/u/7162870?v=3","gravatar_id":"","url":"https://api.github.com/users/auke-","html_url":"https://github.com/auke-","followers_url":"https://api.github.com/users/auke-/followers","following_url":"https://api.github.com/users/auke-/following{/other_user}","gists_url":"https://api.github.com/users/auke-/gists{/gist_id}","starred_url":"https://api.github.com/users/auke-/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auke-/subscriptions","organizations_url":"https://api.github.com/users/auke-/orgs","repos_url":"https://api.github.com/users/auke-/repos","events_url":"https://api.github.com/users/auke-/events{/privacy}","received_events_url":"https://api.github.com/users/auke-/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/auke-/javawriter","description":"A utility class which aids in generating Java source files.","fork":true,"url":"https://api.github.com/repos/auke-/javawriter","forks_url":"https://api.github.com/repos/auke-/javawriter/forks","keys_url":"https://api.github.com/repos/auke-/javawriter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/auke-/javawriter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/auke-/javawriter/teams","hooks_url":"https://api.github.com/repos/auke-/javawriter/hooks","issue_events_url":"https://api.github.com/repos/auke-/javawriter/issues/events{/number}","events_url":"https://api.github.com/repos/auke-/javawriter/events","assignees_url":"https://api.github.com/repos/auke-/javawriter/assignees{/user}","branches_url":"https://api.github.com/repos/auke-/javawriter/branches{/branch}","tags_url":"https://api.github.com/repos/auke-/javawriter/tags","blobs_url":"https://api.github.com/repos/auke-/javawriter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/auke-/javawriter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/auke-/javawriter/git/refs{/sha}","trees_url":"https://api.github.com/repos/auke-/javawriter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/auke-/javawriter/statuses/{sha}","languages_url":"https://api.github.com/repos/auke-/javawriter/languages","stargazers_url":"https://api.github.com/repos/auke-/javawriter/stargazers","contributors_url":"https://api.github.com/repos/auke-/javawriter/contributors","subscribers_url":"https://api.github.com/repos/auke-/javawriter/subscribers","subscription_url":"https://api.github.com/repos/auke-/javawriter/subscription","commits_url":"https://api.github.com/repos/auke-/javawriter/commits{/sha}","git_commits_url":"https://api.github.com/repos/auke-/javawriter/git/commits{/sha}","comments_url":"https://api.github.com/repos/auke-/javawriter/comments{/number}","issue_comment_url":"https://api.github.com/repos/auke-/javawriter/issues/comments{/number}","contents_url":"https://api.github.com/repos/auke-/javawriter/contents/{+path}","compare_url":"https://api.github.com/repos/auke-/javawriter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/auke-/javawriter/merges","archive_url":"https://api.github.com/repos/auke-/javawriter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/auke-/javawriter/downloads","issues_url":"https://api.github.com/repos/auke-/javawriter/issues{/number}","pulls_url":"https://api.github.com/repos/auke-/javawriter/pulls{/number}","milestones_url":"https://api.github.com/repos/auke-/javawriter/milestones{/number}","notifications_url":"https://api.github.com/repos/auke-/javawriter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/auke-/javawriter/labels{/name}","releases_url":"https://api.github.com/repos/auke-/javawriter/releases{/id}","created_at":"2014-04-04T10:13:08Z","updated_at":"2015-01-13T23:37:54Z","pushed_at":"2015-09-25T07:28:52Z","git_url":"git://github.com/auke-/javawriter.git","ssh_url":"git@github.com:auke-/javawriter.git","clone_url":"https://github.com/auke-/javawriter.git","svn_url":"https://github.com/auke-/javawriter","homepage":"http://square.github.io/javawriter/","size":1050,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"ebde08a42d191127b2c08e26513f81ced71ca902","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","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":7961991,"name":"javapoet","full_name":"square/javapoet","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","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/javapoet","description":"A Java API for generating .java source files.","fork":false,"url":"https://api.github.com/repos/square/javapoet","forks_url":"https://api.github.com/repos/square/javapoet/forks","keys_url":"https://api.github.com/repos/square/javapoet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/javapoet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/javapoet/teams","hooks_url":"https://api.github.com/repos/square/javapoet/hooks","issue_events_url":"https://api.github.com/repos/square/javapoet/issues/events{/number}","events_url":"https://api.github.com/repos/square/javapoet/events","assignees_url":"https://api.github.com/repos/square/javapoet/assignees{/user}","branches_url":"https://api.github.com/repos/square/javapoet/branches{/branch}","tags_url":"https://api.github.com/repos/square/javapoet/tags","blobs_url":"https://api.github.com/repos/square/javapoet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/javapoet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/javapoet/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/javapoet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/javapoet/statuses/{sha}","languages_url":"https://api.github.com/repos/square/javapoet/languages","stargazers_url":"https://api.github.com/repos/square/javapoet/stargazers","contributors_url":"https://api.github.com/repos/square/javapoet/contributors","subscribers_url":"https://api.github.com/repos/square/javapoet/subscribers","subscription_url":"https://api.github.com/repos/square/javapoet/subscription","commits_url":"https://api.github.com/repos/square/javapoet/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/javapoet/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/javapoet/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/javapoet/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/javapoet/contents/{+path}","compare_url":"https://api.github.com/repos/square/javapoet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/javapoet/merges","archive_url":"https://api.github.com/repos/square/javapoet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/javapoet/downloads","issues_url":"https://api.github.com/repos/square/javapoet/issues{/number}","pulls_url":"https://api.github.com/repos/square/javapoet/pulls{/number}","milestones_url":"https://api.github.com/repos/square/javapoet/milestones{/number}","notifications_url":"https://api.github.com/repos/square/javapoet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/javapoet/labels{/name}","releases_url":"https://api.github.com/repos/square/javapoet/releases{/id}","created_at":"2013-02-01T16:56:30Z","updated_at":"2015-10-22T10:16:04Z","pushed_at":"2015-10-18T18:22:07Z","git_url":"git://github.com/square/javapoet.git","ssh_url":"git@github.com:square/javapoet.git","clone_url":"https://github.com/square/javapoet.git","svn_url":"https://github.com/square/javapoet","homepage":"","size":3919,"stargazers_count":1318,"watchers_count":1318,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":201,"mirror_url":null,"open_issues_count":15,"forks":201,"open_issues":15,"watchers":1318,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/javapoet/pulls/323"},"html":{"href":"https://github.com/square/javapoet/pull/323"},"issue":{"href":"https://api.github.com/repos/square/javapoet/issues/323"},"comments":{"href":"https://api.github.com/repos/square/javapoet/issues/323/comments"},"review_comments":{"href":"https://api.github.com/repos/square/javapoet/pulls/323/comments"},"review_comment":{"href":"https://api.github.com/repos/square/javapoet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/javapoet/pulls/323/commits"},"statuses":{"href":"https://api.github.com/repos/square/javapoet/statuses/0d926aa0e9dac7a479227d577a2e3cc722bf8f67"}},"merged":false,"mergeable":false,"mergeable_state":"dirty","merged_by":null,"comments":8,"review_comments":3,"commits":1,"additions":231,"deletions":69,"changed_files":2}}