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

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

Issue 1833823002: Add tests for summarizing / resynthesizing using only AST. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/summarize_ast.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 688abe542db361e5e5b4de21218071110f25ce9f..6a332c1c827d57f298c3d94dc9cc656eeb5827a9 100644
--- a/pkg/analyzer/lib/src/summary/prelink.dart
+++ b/pkg/analyzer/lib/src/summary/prelink.dart
@@ -2,6 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+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/summary/format.dart';
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary/name_filter.dart';
@@ -507,7 +510,37 @@ class _Prelinker {
if (sourceUri == null) {
return relativeUri;
} else {
- return Uri.parse(sourceUri).resolve(relativeUri).toString();
+// 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));
+ }
}
}
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/summarize_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698