Files
sdk/pkg/analysis_server/test/lsp/analyzer_status_test.dart
T
Danny Tuppeny cdcc387084 Add LSP custom notifications for analyzing status
Change-Id: I0d26d274c9ccc472da81e45d0c9170104bbd9414
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102370
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
2019-05-15 06:35:48 +00:00

60 lines
1.9 KiB
Dart

// Copyright (c) 2019, 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:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'server_abstract.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(AnalyzerStatusTest);
});
}
@reflectiveTest
class AnalyzerStatusTest extends AbstractLspAnalysisServerTest {
test_afterInitialize() async {
const initialContents = 'int a = 1;';
newFile(mainFilePath, content: initialContents);
// To avoid races, set up listeners for the notifications before we initialise
// and track which event came first to ensure they arrived in the expected
// order.
bool firstNotificationWasAnalyzing = null;
final startNotification = waitForAnalysisStart()
.then((_) => firstNotificationWasAnalyzing ??= true);
final completeNotification = waitForAnalysisComplete()
.then((_) => firstNotificationWasAnalyzing ??= false);
await initialize();
await startNotification;
await completeNotification;
expect(firstNotificationWasAnalyzing, isTrue);
}
test_afterDocumentEdits() async {
const initialContents = 'int a = 1;';
newFile(mainFilePath, content: initialContents);
final initialAnalysis = waitForAnalysisComplete();
await initialize();
await initialAnalysis;
// Set up futures to wait for the new events.
final startNotification = waitForAnalysisStart();
final completeNotification = waitForAnalysisComplete();
// Send a modification
await openFile(mainFileUri, initialContents);
await replaceFile(222, mainFileUri, 'String a = 1;');
// Ensure the notifications come through again.
await startNotification;
await completeNotification;
}
}