| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 * Tools for code generation. | 6 * Tools for code generation. |
| 7 */ | 7 */ |
| 8 library codegen.tools; | 8 library codegen.tools; |
| 9 | 9 |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 new Directory(joinAll(posix.split(outputDirPath))); | 204 new Directory(joinAll(posix.split(outputDirPath))); |
| 205 | 205 |
| 206 /** | 206 /** |
| 207 * Check whether the directory has the correct contents, and return true if it | 207 * Check whether the directory has the correct contents, and return true if it |
| 208 * does. | 208 * does. |
| 209 */ | 209 */ |
| 210 @override | 210 @override |
| 211 bool check() { | 211 bool check() { |
| 212 Map<String, FileContentsComputer> map = directoryContentsComputer(); | 212 Map<String, FileContentsComputer> map = directoryContentsComputer(); |
| 213 try { | 213 try { |
| 214 map.forEach((String file, FileContentsComputer fileContentsComputer) { | 214 for (String file in map.keys) { |
| 215 FileContentsComputer fileContentsComputer = map[file]; |
| 215 String expectedContents = fileContentsComputer(); | 216 String expectedContents = fileContentsComputer(); |
| 216 File outputFile = | 217 File outputFile = |
| 217 new File(joinAll(posix.split(posix.join(outputDirPath, file)))); | 218 new File(joinAll(posix.split(posix.join(outputDirPath, file)))); |
| 218 if (expectedContents != outputFile.readAsStringSync()) { | 219 if (expectedContents != outputFile.readAsStringSync()) { |
| 219 return false; | 220 return false; |
| 220 } | 221 } |
| 221 }); | 222 } |
| 222 int nonHiddenFileCount = 0; | 223 int nonHiddenFileCount = 0; |
| 223 outputFile.listSync( | 224 outputFile.listSync( |
| 224 recursive: false, | 225 recursive: false, |
| 225 followLinks: false).forEach((FileSystemEntity fileSystemEntity) { | 226 followLinks: false).forEach((FileSystemEntity fileSystemEntity) { |
| 226 if (fileSystemEntity is File && | 227 if (fileSystemEntity is File && |
| 227 !basename(fileSystemEntity.path).startsWith('.')) { | 228 !basename(fileSystemEntity.path).startsWith('.')) { |
| 228 nonHiddenFileCount++; | 229 nonHiddenFileCount++; |
| 229 } | 230 } |
| 230 }); | 231 }); |
| 231 if (nonHiddenFileCount != map.length) { | 232 if (nonHiddenFileCount != map.length) { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 if (lines.last.isEmpty) { | 453 if (lines.last.isEmpty) { |
| 453 lines.removeLast(); | 454 lines.removeLast(); |
| 454 buffer.add(new dom.Text(lines.join('\n$indent') + '\n')); | 455 buffer.add(new dom.Text(lines.join('\n$indent') + '\n')); |
| 455 indentNeeded = true; | 456 indentNeeded = true; |
| 456 } else { | 457 } else { |
| 457 buffer.add(new dom.Text(lines.join('\n$indent'))); | 458 buffer.add(new dom.Text(lines.join('\n$indent'))); |
| 458 indentNeeded = false; | 459 indentNeeded = false; |
| 459 } | 460 } |
| 460 } | 461 } |
| 461 } | 462 } |
| OLD | NEW |