OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 analyzer_impl; | 5 library analyzer_impl; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
| 9 import 'package:path/path.dart' as pathos; |
| 10 |
9 import 'generated/java_io.dart'; | 11 import 'generated/java_io.dart'; |
10 import 'generated/engine.dart'; | 12 import 'generated/engine.dart'; |
11 import 'generated/error.dart'; | 13 import 'generated/error.dart'; |
12 import 'generated/source_io.dart'; | 14 import 'generated/source_io.dart'; |
13 import 'generated/sdk.dart'; | 15 import 'generated/sdk.dart'; |
14 import 'generated/sdk_io.dart'; | 16 import 'generated/sdk_io.dart'; |
15 import 'generated/ast.dart'; | 17 import 'generated/ast.dart'; |
16 import 'generated/element.dart'; | 18 import 'generated/element.dart'; |
17 import '../options.dart'; | 19 import '../options.dart'; |
18 | 20 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 Set<CompilationUnitElement> units) { | 123 Set<CompilationUnitElement> units) { |
122 if (unit == null || units.contains(unit)) { | 124 if (unit == null || units.contains(unit)) { |
123 return; | 125 return; |
124 } | 126 } |
125 units.add(unit); | 127 units.add(unit); |
126 sources.add(unit.source); | 128 sources.add(unit.source); |
127 } | 129 } |
128 | 130 |
129 void addLibrarySources(LibraryElement library, Set<LibraryElement> libraries, | 131 void addLibrarySources(LibraryElement library, Set<LibraryElement> libraries, |
130 Set<CompilationUnitElement> units) { | 132 Set<CompilationUnitElement> units) { |
131 if (library == null || libraries.contains(library)) { | 133 if (library == null || !libraries.add(library) ) { |
132 return; | 134 return; |
133 } | 135 } |
134 libraries.add(library); | |
135 // may be skip library | 136 // may be skip library |
136 { | 137 { |
137 UriKind uriKind = library.source.uriKind; | 138 UriKind uriKind = library.source.uriKind; |
138 // Optionally skip package: libraries. | 139 // Optionally skip package: libraries. |
139 if (!options.showPackageWarnings && uriKind == UriKind.PACKAGE_URI) { | 140 if (!options.showPackageWarnings && uriKind == UriKind.PACKAGE_URI) { |
140 return; | 141 return; |
141 } | 142 } |
142 // Optionally skip SDK libraries. | 143 // Optionally skip SDK libraries. |
143 if (!options.showSdkWarnings && uriKind == UriKind.DART_URI) { | 144 if (!options.showSdkWarnings && uriKind == UriKind.DART_URI) { |
144 return; | 145 return; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 186 |
186 /** | 187 /** |
187 * Returns the [UriKind] for the given input file. Usually {@link UriKind#FILE
_URI}, but if | 188 * Returns the [UriKind] for the given input file. Usually {@link UriKind#FILE
_URI}, but if |
188 * the given file is located in the "lib" directory of the [sdk], then returns | 189 * the given file is located in the "lib" directory of the [sdk], then returns |
189 * {@link UriKind#DART_URI}. | 190 * {@link UriKind#DART_URI}. |
190 */ | 191 */ |
191 static UriKind getUriKind(JavaFile file) { | 192 static UriKind getUriKind(JavaFile file) { |
192 // may be file in SDK | 193 // may be file in SDK |
193 if (sdk is DirectoryBasedDartSdk) { | 194 if (sdk is DirectoryBasedDartSdk) { |
194 DirectoryBasedDartSdk directoryBasedSdk = sdk; | 195 DirectoryBasedDartSdk directoryBasedSdk = sdk; |
195 String sdkLibPath = directoryBasedSdk.libraryDirectory.getPath() + JavaFil
e.separator; | 196 var libraryDirectory = directoryBasedSdk.libraryDirectory.getAbsolutePath(
); |
196 if (file.getPath().startsWith(sdkLibPath)) { | 197 var sdkLibPath = libraryDirectory + pathos.separator; |
197 return UriKind.DART_URI; | 198 var filePath = file.getPath(); |
| 199 if (filePath.startsWith(sdkLibPath)) { |
| 200 var internalPath = pathos.join(libraryDirectory, '_internal') + pathos.s
eparator; |
| 201 if (!filePath.startsWith(internalPath)) { |
| 202 return UriKind.DART_URI; |
| 203 } |
198 } | 204 } |
199 } | 205 } |
200 // some generic file | 206 // some generic file |
201 return UriKind.FILE_URI; | 207 return UriKind.FILE_URI; |
202 } | 208 } |
203 } | 209 } |
OLD | NEW |