OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Command-line tool to query for code dependencies. Currently this tool only | 5 /// Command-line tool to query for code dependencies. Currently this tool only |
6 /// supports the `some_path` query, which gives you the shortest path for how | 6 /// supports the `some_path` query, which gives you the shortest path for how |
7 /// one function depends on another. | 7 /// one function depends on another. |
8 /// | 8 /// |
9 /// You can run this tool as follows: | 9 /// You can run this tool as follows: |
10 /// ```bash | 10 /// ```bash |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 exit(1); | 42 exit(1); |
43 } | 43 } |
44 | 44 |
45 var json; | 45 var json; |
46 try { | 46 try { |
47 json = JSON.decode(new File(args[0]).readAsStringSync()); | 47 json = JSON.decode(new File(args[0]).readAsStringSync()); |
48 } catch (e) { | 48 } catch (e) { |
49 print('error: could not read ${args[0]}'); | 49 print('error: could not read ${args[0]}'); |
50 exit(1); | 50 exit(1); |
51 } | 51 } |
52 var info = new AllInfo.fromJson(json); | 52 var info = new AllInfoJsonCodec().decode(json); |
53 var graph = graphFromInfo(info); | 53 var graph = graphFromInfo(info); |
54 | 54 |
55 var queryName = args[1]; | 55 var queryName = args[1]; |
56 if (queryName == 'some_path') { | 56 if (queryName == 'some_path') { |
57 if (args.length < 4) { | 57 if (args.length < 4) { |
58 print('missing arguments for `some_path`'); | 58 print('missing arguments for `some_path`'); |
59 exit(1); | 59 exit(1); |
60 } | 60 } |
61 var source = info.functions | 61 var source = info.functions |
62 .firstWhere(_longNameMatcher(new RegExp(args[2])), orElse: () => null); | 62 .firstWhere(_longNameMatcher(new RegExp(args[2])), orElse: () => null); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 if (seen.containsKey(neighbor)) continue; | 120 if (seen.containsKey(neighbor)) continue; |
121 seen[neighbor] = node; | 121 seen[neighbor] = node; |
122 queue.addLast(neighbor); | 122 queue.addLast(neighbor); |
123 } | 123 } |
124 } | 124 } |
125 return []; | 125 return []; |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 _longNameMatcher(RegExp regexp) => (e) => regexp.hasMatch(longName(e)); | 129 _longNameMatcher(RegExp regexp) => (e) => regexp.hasMatch(longName(e)); |
OLD | NEW |