{"action":"created","comment":{"url":"https://api.github.com/repos/klazuka/intellij-elm/pulls/comments/327646078","pull_request_review_id":292461584,"id":327646078,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMyNzY0NjA3OA==","diff_hunk":"@@ -7,53 +7,73 @@\n \n package org.elm.lang.core.psi\n \n+import com.intellij.injected.editor.VirtualFileWindow\n import com.intellij.openapi.components.ProjectComponent\n import com.intellij.openapi.project.Project\n import com.intellij.openapi.util.SimpleModificationTracker\n import com.intellij.psi.*\n+import com.intellij.psi.PsiTreeChangeEvent.PROP_WRITABLE\n import com.intellij.psi.impl.PsiTreeChangeEventImpl\n+import com.intellij.psi.util.PsiModificationTracker\n import org.elm.lang.core.ElmFileType\n-import org.elm.lang.core.psi.elements.ElmValueDeclaration\n+import org.elm.lang.core.psi.elements.ElmFunctionDeclarationLeft\n \n class ElmPsiManager(val project: Project) : ProjectComponent {\n+    /**\n+     * A modification tracker that is incremented on PSI changes that can affect non-local references or inference.\n+     *\n+     * It is incremented whenever a non-whitespace, non-comment change is made to the PSI of an Elm\n+     * file outside of function bodies.\n+     */\n     val modificationTracker = SimpleModificationTracker()\n \n     override fun projectOpened() {\n         PsiManager.getInstance(project).addPsiTreeChangeListener(CacheInvalidator())\n     }\n \n     inner class CacheInvalidator : PsiTreeChangeAdapter() {\n-        override fun beforeChildRemoval(event: PsiTreeChangeEvent) = onPsiChange(event)\n-        override fun childReplaced(event: PsiTreeChangeEvent) = onPsiChange(event)\n-        override fun childAdded(event: PsiTreeChangeEvent) = onPsiChange(event)\n-        override fun childrenChanged(event: PsiTreeChangeEvent) = onPsiChange(event)\n-        override fun childMoved(event: PsiTreeChangeEvent) = onPsiChange(event)\n-        override fun propertyChanged(event: PsiTreeChangeEvent) = onPsiChange(event)\n-\n-        private fun onPsiChange(event: PsiTreeChangeEvent) {\n+        override fun beforeChildRemoval(event: PsiTreeChangeEvent) = onPsiChange(event, event.child)\n+        override fun beforeChildReplacement(event: PsiTreeChangeEvent) = onPsiChange(event, event.oldChild)\n+        override fun beforeChildMovement(event: PsiTreeChangeEvent) = onPsiChange(event, event.child)\n+        override fun childReplaced(event: PsiTreeChangeEvent) = onPsiChange(event, event.newChild)\n+        override fun childAdded(event: PsiTreeChangeEvent) = onPsiChange(event, event.child)\n+        override fun childMoved(event: PsiTreeChangeEvent) = onPsiChange(event, event.child)\n+        override fun childrenChanged(event: PsiTreeChangeEvent) {\n             // `GenericChange` event means that \"something changed in the file\" and sends\n             // after all events for concrete PSI changes in a file.\n-            // We handle more concrete events and so should ignore generic event\n-            if (event is PsiTreeChangeEventImpl && event.isGenericChange) return\n+            // We handle more concrete events and so should ignore the generic event.\n+            if (event !is PsiTreeChangeEventImpl || !event.isGenericChange) onPsiChange(event, event.parent)\n+        }\n \n-            // There are some cases when PsiFile stored in the event as a child\n-            // e.g. file removal by external VFS change\n-            val file = event.file ?: event.child as? PsiFile\n-            if (file?.fileType != ElmFileType) return\n+        override fun propertyChanged(event: PsiTreeChangeEvent) {","path":"src/main/kotlin/org/elm/lang/core/psi/ElmPsiManager.kt","position":57,"original_position":57,"commit_id":"344cbbda9c3ec49fa3410cd08b990976f3218649","original_commit_id":"344cbbda9c3ec49fa3410cd08b990976f3218649","user":{"login":"klazuka","id":84525,"node_id":"MDQ6VXNlcjg0NTI1","avatar_url":"https://avatars0.githubusercontent.com/u/84525?v=4","gravatar_id":"","url":"https://api.github.com/users/klazuka","html_url":"https://github.com/klazuka","followers_url":"https://api.github.com/users/klazuka/followers","following_url":"https://api.github.com/users/klazuka/following{/other_user}","gists_url":"https://api.github.com/users/klazuka/gists{/gist_id}","starred_url":"https://api.github.com/users/klazuka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klazuka/subscriptions","organizations_url":"https://api.github.com/users/klazuka/orgs","repos_url":"https://api.github.com/users/klazuka/repos","events_url":"https://api.github.com/users/klazuka/events{/privacy}","received_events_url":"https://api.github.com/users/klazuka/received_events","type":"User","site_admin":false},"body":"The javadoc on `PsiTreeChangeEvent` is pretty scary. But I guess we've been doing it for a while, so what can possibly go wrong 😄","created_at":"2019-09-24T14:25:14Z","updated_at":"2019-09-24T14:39:30Z","html_url":"https://github.com/klazuka/intellij-elm/pull/516#discussion_r327646078","pull_request_url":"https://api.github.com/repos/klazuka/intellij-elm/pulls/516","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/klazuka/intellij-elm/pulls/comments/327646078"},"html":{"href":"https://github.com/klazuka/intellij-elm/pull/516#discussion_r327646078"},"pull_request":{"href":"https://api.github.com/repos/klazuka/intellij-elm/pulls/516"}}},"pull_request":{"url":"https://api.github.com/repos/klazuka/intellij-elm/pulls/516","id":320521558,"node_id":"MDExOlB1bGxSZXF1ZXN0MzIwNTIxNTU4","html_url":"https://github.com/klazuka/intellij-elm/pull/516","diff_url":"https://github.com/klazuka/intellij-elm/pull/516.diff","patch_url":"https://github.com/klazuka/intellij-elm/pull/516.patch","issue_url":"https://api.github.com/repos/klazuka/intellij-elm/issues/516","number":516,"state":"open","locked":false,"title":"Fix several cache invalidation bugs","user":{"login":"ajalt","id":1109214,"node_id":"MDQ6VXNlcjExMDkyMTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1109214?v=4","gravatar_id":"","url":"https://api.github.com/users/ajalt","html_url":"https://github.com/ajalt","followers_url":"https://api.github.com/users/ajalt/followers","following_url":"https://api.github.com/users/ajalt/following{/other_user}","gists_url":"https://api.github.com/users/ajalt/gists{/gist_id}","starred_url":"https://api.github.com/users/ajalt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajalt/subscriptions","organizations_url":"https://api.github.com/users/ajalt/orgs","repos_url":"https://api.github.com/users/ajalt/repos","events_url":"https://api.github.com/users/ajalt/events{/privacy}","received_events_url":"https://api.github.com/users/ajalt/received_events","type":"User","site_admin":false},"body":"- Language injections don't have an event system, so we need to invalidate their contents on any PSI change\r\n- Invalidate globally when the body of an unannotated top-level function changes, since that can change the return type or parameters\r\n- Invalidate globally when a VFS directory is deleted","created_at":"2019-09-23T23:31:57Z","updated_at":"2019-09-24T14:39:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"706aada228947114892129c50c4cdec6512fbc16","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/klazuka/intellij-elm/pulls/516/commits","review_comments_url":"https://api.github.com/repos/klazuka/intellij-elm/pulls/516/comments","review_comment_url":"https://api.github.com/repos/klazuka/intellij-elm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/klazuka/intellij-elm/issues/516/comments","statuses_url":"https://api.github.com/repos/klazuka/intellij-elm/statuses/344cbbda9c3ec49fa3410cd08b990976f3218649","head":{"label":"ajalt:aj/better-cache","ref":"aj/better-cache","sha":"344cbbda9c3ec49fa3410cd08b990976f3218649","user":{"login":"ajalt","id":1109214,"node_id":"MDQ6VXNlcjExMDkyMTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1109214?v=4","gravatar_id":"","url":"https://api.github.com/users/ajalt","html_url":"https://github.com/ajalt","followers_url":"https://api.github.com/users/ajalt/followers","following_url":"https://api.github.com/users/ajalt/following{/other_user}","gists_url":"https://api.github.com/users/ajalt/gists{/gist_id}","starred_url":"https://api.github.com/users/ajalt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajalt/subscriptions","organizations_url":"https://api.github.com/users/ajalt/orgs","repos_url":"https://api.github.com/users/ajalt/repos","events_url":"https://api.github.com/users/ajalt/events{/privacy}","received_events_url":"https://api.github.com/users/ajalt/received_events","type":"User","site_admin":false},"repo":{"id":141737472,"node_id":"MDEwOlJlcG9zaXRvcnkxNDE3Mzc0NzI=","name":"intellij-elm","full_name":"ajalt/intellij-elm","private":false,"owner":{"login":"ajalt","id":1109214,"node_id":"MDQ6VXNlcjExMDkyMTQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1109214?v=4","gravatar_id":"","url":"https://api.github.com/users/ajalt","html_url":"https://github.com/ajalt","followers_url":"https://api.github.com/users/ajalt/followers","following_url":"https://api.github.com/users/ajalt/following{/other_user}","gists_url":"https://api.github.com/users/ajalt/gists{/gist_id}","starred_url":"https://api.github.com/users/ajalt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajalt/subscriptions","organizations_url":"https://api.github.com/users/ajalt/orgs","repos_url":"https://api.github.com/users/ajalt/repos","events_url":"https://api.github.com/users/ajalt/events{/privacy}","received_events_url":"https://api.github.com/users/ajalt/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ajalt/intellij-elm","description":"Elm language support for IntelliJ, WebStorm, PhpStorm and PyCharm (JetBrains)","fork":true,"url":"https://api.github.com/repos/ajalt/intellij-elm","forks_url":"https://api.github.com/repos/ajalt/intellij-elm/forks","keys_url":"https://api.github.com/repos/ajalt/intellij-elm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ajalt/intellij-elm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ajalt/intellij-elm/teams","hooks_url":"https://api.github.com/repos/ajalt/intellij-elm/hooks","issue_events_url":"https://api.github.com/repos/ajalt/intellij-elm/issues/events{/number}","events_url":"https://api.github.com/repos/ajalt/intellij-elm/events","assignees_url":"https://api.github.com/repos/ajalt/intellij-elm/assignees{/user}","branches_url":"https://api.github.com/repos/ajalt/intellij-elm/branches{/branch}","tags_url":"https://api.github.com/repos/ajalt/intellij-elm/tags","blobs_url":"https://api.github.com/repos/ajalt/intellij-elm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ajalt/intellij-elm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ajalt/intellij-elm/git/refs{/sha}","trees_url":"https://api.github.com/repos/ajalt/intellij-elm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ajalt/intellij-elm/statuses/{sha}","languages_url":"https://api.github.com/repos/ajalt/intellij-elm/languages","stargazers_url":"https://api.github.com/repos/ajalt/intellij-elm/stargazers","contributors_url":"https://api.github.com/repos/ajalt/intellij-elm/contributors","subscribers_url":"https://api.github.com/repos/ajalt/intellij-elm/subscribers","subscription_url":"https://api.github.com/repos/ajalt/intellij-elm/subscription","commits_url":"https://api.github.com/repos/ajalt/intellij-elm/commits{/sha}","git_commits_url":"https://api.github.com/repos/ajalt/intellij-elm/git/commits{/sha}","comments_url":"https://api.github.com/repos/ajalt/intellij-elm/comments{/number}","issue_comment_url":"https://api.github.com/repos/ajalt/intellij-elm/issues/comments{/number}","contents_url":"https://api.github.com/repos/ajalt/intellij-elm/contents/{+path}","compare_url":"https://api.github.com/repos/ajalt/intellij-elm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ajalt/intellij-elm/merges","archive_url":"https://api.github.com/repos/ajalt/intellij-elm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ajalt/intellij-elm/downloads","issues_url":"https://api.github.com/repos/ajalt/intellij-elm/issues{/number}","pulls_url":"https://api.github.com/repos/ajalt/intellij-elm/pulls{/number}","milestones_url":"https://api.github.com/repos/ajalt/intellij-elm/milestones{/number}","notifications_url":"https://api.github.com/repos/ajalt/intellij-elm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ajalt/intellij-elm/labels{/name}","releases_url":"https://api.github.com/repos/ajalt/intellij-elm/releases{/id}","deployments_url":"https://api.github.com/repos/ajalt/intellij-elm/deployments","created_at":"2018-07-20T17:00:59Z","updated_at":"2019-08-07T21:24:47Z","pushed_at":"2019-09-23T23:29:56Z","git_url":"git://github.com/ajalt/intellij-elm.git","ssh_url":"git@github.com:ajalt/intellij-elm.git","clone_url":"https://github.com/ajalt/intellij-elm.git","svn_url":"https://github.com/ajalt/intellij-elm","homepage":"https://klazuka.github.io/intellij-elm/","size":19436,"stargazers_count":0,"watchers_count":0,"language":"Kotlin","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"klazuka:master","ref":"master","sha":"84511184797cb17608fe05c5f063f37fff90435b","user":{"login":"klazuka","id":84525,"node_id":"MDQ6VXNlcjg0NTI1","avatar_url":"https://avatars0.githubusercontent.com/u/84525?v=4","gravatar_id":"","url":"https://api.github.com/users/klazuka","html_url":"https://github.com/klazuka","followers_url":"https://api.github.com/users/klazuka/followers","following_url":"https://api.github.com/users/klazuka/following{/other_user}","gists_url":"https://api.github.com/users/klazuka/gists{/gist_id}","starred_url":"https://api.github.com/users/klazuka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klazuka/subscriptions","organizations_url":"https://api.github.com/users/klazuka/orgs","repos_url":"https://api.github.com/users/klazuka/repos","events_url":"https://api.github.com/users/klazuka/events{/privacy}","received_events_url":"https://api.github.com/users/klazuka/received_events","type":"User","site_admin":false},"repo":{"id":104530474,"node_id":"MDEwOlJlcG9zaXRvcnkxMDQ1MzA0NzQ=","name":"intellij-elm","full_name":"klazuka/intellij-elm","private":false,"owner":{"login":"klazuka","id":84525,"node_id":"MDQ6VXNlcjg0NTI1","avatar_url":"https://avatars0.githubusercontent.com/u/84525?v=4","gravatar_id":"","url":"https://api.github.com/users/klazuka","html_url":"https://github.com/klazuka","followers_url":"https://api.github.com/users/klazuka/followers","following_url":"https://api.github.com/users/klazuka/following{/other_user}","gists_url":"https://api.github.com/users/klazuka/gists{/gist_id}","starred_url":"https://api.github.com/users/klazuka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klazuka/subscriptions","organizations_url":"https://api.github.com/users/klazuka/orgs","repos_url":"https://api.github.com/users/klazuka/repos","events_url":"https://api.github.com/users/klazuka/events{/privacy}","received_events_url":"https://api.github.com/users/klazuka/received_events","type":"User","site_admin":false},"html_url":"https://github.com/klazuka/intellij-elm","description":"Elm language support for IntelliJ, WebStorm, PhpStorm and PyCharm (JetBrains)","fork":false,"url":"https://api.github.com/repos/klazuka/intellij-elm","forks_url":"https://api.github.com/repos/klazuka/intellij-elm/forks","keys_url":"https://api.github.com/repos/klazuka/intellij-elm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/klazuka/intellij-elm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/klazuka/intellij-elm/teams","hooks_url":"https://api.github.com/repos/klazuka/intellij-elm/hooks","issue_events_url":"https://api.github.com/repos/klazuka/intellij-elm/issues/events{/number}","events_url":"https://api.github.com/repos/klazuka/intellij-elm/events","assignees_url":"https://api.github.com/repos/klazuka/intellij-elm/assignees{/user}","branches_url":"https://api.github.com/repos/klazuka/intellij-elm/branches{/branch}","tags_url":"https://api.github.com/repos/klazuka/intellij-elm/tags","blobs_url":"https://api.github.com/repos/klazuka/intellij-elm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/klazuka/intellij-elm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/klazuka/intellij-elm/git/refs{/sha}","trees_url":"https://api.github.com/repos/klazuka/intellij-elm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/klazuka/intellij-elm/statuses/{sha}","languages_url":"https://api.github.com/repos/klazuka/intellij-elm/languages","stargazers_url":"https://api.github.com/repos/klazuka/intellij-elm/stargazers","contributors_url":"https://api.github.com/repos/klazuka/intellij-elm/contributors","subscribers_url":"https://api.github.com/repos/klazuka/intellij-elm/subscribers","subscription_url":"https://api.github.com/repos/klazuka/intellij-elm/subscription","commits_url":"https://api.github.com/repos/klazuka/intellij-elm/commits{/sha}","git_commits_url":"https://api.github.com/repos/klazuka/intellij-elm/git/commits{/sha}","comments_url":"https://api.github.com/repos/klazuka/intellij-elm/comments{/number}","issue_comment_url":"https://api.github.com/repos/klazuka/intellij-elm/issues/comments{/number}","contents_url":"https://api.github.com/repos/klazuka/intellij-elm/contents/{+path}","compare_url":"https://api.github.com/repos/klazuka/intellij-elm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/klazuka/intellij-elm/merges","archive_url":"https://api.github.com/repos/klazuka/intellij-elm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/klazuka/intellij-elm/downloads","issues_url":"https://api.github.com/repos/klazuka/intellij-elm/issues{/number}","pulls_url":"https://api.github.com/repos/klazuka/intellij-elm/pulls{/number}","milestones_url":"https://api.github.com/repos/klazuka/intellij-elm/milestones{/number}","notifications_url":"https://api.github.com/repos/klazuka/intellij-elm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/klazuka/intellij-elm/labels{/name}","releases_url":"https://api.github.com/repos/klazuka/intellij-elm/releases{/id}","deployments_url":"https://api.github.com/repos/klazuka/intellij-elm/deployments","created_at":"2017-09-23T00:49:28Z","updated_at":"2019-09-19T15:37:46Z","pushed_at":"2019-09-23T23:31:59Z","git_url":"git://github.com/klazuka/intellij-elm.git","ssh_url":"git@github.com:klazuka/intellij-elm.git","clone_url":"https://github.com/klazuka/intellij-elm.git","svn_url":"https://github.com/klazuka/intellij-elm","homepage":"https://klazuka.github.io/intellij-elm/","size":19649,"stargazers_count":224,"watchers_count":224,"language":"Kotlin","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":17,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":65,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":17,"open_issues":65,"watchers":224,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/klazuka/intellij-elm/pulls/516"},"html":{"href":"https://github.com/klazuka/intellij-elm/pull/516"},"issue":{"href":"https://api.github.com/repos/klazuka/intellij-elm/issues/516"},"comments":{"href":"https://api.github.com/repos/klazuka/intellij-elm/issues/516/comments"},"review_comments":{"href":"https://api.github.com/repos/klazuka/intellij-elm/pulls/516/comments"},"review_comment":{"href":"https://api.github.com/repos/klazuka/intellij-elm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/klazuka/intellij-elm/pulls/516/commits"},"statuses":{"href":"https://api.github.com/repos/klazuka/intellij-elm/statuses/344cbbda9c3ec49fa3410cd08b990976f3218649"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"klazuka"}}