| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:analyzer/src/generated/java_core.dart'; |
| 6 import 'package:analyzer/src/generated/java_engine.dart'; |
| 7 import 'package:analyzer/src/generated/source.dart'; |
| 5 import 'package:analyzer/src/summary/format.dart'; | 8 import 'package:analyzer/src/summary/format.dart'; |
| 6 import 'package:analyzer/src/summary/idl.dart'; | 9 import 'package:analyzer/src/summary/idl.dart'; |
| 7 import 'package:analyzer/src/summary/name_filter.dart'; | 10 import 'package:analyzer/src/summary/name_filter.dart'; |
| 8 | 11 |
| 9 /** | 12 /** |
| 10 * Create a [LinkedLibraryBuilder] corresponding to the given | 13 * Create a [LinkedLibraryBuilder] corresponding to the given |
| 11 * [definingUnit], which should be the defining compilation unit for a library. | 14 * [definingUnit], which should be the defining compilation unit for a library. |
| 12 * Compilation units referenced by the defining compilation unit via `part` | 15 * Compilation units referenced by the defining compilation unit via `part` |
| 13 * declarations will be retrieved using [getPart]. Public namespaces for | 16 * declarations will be retrieved using [getPart]. Public namespaces for |
| 14 * libraries referenced by the defining compilation unit via `import` | 17 * libraries referenced by the defining compilation unit via `import` |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 } | 503 } |
| 501 | 504 |
| 502 /** | 505 /** |
| 503 * Resolve [relativeUri] relative to [sourceUri]. Works correctly if | 506 * Resolve [relativeUri] relative to [sourceUri]. Works correctly if |
| 504 * [sourceUri] is also relative. | 507 * [sourceUri] is also relative. |
| 505 */ | 508 */ |
| 506 String resolveUri(String sourceUri, String relativeUri) { | 509 String resolveUri(String sourceUri, String relativeUri) { |
| 507 if (sourceUri == null) { | 510 if (sourceUri == null) { |
| 508 return relativeUri; | 511 return relativeUri; |
| 509 } else { | 512 } else { |
| 510 return Uri.parse(sourceUri).resolve(relativeUri).toString(); | 513 // return Uri.parse(sourceUri).resolve(relativeUri).toString(); |
| 514 // TODO(paulberry): this algorithm is mostly copied from FileBasedSource. |
| 515 // The code should be refactored so it can be shared. |
| 516 Uri containedUri = Uri.parse(relativeUri); |
| 517 if (containedUri.isAbsolute) { |
| 518 return relativeUri; |
| 519 } |
| 520 Uri uri = Uri.parse(sourceUri); |
| 521 try { |
| 522 Uri baseUri = uri; |
| 523 bool isOpaque = uri.isAbsolute && !uri.path.startsWith('/'); |
| 524 if (isOpaque) { |
| 525 String scheme = uri.scheme; |
| 526 String part = uri.path; |
| 527 if (scheme == DartUriResolver.DART_SCHEME && part.indexOf('/') < 0) { |
| 528 part = "$part/$part.dart"; |
| 529 } |
| 530 baseUri = parseUriWithException("$scheme:/$part"); |
| 531 } |
| 532 Uri result = baseUri.resolveUri(containedUri); |
| 533 if (isOpaque) { |
| 534 result = parseUriWithException( |
| 535 "${result.scheme}:${result.path.substring(1)}"); |
| 536 } |
| 537 //print('$sourceUri | $relativeUri -> $result'); |
| 538 return result.toString(); |
| 539 } catch (exception, stackTrace) { |
| 540 throw new AnalysisException( |
| 541 "Could not resolve URI ($containedUri) relative to source ($uri)", |
| 542 new CaughtException(exception, stackTrace)); |
| 543 } |
| 511 } | 544 } |
| 512 } | 545 } |
| 513 } | 546 } |
| OLD | NEW |