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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/summarize_ast.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« 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