| OLD | NEW |
| 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_impl; | 5 library analyzer_impl; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 packageDirectory = getPackageDirectoryFor(sourceFile); | 152 packageDirectory = getPackageDirectoryFor(sourceFile); |
| 153 } | 153 } |
| 154 if (packageDirectory != null) { | 154 if (packageDirectory != null) { |
| 155 resolvers.add(new PackageUriResolver([packageDirectory])); | 155 resolvers.add(new PackageUriResolver([packageDirectory])); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 sourceFactory = new SourceFactory(resolvers); | 158 sourceFactory = new SourceFactory(resolvers); |
| 159 context = AnalysisEngine.instance.createAnalysisContext(); | 159 context = AnalysisEngine.instance.createAnalysisContext(); |
| 160 context.sourceFactory = sourceFactory; | 160 context.sourceFactory = sourceFactory; |
| 161 // Uncomment the following to have errors reported on stdout and stderr | 161 // Uncomment the following to have errors reported on stdout and stderr |
| 162 // AnalysisEngine.instance.logger = new StdLogger(); | 162 AnalysisEngine.instance.logger = new StdLogger(options.log); |
| 163 | 163 |
| 164 // set options for context | 164 // set options for context |
| 165 AnalysisOptionsImpl contextOptions = new AnalysisOptionsImpl(); | 165 AnalysisOptionsImpl contextOptions = new AnalysisOptionsImpl(); |
| 166 contextOptions.cacheSize = _MAX_CACHE_SIZE; | 166 contextOptions.cacheSize = _MAX_CACHE_SIZE; |
| 167 contextOptions.hint = !options.disableHints; | 167 contextOptions.hint = !options.disableHints; |
| 168 context.analysisOptions = contextOptions; | 168 context.analysisOptions = contextOptions; |
| 169 | 169 |
| 170 // Create and add a ChangeSet | 170 // Create and add a ChangeSet |
| 171 ChangeSet changeSet = new ChangeSet(); | 171 ChangeSet changeSet = new ChangeSet(); |
| 172 changeSet.addedSource(source); | 172 changeSet.addedSource(source); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // some generic file | 260 // some generic file |
| 261 return UriKind.FILE_URI; | 261 return UriKind.FILE_URI; |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 | 264 |
| 265 /** | 265 /** |
| 266 * This [Logger] prints out information comments to [stdout] and error messages | 266 * This [Logger] prints out information comments to [stdout] and error messages |
| 267 * to [stderr]. | 267 * to [stderr]. |
| 268 */ | 268 */ |
| 269 class StdLogger extends Logger { | 269 class StdLogger extends Logger { |
| 270 | 270 final bool log; |
| 271 |
| 272 StdLogger(this.log); |
| 273 |
| 271 @override | 274 @override |
| 272 void logError(String message) { | 275 void logError(String message) { |
| 273 stderr.writeln(message); | 276 stderr.writeln(message); |
| 274 } | 277 } |
| 275 | 278 |
| 276 @override | 279 @override |
| 277 void logError2(String message, Exception exception) { | 280 void logError2(String message, Exception exception) { |
| 278 stderr.writeln(message); | 281 stderr.writeln(message); |
| 279 } | 282 } |
| 280 | 283 |
| 281 @override | 284 @override |
| 282 void logInformation(String message) { | 285 void logInformation(String message) { |
| 283 stdout.writeln(message); | 286 if (log) { |
| 287 stdout.writeln(message); |
| 288 } |
| 284 } | 289 } |
| 285 | 290 |
| 286 @override | 291 @override |
| 287 void logInformation2(String message, Exception exception) { | 292 void logInformation2(String message, Exception exception) { |
| 288 stdout.writeln(message); | 293 if (log) { |
| 294 stdout.writeln(message); |
| 295 } |
| 289 } | 296 } |
| 290 } | 297 } |
| OLD | NEW |