| 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 #library("patchparser"); | 5 #library("patchparser"); |
| 6 #import("dart:uri"); | 6 #import("dart:uri"); |
| 7 | 7 |
| 8 #import("tree/tree.dart", prefix: "tree"); | 8 #import("tree/tree.dart", prefix: "tree"); |
| 9 #import("leg.dart", prefix: 'leg'); // CompilerTask, Compiler. | 9 #import("leg.dart", prefix: 'leg'); // CompilerTask, Compiler. |
| 10 #import("apiimpl.dart"); | 10 #import("apiimpl.dart"); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 scanLibraryElements(library); | 32 scanLibraryElements(library); |
| 33 compiler.onLibraryLoaded(library, uri); | 33 compiler.onLibraryLoaded(library, uri); |
| 34 }); | 34 }); |
| 35 } | 35 } |
| 36 return library; | 36 return library; |
| 37 } | 37 } |
| 38 | 38 |
| 39 void scanLibraryElements(LibraryElement library) { | 39 void scanLibraryElements(LibraryElement library) { |
| 40 measure(() { | 40 measure(() { |
| 41 // TODO(lrn): Possibly recursively handle #source directives in patch. | 41 // TODO(lrn): Possibly recursively handle #source directives in patch. |
| 42 leg.Script script = library.script; | 42 leg.Script script = library.entryCompilationUnit.script; |
| 43 Token tokens = new StringScanner(script.text).tokenize(); | 43 Token tokens = new StringScanner(script.text).tokenize(); |
| 44 Function idGenerator = compiler.getNextFreeClassId; | 44 Function idGenerator = compiler.getNextFreeClassId; |
| 45 PatchListener patchListener = | 45 PatchListener patchListener = |
| 46 new PatchElementListener(compiler, library, idGenerator); | 46 new PatchElementListener(compiler, |
| 47 library.entryCompilationUnit, |
| 48 idGenerator); |
| 47 new PatchParser(patchListener).parseUnit(tokens); | 49 new PatchParser(patchListener).parseUnit(tokens); |
| 48 }); | 50 }); |
| 49 } | 51 } |
| 50 | 52 |
| 51 tree.ClassNode parsePatchClassNode(PartialClassElement element) { | 53 tree.ClassNode parsePatchClassNode(PartialClassElement element) { |
| 52 // Parse [PartialClassElement] using a "patch"-aware parser instead | 54 // Parse [PartialClassElement] using a "patch"-aware parser instead |
| 53 // of calling its [parseNode] method. | 55 // of calling its [parseNode] method. |
| 54 if (element.cachedNode != null) return element.cachedNode; | 56 if (element.cachedNode != null) return element.cachedNode; |
| 55 PatchMemberListener listener = | 57 PatchMemberListener listener = |
| 56 new PatchMemberListener(compiler, element); | 58 new PatchMemberListener(compiler, element); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 209 } |
| 208 } | 210 } |
| 209 | 211 |
| 210 void addMember(Element element) { | 212 void addMember(Element element) { |
| 211 if (isMemberPatch || (isClassPatch && element is ClassElement)) { | 213 if (isMemberPatch || (isClassPatch && element is ClassElement)) { |
| 212 element.addMetadata(popNode()); | 214 element.addMetadata(popNode()); |
| 213 } | 215 } |
| 214 super.addMember(element); | 216 super.addMember(element); |
| 215 } | 217 } |
| 216 } | 218 } |
| OLD | NEW |