{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/PTVS/pulls/comments/183552081","pull_request_review_id":114572712,"id":183552081,"diff_hunk":"@@ -0,0 +1,73 @@\n+﻿// Python Tools for Visual Studio\n+// Copyright(c) Microsoft Corporation\n+// All rights reserved.\n+//\n+// Licensed under the Apache License, Version 2.0 (the License); you may not use\n+// this file except in compliance with the License. You may obtain a copy of the\n+// License at http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// THIS CODE IS PROVIDED ON AN  *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS\n+// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY\n+// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\n+// MERCHANTABLITY OR NON-INFRINGEMENT.\n+//\n+// See the Apache Version 2.0 License for specific language governing\n+// permissions and limitations under the License.\n+\n+using System;\n+using System.Collections.Concurrent;\n+using System.Collections.Generic;\n+using System.Globalization;\n+using System.Linq;\n+using Microsoft.PythonTools.Analysis.Infrastructure;\n+using Microsoft.PythonTools.Intellisense;\n+using Microsoft.PythonTools.Parsing.Ast;\n+\n+namespace Microsoft.PythonTools.Analysis.LanguageServer {\n+    sealed class ProjectFiles {\n+        private readonly ConcurrentDictionary<Uri, IProjectEntry> _projectFiles = new ConcurrentDictionary<Uri, IProjectEntry>();\n+\n+        public void Clear() => _projectFiles.Clear();\n+        public IProjectEntry GetOrAddEntry(Uri documentUri, IProjectEntry entry) => _projectFiles.GetOrAdd(documentUri, entry);\n+        public IProjectEntry RemoveEntry(Uri documentUri) => _projectFiles.TryRemove(documentUri, out var entry) ? entry : null;\n+        public IEnumerable<IProjectEntry> All => _projectFiles.Values;\n+        public IEnumerable<string> GetLoadedFiles() => _projectFiles.Keys.Select(k => k.AbsoluteUri);\n+\n+        public IProjectEntry GetEntry(TextDocumentIdentifier document) => GetEntry(document.uri);\n+        public IProjectEntry GetEntry(Uri documentUri, bool throwIfMissing = true) {\n+            IProjectEntry entry = null;\n+            if ((documentUri == null || !_projectFiles.TryGetValue(documentUri, out entry)) && throwIfMissing) {\n+                throw new LanguageServerException(LanguageServerException.UnknownDocument, \"unknown document\");\n+            }\n+            return entry;\n+        }\n+\n+        public void GetAnalysis(TextDocumentIdentifier document, Position position, int? expectedVersion, out ProjectEntry entry, out PythonAst tree) {\n+            entry = GetEntry(document) as ProjectEntry;\n+            if (entry == null) {\n+                throw new LanguageServerException(LanguageServerException.UnsupportedDocumentType, \"unsupported document\");\n+            }\n+            var parse = entry.GetCurrentParse();\n+            tree = parse?.Tree;\n+            if (expectedVersion.HasValue && parse?.Cookie is VersionCookie vc) {\n+                if (vc.Versions.TryGetValue(GetPart(document.uri), out var bv)) {\n+                    if (bv.Version != expectedVersion.Value) {\n+                        // throw new LanguageServerException(LanguageServerException.MismatchedVersion, $\"document is at version {bv.Version}; expected {expectedVersion.Value}\");","path":"Python/Product/Analysis/LanguageServer/ProjectFiles.cs","position":55,"original_position":55,"commit_id":"aec3bd9f198ded5dd46bd04098d6c899d8d5c9e8","original_commit_id":"aec3bd9f198ded5dd46bd04098d6c899d8d5c9e8","user":{"login":"zooba","id":1693688,"avatar_url":"https://avatars2.githubusercontent.com/u/1693688?v=4","gravatar_id":"","url":"https://api.github.com/users/zooba","html_url":"https://github.com/zooba","followers_url":"https://api.github.com/users/zooba/followers","following_url":"https://api.github.com/users/zooba/following{/other_user}","gists_url":"https://api.github.com/users/zooba/gists{/gist_id}","starred_url":"https://api.github.com/users/zooba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zooba/subscriptions","organizations_url":"https://api.github.com/users/zooba/orgs","repos_url":"https://api.github.com/users/zooba/repos","events_url":"https://api.github.com/users/zooba/events{/privacy}","received_events_url":"https://api.github.com/users/zooba/received_events","type":"User","site_admin":false},"body":"We should already have a tree at this point, but this is a better tree if a specific version is required.","created_at":"2018-04-23T22:06:48Z","updated_at":"2018-04-23T22:06:48Z","html_url":"https://github.com/Microsoft/PTVS/pull/4094#discussion_r183552081","pull_request_url":"https://api.github.com/repos/Microsoft/PTVS/pulls/4094","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/PTVS/pulls/comments/183552081"},"html":{"href":"https://github.com/Microsoft/PTVS/pull/4094#discussion_r183552081"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/PTVS/pulls/4094"}},"in_reply_to_id":183489674},"pull_request":{"url":"https://api.github.com/repos/Microsoft/PTVS/pulls/4094","id":183188901,"html_url":"https://github.com/Microsoft/PTVS/pull/4094","diff_url":"https://github.com/Microsoft/PTVS/pull/4094.diff","patch_url":"https://github.com/Microsoft/PTVS/pull/4094.patch","issue_url":"https://api.github.com/repos/Microsoft/PTVS/issues/4094","number":4094,"state":"open","locked":false,"title":"Code split + better change request synchronization + completion experience improvements","user":{"login":"MikhailArkhipov","id":12820357,"avatar_url":"https://avatars2.githubusercontent.com/u/12820357?v=4","gravatar_id":"","url":"https://api.github.com/users/MikhailArkhipov","html_url":"https://github.com/MikhailArkhipov","followers_url":"https://api.github.com/users/MikhailArkhipov/followers","following_url":"https://api.github.com/users/MikhailArkhipov/following{/other_user}","gists_url":"https://api.github.com/users/MikhailArkhipov/gists{/gist_id}","starred_url":"https://api.github.com/users/MikhailArkhipov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MikhailArkhipov/subscriptions","organizations_url":"https://api.github.com/users/MikhailArkhipov/orgs","repos_url":"https://api.github.com/users/MikhailArkhipov/repos","events_url":"https://api.github.com/users/MikhailArkhipov/events{/privacy}","received_events_url":"https://api.github.com/users/MikhailArkhipov/received_events","type":"User","site_admin":false},"body":"- Splits Server into partial classes\r\n- Remove custom doc change/completion synchronization and instead use new StreamJsonRpc sync context feature\r\n- Preserve previous analysis dictionaries while new analysis still running (improves experience in VSC)\r\n- Add small wait to completion letting analysis to complete if it is close\r\n- Add ability to hide `__` members for VSC","created_at":"2018-04-20T23:07:22Z","updated_at":"2018-04-23T22:06:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ffe6e505921ac03c61bed80171adc3888cb61907","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/PTVS/pulls/4094/commits","review_comments_url":"https://api.github.com/repos/Microsoft/PTVS/pulls/4094/comments","review_comment_url":"https://api.github.com/repos/Microsoft/PTVS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/PTVS/issues/4094/comments","statuses_url":"https://api.github.com/repos/Microsoft/PTVS/statuses/aec3bd9f198ded5dd46bd04098d6c899d8d5c9e8","head":{"label":"MikhailArkhipov:analysis","ref":"analysis","sha":"aec3bd9f198ded5dd46bd04098d6c899d8d5c9e8","user":{"login":"MikhailArkhipov","id":12820357,"avatar_url":"https://avatars2.githubusercontent.com/u/12820357?v=4","gravatar_id":"","url":"https://api.github.com/users/MikhailArkhipov","html_url":"https://github.com/MikhailArkhipov","followers_url":"https://api.github.com/users/MikhailArkhipov/followers","following_url":"https://api.github.com/users/MikhailArkhipov/following{/other_user}","gists_url":"https://api.github.com/users/MikhailArkhipov/gists{/gist_id}","starred_url":"https://api.github.com/users/MikhailArkhipov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MikhailArkhipov/subscriptions","organizations_url":"https://api.github.com/users/MikhailArkhipov/orgs","repos_url":"https://api.github.com/users/MikhailArkhipov/repos","events_url":"https://api.github.com/users/MikhailArkhipov/events{/privacy}","received_events_url":"https://api.github.com/users/MikhailArkhipov/received_events","type":"User","site_admin":false},"repo":{"id":127790114,"name":"PTVS","full_name":"MikhailArkhipov/PTVS","owner":{"login":"MikhailArkhipov","id":12820357,"avatar_url":"https://avatars2.githubusercontent.com/u/12820357?v=4","gravatar_id":"","url":"https://api.github.com/users/MikhailArkhipov","html_url":"https://github.com/MikhailArkhipov","followers_url":"https://api.github.com/users/MikhailArkhipov/followers","following_url":"https://api.github.com/users/MikhailArkhipov/following{/other_user}","gists_url":"https://api.github.com/users/MikhailArkhipov/gists{/gist_id}","starred_url":"https://api.github.com/users/MikhailArkhipov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MikhailArkhipov/subscriptions","organizations_url":"https://api.github.com/users/MikhailArkhipov/orgs","repos_url":"https://api.github.com/users/MikhailArkhipov/repos","events_url":"https://api.github.com/users/MikhailArkhipov/events{/privacy}","received_events_url":"https://api.github.com/users/MikhailArkhipov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MikhailArkhipov/PTVS","description":"Python Tools for Visual Studio","fork":true,"url":"https://api.github.com/repos/MikhailArkhipov/PTVS","forks_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/forks","keys_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/teams","hooks_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/hooks","issue_events_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/issues/events{/number}","events_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/events","assignees_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/assignees{/user}","branches_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/branches{/branch}","tags_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/tags","blobs_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/git/refs{/sha}","trees_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/statuses/{sha}","languages_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/languages","stargazers_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/stargazers","contributors_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/contributors","subscribers_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/subscribers","subscription_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/subscription","commits_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/commits{/sha}","git_commits_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/git/commits{/sha}","comments_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/comments{/number}","issue_comment_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/issues/comments{/number}","contents_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/contents/{+path}","compare_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/merges","archive_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/downloads","issues_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/issues{/number}","pulls_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/pulls{/number}","milestones_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/milestones{/number}","notifications_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/labels{/name}","releases_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/releases{/id}","deployments_url":"https://api.github.com/repos/MikhailArkhipov/PTVS/deployments","created_at":"2018-04-02T17:36:52Z","updated_at":"2018-04-11T17:07:43Z","pushed_at":"2018-04-23T17:24:49Z","git_url":"git://github.com/MikhailArkhipov/PTVS.git","ssh_url":"git@github.com:MikhailArkhipov/PTVS.git","clone_url":"https://github.com/MikhailArkhipov/PTVS.git","svn_url":"https://github.com/MikhailArkhipov/PTVS","homepage":"https://aka.ms/PTVS","size":186075,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"728e0b01742cce08f317c7fdf902057f5fd7b36f","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":32487763,"name":"PTVS","full_name":"Microsoft/PTVS","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/PTVS","description":"Python Tools for Visual Studio","fork":false,"url":"https://api.github.com/repos/Microsoft/PTVS","forks_url":"https://api.github.com/repos/Microsoft/PTVS/forks","keys_url":"https://api.github.com/repos/Microsoft/PTVS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/PTVS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/PTVS/teams","hooks_url":"https://api.github.com/repos/Microsoft/PTVS/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/PTVS/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/PTVS/events","assignees_url":"https://api.github.com/repos/Microsoft/PTVS/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/PTVS/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/PTVS/tags","blobs_url":"https://api.github.com/repos/Microsoft/PTVS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/PTVS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/PTVS/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/PTVS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/PTVS/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/PTVS/languages","stargazers_url":"https://api.github.com/repos/Microsoft/PTVS/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/PTVS/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/PTVS/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/PTVS/subscription","commits_url":"https://api.github.com/repos/Microsoft/PTVS/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/PTVS/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/PTVS/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/PTVS/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/PTVS/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/PTVS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/PTVS/merges","archive_url":"https://api.github.com/repos/Microsoft/PTVS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/PTVS/downloads","issues_url":"https://api.github.com/repos/Microsoft/PTVS/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/PTVS/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/PTVS/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/PTVS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/PTVS/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/PTVS/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/PTVS/deployments","created_at":"2015-03-18T22:30:53Z","updated_at":"2018-04-23T19:06:00Z","pushed_at":"2018-04-23T21:40:41Z","git_url":"git://github.com/Microsoft/PTVS.git","ssh_url":"git@github.com:Microsoft/PTVS.git","clone_url":"https://github.com/Microsoft/PTVS.git","svn_url":"https://github.com/Microsoft/PTVS","homepage":"https://aka.ms/PTVS","size":187208,"stargazers_count":1936,"watchers_count":1936,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":508,"mirror_url":null,"archived":false,"open_issues_count":526,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":508,"open_issues":526,"watchers":1936,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/PTVS/pulls/4094"},"html":{"href":"https://github.com/Microsoft/PTVS/pull/4094"},"issue":{"href":"https://api.github.com/repos/Microsoft/PTVS/issues/4094"},"comments":{"href":"https://api.github.com/repos/Microsoft/PTVS/issues/4094/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/PTVS/pulls/4094/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/PTVS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/PTVS/pulls/4094/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/PTVS/statuses/aec3bd9f198ded5dd46bd04098d6c899d8d5c9e8"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"zooba"}}