OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * This library contains the infrastructure to parse and integrate patch files. | 6 * This library contains the infrastructure to parse and integrate patch files. |
7 * | 7 * |
8 * Three types of elements can be patched: [LibraryElement], [ClassElement], | 8 * Three types of elements can be patched: [LibraryElement], [ClassElement], |
9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded | 9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded |
10 * together with the corresponding origin library. Which libraries that are | 10 * together with the corresponding origin library. Which libraries that are |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 imports); | 171 imports); |
172 new PatchParser(patchListener).parseUnit(tokens); | 172 new PatchParser(patchListener).parseUnit(tokens); |
173 }); | 173 }); |
174 } | 174 } |
175 | 175 |
176 void parsePatchClassNode(PartialClassElement element) { | 176 void parsePatchClassNode(PartialClassElement element) { |
177 // Parse [PartialClassElement] using a "patch"-aware parser instead | 177 // Parse [PartialClassElement] using a "patch"-aware parser instead |
178 // of calling its [parseNode] method. | 178 // of calling its [parseNode] method. |
179 if (element.cachedNode != null) return; | 179 if (element.cachedNode != null) return; |
180 | 180 |
181 return measure(() => compiler.withCurrentElement(element, () { | 181 measure(() => compiler.withCurrentElement(element, () { |
182 PatchMemberListener listener = new PatchMemberListener(compiler, element); | 182 PatchMemberListener listener = new PatchMemberListener(compiler, element); |
183 Parser parser = new PatchClassElementParser(listener); | 183 Parser parser = new PatchClassElementParser(listener); |
184 Token token = parser.parseTopLevelDeclaration(element.beginToken); | 184 Token token = parser.parseTopLevelDeclaration(element.beginToken); |
185 assert(identical(token, element.endToken.next)); | 185 assert(identical(token, element.endToken.next)); |
186 element.cachedNode = listener.popNode(); | 186 element.cachedNode = listener.popNode(); |
187 assert(listener.nodes.isEmpty); | 187 assert(listener.nodes.isEmpty); |
188 | 188 |
189 Link<Element> patches = element.localMembers; | 189 Link<Element> patches = element.localMembers; |
190 applyContainerPatch(element.origin, patches); | 190 applyContainerPatch(element.origin, patches); |
191 })); | 191 })); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 | 549 |
550 // TODO(johnniwinther): Add unittest when patch is (real) metadata. | 550 // TODO(johnniwinther): Add unittest when patch is (real) metadata. |
551 bool isPatchElement(Element element) { | 551 bool isPatchElement(Element element) { |
552 // TODO(lrn): More checks needed if we introduce metadata for real. | 552 // TODO(lrn): More checks needed if we introduce metadata for real. |
553 // In that case, it must have the identifier "native" as metadata. | 553 // In that case, it must have the identifier "native" as metadata. |
554 for (Link link = element.metadata; !link.isEmpty; link = link.tail) { | 554 for (Link link = element.metadata; !link.isEmpty; link = link.tail) { |
555 if (link.head is PatchMetadataAnnotation) return true; | 555 if (link.head is PatchMetadataAnnotation) return true; |
556 } | 556 } |
557 return false; | 557 return false; |
558 } | 558 } |
OLD | NEW |