| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 mock_compiler; | 5 library mock_compiler; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:collection'; | 9 import 'dart:collection'; |
| 10 | 10 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 // TODO(johnniwinther): Remove this when we don't filter certain type checker | 157 // TODO(johnniwinther): Remove this when we don't filter certain type checker |
| 158 // warnings. | 158 // warnings. |
| 159 void reportWarning(Spannable node, MessageKind messageKind, | 159 void reportWarning(Spannable node, MessageKind messageKind, |
| 160 [Map arguments = const {}]) { | 160 [Map arguments = const {}]) { |
| 161 reportDiagnostic(node, | 161 reportDiagnostic(node, |
| 162 messageKind.message(arguments, terseDiagnostics), | 162 messageKind.message(arguments, terseDiagnostics), |
| 163 api.Diagnostic.WARNING); | 163 api.Diagnostic.WARNING); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void reportFatalError(Spannable node, | |
| 167 MessageKind messageKind, | |
| 168 [Map arguments = const {}]) { | |
| 169 reportError(node, messageKind, arguments); | |
| 170 } | |
| 171 | |
| 172 void reportDiagnostic(Spannable node, | 166 void reportDiagnostic(Spannable node, |
| 173 Message message, | 167 Message message, |
| 174 api.Diagnostic kind) { | 168 api.Diagnostic kind) { |
| 175 var diagnostic = new WarningMessage(node, message); | 169 var diagnostic = new WarningMessage(node, message); |
| 176 if (kind == api.Diagnostic.CRASH) { | 170 if (kind == api.Diagnostic.CRASH) { |
| 177 crashes.add(diagnostic); | 171 crashes.add(diagnostic); |
| 178 } else if (kind == api.Diagnostic.ERROR) { | 172 } else if (kind == api.Diagnostic.ERROR) { |
| 179 errors.add(diagnostic); | 173 errors.add(diagnostic); |
| 180 } else if (kind == api.Diagnostic.WARNING) { | 174 } else if (kind == api.Diagnostic.WARNING) { |
| 181 warnings.add(diagnostic); | 175 warnings.add(diagnostic); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 211 | 205 |
| 212 TreeElementMapping resolveNodeStatement(Node tree, | 206 TreeElementMapping resolveNodeStatement(Node tree, |
| 213 ExecutableElement element) { | 207 ExecutableElement element) { |
| 214 ResolverVisitor visitor = | 208 ResolverVisitor visitor = |
| 215 new ResolverVisitor(this, element, | 209 new ResolverVisitor(this, element, |
| 216 new ResolutionRegistry.internal(this, | 210 new ResolutionRegistry.internal(this, |
| 217 new CollectingTreeElements(element))); | 211 new CollectingTreeElements(element))); |
| 218 if (visitor.scope is LibraryScope) { | 212 if (visitor.scope is LibraryScope) { |
| 219 visitor.scope = new MethodScope(visitor.scope, element); | 213 visitor.scope = new MethodScope(visitor.scope, element); |
| 220 } | 214 } |
| 221 visitor.visit(tree); | 215 try { |
| 216 visitor.visit(tree); |
| 217 } on CompilerCancelledException catch (_) { |
| 218 // Ignored. |
| 219 |
| 220 // TODO(ahe): Don't ignore CompilerCancelledException, instead, fix |
| 221 // pkg/compiler/lib/src/resolution/members.dart. |
| 222 } |
| 222 visitor.scope = new LibraryScope(element.library); | 223 visitor.scope = new LibraryScope(element.library); |
| 223 return visitor.registry.mapping; | 224 return visitor.registry.mapping; |
| 224 } | 225 } |
| 225 | 226 |
| 226 resolverVisitor() { | 227 resolverVisitor() { |
| 227 Element mockElement = new MockElement(mainApp.entryCompilationUnit); | 228 Element mockElement = new MockElement(mainApp.entryCompilationUnit); |
| 228 ResolverVisitor visitor = | 229 ResolverVisitor visitor = |
| 229 new ResolverVisitor(this, mockElement, | 230 new ResolverVisitor(this, mockElement, |
| 230 new ResolutionRegistry.internal(this, | 231 new ResolutionRegistry.internal(this, |
| 231 new CollectingTreeElements(mockElement))); | 232 new CollectingTreeElements(mockElement))); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 MockElement(Element enclosingElement) | 396 MockElement(Element enclosingElement) |
| 396 : super('', ElementKind.FUNCTION, Modifiers.EMPTY, | 397 : super('', ElementKind.FUNCTION, Modifiers.EMPTY, |
| 397 enclosingElement, false); | 398 enclosingElement, false); |
| 398 | 399 |
| 399 get node => null; | 400 get node => null; |
| 400 | 401 |
| 401 parseNode(_) => null; | 402 parseNode(_) => null; |
| 402 | 403 |
| 403 bool get hasNode => false; | 404 bool get hasNode => false; |
| 404 } | 405 } |
| OLD | NEW |