Chromium Code Reviews| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 stdout.writeln("resolve:$resolveTime"); | 118 stdout.writeln("resolve:$resolveTime"); |
| 119 stdout.writeln("errors:$errorsTime"); | 119 stdout.writeln("errors:$errorsTime"); |
| 120 stdout.writeln("hints:$hintsTime"); | 120 stdout.writeln("hints:$hintsTime"); |
| 121 stdout.writeln("angular:$angularTime"); | 121 stdout.writeln("angular:$angularTime"); |
| 122 stdout.writeln("other:${totalTime | 122 stdout.writeln("other:${totalTime |
| 123 - (ioTime + scanTime + parseTime + resolveTime + errorsTime + hints Time | 123 - (ioTime + scanTime + parseTime + resolveTime + errorsTime + hints Time |
| 124 + angularTime)}"); | 124 + angularTime)}"); |
| 125 stdout.writeln("total:$totalTime"); | 125 stdout.writeln("total:$totalTime"); |
| 126 } | 126 } |
| 127 }).catchError((exception, stackTrace) { | 127 }).catchError((exception, stackTrace) { |
| 128 AnalysisEngine.instance.logger.logError(exception); | 128 AnalysisEngine.instance.logger.logError(exception.toString()); |
| 129 }); | 129 }); |
| 130 } | 130 } |
| 131 | 131 |
| 132 /// Returns the maximal [ErrorSeverity] of the recorded errors. | 132 /// Returns the maximal [ErrorSeverity] of the recorded errors. |
| 133 ErrorSeverity get maxErrorSeverity { | 133 ErrorSeverity get maxErrorSeverity { |
| 134 var status = ErrorSeverity.NONE; | 134 var status = ErrorSeverity.NONE; |
| 135 for (AnalysisErrorInfo errorInfo in errorInfos) { | 135 for (AnalysisErrorInfo errorInfo in errorInfos) { |
| 136 for (AnalysisError error in errorInfo.errors) { | 136 for (AnalysisError error in errorInfo.errors) { |
| 137 var severity = error.errorCode.errorSeverity; | 137 var severity = error.errorCode.errorSeverity; |
| 138 status = status.max(severity); | 138 status = status.max(severity); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 151 } else { | 151 } else { |
| 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 | |
| 162 // AnalysisEngine.instance.logger = new StdLogger(); | |
|
jwren
2014/03/11 23:53:37
Do we want an additional --verbose flag to enable
Brian Wilkerson
2014/03/12 13:19:18
I would probably call it "--debug", but it seems l
jwren
2014/03/12 16:28:44
Will add the flag in a follow up CL.
| |
| 161 | 163 |
| 162 // set options for context | 164 // set options for context |
| 163 AnalysisOptionsImpl contextOptions = new AnalysisOptionsImpl(); | 165 AnalysisOptionsImpl contextOptions = new AnalysisOptionsImpl(); |
| 164 contextOptions.cacheSize = _MAX_CACHE_SIZE; | 166 contextOptions.cacheSize = _MAX_CACHE_SIZE; |
| 165 contextOptions.hint = !options.disableHints; | 167 contextOptions.hint = !options.disableHints; |
| 166 context.analysisOptions = contextOptions; | 168 context.analysisOptions = contextOptions; |
| 167 | 169 |
| 168 // Create and add a ChangeSet | 170 // Create and add a ChangeSet |
| 169 ChangeSet changeSet = new ChangeSet(); | 171 ChangeSet changeSet = new ChangeSet(); |
| 170 changeSet.addedSource(source); | 172 changeSet.addedSource(source); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 var internalPath = pathos.join(libraryDirectory, '_internal') + pathos.s eparator; | 254 var internalPath = pathos.join(libraryDirectory, '_internal') + pathos.s eparator; |
| 253 if (!filePath.startsWith(internalPath)) { | 255 if (!filePath.startsWith(internalPath)) { |
| 254 return UriKind.DART_URI; | 256 return UriKind.DART_URI; |
| 255 } | 257 } |
| 256 } | 258 } |
| 257 } | 259 } |
| 258 // some generic file | 260 // some generic file |
| 259 return UriKind.FILE_URI; | 261 return UriKind.FILE_URI; |
| 260 } | 262 } |
| 261 } | 263 } |
| 264 | |
| 265 /** | |
| 266 * This [Logger] prints out information comments to [stdout] and error messages | |
| 267 * to [stderr]. | |
| 268 */ | |
| 269 class StdLogger extends Logger { | |
| 270 | |
| 271 @override | |
| 272 void logError(String message) { | |
| 273 stderr.writeln(message); | |
| 274 } | |
| 275 | |
| 276 @override | |
| 277 void logError2(String message, Exception exception) { | |
| 278 stderr.writeln(message); | |
| 279 } | |
| 280 | |
| 281 @override | |
| 282 void logInformation(String message) { | |
| 283 stdout.writeln(message); | |
| 284 } | |
| 285 | |
| 286 @override | |
| 287 void logInformation2(String message, Exception exception) { | |
| 288 stdout.writeln(message); | |
| 289 } | |
| 290 } | |
| OLD | NEW |