| 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 yaml; | 5 library yaml; |
| 6 | 6 |
| 7 import 'src/loader.dart'; | 7 import 'src/loader.dart'; |
| 8 import 'src/style.dart'; | 8 import 'src/style.dart'; |
| 9 import 'src/yaml_document.dart'; | 9 import 'src/yaml_document.dart'; |
| 10 import 'src/yaml_exception.dart'; | 10 import 'src/yaml_exception.dart'; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 /// Loads a single document from a YAML string as a [YamlDocument]. | 46 /// Loads a single document from a YAML string as a [YamlDocument]. |
| 47 /// | 47 /// |
| 48 /// This is just like [loadYaml], except that where [loadYaml] would return a | 48 /// This is just like [loadYaml], except that where [loadYaml] would return a |
| 49 /// normal Dart value this returns a [YamlDocument] instead. This allows the | 49 /// normal Dart value this returns a [YamlDocument] instead. This allows the |
| 50 /// caller to access document metadata. | 50 /// caller to access document metadata. |
| 51 YamlDocument loadYamlDocument(String yaml, {sourceUrl}) { | 51 YamlDocument loadYamlDocument(String yaml, {sourceUrl}) { |
| 52 var loader = new Loader(yaml, sourceUrl: sourceUrl); | 52 var loader = new Loader(yaml, sourceUrl: sourceUrl); |
| 53 var document = loader.load(); | 53 var document = loader.load(); |
| 54 if (document == null) { | 54 if (document == null) { |
| 55 return new YamlDocument.internal( | 55 return new YamlDocument.internal( |
| 56 new YamlScalar.internal(null, loader.span, ScalarStyle.ANY), | 56 new YamlScalar.internalWithSpan(null, loader.span), |
| 57 loader.span, null, const []); | 57 loader.span, null, const []); |
| 58 } | 58 } |
| 59 | 59 |
| 60 var nextDocument = loader.load(); | 60 var nextDocument = loader.load(); |
| 61 if (nextDocument != null) { | 61 if (nextDocument != null) { |
| 62 throw new YamlException("Only expected one document.", nextDocument.span); | 62 throw new YamlException("Only expected one document.", nextDocument.span); |
| 63 } | 63 } |
| 64 | 64 |
| 65 return document; | 65 return document; |
| 66 } | 66 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 var documents = []; | 104 var documents = []; |
| 105 var document = loader.load(); | 105 var document = loader.load(); |
| 106 while (document != null) { | 106 while (document != null) { |
| 107 documents.add(document); | 107 documents.add(document); |
| 108 document = loader.load(); | 108 document = loader.load(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 return documents; | 111 return documents; |
| 112 } | 112 } |
| OLD | NEW |