| 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 library related_types; | 5 library related_types; |
| 6 | 6 |
| 7 import 'package:compiler/src/commandline_options.dart'; |
| 7 import 'package:compiler/src/compiler.dart'; | 8 import 'package:compiler/src/compiler.dart'; |
| 8 import 'package:compiler/src/core_types.dart'; | 9 import 'package:compiler/src/core_types.dart'; |
| 9 import 'package:compiler/src/dart_types.dart'; | 10 import 'package:compiler/src/dart_types.dart'; |
| 10 import 'package:compiler/src/diagnostics/messages.dart'; | 11 import 'package:compiler/src/diagnostics/messages.dart'; |
| 11 import 'package:compiler/src/elements/elements.dart'; | 12 import 'package:compiler/src/elements/elements.dart'; |
| 13 import 'package:compiler/src/filenames.dart'; |
| 12 import 'package:compiler/src/resolution/semantic_visitor.dart'; | 14 import 'package:compiler/src/resolution/semantic_visitor.dart'; |
| 13 import 'package:compiler/src/tree/tree.dart'; | 15 import 'package:compiler/src/tree/tree.dart'; |
| 14 import 'package:compiler/src/universe/universe.dart'; | 16 import 'package:compiler/src/universe/universe.dart'; |
| 15 import 'package:compiler/src/world.dart'; | 17 import 'package:compiler/src/world.dart'; |
| 18 import 'memory_compiler.dart'; |
| 19 |
| 20 main(List<String> arguments) async { |
| 21 if (arguments.isNotEmpty) { |
| 22 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.last)); |
| 23 CompilationResult result = await runCompiler( |
| 24 entryPoint: entryPoint, |
| 25 options: [Flags.analyzeOnly, '--categories=Client,Server']); |
| 26 if (result.isSuccess) { |
| 27 checkRelatedTypes(result.compiler); |
| 28 } |
| 29 } else { |
| 30 print('Usage dart related_types.dart <entry-point>'); |
| 31 } |
| 32 } |
| 16 | 33 |
| 17 /// Check all loaded libraries in [compiler] for unrelated types. | 34 /// Check all loaded libraries in [compiler] for unrelated types. |
| 18 void checkRelatedTypes(Compiler compiler) { | 35 void checkRelatedTypes(Compiler compiler) { |
| 19 for (LibraryElement library in compiler.libraryLoader.libraries) { | 36 for (LibraryElement library in compiler.libraryLoader.libraries) { |
| 20 checkLibraryElement(compiler, library); | 37 checkLibraryElement(compiler, library); |
| 21 } | 38 } |
| 22 } | 39 } |
| 23 | 40 |
| 24 /// Check [library] for unrelated types. | 41 /// Check [library] for unrelated types. |
| 25 void checkLibraryElement(Compiler compiler, LibraryElement library) { | 42 void checkLibraryElement(Compiler compiler, LibraryElement library) { |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 ClassElement findClass(DartType type) => type.accept(this, null); | 421 ClassElement findClass(DartType type) => type.accept(this, null); |
| 405 | 422 |
| 406 @override | 423 @override |
| 407 ClassElement visitType(DartType type, _) => null; | 424 ClassElement visitType(DartType type, _) => null; |
| 408 | 425 |
| 409 @override | 426 @override |
| 410 ClassElement visitInterfaceType(InterfaceType type, _) { | 427 ClassElement visitInterfaceType(InterfaceType type, _) { |
| 411 return type.element; | 428 return type.element; |
| 412 } | 429 } |
| 413 } | 430 } |
| OLD | NEW |