be4df1a869
This aligns names with ResourceProvider.getFile/Folder. Change-Id: I30383ef1fa6f7cbe60b187338e25b8ca75806730 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/511120 Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jonas Jensen <jonasfj@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
70 lines
2.0 KiB
Dart
70 lines
2.0 KiB
Dart
// Copyright (c) 2014, 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/protocol/protocol.dart';
|
|
import 'package:analysis_server/protocol/protocol_constants.dart';
|
|
import 'package:analysis_server/protocol/protocol_generated.dart';
|
|
import 'package:analyzer/file_system/file_system.dart';
|
|
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
|
import 'package:test/test.dart';
|
|
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|
|
|
import '../analysis_server_base.dart';
|
|
|
|
void main() {
|
|
defineReflectiveSuite(() {
|
|
defineReflectiveTests(ReanalyzeTest);
|
|
});
|
|
}
|
|
|
|
@reflectiveTest
|
|
class ReanalyzeTest extends PubPackageAnalysisServerTest {
|
|
Map<File, List<AnalysisError>> filesErrors = {};
|
|
|
|
@override
|
|
void processNotification(Notification notification) {
|
|
if (notification.event == analysisNotificationErrors) {
|
|
var decoded = AnalysisErrorsParams.fromNotification(
|
|
notification,
|
|
clientUriConverter: server.uriConverter,
|
|
);
|
|
filesErrors[getFile(decoded.file)] = decoded.errors;
|
|
}
|
|
}
|
|
|
|
Future<void> test_reanalyze() async {
|
|
var b = getFolder(testPackageLibPath).parent.getFile('b.dart');
|
|
|
|
var file = newFile('$testPackageTestPath/a.dart', r'''
|
|
import '../b.dart';
|
|
|
|
var b = B();
|
|
''');
|
|
|
|
await setRoots(included: [testPackageTestPath], excluded: []);
|
|
|
|
// b.dart does not exist, and `B` is unresolved.
|
|
await waitForTasksFinished();
|
|
expect(filesErrors[file], hasLength(2));
|
|
|
|
// Clear errors, so that we'll notice new results.
|
|
filesErrors.clear();
|
|
|
|
// Create b.dart, reanalyzing should fix the error.
|
|
b.writeAsStringSync('class B {}');
|
|
|
|
// Reanalyze.
|
|
await handleSuccessfulRequest(
|
|
AnalysisReanalyzeParams().toRequest(
|
|
'0',
|
|
clientUriConverter: server.uriConverter,
|
|
),
|
|
);
|
|
await waitForTasksFinished();
|
|
|
|
// No errors.
|
|
expect(filesErrors[file], isEmpty);
|
|
}
|
|
}
|