blob: 0941eff9cf0ab8b1fb1892b1322f56e8b0467c0b [file] [log] [blame]
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/flutter/flutter_outline_computer.dart';
import 'package:analysis_server/src/protocol_server.dart' as protocol;
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/src/generated/engine.dart';
void sendFlutterNotificationOutline(
AnalysisServer server, ResolvedUnitResult resolvedUnit) {
_sendNotification(server, () {
var computer = new FlutterOutlineComputer(resolvedUnit);
protocol.FlutterOutline outline = computer.compute();
// send notification
var params = new protocol.FlutterOutlineParams(
resolvedUnit.path,
outline,
);
server.sendNotification(params.toNotification());
});
}
/**
* Runs the given notification producing function [f], catching exceptions.
*/
void _sendNotification(AnalysisServer server, f()) {
ServerPerformanceStatistics.notices.makeCurrentWhile(() {
try {
f();
} catch (exception, stackTrace) {
AnalysisEngine.instance.instrumentationService.logException(
CaughtException.withMessage(
'Failed to send notification', exception, stackTrace));
}
});
}