GitHub PullRequestReviewCommentEvent at 2014-10-17 04:46:21
Repository: angular
Actor: mhevery
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/angular/angular/pulls/comments/19001562","id":19001562,"diff_hunk":"@@ -107,10 +198,86 @@ export class ElementInjector {\n   _query1:Query;\n \n    */\n-  @FIELD('final protoInjector:ProtoElementInjector')\n-  constructor(protoInjector:ProtoElementInjector) {\n-    this.protoInjector = protoInjector;\n+\n+  @FIELD('_proto:ProtoElementInjector')\n+  @FIELD('_appInjector:Injector')\n+  constructor({proto, parent, appInjector}) {\n+    super(parent);\n+    this._proto = proto;\n+    this._appInjector = appInjector;\n+\n+    this._obj0 = null;\n+    this._obj1 = null;\n+    this._obj2 = null;\n+  }\n+\n+  instantiateDirectives() {\n+    var p = this._proto;\n+    this._obj0 = this._new(p._binding0);\n+    this._obj1 = this._new(p._binding1);\n+    this._obj2 = this._new(p._binding2);\n+  }\n+\n+  get(token) {\n+    return this._getByKey(Key.get(token), 0);\n+  }\n+\n+  _new(binding:Binding) {\n+    if (isBlank(binding)) return null;\n+\n+    var factory = binding.factory;\n+    var deps = binding.dependencies;\n+    var length = deps.length;\n+\n+    var d0,d1,d2;\n+    try {\n+      d0 = length > 0 ? this._getByDependency(deps[0]) : null;\n+      d1 = length > 1 ? this._getByDependency(deps[1]) : null;\n+      d2 = length > 2 ? this._getByDependency(deps[2]) : null;\n+    } catch(e) {\n+      if (e instanceof ProviderError) e.addKey(binding.key);\n+      throw e;\n+    }\n+\n+    var obj;\n+    switch(length) {\n+      case 0: obj = factory(); break;\n+      case 1: obj = factory(d0); break;\n+      case 2: obj = factory(d0, d1); break;\n+      case 3: obj = factory(d0, d1, d2); break;\n+    }\n+\n+    return obj;\n+  }\n+\n+  _getByDependency(dep:Dependency) {\n+    return this._getByKey(dep.key, this._depth(dep.properties));\n   }\n \n+  _getByKey(key:Key, depth:int) {\n+    var ei = this;\n+    while (ei != null && depth >= 0) {\n+      var obj = ei._getDirectiveByKey(key);\n+      if (isPresent(obj)) return obj;\n+      ei = ei._parent;\n+    }\n+    return this._appInjector.get(key);\n+  }\n+\n+  //TODO: this can be moved to Proto\n+  _depth(properties):int {\n+    if (properties.length == 0) return 0;\n+    if (properties[0] instanceof Parent) return 1;\n+    if (properties[0] instanceof Ancestor) return 99999;\n+    return 0;\n+  }\n+\n+  _getDirectiveByKey(key:Key) {\n+    var p = this._proto;\n+    if (p._keyId0 === key.id) return this._obj0;","path":"modules/core/src/compiler/element_injector.js","position":255,"original_position":255,"commit_id":"0544ba3cd98bd4f312b21e2ef3cfd000129a31ad","original_commit_id":"0544ba3cd98bd4f312b21e2ef3cfd000129a31ad","user":{"login":"mhevery","id":111951,"avatar_url":"https://avatars.githubusercontent.com/u/111951?v=2","gravatar_id":"","url":"https://api.github.com/users/mhevery","html_url":"https://github.com/mhevery","followers_url":"https://api.github.com/users/mhevery/followers","following_url":"https://api.github.com/users/mhevery/following{/other_user}","gists_url":"https://api.github.com/users/mhevery/gists{/gist_id}","starred_url":"https://api.github.com/users/mhevery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhevery/subscriptions","organizations_url":"https://api.github.com/users/mhevery/orgs","repos_url":"https://api.github.com/users/mhevery/repos","events_url":"https://api.github.com/users/mhevery/events{/privacy}","received_events_url":"https://api.github.com/users/mhevery/received_events","type":"User","site_admin":false},"body":"dereference key.id only once and store it in `var`.","created_at":"2014-10-17T04:46:21Z","updated_at":"2014-10-17T04:46:21Z","html_url":"https://github.com/angular/angular/pull/96#discussion_r19001562","pull_request_url":"https://api.github.com/repos/angular/angular/pulls/96","_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/comments/19001562"},"html":{"href":"https://github.com/angular/angular/pull/96#discussion_r19001562"},"pull_request":{"href":"https://api.github.com/repos/angular/angular/pulls/96"}}},"pull_request":{"url":"https://api.github.com/repos/angular/angular/pulls/96","id":22857441,"html_url":"https://github.com/angular/angular/pull/96","diff_url":"https://github.com/angular/angular/pull/96.diff","patch_url":"https://github.com/angular/angular/pull/96.patch","issue_url":"https://api.github.com/repos/angular/angular/issues/96","number":96,"state":"open","locked":false,"title":"feat(ElementInjector): implement ElementInjector","user":{"login":"vsavkin","id":35996,"avatar_url":"https://avatars.githubusercontent.com/u/35996?v=2","gravatar_id":"","url":"https://api.github.com/users/vsavkin","html_url":"https://github.com/vsavkin","followers_url":"https://api.github.com/users/vsavkin/followers","following_url":"https://api.github.com/users/vsavkin/following{/other_user}","gists_url":"https://api.github.com/users/vsavkin/gists{/gist_id}","starred_url":"https://api.github.com/users/vsavkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vsavkin/subscriptions","organizations_url":"https://api.github.com/users/vsavkin/orgs","repos_url":"https://api.github.com/users/vsavkin/repos","events_url":"https://api.github.com/users/vsavkin/events{/privacy}","received_events_url":"https://api.github.com/users/vsavkin/received_events","type":"User","site_admin":false},"body":"Initial implementation of ElementInjector.\r\n\r\nWorks:\r\n1. The creation of proto element injector trees\r\n2. Bindings\r\n3. The instantiation of element injectors\r\n4. The instantiation of directives\r\n5. Visibility: Parent and Ancestor\r\n6. Delegation to application injectors\r\n7. Error handling\r\n\r\nMissing features:\r\n1. Handling components.\r\n2. Setting \"special\" properties (e.g., Element, View).\r\n3. Cycle detection\r\n4. Distance\r\n5. Text nodes","created_at":"2014-10-16T14:10:01Z","updated_at":"2014-10-17T04:46:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"13b4bff4d8d9fd3fd9f1ba130be5fedb990790fb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/angular/angular/pulls/96/commits","review_comments_url":"https://api.github.com/repos/angular/angular/pulls/96/comments","review_comment_url":"https://api.github.com/repos/angular/angular/pulls/comments/{number}","comments_url":"https://api.github.com/repos/angular/angular/issues/96/comments","statuses_url":"https://api.github.com/repos/angular/angular/statuses/0544ba3cd98bd4f312b21e2ef3cfd000129a31ad","head":{"label":"vsavkin:add_element_injector","ref":"add_element_injector","sha":"0544ba3cd98bd4f312b21e2ef3cfd000129a31ad","user":{"login":"vsavkin","id":35996,"avatar_url":"https://avatars.githubusercontent.com/u/35996?v=2","gravatar_id":"","url":"https://api.github.com/users/vsavkin","html_url":"https://github.com/vsavkin","followers_url":"https://api.github.com/users/vsavkin/followers","following_url":"https://api.github.com/users/vsavkin/following{/other_user}","gists_url":"https://api.github.com/users/vsavkin/gists{/gist_id}","starred_url":"https://api.github.com/users/vsavkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vsavkin/subscriptions","organizations_url":"https://api.github.com/users/vsavkin/orgs","repos_url":"https://api.github.com/users/vsavkin/repos","events_url":"https://api.github.com/users/vsavkin/events{/privacy}","received_events_url":"https://api.github.com/users/vsavkin/received_events","type":"User","site_admin":false},"repo":{"id":24644769,"name":"angular","full_name":"vsavkin/angular","owner":{"login":"vsavkin","id":35996,"avatar_url":"https://avatars.githubusercontent.com/u/35996?v=2","gravatar_id":"","url":"https://api.github.com/users/vsavkin","html_url":"https://github.com/vsavkin","followers_url":"https://api.github.com/users/vsavkin/followers","following_url":"https://api.github.com/users/vsavkin/following{/other_user}","gists_url":"https://api.github.com/users/vsavkin/gists{/gist_id}","starred_url":"https://api.github.com/users/vsavkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vsavkin/subscriptions","organizations_url":"https://api.github.com/users/vsavkin/orgs","repos_url":"https://api.github.com/users/vsavkin/repos","events_url":"https://api.github.com/users/vsavkin/events{/privacy}","received_events_url":"https://api.github.com/users/vsavkin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vsavkin/angular","description":"","fork":true,"url":"https://api.github.com/repos/vsavkin/angular","forks_url":"https://api.github.com/repos/vsavkin/angular/forks","keys_url":"https://api.github.com/repos/vsavkin/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vsavkin/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vsavkin/angular/teams","hooks_url":"https://api.github.com/repos/vsavkin/angular/hooks","issue_events_url":"https://api.github.com/repos/vsavkin/angular/issues/events{/number}","events_url":"https://api.github.com/repos/vsavkin/angular/events","assignees_url":"https://api.github.com/repos/vsavkin/angular/assignees{/user}","branches_url":"https://api.github.com/repos/vsavkin/angular/branches{/branch}","tags_url":"https://api.github.com/repos/vsavkin/angular/tags","blobs_url":"https://api.github.com/repos/vsavkin/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vsavkin/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vsavkin/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/vsavkin/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vsavkin/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/vsavkin/angular/languages","stargazers_url":"https://api.github.com/repos/vsavkin/angular/stargazers","contributors_url":"https://api.github.com/repos/vsavkin/angular/contributors","subscribers_url":"https://api.github.com/repos/vsavkin/angular/subscribers","subscription_url":"https://api.github.com/repos/vsavkin/angular/subscription","commits_url":"https://api.github.com/repos/vsavkin/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/vsavkin/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/vsavkin/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/vsavkin/angular/issues/comments/{number}","contents_url":"https://api.github.com/repos/vsavkin/angular/contents/{+path}","compare_url":"https://api.github.com/repos/vsavkin/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vsavkin/angular/merges","archive_url":"https://api.github.com/repos/vsavkin/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vsavkin/angular/downloads","issues_url":"https://api.github.com/repos/vsavkin/angular/issues{/number}","pulls_url":"https://api.github.com/repos/vsavkin/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/vsavkin/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/vsavkin/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vsavkin/angular/labels{/name}","releases_url":"https://api.github.com/repos/vsavkin/angular/releases{/id}","created_at":"2014-09-30T15:59:47Z","updated_at":"2014-10-02T21:29:21Z","pushed_at":"2014-10-16T21:31:28Z","git_url":"git://github.com/vsavkin/angular.git","ssh_url":"git@github.com:vsavkin/angular.git","clone_url":"https://github.com/vsavkin/angular.git","svn_url":"https://github.com/vsavkin/angular","homepage":null,"size":831,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"angular:master","ref":"master","sha":"2f732c6b841f196563a3f79f54ecd2b503bc8f2b","user":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=2","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"repo":{"id":24195339,"name":"angular","full_name":"angular/angular","owner":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=2","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/angular/angular","description":"","fork":false,"url":"https://api.github.com/repos/angular/angular","forks_url":"https://api.github.com/repos/angular/angular/forks","keys_url":"https://api.github.com/repos/angular/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angular/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angular/angular/teams","hooks_url":"https://api.github.com/repos/angular/angular/hooks","issue_events_url":"https://api.github.com/repos/angular/angular/issues/events{/number}","events_url":"https://api.github.com/repos/angular/angular/events","assignees_url":"https://api.github.com/repos/angular/angular/assignees{/user}","branches_url":"https://api.github.com/repos/angular/angular/branches{/branch}","tags_url":"https://api.github.com/repos/angular/angular/tags","blobs_url":"https://api.github.com/repos/angular/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angular/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angular/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/angular/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angular/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/angular/angular/languages","stargazers_url":"https://api.github.com/repos/angular/angular/stargazers","contributors_url":"https://api.github.com/repos/angular/angular/contributors","subscribers_url":"https://api.github.com/repos/angular/angular/subscribers","subscription_url":"https://api.github.com/repos/angular/angular/subscription","commits_url":"https://api.github.com/repos/angular/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/angular/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/angular/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/angular/angular/issues/comments/{number}","contents_url":"https://api.github.com/repos/angular/angular/contents/{+path}","compare_url":"https://api.github.com/repos/angular/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angular/angular/merges","archive_url":"https://api.github.com/repos/angular/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angular/angular/downloads","issues_url":"https://api.github.com/repos/angular/angular/issues{/number}","pulls_url":"https://api.github.com/repos/angular/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/angular/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/angular/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angular/angular/labels{/name}","releases_url":"https://api.github.com/repos/angular/angular/releases{/id}","created_at":"2014-09-18T16:12:01Z","updated_at":"2014-10-14T20:36:09Z","pushed_at":"2014-10-16T21:29:56Z","git_url":"git://github.com/angular/angular.git","ssh_url":"git@github.com:angular/angular.git","clone_url":"https://github.com/angular/angular.git","svn_url":"https://github.com/angular/angular","homepage":null,"size":1313,"stargazers_count":41,"watchers_count":41,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":41,"forks":21,"open_issues":41,"watchers":41,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/96"},"html":{"href":"https://github.com/angular/angular/pull/96"},"issue":{"href":"https://api.github.com/repos/angular/angular/issues/96"},"comments":{"href":"https://api.github.com/repos/angular/angular/issues/96/comments"},"review_comments":{"href":"https://api.github.com/repos/angular/angular/pulls/96/comments"},"review_comment":{"href":"https://api.github.com/repos/angular/angular/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/angular/angular/pulls/96/commits"},"statuses":{"href":"https://api.github.com/repos/angular/angular/statuses/0544ba3cd98bd4f312b21e2ef3cfd000129a31ad"}}}}