Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(834)

Side by Side Diff: lib/src/info.dart

Issue 1174643003: expose strong checker API, for use by analyzer_cli (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /// Defines static information collected by the type checker and used later by 5 /// Defines static information collected by the type checker and used later by
6 /// emitters to generate code. 6 /// emitters to generate code.
7 library dev_compiler.src.info; 7 library dev_compiler.src.info;
8 8
9 import 'dart:mirrors';
10
11 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
12 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
13 import 'package:analyzer/src/generated/error.dart' as analyzer; 11 import 'package:analyzer/src/generated/error.dart' as analyzer;
14 import 'package:logging/logging.dart' show Level; 12 import 'package:logging/logging.dart' show Level;
15 13
16 import 'package:dev_compiler/src/checker/rules.dart'; 14 import 'package:dev_compiler/src/checker/rules.dart';
17 import 'package:dev_compiler/src/utils.dart' as utils; 15 import 'package:dev_compiler/src/utils.dart' as utils;
18 16
19 import 'report.dart' show Message; 17 import 'report.dart' show Message;
20 18
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 /// <http://goo.gl/q1T4BB> 505 /// <http://goo.gl/q1T4BB>
508 /// 506 ///
509 /// For now this is the only pattern we support. 507 /// For now this is the only pattern we support.
510 class InvalidSuperInvocation extends StaticError { 508 class InvalidSuperInvocation extends StaticError {
511 InvalidSuperInvocation(SuperConstructorInvocation node) : super(node); 509 InvalidSuperInvocation(SuperConstructorInvocation node) : super(node);
512 510
513 String get message => "super call must be last in an initializer list " 511 String get message => "super call must be last in an initializer list "
514 "(see http://goo.gl/q1T4BB): $node"; 512 "(see http://goo.gl/q1T4BB): $node";
515 } 513 }
516 514
517 /// Automatically infer list of types by scanning this library using mirrors.
518 final List<Type> infoTypes = () {
519 var allTypes = new Set();
520 var baseTypes = new Set();
521 var infoMirror = reflectClass(StaticInfo);
522 var libMirror = infoMirror.owner as LibraryMirror;
523 var declarations = libMirror.declarations.values;
524 for (ClassMirror cls in declarations.where((d) => d is ClassMirror)) {
525 if (cls.isSubtypeOf(infoMirror)) {
526 allTypes.add(cls);
527 baseTypes.add(cls.superclass);
528 }
529 }
530 allTypes.removeAll(baseTypes);
531 return new List<Type>.from(allTypes.map((mirror) => mirror.reflectedType))
532 ..sort((t1, t2) => '$t1'.compareTo('$t2'));
533 }();
534
535 class AnalyzerError extends Message { 515 class AnalyzerError extends Message {
536 factory AnalyzerError.from(analyzer.AnalysisError error) { 516 factory AnalyzerError.from(analyzer.AnalysisError error) {
537 var severity = error.errorCode.type.severity; 517 var severity = error.errorCode.type.severity;
538 var isError = severity == analyzer.ErrorSeverity.WARNING; 518 var isError = severity == analyzer.ErrorSeverity.WARNING;
539 var level = isError ? Level.SEVERE : Level.WARNING; 519 var level = isError ? Level.SEVERE : Level.WARNING;
540 int begin = error.offset; 520 int begin = error.offset;
541 int end = begin + error.length; 521 int end = begin + error.length;
542 return new AnalyzerError(error.message, level, begin, end); 522 return new AnalyzerError(error.message, level, begin, end);
543 } 523 }
544 524
545 const AnalyzerError(String message, Level level, int begin, int end) 525 const AnalyzerError(String message, Level level, int begin, int end)
546 : super(message, level, begin, end); 526 : super(message, level, begin, end);
547 } 527 }
OLDNEW
« no previous file with comments | « lib/src/dependency_graph.dart ('k') | lib/src/options.dart » ('j') | lib/src/options.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698