| 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 library package.map.provider; | 5 library package.map.provider; |
| 6 | 6 |
| 7 import 'dart:collection'; |
| 7 import 'dart:convert'; | 8 import 'dart:convert'; |
| 8 import 'dart:io' as io; | 9 import 'dart:io' as io; |
| 9 | 10 |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 11 import 'package:analysis_server/src/analysis_server.dart'; |
| 11 import 'package:analysis_server/src/resource.dart'; | 12 import 'package:analysis_server/src/resource.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 13 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:path/path.dart'; | 14 import 'package:path/path.dart'; |
| 14 | 15 |
| 15 /** | 16 /** |
| 16 * A PackageMapProvider is an entity capable of determining the mapping from | 17 * A PackageMapProvider is an entity capable of determining the mapping from |
| (...skipping 13 matching lines...) Expand all Loading... |
| 30 * Data structure output by PackageMapProvider. This contains both the package | 31 * Data structure output by PackageMapProvider. This contains both the package |
| 31 * map and dependency information. | 32 * map and dependency information. |
| 32 */ | 33 */ |
| 33 class PackageMapInfo { | 34 class PackageMapInfo { |
| 34 /** | 35 /** |
| 35 * The package map itself. This is a map from package name to a list of | 36 * The package map itself. This is a map from package name to a list of |
| 36 * the folders containing source code for the package. | 37 * the folders containing source code for the package. |
| 37 * | 38 * |
| 38 * `null` if an error occurred. | 39 * `null` if an error occurred. |
| 39 */ | 40 */ |
| 40 Map<String, List<Folder>> packageMap; | 41 HashMap<String, List<Folder>> packageMap; |
| 41 | 42 |
| 42 /** | 43 /** |
| 43 * Dependency information. This is a set of the paths which were consulted | 44 * Dependency information. This is a set of the paths which were consulted |
| 44 * in order to generate the package map. If any of these files is | 45 * in order to generate the package map. If any of these files is |
| 45 * modified, the package map will need to be regenerated. | 46 * modified, the package map will need to be regenerated. |
| 46 */ | 47 */ |
| 47 Set<String> dependencies; | 48 Set<String> dependencies; |
| 48 | 49 |
| 49 PackageMapInfo(this.packageMap, this.dependencies); | 50 PackageMapInfo(this.packageMap, this.dependencies); |
| 50 } | 51 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // { | 119 // { |
| 119 // "packages": { | 120 // "packages": { |
| 120 // "foo": "path/to/foo", | 121 // "foo": "path/to/foo", |
| 121 // "bar": ["path/to/bar1", "path/to/bar2"], | 122 // "bar": ["path/to/bar1", "path/to/bar2"], |
| 122 // "myapp": "path/to/myapp", // self link is included | 123 // "myapp": "path/to/myapp", // self link is included |
| 123 // }, | 124 // }, |
| 124 // "input_files": [ | 125 // "input_files": [ |
| 125 // "path/to/myapp/pubspec.lock" | 126 // "path/to/myapp/pubspec.lock" |
| 126 // ] | 127 // ] |
| 127 // } | 128 // } |
| 128 Map<String, List<Folder>> packageMap = <String, List<Folder>>{}; | 129 HashMap<String, List<Folder>> packageMap = new HashMap<String, List<Folder>>
(); |
| 129 Map obj = JSON.decode(jsonText); | 130 HashMap obj = JSON.decode(jsonText); |
| 130 Map packages = obj['packages']; | 131 HashMap packages = obj['packages']; |
| 131 processPaths(String packageName, List paths) { | 132 processPaths(String packageName, List paths) { |
| 132 List<Folder> folders = <Folder>[]; | 133 List<Folder> folders = <Folder>[]; |
| 133 for (var path in paths) { | 134 for (var path in paths) { |
| 134 if (path is String) { | 135 if (path is String) { |
| 135 Resource resource = resourceProvider.getResource(path); | 136 Resource resource = resourceProvider.getResource(path); |
| 136 if (resource is Folder) { | 137 if (resource is Folder) { |
| 137 folders.add(resource); | 138 folders.add(resource); |
| 138 } | 139 } |
| 139 } | 140 } |
| 140 } | 141 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 154 if (inputFiles != null) { | 155 if (inputFiles != null) { |
| 155 for (var path in inputFiles) { | 156 for (var path in inputFiles) { |
| 156 if (path is String) { | 157 if (path is String) { |
| 157 dependencies.add(path); | 158 dependencies.add(path); |
| 158 } | 159 } |
| 159 } | 160 } |
| 160 } | 161 } |
| 161 return new PackageMapInfo(packageMap, dependencies); | 162 return new PackageMapInfo(packageMap, dependencies); |
| 162 } | 163 } |
| 163 } | 164 } |
| OLD | NEW |