Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: pkg/analyzer/lib/src/summary/prelink.dart

Issue 1831133005: Consolidate duplicate code for resloving URIs. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Sort Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/summary/prelink.dart
diff --git a/pkg/analyzer/lib/src/summary/prelink.dart b/pkg/analyzer/lib/src/summary/prelink.dart
index 6a332c1c827d57f298c3d94dc9cc656eeb5827a9..e34a9452a5a0a28ffec40f534f25e19e5de636b0 100644
--- a/pkg/analyzer/lib/src/summary/prelink.dart
+++ b/pkg/analyzer/lib/src/summary/prelink.dart
@@ -5,6 +5,7 @@
import 'package:analyzer/src/generated/java_core.dart';
import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/source.dart';
+import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:analyzer/src/summary/format.dart';
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/name_filter.dart';
@@ -510,37 +511,8 @@ class _Prelinker {
if (sourceUri == null) {
return relativeUri;
} else {
-// return Uri.parse(sourceUri).resolve(relativeUri).toString();
- // TODO(paulberry): this algorithm is mostly copied from FileBasedSource.
- // The code should be refactored so it can be shared.
- Uri containedUri = Uri.parse(relativeUri);
- if (containedUri.isAbsolute) {
- return relativeUri;
- }
- Uri uri = Uri.parse(sourceUri);
- try {
- Uri baseUri = uri;
- bool isOpaque = uri.isAbsolute && !uri.path.startsWith('/');
- if (isOpaque) {
- String scheme = uri.scheme;
- String part = uri.path;
- if (scheme == DartUriResolver.DART_SCHEME && part.indexOf('/') < 0) {
- part = "$part/$part.dart";
- }
- baseUri = parseUriWithException("$scheme:/$part");
- }
- Uri result = baseUri.resolveUri(containedUri);
- if (isOpaque) {
- result = parseUriWithException(
- "${result.scheme}:${result.path.substring(1)}");
- }
- //print('$sourceUri | $relativeUri -> $result');
- return result.toString();
- } catch (exception, stackTrace) {
- throw new AnalysisException(
- "Could not resolve URI ($containedUri) relative to source ($uri)",
- new CaughtException(exception, stackTrace));
- }
+ return resolveRelativeUri(Uri.parse(sourceUri), Uri.parse(relativeUri))
+ .toString();
}
}
}

Powered by Google App Engine
This is Rietveld 408576698