{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/6878","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/6878/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/6878/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/6878/events","html_url":"https://github.com/dotnet/roslyn/pull/6878","id":117889126,"number":6878,"title":"Implement \"Target type preselection\"","user":{"login":"rchande","id":3751401,"avatar_url":"https://avatars.githubusercontent.com/u/3751401?v=3","gravatar_id":"","url":"https://api.github.com/users/rchande","html_url":"https://github.com/rchande","followers_url":"https://api.github.com/users/rchande/followers","following_url":"https://api.github.com/users/rchande/following{/other_user}","gists_url":"https://api.github.com/users/rchande/gists{/gist_id}","starred_url":"https://api.github.com/users/rchande/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rchande/subscriptions","organizations_url":"https://api.github.com/users/rchande/orgs","repos_url":"https://api.github.com/users/rchande/repos","events_url":"https://api.github.com/users/rchande/events{/privacy}","received_events_url":"https://api.github.com/users/rchande/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-IDE","name":"Area-IDE","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/cla-already-signed","name":"cla-already-signed","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":19,"created_at":"2015-11-19T19:28:45Z","updated_at":"2016-02-22T21:42:57Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/6878","html_url":"https://github.com/dotnet/roslyn/pull/6878","diff_url":"https://github.com/dotnet/roslyn/pull/6878.diff","patch_url":"https://github.com/dotnet/roslyn/pull/6878.patch"},"body":"A common dogfooding complaint is that, in the following case, IntelliSense will select the type \"CancellationToken\" instead of the parameter \"cancellationToken\" as the user types.\r\n\r\n``` C#\r\n    static void Foo(int x, CancellationToken cancellationToken)\r\n    {\r\n        Foo(1, cancellationToken:$$ );\r\n    }\r\n```\r\n\r\nWith this change, completion now attempts to determine the \"target type\" required at a position and will attempt to preselect items in the list matching that type. To accomplish this:\r\n* The boolean \"preselect bit\" has been placed with an Enum, \"MatchPriority\". This enum allows the matching algorithm to differentiate between items that should be always preselected (enums, object creation), and items that can be opportunistically preselected for target typing.\r\n* The C# and VB Symbol providers infer the target type and ask to preselect any symbols that match that type.\r\n* A new rule has been added to CompletionItemRules which allows items with the same MatchPriority and provider to determine which is a better match. This allows target typing to provide slightly more effective matches.\r\n\r\nNot yet implemented:\r\n- [ ] Target typing based on type convertibility. We need to come up with a better approach for completion than walking the entire type hierarchy for every symbol it might preselect, because that's too slow.\r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/187399436","html_url":"https://github.com/dotnet/roslyn/pull/6878#issuecomment-187399436","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/6878","id":187399436,"user":{"login":"CyrusNajmabadi","id":4564579,"avatar_url":"https://avatars.githubusercontent.com/u/4564579?v=3","gravatar_id":"","url":"https://api.github.com/users/CyrusNajmabadi","html_url":"https://github.com/CyrusNajmabadi","followers_url":"https://api.github.com/users/CyrusNajmabadi/followers","following_url":"https://api.github.com/users/CyrusNajmabadi/following{/other_user}","gists_url":"https://api.github.com/users/CyrusNajmabadi/gists{/gist_id}","starred_url":"https://api.github.com/users/CyrusNajmabadi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CyrusNajmabadi/subscriptions","organizations_url":"https://api.github.com/users/CyrusNajmabadi/orgs","repos_url":"https://api.github.com/users/CyrusNajmabadi/repos","events_url":"https://api.github.com/users/CyrusNajmabadi/events{/privacy}","received_events_url":"https://api.github.com/users/CyrusNajmabadi/received_events","type":"User","site_admin":false},"created_at":"2016-02-22T21:42:57Z","updated_at":"2016-02-22T21:42:57Z","body":"Feel free to keep pinging me."}}