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

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

Issue 988483006: Add widget to display errors, and report dependency_graph errors correctly (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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'; 9 import 'dart:mirrors';
10 10
11 import 'package:analyzer/src/generated/ast.dart'; 11 import 'package:analyzer/src/generated/ast.dart';
12 import 'package:analyzer/src/generated/element.dart'; 12 import 'package:analyzer/src/generated/element.dart';
13 import 'package:analyzer/src/generated/scanner.dart' 13 import 'package:analyzer/src/generated/scanner.dart'
14 show Token, TokenType, SyntheticStringToken; 14 show Token, TokenType, SyntheticStringToken;
15 import 'package:logging/logging.dart' show Level; 15 import 'package:logging/logging.dart' show Level;
16 16
17 import 'package:dev_compiler/src/checker/rules.dart'; 17 import 'package:dev_compiler/src/checker/rules.dart';
18 import 'package:dev_compiler/src/utils.dart' as utils; 18 import 'package:dev_compiler/src/utils.dart' as utils;
19 19
20 import 'report.dart' show Message;
21
20 /// Represents a summary of the results collected by running the program 22 /// Represents a summary of the results collected by running the program
21 /// checker. 23 /// checker.
22 class CheckerResults { 24 class CheckerResults {
23 final List<LibraryInfo> libraries; 25 final List<LibraryInfo> libraries;
24 final TypeRules rules; 26 final TypeRules rules;
25 final bool failure; 27 final bool failure;
26 28
27 CheckerResults(this.libraries, this.rules, this.failure); 29 CheckerResults(this.libraries, this.rules, this.failure);
28 } 30 }
29 31
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 : super(fromType, toType); 109 : super(fromType, toType);
108 } 110 }
109 111
110 // The error coercion. This coercion signals that a coercion 112 // The error coercion. This coercion signals that a coercion
111 // could not be generated. The code generator should not see 113 // could not be generated. The code generator should not see
112 // these. 114 // these.
113 class CoercionError extends Coercion { 115 class CoercionError extends Coercion {
114 CoercionError() : super(null, null); 116 CoercionError() : super(null, null);
115 } 117 }
116 118
117 abstract class StaticInfo { 119 abstract class StaticInfo implements Message {
118 /// AST Node this info is attached to. 120 /// AST Node this info is attached to.
119 // TODO(jmesserly): this is somewhat redundant with SemanticNode. 121 // TODO(jmesserly): this is somewhat redundant with SemanticNode.
120 AstNode get node; 122 AstNode get node;
121 123
122 /// Log level for error messages. This is a placeholder 124 @override
123 /// for severity. 125 int get begin => node is AnnotatedNode
124 Level get level; 126 ? (node as AnnotatedNode).firstTokenAfterCommentAndMetadata.offset
127 : node.offset;
125 128
126 /// Description / error message. 129 @override
127 String get message; 130 int get end => node.end;
128 } 131 }
129 132
130 /// Implicitly injected expression conversion. 133 /// Implicitly injected expression conversion.
131 // TODO(jmesserly): rename to have Expression suffix? 134 // TODO(jmesserly): rename to have Expression suffix?
132 abstract class Conversion extends Expression implements StaticInfo { 135 abstract class Conversion extends Expression with StaticInfo {
133 final TypeRules rules; 136 final TypeRules rules;
134 137
135 // TODO(jmesserly): should probably rename this "operand" for consistency with 138 // TODO(jmesserly): should probably rename this "operand" for consistency with
136 // analyzer's unary expressions (e.g. PrefixExpression). 139 // analyzer's unary expressions (e.g. PrefixExpression).
137 final Expression expression; 140 final Expression expression;
138 141
139 AstNode get node => expression; 142 AstNode get node => expression;
140 DartType _convertedType; 143 DartType _convertedType;
141 144
142 Conversion(this.rules, this.expression) { 145 Conversion(this.rules, this.expression) {
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 for (var cls in declarations.where((d) => d is ClassMirror)) { 582 for (var cls in declarations.where((d) => d is ClassMirror)) {
580 if (cls.isSubtypeOf(infoMirror)) { 583 if (cls.isSubtypeOf(infoMirror)) {
581 allTypes.add(cls); 584 allTypes.add(cls);
582 baseTypes.add(cls.superclass); 585 baseTypes.add(cls.superclass);
583 } 586 }
584 } 587 }
585 allTypes.removeAll(baseTypes); 588 allTypes.removeAll(baseTypes);
586 return new List<Type>.from(allTypes.map((mirror) => mirror.reflectedType)) 589 return new List<Type>.from(allTypes.map((mirror) => mirror.reflectedType))
587 ..sort((t1, t2) => '$t1'.compareTo('$t2')); 590 ..sort((t1, t2) => '$t1'.compareTo('$t2'));
588 }(); 591 }();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698