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

Unified Diff: lib/src/dependency_graph.dart

Issue 1230903002: fixes #6, refactor to use AnalysisError/Listener throughout dev_compiler (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/codegen/js_printer.dart ('k') | lib/src/info.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/dependency_graph.dart
diff --git a/lib/src/dependency_graph.dart b/lib/src/dependency_graph.dart
index dd39df563512aea9c309a464613c4e10ff77cf96..0600b59d1d60faccd4e69b0d81932390989def2c 100644
--- a/lib/src/dependency_graph.dart
+++ b/lib/src/dependency_graph.dart
@@ -21,6 +21,7 @@ import 'package:analyzer/src/generated/ast.dart'
UriBasedDirective;
import 'package:analyzer/src/generated/engine.dart'
show ParseDartTask, AnalysisContext;
+import 'package:analyzer/src/generated/error.dart';
import 'package:analyzer/src/generated/source.dart' show Source, SourceKind;
import 'package:html/dom.dart' show Document, Node, Element;
import 'package:html/parser.dart' as html;
@@ -44,7 +45,7 @@ class SourceGraph {
/// Analyzer used to resolve source files.
final AnalysisContext _context;
- final CompilerReporter _reporter;
+ final AnalysisErrorListener _reporter;
final CompilerOptions _options;
SourceGraph(this._context, this._reporter, this._options) {
@@ -181,7 +182,10 @@ class HtmlSourceNode extends SourceNode {
void update() {
super.update();
if (needsRebuild) {
- graph._reporter.clearHtml(uri);
+ var reporter = graph._reporter;
+ if (reporter is SummaryReporter) {
+ reporter.clearHtml(uri);
+ }
document = html.parse(contents, generateSpans: true);
var newScripts = new Set<DartSourceNode>();
var tags = document.querySelectorAll('script[type="application/dart"]');
@@ -232,11 +236,12 @@ class HtmlSourceNode extends SourceNode {
}
void _reportError(SourceGraph graph, String message, Node node) {
- graph._reporter.enterHtml(_source.uri);
var span = node.sourceSpan;
- graph._reporter.log(
- new Message(message, Level.SEVERE, span.start.offset, span.end.offset));
- graph._reporter.leaveHtml();
+
+ // TODO(jmesserly): should these be errors or warnings?
+ var errorCode = new HtmlWarningCode('dev_compiler.$runtimeType', message);
+ graph._reporter.onError(new AnalysisError(
+ _source, span.start.offset, span.length, errorCode));
}
}
@@ -281,7 +286,11 @@ class DartSourceNode extends SourceNode {
super.update();
if (needsRebuild) {
- graph._reporter.clearLibrary(uri);
+ var reporter = graph._reporter;
+ if (reporter is SummaryReporter) {
+ reporter.clearLibrary(uri);
+ }
+
// If the defining compilation-unit changed, the structure might have
// changed.
var unit = parseDirectives(contents, name: _source.fullName);
@@ -306,7 +315,7 @@ class DartSourceNode extends SourceNode {
targetUri, () => new DartSourceNode(graph, targetUri, target));
//var node = graph.nodeFromUri(targetUri);
if (node._source == null || !node._source.exists()) {
- _reportError(graph, 'File $targetUri not found', unit, d);
+ _reportError(graph, 'File $targetUri not found', d);
}
if (d is ImportDirective) {
@@ -360,14 +369,9 @@ class DartSourceNode extends SourceNode {
}
}
- void _reportError(
- SourceGraph graph, String message, CompilationUnit unit, AstNode node) {
- graph._reporter
- ..enterLibrary(_source.uri)
- ..enterCompilationUnit(unit, _source)
- ..log(new Message(message, Level.SEVERE, node.offset, node.end))
- ..leaveCompilationUnit()
- ..leaveLibrary();
+ void _reportError(SourceGraph graph, String message, AstNode node) {
+ graph._reporter.onError(new AnalysisError(_source, node.offset,
+ node.length, new CompileTimeErrorCode('dev_compiler.$runtimeType', message)));
}
}
« no previous file with comments | « lib/src/codegen/js_printer.dart ('k') | lib/src/info.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698