{"action":"created","issue":{"url":"https://api.github.com/repos/haskell/haskell-ide-engine/issues/1334","repository_url":"https://api.github.com/repos/haskell/haskell-ide-engine","labels_url":"https://api.github.com/repos/haskell/haskell-ide-engine/issues/1334/labels{/name}","comments_url":"https://api.github.com/repos/haskell/haskell-ide-engine/issues/1334/comments","events_url":"https://api.github.com/repos/haskell/haskell-ide-engine/issues/1334/events","html_url":"https://github.com/haskell/haskell-ide-engine/pull/1334","id":470695276,"node_id":"MDExOlB1bGxSZXF1ZXN0Mjk5NTc3OTQ1","number":1334,"title":"Simpler completion","user":{"login":"wz1000","id":4812498,"node_id":"MDQ6VXNlcjQ4MTI0OTg=","avatar_url":"https://avatars1.githubusercontent.com/u/4812498?v=4","gravatar_id":"","url":"https://api.github.com/users/wz1000","html_url":"https://github.com/wz1000","followers_url":"https://api.github.com/users/wz1000/followers","following_url":"https://api.github.com/users/wz1000/following{/other_user}","gists_url":"https://api.github.com/users/wz1000/gists{/gist_id}","starred_url":"https://api.github.com/users/wz1000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wz1000/subscriptions","organizations_url":"https://api.github.com/users/wz1000/orgs","repos_url":"https://api.github.com/users/wz1000/repos","events_url":"https://api.github.com/users/wz1000/events{/privacy}","received_events_url":"https://api.github.com/users/wz1000/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2019-07-20T17:09:46Z","updated_at":"2019-07-21T06:56:33Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/haskell/haskell-ide-engine/pulls/1334","html_url":"https://github.com/haskell/haskell-ide-engine/pull/1334","diff_url":"https://github.com/haskell/haskell-ide-engine/pull/1334.diff","patch_url":"https://github.com/haskell/haskell-ide-engine/pull/1334.patch"},"body":"After @mpickering pointed this out yesterday, I noticed that completion was a lot more complicated than it needed to be. Instead of the convoluted wrangling we do with import declarations, all the information we need is in the `GlobalRdrEnv`.\r\n\r\nIn addition to this, I've separated out the step of getting the type information/snippets for the completion into the LSP `CompletionItemResolve` request. Type information for local variables which\r\nis readily at hand in the `TypecheckedModule` itself is still reported in the original completion request.\r\n\r\nA potential performance issue I've tried to fix is that looking up the types of all the possible completions would result in GHC loading a bunch of interface files it didn't need to.\r\n\r\nFor example, consider a module that imports `Prelude`, but doesn't use any functions from `GHC.Enum`(like `enumFrom`). Normally, GHC will not load the interface file for `GHC.Enum`. However, when we try to get the type of the `enumFrom` completion, this forces GHC to go and actually load the interface file for that module. \r\n\r\nI've implemented the function we used to look up the type information to just return `Nothing` in this case and not try to load the `GHC.Enum` interface file. You can see this in action in the `\"does not pull in unnecessary modules until needed\"` test case I've added.\r\n\r\nThe above behaviour is up for discussion, and I will re-implement the old/default behaviour for `getTypeForName` depending on the consensus.\r\n\r\nThe behavioural changes due to this PR are:\r\n\r\n- Completion items need to be resolved to get their type information/snippets.\r\n- The types/snippets for some functions from modules that haven't been used previously may not be available, as described above."},"comment":{"url":"https://api.github.com/repos/haskell/haskell-ide-engine/issues/comments/513528892","html_url":"https://github.com/haskell/haskell-ide-engine/pull/1334#issuecomment-513528892","issue_url":"https://api.github.com/repos/haskell/haskell-ide-engine/issues/1334","id":513528892,"node_id":"MDEyOklzc3VlQ29tbWVudDUxMzUyODg5Mg==","user":{"login":"wz1000","id":4812498,"node_id":"MDQ6VXNlcjQ4MTI0OTg=","avatar_url":"https://avatars1.githubusercontent.com/u/4812498?v=4","gravatar_id":"","url":"https://api.github.com/users/wz1000","html_url":"https://github.com/wz1000","followers_url":"https://api.github.com/users/wz1000/followers","following_url":"https://api.github.com/users/wz1000/following{/other_user}","gists_url":"https://api.github.com/users/wz1000/gists{/gist_id}","starred_url":"https://api.github.com/users/wz1000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wz1000/subscriptions","organizations_url":"https://api.github.com/users/wz1000/orgs","repos_url":"https://api.github.com/users/wz1000/repos","events_url":"https://api.github.com/users/wz1000/events{/privacy}","received_events_url":"https://api.github.com/users/wz1000/received_events","type":"User","site_admin":false},"created_at":"2019-07-21T06:56:33Z","updated_at":"2019-07-21T06:56:33Z","author_association":"COLLABORATOR","body":"@bubba, @lorenzo any comments on the type lookup behaviour? If I restore the old behaviour, because looking up the type is anyway done in the `resolveCompletion` step, the interface file would only be loaded in when the user goes over the relevant completion (or whenever the client decides to resolve the completion)."}}
{"actor":{"display_login":"wz1000"}}