| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Encapsulates how to invoke the analyzer resolver and overrides how it | 5 /// Encapsulates how to invoke the analyzer resolver and overrides how it |
| 6 /// computes types on expressions to use our restricted set of types. | 6 /// computes types on expressions to use our restricted set of types. |
| 7 library dev_compiler.src.checker.resolver; | 7 library dev_compiler.src.checker.resolver; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 reporter.log(message); | 104 reporter.log(message); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 return failure; | 107 return failure; |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 class AnalyzerError extends Message { | 111 class AnalyzerError extends Message { |
| 112 factory AnalyzerError.from(analyzer.AnalysisError error) { | 112 factory AnalyzerError.from(analyzer.AnalysisError error) { |
| 113 var severity = error.errorCode.type.severity; | 113 var severity = error.errorCode.type.severity; |
| 114 var isError = severity == analyzer.ErrorSeverity.ERROR; | 114 var isError = severity == analyzer.ErrorSeverity.WARNING; |
| 115 var level = isError ? logger.Level.SEVERE : logger.Level.WARNING; | 115 var level = isError ? logger.Level.SEVERE : logger.Level.WARNING; |
| 116 int begin = error.offset; | 116 int begin = error.offset; |
| 117 int end = begin + error.length; | 117 int end = begin + error.length; |
| 118 return new AnalyzerError(error.message, level, begin, end); | 118 return new AnalyzerError(error.message, level, begin, end); |
| 119 } | 119 } |
| 120 | 120 |
| 121 const AnalyzerError(String message, logger.Level level, int begin, int end) | 121 const AnalyzerError(String message, logger.Level level, int begin, int end) |
| 122 : super('[from analyzer]: $message', level, begin, end); | 122 : super(message, level, begin, end); |
| 123 } | 123 } |
| 124 | 124 |
| 125 /// Creates an analysis context that contains our restricted typing rules. | 125 /// Creates an analysis context that contains our restricted typing rules. |
| 126 InternalAnalysisContext _initContext(ResolverOptions options) { | 126 InternalAnalysisContext _initContext(ResolverOptions options) { |
| 127 var analysisOptions = new AnalysisOptionsImpl()..cacheSize = 512; | 127 var analysisOptions = new AnalysisOptionsImpl()..cacheSize = 512; |
| 128 AnalysisContextImpl res = AnalysisEngine.instance.createAnalysisContext(); | 128 AnalysisContextImpl res = AnalysisEngine.instance.createAnalysisContext(); |
| 129 res.analysisOptions = analysisOptions; | 129 res.analysisOptions = analysisOptions; |
| 130 res.libraryResolverFactory = | 130 res.libraryResolverFactory = |
| 131 (context) => new LibraryResolverWithInference(context, options); | 131 (context) => new LibraryResolverWithInference(context, options); |
| 132 return res; | 132 return res; |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 } | 788 } |
| 789 } | 789 } |
| 790 | 790 |
| 791 // Review note: no longer need to override visitFunctionExpression, this is | 791 // Review note: no longer need to override visitFunctionExpression, this is |
| 792 // handled by the analyzer internally. | 792 // handled by the analyzer internally. |
| 793 // TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result? | 793 // TODO(vsm): in visitbinaryExpression: check computeStaticReturnType result? |
| 794 // TODO(vsm): in visitFunctionDeclaration: Should we ever use the expression | 794 // TODO(vsm): in visitFunctionDeclaration: Should we ever use the expression |
| 795 // type in a (...) => expr or just the written type? | 795 // type in a (...) => expr or just the written type? |
| 796 | 796 |
| 797 } | 797 } |
| OLD | NEW |