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

Side by Side Diff: pkg/analyzer/lib/src/dart/sdk/sdk.dart

Issue 2321263003: Remove parseUriWithException() and URISyntaxException. (Closed)
Patch Set: Created 4 years, 3 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
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 library analyzer.src.generated.sdk2; 5 library analyzer.src.generated.sdk2;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io' as io; 9 import 'dart:io' as io;
10 10
11 import 'package:analyzer/dart/ast/ast.dart'; 11 import 'package:analyzer/dart/ast/ast.dart';
12 import 'package:analyzer/file_system/file_system.dart'; 12 import 'package:analyzer/file_system/file_system.dart';
13 import 'package:analyzer/file_system/memory_file_system.dart'; 13 import 'package:analyzer/file_system/memory_file_system.dart';
14 import 'package:analyzer/src/context/context.dart'; 14 import 'package:analyzer/src/context/context.dart';
15 import 'package:analyzer/src/dart/scanner/reader.dart'; 15 import 'package:analyzer/src/dart/scanner/reader.dart';
16 import 'package:analyzer/src/dart/scanner/scanner.dart'; 16 import 'package:analyzer/src/dart/scanner/scanner.dart';
17 import 'package:analyzer/src/generated/engine.dart'; 17 import 'package:analyzer/src/generated/engine.dart';
18 import 'package:analyzer/src/generated/error.dart'; 18 import 'package:analyzer/src/generated/error.dart';
19 import 'package:analyzer/src/generated/java_core.dart';
20 import 'package:analyzer/src/generated/java_engine.dart'; 19 import 'package:analyzer/src/generated/java_engine.dart';
21 import 'package:analyzer/src/generated/java_engine_io.dart'; 20 import 'package:analyzer/src/generated/java_engine_io.dart';
22 import 'package:analyzer/src/generated/parser.dart'; 21 import 'package:analyzer/src/generated/parser.dart';
23 import 'package:analyzer/src/generated/sdk.dart'; 22 import 'package:analyzer/src/generated/sdk.dart';
24 import 'package:analyzer/src/generated/source_io.dart'; 23 import 'package:analyzer/src/generated/source_io.dart';
25 import 'package:analyzer/src/summary/idl.dart' show PackageBundle; 24 import 'package:analyzer/src/summary/idl.dart' show PackageBundle;
26 import 'package:analyzer/src/summary/summary_sdk.dart'; 25 import 'package:analyzer/src/summary/summary_sdk.dart';
27 import 'package:path/path.dart' as pathos; 26 import 'package:path/path.dart' as pathos;
28 import 'package:yaml/yaml.dart'; 27 import 'package:yaml/yaml.dart';
29 28
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 137
139 @override 138 @override
140 Source fromFileUri(Uri uri) { 139 Source fromFileUri(Uri uri) {
141 File file = 140 File file =
142 resourceProvider.getFile(resourceProvider.pathContext.fromUri(uri)); 141 resourceProvider.getFile(resourceProvider.pathContext.fromUri(uri));
143 String path = _getPath(file); 142 String path = _getPath(file);
144 if (path == null) { 143 if (path == null) {
145 return null; 144 return null;
146 } 145 }
147 try { 146 try {
148 return file.createSource(parseUriWithException(path)); 147 return file.createSource(Uri.parse(path));
149 } on URISyntaxException catch (exception, stackTrace) { 148 } on FormatException catch (exception, stackTrace) {
150 AnalysisEngine.instance.logger.logInformation( 149 AnalysisEngine.instance.logger.logInformation(
151 "Failed to create URI: $path", 150 "Failed to create URI: $path",
152 new CaughtException(exception, stackTrace)); 151 new CaughtException(exception, stackTrace));
153 } 152 }
154 return null; 153 return null;
155 } 154 }
156 155
157 @override 156 @override
158 PackageBundle getLinkedBundle() { 157 PackageBundle getLinkedBundle() {
159 bool strongMode = _analysisOptions?.strongMode ?? false; 158 bool strongMode = _analysisOptions?.strongMode ?? false;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (index == -1) { 200 if (index == -1) {
202 return null; 201 return null;
203 } 202 }
204 } 203 }
205 String prefix = libraryPath.substring(0, index + 1); 204 String prefix = libraryPath.substring(0, index + 1);
206 srcPath = '$prefix$relativePath'; 205 srcPath = '$prefix$relativePath';
207 } 206 }
208 String filePath = srcPath.replaceAll('/', separator); 207 String filePath = srcPath.replaceAll('/', separator);
209 try { 208 try {
210 File file = resourceProvider.getFile(filePath); 209 File file = resourceProvider.getFile(filePath);
211 return file.createSource(parseUriWithException(dartUri)); 210 return file.createSource(Uri.parse(dartUri));
212 } on URISyntaxException { 211 } on FormatException {
213 return null; 212 return null;
214 } 213 }
215 } 214 }
216 215
217 @override 216 @override
218 Source mapDartUri(String dartUri) { 217 Source mapDartUri(String dartUri) {
219 Source source = _uriToSourceMap[dartUri]; 218 Source source = _uriToSourceMap[dartUri];
220 if (source == null) { 219 if (source == null) {
221 source = internalMapDartUri(dartUri); 220 source = internalMapDartUri(dartUri);
222 _uriToSourceMap[dartUri] = source; 221 _uriToSourceMap[dartUri] = source;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 if (index == -1) { 324 if (index == -1) {
326 return null; 325 return null;
327 } 326 }
328 } 327 }
329 String prefix = libraryPath.substring(0, index + 1); 328 String prefix = libraryPath.substring(0, index + 1);
330 srcPath = '$prefix$relativePath'; 329 srcPath = '$prefix$relativePath';
331 } 330 }
332 String filePath = srcPath.replaceAll('/', separator); 331 String filePath = srcPath.replaceAll('/', separator);
333 try { 332 try {
334 File file = resourceProvider.getFile(filePath); 333 File file = resourceProvider.getFile(filePath);
335 return file.createSource(parseUriWithException(dartUri)); 334 return file.createSource(Uri.parse(dartUri));
336 } on URISyntaxException { 335 } on FormatException {
337 return null; 336 return null;
338 } 337 }
339 } 338 }
340 339
341 void _loadEmbedderBundle(Folder libFolder) { 340 void _loadEmbedderBundle(Folder libFolder) {
342 File bundleFile = libFolder.parent.getChildAssumingFile('sdk.ds'); 341 File bundleFile = libFolder.parent.getChildAssumingFile('sdk.ds');
343 if (bundleFile.exists) { 342 if (bundleFile.exists) {
344 try { 343 try {
345 List<int> bytes = bundleFile.readAsBytesSync(); 344 List<int> bytes = bundleFile.readAsBytesSync();
346 _embedderBundle = new PackageBundle.fromBuffer(bytes); 345 _embedderBundle = new PackageBundle.fromBuffer(bytes);
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 } 638 }
640 SdkLibrary library = getSdkLibrary(libraryName); 639 SdkLibrary library = getSdkLibrary(libraryName);
641 if (library == null) { 640 if (library == null) {
642 return null; 641 return null;
643 } 642 }
644 try { 643 try {
645 File file = libraryDirectory.getChildAssumingFile(library.path); 644 File file = libraryDirectory.getChildAssumingFile(library.path);
646 if (!relativePath.isEmpty) { 645 if (!relativePath.isEmpty) {
647 file = file.parent.getChildAssumingFile(relativePath); 646 file = file.parent.getChildAssumingFile(relativePath);
648 } 647 }
649 return file.createSource(parseUriWithException(dartUri)); 648 return file.createSource(Uri.parse(dartUri));
650 } on URISyntaxException { 649 } on FormatException {
651 return null; 650 return null;
652 } 651 }
653 } 652 }
654 653
655 /** 654 /**
656 * Return the default directory for the Dart SDK, or `null` if the directory 655 * Return the default directory for the Dart SDK, or `null` if the directory
657 * cannot be determined (or does not exist). The default directory is provided 656 * cannot be determined (or does not exist). The default directory is provided
658 * by a system property named `com.google.dart.sdk`. 657 * by a system property named `com.google.dart.sdk`.
659 */ 658 */
660 static Folder defaultSdkDirectory(ResourceProvider resourceProvider) { 659 static Folder defaultSdkDirectory(ResourceProvider resourceProvider) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 SdkLibrariesReader_LibraryBuilder libraryBuilder = 866 SdkLibrariesReader_LibraryBuilder libraryBuilder =
868 new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths); 867 new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths);
869 // If any syntactic errors were found then don't try to visit the AST 868 // If any syntactic errors were found then don't try to visit the AST
870 // structure. 869 // structure.
871 if (!errorListener.errorReported) { 870 if (!errorListener.errorReported) {
872 unit.accept(libraryBuilder); 871 unit.accept(libraryBuilder);
873 } 872 }
874 return libraryBuilder.librariesMap; 873 return libraryBuilder.librariesMap;
875 } 874 }
876 } 875 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698