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

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

Issue 2060263006: Deprecate FileUriResolver and RelativeFileUriResolver in source_io.dart, replace the usages with Re… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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; 5 library analyzer;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/src/dart/scanner/reader.dart'; 10 import 'package:analyzer/src/dart/scanner/reader.dart';
11 import 'package:analyzer/src/dart/scanner/scanner.dart'; 11 import 'package:analyzer/src/dart/scanner/scanner.dart';
12 import 'package:analyzer/src/error.dart'; 12 import 'package:analyzer/src/error.dart';
13 import 'package:analyzer/src/generated/error.dart'; 13 import 'package:analyzer/src/generated/error.dart';
14 import 'package:analyzer/src/generated/parser.dart'; 14 import 'package:analyzer/src/generated/parser.dart';
15 import 'package:analyzer/src/generated/source_io.dart'; 15 import 'package:analyzer/src/generated/source_io.dart';
16 import 'package:analyzer/src/string_source.dart'; 16 import 'package:analyzer/src/string_source.dart';
17 import 'package:analyzer/file_system/file_system.dart' hide File;
18 import 'package:analyzer/file_system/physical_file_system.dart';
17 import 'package:path/path.dart' as pathos; 19 import 'package:path/path.dart' as pathos;
18 20
19 export 'package:analyzer/dart/ast/ast.dart'; 21 export 'package:analyzer/dart/ast/ast.dart';
20 export 'package:analyzer/dart/ast/visitor.dart'; 22 export 'package:analyzer/dart/ast/visitor.dart';
21 export 'package:analyzer/src/dart/ast/utilities.dart'; 23 export 'package:analyzer/src/dart/ast/utilities.dart';
22 export 'package:analyzer/src/error.dart'; 24 export 'package:analyzer/src/error.dart';
23 export 'package:analyzer/src/generated/error.dart'; 25 export 'package:analyzer/src/generated/error.dart';
24 export 'package:analyzer/src/generated/utilities_dart.dart'; 26 export 'package:analyzer/src/generated/utilities_dart.dart';
25 27
26 /// Parses a string of Dart code into an AST. 28 /// Parses a string of Dart code into an AST.
(...skipping 16 matching lines...) Expand all
43 /// Parses a Dart file into an AST. 45 /// Parses a Dart file into an AST.
44 /// 46 ///
45 /// Throws an [AnalyzerErrorGroup] if any errors occurred, unless 47 /// Throws an [AnalyzerErrorGroup] if any errors occurred, unless
46 /// [suppressErrors] is `true`, in which case any errors are discarded. 48 /// [suppressErrors] is `true`, in which case any errors are discarded.
47 /// 49 ///
48 /// If [parseFunctionBodies] is [false] then only function signatures will be 50 /// If [parseFunctionBodies] is [false] then only function signatures will be
49 /// parsed. 51 /// parsed.
50 CompilationUnit parseDartFile(String path, 52 CompilationUnit parseDartFile(String path,
51 {bool suppressErrors: false, bool parseFunctionBodies: true}) { 53 {bool suppressErrors: false, bool parseFunctionBodies: true}) {
52 String contents = new File(path).readAsStringSync(); 54 String contents = new File(path).readAsStringSync();
53 var sourceFactory = new SourceFactory([new FileUriResolver()]); 55 var sourceFactory = new SourceFactory(
56 [new ResourceUriResolver(PhysicalResourceProvider.INSTANCE)]);
54 57
55 var absolutePath = pathos.absolute(path); 58 var absolutePath = pathos.absolute(path);
56 var source = sourceFactory.forUri(pathos.toUri(absolutePath).toString()); 59 var source = sourceFactory.forUri(pathos.toUri(absolutePath).toString());
57 if (source == null) { 60 if (source == null) {
58 throw new ArgumentError("Can't get source for path $path"); 61 throw new ArgumentError("Can't get source for path $path");
59 } 62 }
60 if (!source.exists()) { 63 if (!source.exists()) {
61 throw new ArgumentError("Source $source doesn't exist"); 64 throw new ArgumentError("Source $source doesn't exist");
62 } 65 }
63 66
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 /// The group of errors collected. 124 /// The group of errors collected.
122 AnalyzerErrorGroup get group => 125 AnalyzerErrorGroup get group =>
123 new AnalyzerErrorGroup.fromAnalysisErrors(_errors); 126 new AnalyzerErrorGroup.fromAnalysisErrors(_errors);
124 127
125 /// Whether any errors where collected. 128 /// Whether any errors where collected.
126 bool get hasErrors => !_errors.isEmpty; 129 bool get hasErrors => !_errors.isEmpty;
127 130
128 @override 131 @override
129 void onError(AnalysisError error) => _errors.add(error); 132 void onError(AnalysisError error) => _errors.add(error);
130 } 133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698