{"action":"created","comment":{"url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls/comments/45911080","id":45911080,"diff_hunk":"@@ -10,22 +12,48 @@ public object RustResolveUtil {\n         while (current != null) {\n             when (current) {\n                 is RustResolveScope -> return current\n-                else -> current = current.parent\n+                else                -> current = current.parent\n             }\n         }\n \n         return null\n     }\n \n-    fun getGlobalResolveScopeFor(elem: PsiElement): RustResolveScope {\n-        var current = getResolveScopeFor(elem)\n-        while (true)\n-        {\n-            val p = current?.let { getResolveScopeFor(it) } ?: break\n-            current = p;\n+    fun getCrateRootFor(elem: PsiElement): RustResolveScope? {\n+        val mod = getSelfModFor(elem) ?: return null\n+\n+        val superMod = getSuperModFor(mod)\n+        return if (superMod == null) mod else getCrateRootFor(superMod)\n+    }\n+\n+    fun getSuperModFor(elem: RustModItem): RustModItem? {\n+        val self = getSelfModFor(elem) ?: return null\n+        val superInFile = self.parentOfType<RustModItem>()","path":"src/org/rust/lang/core/resolve/util/RustResolveUtil.kt","position":36,"original_position":36,"commit_id":"db8d484e7bbd2d6e4747ca4643da33907c60debc","original_commit_id":"db8d484e7bbd2d6e4747ca4643da33907c60debc","user":{"login":"alexeykudinkin","id":428277,"avatar_url":"https://avatars.githubusercontent.com/u/428277?v=3","gravatar_id":"","url":"https://api.github.com/users/alexeykudinkin","html_url":"https://github.com/alexeykudinkin","followers_url":"https://api.github.com/users/alexeykudinkin/followers","following_url":"https://api.github.com/users/alexeykudinkin/following{/other_user}","gists_url":"https://api.github.com/users/alexeykudinkin/gists{/gist_id}","starred_url":"https://api.github.com/users/alexeykudinkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexeykudinkin/subscriptions","organizations_url":"https://api.github.com/users/alexeykudinkin/orgs","repos_url":"https://api.github.com/users/alexeykudinkin/repos","events_url":"https://api.github.com/users/alexeykudinkin/events{/privacy}","received_events_url":"https://api.github.com/users/alexeykudinkin/received_events","type":"User","site_admin":false},"body":"`containingMod`?","created_at":"2015-11-25T19:42:33Z","updated_at":"2015-11-25T19:42:33Z","html_url":"https://github.com/alexeykudinkin/intellij-rust/pull/154#discussion_r45911080","pull_request_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls/154","_links":{"self":{"href":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls/comments/45911080"},"html":{"href":"https://github.com/alexeykudinkin/intellij-rust/pull/154#discussion_r45911080"},"pull_request":{"href":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls/154"}}},"pull_request":{"url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls/154","id":51703907,"html_url":"https://github.com/alexeykudinkin/intellij-rust/pull/154","diff_url":"https://github.com/alexeykudinkin/intellij-rust/pull/154.diff","patch_url":"https://github.com/alexeykudinkin/intellij-rust/pull/154.patch","issue_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/issues/154","number":154,"state":"open","locked":false,"title":"(RES): resolve global paths","user":{"login":"matklad","id":1711539,"avatar_url":"https://avatars.githubusercontent.com/u/1711539?v=3","gravatar_id":"","url":"https://api.github.com/users/matklad","html_url":"https://github.com/matklad","followers_url":"https://api.github.com/users/matklad/followers","following_url":"https://api.github.com/users/matklad/following{/other_user}","gists_url":"https://api.github.com/users/matklad/gists{/gist_id}","starred_url":"https://api.github.com/users/matklad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matklad/subscriptions","organizations_url":"https://api.github.com/users/matklad/orgs","repos_url":"https://api.github.com/users/matklad/repos","events_url":"https://api.github.com/users/matklad/events{/privacy}","received_events_url":"https://api.github.com/users/matklad/received_events","type":"User","site_admin":false},"body":"This add resolve for `::foo::bar` paths everywhere and `foo::bar` paths\r\nin `use foo::bar`. It also lays foundation for proper use resolve and\r\n`self::foo`, `super::foo` resolve.\r\n\r\n`view_path_part_leftish` is made a distinct subclass of path part. This is necessary to override `isFullyQualified`. The name is way to long for a public PSI node, so I am open for suggestions for a shorter one (`use_path_start` maybe?). The code for determining the crate root and parent module is not strictly correct, but is a good approximation. \r\n\r\nI am also not sure about `getGlobalResolveScopeFor` -> `getCrateRootFor` renaming. I think it is better to stick to Rust specific term in this case. \r\n\r\n@alexeykudinkin @atsky please review","created_at":"2015-11-24T19:17:40Z","updated_at":"2015-11-25T19:42:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9db431dd1af3cbcb5e05f614ccdba66b8edf83a3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls/154/commits","review_comments_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls/154/comments","review_comment_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/issues/154/comments","statuses_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/statuses/db8d484e7bbd2d6e4747ca4643da33907c60debc","head":{"label":"alexeykudinkin:resolve-global-paths","ref":"resolve-global-paths","sha":"db8d484e7bbd2d6e4747ca4643da33907c60debc","user":{"login":"alexeykudinkin","id":428277,"avatar_url":"https://avatars.githubusercontent.com/u/428277?v=3","gravatar_id":"","url":"https://api.github.com/users/alexeykudinkin","html_url":"https://github.com/alexeykudinkin","followers_url":"https://api.github.com/users/alexeykudinkin/followers","following_url":"https://api.github.com/users/alexeykudinkin/following{/other_user}","gists_url":"https://api.github.com/users/alexeykudinkin/gists{/gist_id}","starred_url":"https://api.github.com/users/alexeykudinkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexeykudinkin/subscriptions","organizations_url":"https://api.github.com/users/alexeykudinkin/orgs","repos_url":"https://api.github.com/users/alexeykudinkin/repos","events_url":"https://api.github.com/users/alexeykudinkin/events{/privacy}","received_events_url":"https://api.github.com/users/alexeykudinkin/received_events","type":"User","site_admin":false},"repo":{"id":42619487,"name":"intellij-rust","full_name":"alexeykudinkin/intellij-rust","owner":{"login":"alexeykudinkin","id":428277,"avatar_url":"https://avatars.githubusercontent.com/u/428277?v=3","gravatar_id":"","url":"https://api.github.com/users/alexeykudinkin","html_url":"https://github.com/alexeykudinkin","followers_url":"https://api.github.com/users/alexeykudinkin/followers","following_url":"https://api.github.com/users/alexeykudinkin/following{/other_user}","gists_url":"https://api.github.com/users/alexeykudinkin/gists{/gist_id}","starred_url":"https://api.github.com/users/alexeykudinkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexeykudinkin/subscriptions","organizations_url":"https://api.github.com/users/alexeykudinkin/orgs","repos_url":"https://api.github.com/users/alexeykudinkin/repos","events_url":"https://api.github.com/users/alexeykudinkin/events{/privacy}","received_events_url":"https://api.github.com/users/alexeykudinkin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexeykudinkin/intellij-rust","description":"Rust IDE built using the IntelliJ Platform","fork":false,"url":"https://api.github.com/repos/alexeykudinkin/intellij-rust","forks_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/forks","keys_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/teams","hooks_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/hooks","issue_events_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/issues/events{/number}","events_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/events","assignees_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/assignees{/user}","branches_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/branches{/branch}","tags_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/tags","blobs_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/statuses/{sha}","languages_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/languages","stargazers_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/stargazers","contributors_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/contributors","subscribers_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/subscribers","subscription_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/subscription","commits_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/contents/{+path}","compare_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/merges","archive_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/downloads","issues_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/issues{/number}","pulls_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls{/number}","milestones_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/milestones{/number}","notifications_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/labels{/name}","releases_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/releases{/id}","created_at":"2015-09-16T23:44:57Z","updated_at":"2015-11-25T16:47:22Z","pushed_at":"2015-11-25T18:45:45Z","git_url":"git://github.com/alexeykudinkin/intellij-rust.git","ssh_url":"git@github.com:alexeykudinkin/intellij-rust.git","clone_url":"https://github.com/alexeykudinkin/intellij-rust.git","svn_url":"https://github.com/alexeykudinkin/intellij-rust","homepage":null,"size":4847,"stargazers_count":135,"watchers_count":135,"language":"Kotlin","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":18,"forks":9,"open_issues":18,"watchers":135,"default_branch":"master"}},"base":{"label":"alexeykudinkin:master","ref":"master","sha":"b523f821c9d51719496a1038c869d1cb4f91cefd","user":{"login":"alexeykudinkin","id":428277,"avatar_url":"https://avatars.githubusercontent.com/u/428277?v=3","gravatar_id":"","url":"https://api.github.com/users/alexeykudinkin","html_url":"https://github.com/alexeykudinkin","followers_url":"https://api.github.com/users/alexeykudinkin/followers","following_url":"https://api.github.com/users/alexeykudinkin/following{/other_user}","gists_url":"https://api.github.com/users/alexeykudinkin/gists{/gist_id}","starred_url":"https://api.github.com/users/alexeykudinkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexeykudinkin/subscriptions","organizations_url":"https://api.github.com/users/alexeykudinkin/orgs","repos_url":"https://api.github.com/users/alexeykudinkin/repos","events_url":"https://api.github.com/users/alexeykudinkin/events{/privacy}","received_events_url":"https://api.github.com/users/alexeykudinkin/received_events","type":"User","site_admin":false},"repo":{"id":42619487,"name":"intellij-rust","full_name":"alexeykudinkin/intellij-rust","owner":{"login":"alexeykudinkin","id":428277,"avatar_url":"https://avatars.githubusercontent.com/u/428277?v=3","gravatar_id":"","url":"https://api.github.com/users/alexeykudinkin","html_url":"https://github.com/alexeykudinkin","followers_url":"https://api.github.com/users/alexeykudinkin/followers","following_url":"https://api.github.com/users/alexeykudinkin/following{/other_user}","gists_url":"https://api.github.com/users/alexeykudinkin/gists{/gist_id}","starred_url":"https://api.github.com/users/alexeykudinkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexeykudinkin/subscriptions","organizations_url":"https://api.github.com/users/alexeykudinkin/orgs","repos_url":"https://api.github.com/users/alexeykudinkin/repos","events_url":"https://api.github.com/users/alexeykudinkin/events{/privacy}","received_events_url":"https://api.github.com/users/alexeykudinkin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexeykudinkin/intellij-rust","description":"Rust IDE built using the IntelliJ Platform","fork":false,"url":"https://api.github.com/repos/alexeykudinkin/intellij-rust","forks_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/forks","keys_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/teams","hooks_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/hooks","issue_events_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/issues/events{/number}","events_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/events","assignees_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/assignees{/user}","branches_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/branches{/branch}","tags_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/tags","blobs_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/statuses/{sha}","languages_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/languages","stargazers_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/stargazers","contributors_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/contributors","subscribers_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/subscribers","subscription_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/subscription","commits_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/contents/{+path}","compare_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/merges","archive_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/downloads","issues_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/issues{/number}","pulls_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls{/number}","milestones_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/milestones{/number}","notifications_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/labels{/name}","releases_url":"https://api.github.com/repos/alexeykudinkin/intellij-rust/releases{/id}","created_at":"2015-09-16T23:44:57Z","updated_at":"2015-11-25T16:47:22Z","pushed_at":"2015-11-25T18:45:45Z","git_url":"git://github.com/alexeykudinkin/intellij-rust.git","ssh_url":"git@github.com:alexeykudinkin/intellij-rust.git","clone_url":"https://github.com/alexeykudinkin/intellij-rust.git","svn_url":"https://github.com/alexeykudinkin/intellij-rust","homepage":null,"size":4847,"stargazers_count":135,"watchers_count":135,"language":"Kotlin","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":18,"forks":9,"open_issues":18,"watchers":135,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls/154"},"html":{"href":"https://github.com/alexeykudinkin/intellij-rust/pull/154"},"issue":{"href":"https://api.github.com/repos/alexeykudinkin/intellij-rust/issues/154"},"comments":{"href":"https://api.github.com/repos/alexeykudinkin/intellij-rust/issues/154/comments"},"review_comments":{"href":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls/154/comments"},"review_comment":{"href":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alexeykudinkin/intellij-rust/pulls/154/commits"},"statuses":{"href":"https://api.github.com/repos/alexeykudinkin/intellij-rust/statuses/db8d484e7bbd2d6e4747ca4643da33907c60debc"}}}}