| OLD | NEW |
| 1 #library("util"); | 1 #library("util"); |
| 2 | 2 |
| 3 #import("dart:io"); |
| 3 #import("dart:json"); | 4 #import("dart:json"); |
| 4 | 5 |
| 5 Map<String, Map> _allProps; | 6 Map<String, Map> _allProps; |
| 6 | 7 |
| 7 Map<String, Map> get allProps() { | 8 Map<String, Map> get allProps() { |
| 8 if (_allProps == null) { | 9 if (_allProps == null) { |
| 9 // Database of expected property names for each type in WebKit. | 10 // Database of expected property names for each type in WebKit. |
| 10 _allProps = JSON.parse(fs.readFileSync('data/dartIdl.json', 'utf8')); | 11 _allProps = JSON.parse( |
| 12 new File('data/dartIdl.json').readAsTextSync()); |
| 11 } | 13 } |
| 12 return _allProps; | 14 return _allProps; |
| 13 } | 15 } |
| 14 | 16 |
| 15 Set<String> matchedTypes; | 17 Set<String> matchedTypes; |
| 16 | 18 |
| 17 /** Returns whether the type has any member matching the specified name. */ | 19 /** Returns whether the type has any member matching the specified name. */ |
| 18 bool hasAny(String type, String prop) { | 20 bool hasAny(String type, String prop) { |
| 19 final data = allProps[type]; | 21 final data = allProps[type]; |
| 20 return data['properties'].containsKey(prop) || | 22 return data['properties'].containsKey(prop) || |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 if (entry != null) { | 77 if (entry != null) { |
| 76 num score = scoreEntry(entry, type); | 78 num score = scoreEntry(entry, type); |
| 77 if (score > bestScore) { | 79 if (score > bestScore) { |
| 78 bestScore = score; | 80 bestScore = score; |
| 79 bestEntry = entry; | 81 bestEntry = entry; |
| 80 } | 82 } |
| 81 } | 83 } |
| 82 } | 84 } |
| 83 return bestEntry; | 85 return bestEntry; |
| 84 } | 86 } |
| 87 |
| 88 /** |
| 89 * Helper for sync creation of a whole file from a string. |
| 90 */ |
| 91 void writeFileSync(String filename, String data) { |
| 92 File f = new File(filename); |
| 93 RandomAccessFile raf = f.openSync(FileMode.WRITE); |
| 94 raf.writeStringSync(data); |
| 95 raf.closeSync(); |
| 96 } |
| OLD | NEW |