Skip to content

Commit

Permalink
Track front end errors.
Browse files Browse the repository at this point in the history
In a later CL I will add code to print out the errors in the case
where the front end detects errors but the analyzer does not.

Change-Id: I675a9ffcce7cfe7afa32406b3310e7b1d42d2afc
Reviewed-on: https://dart-review.googlesource.com/76720
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
  • Loading branch information
stereotype441 authored and commit-bot@chromium.org committed Sep 26, 2018
1 parent 15c64b4 commit e31f9fc
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions pkg/analyzer_fe_comparison/lib/src/kernel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'dart:async';

import 'package:analyzer_fe_comparison/src/comparison_node.dart';
import 'package:front_end/src/api_prototype/compilation_message.dart';
import 'package:front_end/src/api_prototype/compiler_options.dart';
import 'package:front_end/src/api_prototype/kernel_generator.dart';
import 'package:front_end/src/api_prototype/standard_file_system.dart';
Expand All @@ -15,14 +16,12 @@ import 'package:kernel/target/targets.dart';
/// [ComparisonNode] representing them.
Future<ComparisonNode> analyzePackage(
List<Uri> inputs, Uri packagesFileUri, Uri platformUri) async {
bool errorOccurred = false;
var errors = <CompilationMessage>[];
var component = await kernelForComponent(
inputs,
_makeCompilerOptions(packagesFileUri, platformUri, (_) {
errorOccurred = true;
}));
if (errorOccurred) {
return ComparisonNode('Error occurred');
inputs, _makeCompilerOptions(packagesFileUri, platformUri, errors.add));
if (errors.isNotEmpty) {
return ComparisonNode(
'Error occurred', errors.map(_compilationMessageToNode).toList());
}
var libraryNodes = <ComparisonNode>[];
var visitor = _KernelVisitor(libraryNodes);
Expand All @@ -40,14 +39,12 @@ Future<ComparisonNode> analyzePackage(
/// Only libraries whose URI passes the [uriFilter] are included in the results.
Future<ComparisonNode> analyzeProgram(Uri input, Uri packagesFileUri,
Uri platformUri, bool uriFilter(Uri uri)) async {
var errorOccurred = false;
var errors = <CompilationMessage>[];
var component = await kernelForProgram(
input,
_makeCompilerOptions(packagesFileUri, platformUri, (_) {
errorOccurred = true;
}));
if (errorOccurred) {
return ComparisonNode('Error occurred');
input, _makeCompilerOptions(packagesFileUri, platformUri, errors.add));
if (errors.isNotEmpty) {
return ComparisonNode(
'Error occurred', errors.map(_compilationMessageToNode).toList());
}
var libraryNodes = <ComparisonNode>[];
var visitor = _KernelVisitor(libraryNodes);
Expand All @@ -59,6 +56,10 @@ Future<ComparisonNode> analyzeProgram(Uri input, Uri packagesFileUri,
return ComparisonNode.sorted('Component', libraryNodes);
}

ComparisonNode _compilationMessageToNode(CompilationMessage message) {
return ComparisonNode(message.toString());
}

CompilerOptions _makeCompilerOptions(
Uri packagesFileUri, Uri platformUri, ErrorHandler onError) {
var targetFlags = TargetFlags(strongMode: true, syncAsync: true);
Expand Down

0 comments on commit e31f9fc

Please sign in to comment.