{"action":"created","comment":{"url":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls/comments/59420331","id":59420331,"diff_hunk":"@@ -0,0 +1,39 @@\n+package org.rust.cargo\n+\n+import com.intellij.openapi.actionSystem.AnAction\n+import com.intellij.openapi.actionSystem.AnActionEvent\n+import com.intellij.openapi.application.ApplicationManager\n+import com.intellij.openapi.module.Module\n+import org.rust.cargo.toolchain.CargoMetadataService\n+import org.rust.cargo.toolchain.RustToolchain\n+import org.rust.cargo.toolchain.toolchain\n+import org.rust.cargo.util.getModules\n+import org.rust.cargo.util.getService\n+\n+class RefreshCargoProjectAction : AnAction() {\n+    init {\n+        templatePresentation.text = \"Refresh Cargo project\"\n+        templatePresentation.description = \"Update Cargo project information and download new dependencies\"\n+    }\n+\n+    override fun update(e: AnActionEvent) {\n+        if (e.modulesWithToolchains.isEmpty()) {\n+            e.presentation.isEnabled = false\n+        }\n+    }\n+\n+    override fun actionPerformed(e: AnActionEvent) {\n+        val modules = e.modulesWithToolchains\n+        if (modules.isEmpty()) return\n+        ApplicationManager.getApplication().saveAll()\n+        for ((module, toolchain) in modules) {\n+            val service = module.getService<CargoMetadataService>()\n+            service.updateNow(toolchain)\n+        }\n+    }\n+}\n+\n+private val AnActionEvent.modulesWithToolchains: List<Pair<Module, RustToolchain>>","path":"src/main/kotlin/org/rust/cargo/RefreshCargoProjectAction.kt","position":36,"original_position":36,"commit_id":"cab6edd83e0f52618b21fb3af7d9295cc37f7cf1","original_commit_id":"affdd265e267490ce7f2883d56fa048d2ed9ae7d","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":"I see: attribute extension method to the `project` itself.","created_at":"2016-04-12T17:44:39Z","updated_at":"2016-04-12T17:44:39Z","html_url":"https://github.com/intellij-rust/intellij-rust/pull/323#discussion_r59420331","pull_request_url":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls/323","_links":{"self":{"href":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls/comments/59420331"},"html":{"href":"https://github.com/intellij-rust/intellij-rust/pull/323#discussion_r59420331"},"pull_request":{"href":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls/323"}}},"pull_request":{"url":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls/323","id":65666290,"html_url":"https://github.com/intellij-rust/intellij-rust/pull/323","diff_url":"https://github.com/intellij-rust/intellij-rust/pull/323.diff","patch_url":"https://github.com/intellij-rust/intellij-rust/pull/323.patch","issue_url":"https://api.github.com/repos/intellij-rust/intellij-rust/issues/323","number":323,"state":"open","locked":false,"title":"Toolchain is the new sdk","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":"![clion](https://cloud.githubusercontent.com/assets/1711539/14359650/32695034-fcfb-11e5-8b39-1bce2c8231be.png)\r\n\r\nOk, so here is an attempt to make the plugin work with other IDEs besides the IDEA itself. The screenshot is from CLion. \r\n\r\n## RustSdkType\r\n\r\nIs gone. Although the SDK class itself is present in IDEs, there is no any SDK associated UI. `chooseAndSetSdk()` for example is a no-op in CLion. So this PR introduces a bit of custom state and UI, called `RustToolchain. \r\n\r\n![cargo-config](https://cloud.githubusercontent.com/assets/1711539/14359886/4ac3d3ce-fcfc-11e5-9875-097bcf824623.png)\r\n\r\n\r\nThis is a per project thing which stores the path to Cargo\r\n\r\n## RustModuleType\r\n\r\nIs gone too. Again, there are module classes in other IDEs, but the UI for creating/configuring modules is missing. This PR allows to work with Rust in any module, so you'll be able to use Java and Rust in the same module (and some of our users [use Java and Rust together](http://nitschinger.at/First-Steps-with-Rust-and-JNI/) :) )\r\n\r\n## ExternalSystem (import project)\r\n\r\nIs also gone. Instead, `CargoMetadataService` is introduced. This service monitors `Cargo.toml` files in the projects and executes `cargo metadata` if necessary. So now you just `open` the directory with Rust sources, setup toolchain in the settings and that's it. \r\n\r\n\r\n## Unresolved questions\r\n\r\n* tests don't yet compile :)\r\n\r\n* some refactoring and code rearrangement may be necessary\r\n\r\n* Should we provide extended functionality (SDK and module types) specifically for IDEA? I think in the long run this is a good idea, but currently it is better to stick with a single implementation for all platforms. \r\n\r\n\r\n@alexeykudinkin please review. This is not finished yet, but the big chunk of work is already done. ","created_at":"2016-04-07T17:14:03Z","updated_at":"2016-04-12T17:44:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f7d18c2848265196a990f1ce91ea6905ae2153f0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls/323/commits","review_comments_url":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls/323/comments","review_comment_url":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls/comments{/number}","comments_url":"https://api.github.com/repos/intellij-rust/intellij-rust/issues/323/comments","statuses_url":"https://api.github.com/repos/intellij-rust/intellij-rust/statuses/cab6edd83e0f52618b21fb3af7d9295cc37f7cf1","head":{"label":"intellij-rust:toolchain-is-the-new-sdk","ref":"toolchain-is-the-new-sdk","sha":"cab6edd83e0f52618b21fb3af7d9295cc37f7cf1","user":{"login":"intellij-rust","id":16057867,"avatar_url":"https://avatars.githubusercontent.com/u/16057867?v=3","gravatar_id":"","url":"https://api.github.com/users/intellij-rust","html_url":"https://github.com/intellij-rust","followers_url":"https://api.github.com/users/intellij-rust/followers","following_url":"https://api.github.com/users/intellij-rust/following{/other_user}","gists_url":"https://api.github.com/users/intellij-rust/gists{/gist_id}","starred_url":"https://api.github.com/users/intellij-rust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intellij-rust/subscriptions","organizations_url":"https://api.github.com/users/intellij-rust/orgs","repos_url":"https://api.github.com/users/intellij-rust/repos","events_url":"https://api.github.com/users/intellij-rust/events{/privacy}","received_events_url":"https://api.github.com/users/intellij-rust/received_events","type":"Organization","site_admin":false},"repo":{"id":42619487,"name":"intellij-rust","full_name":"intellij-rust/intellij-rust","owner":{"login":"intellij-rust","id":16057867,"avatar_url":"https://avatars.githubusercontent.com/u/16057867?v=3","gravatar_id":"","url":"https://api.github.com/users/intellij-rust","html_url":"https://github.com/intellij-rust","followers_url":"https://api.github.com/users/intellij-rust/followers","following_url":"https://api.github.com/users/intellij-rust/following{/other_user}","gists_url":"https://api.github.com/users/intellij-rust/gists{/gist_id}","starred_url":"https://api.github.com/users/intellij-rust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intellij-rust/subscriptions","organizations_url":"https://api.github.com/users/intellij-rust/orgs","repos_url":"https://api.github.com/users/intellij-rust/repos","events_url":"https://api.github.com/users/intellij-rust/events{/privacy}","received_events_url":"https://api.github.com/users/intellij-rust/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/intellij-rust/intellij-rust","description":"Rust IDE built using the IntelliJ Platform","fork":false,"url":"https://api.github.com/repos/intellij-rust/intellij-rust","forks_url":"https://api.github.com/repos/intellij-rust/intellij-rust/forks","keys_url":"https://api.github.com/repos/intellij-rust/intellij-rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/intellij-rust/intellij-rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/intellij-rust/intellij-rust/teams","hooks_url":"https://api.github.com/repos/intellij-rust/intellij-rust/hooks","issue_events_url":"https://api.github.com/repos/intellij-rust/intellij-rust/issues/events{/number}","events_url":"https://api.github.com/repos/intellij-rust/intellij-rust/events","assignees_url":"https://api.github.com/repos/intellij-rust/intellij-rust/assignees{/user}","branches_url":"https://api.github.com/repos/intellij-rust/intellij-rust/branches{/branch}","tags_url":"https://api.github.com/repos/intellij-rust/intellij-rust/tags","blobs_url":"https://api.github.com/repos/intellij-rust/intellij-rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/intellij-rust/intellij-rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/intellij-rust/intellij-rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/intellij-rust/intellij-rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/intellij-rust/intellij-rust/statuses/{sha}","languages_url":"https://api.github.com/repos/intellij-rust/intellij-rust/languages","stargazers_url":"https://api.github.com/repos/intellij-rust/intellij-rust/stargazers","contributors_url":"https://api.github.com/repos/intellij-rust/intellij-rust/contributors","subscribers_url":"https://api.github.com/repos/intellij-rust/intellij-rust/subscribers","subscription_url":"https://api.github.com/repos/intellij-rust/intellij-rust/subscription","commits_url":"https://api.github.com/repos/intellij-rust/intellij-rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/intellij-rust/intellij-rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/intellij-rust/intellij-rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/intellij-rust/intellij-rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/intellij-rust/intellij-rust/contents/{+path}","compare_url":"https://api.github.com/repos/intellij-rust/intellij-rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/intellij-rust/intellij-rust/merges","archive_url":"https://api.github.com/repos/intellij-rust/intellij-rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/intellij-rust/intellij-rust/downloads","issues_url":"https://api.github.com/repos/intellij-rust/intellij-rust/issues{/number}","pulls_url":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls{/number}","milestones_url":"https://api.github.com/repos/intellij-rust/intellij-rust/milestones{/number}","notifications_url":"https://api.github.com/repos/intellij-rust/intellij-rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/intellij-rust/intellij-rust/labels{/name}","releases_url":"https://api.github.com/repos/intellij-rust/intellij-rust/releases{/id}","deployments_url":"https://api.github.com/repos/intellij-rust/intellij-rust/deployments","created_at":"2015-09-16T23:44:57Z","updated_at":"2016-04-12T13:44:31Z","pushed_at":"2016-04-12T16:08:36Z","git_url":"git://github.com/intellij-rust/intellij-rust.git","ssh_url":"git@github.com:intellij-rust/intellij-rust.git","clone_url":"https://github.com/intellij-rust/intellij-rust.git","svn_url":"https://github.com/intellij-rust/intellij-rust","homepage":null,"size":6516,"stargazers_count":536,"watchers_count":536,"language":"Kotlin","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":31,"forks":40,"open_issues":31,"watchers":536,"default_branch":"master"}},"base":{"label":"intellij-rust:master","ref":"master","sha":"7caa46d2449935456a0e3e99154b6de0bede527d","user":{"login":"intellij-rust","id":16057867,"avatar_url":"https://avatars.githubusercontent.com/u/16057867?v=3","gravatar_id":"","url":"https://api.github.com/users/intellij-rust","html_url":"https://github.com/intellij-rust","followers_url":"https://api.github.com/users/intellij-rust/followers","following_url":"https://api.github.com/users/intellij-rust/following{/other_user}","gists_url":"https://api.github.com/users/intellij-rust/gists{/gist_id}","starred_url":"https://api.github.com/users/intellij-rust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intellij-rust/subscriptions","organizations_url":"https://api.github.com/users/intellij-rust/orgs","repos_url":"https://api.github.com/users/intellij-rust/repos","events_url":"https://api.github.com/users/intellij-rust/events{/privacy}","received_events_url":"https://api.github.com/users/intellij-rust/received_events","type":"Organization","site_admin":false},"repo":{"id":42619487,"name":"intellij-rust","full_name":"intellij-rust/intellij-rust","owner":{"login":"intellij-rust","id":16057867,"avatar_url":"https://avatars.githubusercontent.com/u/16057867?v=3","gravatar_id":"","url":"https://api.github.com/users/intellij-rust","html_url":"https://github.com/intellij-rust","followers_url":"https://api.github.com/users/intellij-rust/followers","following_url":"https://api.github.com/users/intellij-rust/following{/other_user}","gists_url":"https://api.github.com/users/intellij-rust/gists{/gist_id}","starred_url":"https://api.github.com/users/intellij-rust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intellij-rust/subscriptions","organizations_url":"https://api.github.com/users/intellij-rust/orgs","repos_url":"https://api.github.com/users/intellij-rust/repos","events_url":"https://api.github.com/users/intellij-rust/events{/privacy}","received_events_url":"https://api.github.com/users/intellij-rust/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/intellij-rust/intellij-rust","description":"Rust IDE built using the IntelliJ Platform","fork":false,"url":"https://api.github.com/repos/intellij-rust/intellij-rust","forks_url":"https://api.github.com/repos/intellij-rust/intellij-rust/forks","keys_url":"https://api.github.com/repos/intellij-rust/intellij-rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/intellij-rust/intellij-rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/intellij-rust/intellij-rust/teams","hooks_url":"https://api.github.com/repos/intellij-rust/intellij-rust/hooks","issue_events_url":"https://api.github.com/repos/intellij-rust/intellij-rust/issues/events{/number}","events_url":"https://api.github.com/repos/intellij-rust/intellij-rust/events","assignees_url":"https://api.github.com/repos/intellij-rust/intellij-rust/assignees{/user}","branches_url":"https://api.github.com/repos/intellij-rust/intellij-rust/branches{/branch}","tags_url":"https://api.github.com/repos/intellij-rust/intellij-rust/tags","blobs_url":"https://api.github.com/repos/intellij-rust/intellij-rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/intellij-rust/intellij-rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/intellij-rust/intellij-rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/intellij-rust/intellij-rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/intellij-rust/intellij-rust/statuses/{sha}","languages_url":"https://api.github.com/repos/intellij-rust/intellij-rust/languages","stargazers_url":"https://api.github.com/repos/intellij-rust/intellij-rust/stargazers","contributors_url":"https://api.github.com/repos/intellij-rust/intellij-rust/contributors","subscribers_url":"https://api.github.com/repos/intellij-rust/intellij-rust/subscribers","subscription_url":"https://api.github.com/repos/intellij-rust/intellij-rust/subscription","commits_url":"https://api.github.com/repos/intellij-rust/intellij-rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/intellij-rust/intellij-rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/intellij-rust/intellij-rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/intellij-rust/intellij-rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/intellij-rust/intellij-rust/contents/{+path}","compare_url":"https://api.github.com/repos/intellij-rust/intellij-rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/intellij-rust/intellij-rust/merges","archive_url":"https://api.github.com/repos/intellij-rust/intellij-rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/intellij-rust/intellij-rust/downloads","issues_url":"https://api.github.com/repos/intellij-rust/intellij-rust/issues{/number}","pulls_url":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls{/number}","milestones_url":"https://api.github.com/repos/intellij-rust/intellij-rust/milestones{/number}","notifications_url":"https://api.github.com/repos/intellij-rust/intellij-rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/intellij-rust/intellij-rust/labels{/name}","releases_url":"https://api.github.com/repos/intellij-rust/intellij-rust/releases{/id}","deployments_url":"https://api.github.com/repos/intellij-rust/intellij-rust/deployments","created_at":"2015-09-16T23:44:57Z","updated_at":"2016-04-12T13:44:31Z","pushed_at":"2016-04-12T16:08:36Z","git_url":"git://github.com/intellij-rust/intellij-rust.git","ssh_url":"git@github.com:intellij-rust/intellij-rust.git","clone_url":"https://github.com/intellij-rust/intellij-rust.git","svn_url":"https://github.com/intellij-rust/intellij-rust","homepage":null,"size":6516,"stargazers_count":536,"watchers_count":536,"language":"Kotlin","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":31,"forks":40,"open_issues":31,"watchers":536,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls/323"},"html":{"href":"https://github.com/intellij-rust/intellij-rust/pull/323"},"issue":{"href":"https://api.github.com/repos/intellij-rust/intellij-rust/issues/323"},"comments":{"href":"https://api.github.com/repos/intellij-rust/intellij-rust/issues/323/comments"},"review_comments":{"href":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls/323/comments"},"review_comment":{"href":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/intellij-rust/intellij-rust/pulls/323/commits"},"statuses":{"href":"https://api.github.com/repos/intellij-rust/intellij-rust/statuses/cab6edd83e0f52618b21fb3af7d9295cc37f7cf1"}}}}