| 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 'dart:uri'; | 7 import 'dart:uri'; | 
| 8 | 8 | 
| 9 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api; | 9 import '../../../sdk/lib/_internal/compiler/compiler.dart' as api; | 
| 10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' | 10 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 128   void reportError(Node node, var message) { | 128   void reportError(Node node, var message) { | 
| 129     if (message is String && message.startsWith("no library name found in")) { | 129     if (message is String && message.startsWith("no library name found in")) { | 
| 130       // TODO(ahe): Fix the MockCompiler to not have this problem. | 130       // TODO(ahe): Fix the MockCompiler to not have this problem. | 
| 131       return; | 131       return; | 
| 132     } | 132     } | 
| 133     errors.add(new WarningMessage(node, message.message)); | 133     errors.add(new WarningMessage(node, message.message)); | 
| 134   } | 134   } | 
| 135 | 135 | 
| 136   void reportMessage(SourceSpan span, var message, api.Diagnostic kind) { | 136   void reportMessage(SourceSpan span, var message, api.Diagnostic kind) { | 
| 137     var diagnostic = new WarningMessage(null, message.message); | 137     var diagnostic = new WarningMessage(null, message.message); | 
| 138     if (kind === api.Diagnostic.ERROR) { | 138     if (kind == api.Diagnostic.ERROR) { | 
| 139       errors.add(diagnostic); | 139       errors.add(diagnostic); | 
| 140     } else { | 140     } else { | 
| 141       warnings.add(diagnostic); | 141       warnings.add(diagnostic); | 
| 142     } | 142     } | 
| 143   } | 143   } | 
| 144 | 144 | 
| 145   void reportDiagnostic(SourceSpan span, String message, var kind) { | 145   void reportDiagnostic(SourceSpan span, String message, var kind) { | 
| 146     print(message); | 146     print(message); | 
| 147   } | 147   } | 
| 148 | 148 | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 176     Element mockElement = | 176     Element mockElement = | 
| 177         new Element(buildSourceString(''), ElementKind.FUNCTION, mainApp); | 177         new Element(buildSourceString(''), ElementKind.FUNCTION, mainApp); | 
| 178     ResolverVisitor visitor = | 178     ResolverVisitor visitor = | 
| 179         new ResolverVisitor(this, mockElement, | 179         new ResolverVisitor(this, mockElement, | 
| 180                             new CollectingTreeElements(mockElement)); | 180                             new CollectingTreeElements(mockElement)); | 
| 181     visitor.scope = new MethodScope(visitor.scope, mockElement); | 181     visitor.scope = new MethodScope(visitor.scope, mockElement); | 
| 182     return visitor; | 182     return visitor; | 
| 183   } | 183   } | 
| 184 | 184 | 
| 185   parseScript(String text, [LibraryElement library]) { | 185   parseScript(String text, [LibraryElement library]) { | 
| 186     if (library === null) library = mainApp; | 186     if (library == null) library = mainApp; | 
| 187     parseUnit(text, this, library); | 187     parseUnit(text, this, library); | 
| 188   } | 188   } | 
| 189 | 189 | 
| 190   void scanBuiltinLibraries() { | 190   void scanBuiltinLibraries() { | 
| 191     // Do nothing. The mock core library is already handled in the constructor. | 191     // Do nothing. The mock core library is already handled in the constructor. | 
| 192   } | 192   } | 
| 193 | 193 | 
| 194   LibraryElement scanBuiltinLibrary(String name) { | 194   LibraryElement scanBuiltinLibrary(String name) { | 
| 195     // Do nothing. The mock core library is already handled in the constructor. | 195     // Do nothing. The mock core library is already handled in the constructor. | 
| 196   } | 196   } | 
| 197 | 197 | 
| 198   void importCoreLibrary(LibraryElement library) { | 198   void importCoreLibrary(LibraryElement library) { | 
| 199     scanner.importLibrary(library, coreLibrary, null); | 199     scanner.importLibrary(library, coreLibrary, null); | 
| 200   } | 200   } | 
| 201 | 201 | 
| 202   // The mock library doesn't need any patches. | 202   // The mock library doesn't need any patches. | 
| 203   Uri resolvePatchUri(String dartLibraryName) => null; | 203   Uri resolvePatchUri(String dartLibraryName) => null; | 
| 204 | 204 | 
| 205   Script readScript(Uri uri, [ScriptTag node]) { | 205   Script readScript(Uri uri, [ScriptTag node]) { | 
| 206     SourceFile sourceFile = sourceFiles[uri.toString()]; | 206     SourceFile sourceFile = sourceFiles[uri.toString()]; | 
| 207     if (sourceFile === null) throw new ArgumentError(uri); | 207     if (sourceFile == null) throw new ArgumentError(uri); | 
| 208     return new Script(uri, sourceFile); | 208     return new Script(uri, sourceFile); | 
| 209   } | 209   } | 
| 210 } | 210 } | 
| 211 | 211 | 
| 212 void compareWarningKinds(String text, expectedWarnings, foundWarnings) { | 212 void compareWarningKinds(String text, expectedWarnings, foundWarnings) { | 
| 213   var fail = (message) => Expect.fail('$text: $message'); | 213   var fail = (message) => Expect.fail('$text: $message'); | 
| 214   Iterator<MessageKind> expected = expectedWarnings.iterator(); | 214   Iterator<MessageKind> expected = expectedWarnings.iterator(); | 
| 215   Iterator<WarningMessage> found = foundWarnings.iterator(); | 215   Iterator<WarningMessage> found = foundWarnings.iterator(); | 
| 216   while (expected.hasNext && found.hasNext) { | 216   while (expected.hasNext && found.hasNext) { | 
| 217     Expect.equals(expected.next(), found.next().message.kind); | 217     Expect.equals(expected.next(), found.next().message.kind); | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 254   operator []=(Node node, Element element) { | 254   operator []=(Node node, Element element) { | 
| 255     map[node] = element; | 255     map[node] = element; | 
| 256   } | 256   } | 
| 257 | 257 | 
| 258   operator [](Node node) => map[node]; | 258   operator [](Node node) => map[node]; | 
| 259 | 259 | 
| 260   void remove(Node node) { | 260   void remove(Node node) { | 
| 261     map.remove(node); | 261     map.remove(node); | 
| 262   } | 262   } | 
| 263 } | 263 } | 
| OLD | NEW | 
|---|