Version 2.12.0-189.0.dev
Merge commit '11b3e34e327101971cee78ae1b0d99adaa62e90e' into 'dev'
diff --git a/pkg/analyzer/example/analyze.dart b/pkg/analyzer/example/analyze.dart
new file mode 100644
index 0000000..d9d5cb3
--- /dev/null
+++ b/pkg/analyzer/example/analyze.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2020, 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 'dart:io';
+
+import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
+import 'package:analyzer/error/error.dart';
+import 'package:analyzer/file_system/physical_file_system.dart';
+
+/// A simple example of using the AnalysisContextCollection API.
+void main(List<String> args) async {
+ var entity = Directory.current;
+ if (args.isNotEmpty) {
+ String arg = args.first;
+ entity = FileSystemEntity.isDirectorySync(arg) ? Directory(arg) : File(arg);
+ }
+
+ var issueCount = 0;
+ final collection = AnalysisContextCollection(
+ includedPaths: [entity.absolute.path],
+ resourceProvider: PhysicalResourceProvider.INSTANCE);
+
+ // Often one context is returned, but depending on the project structure we
+ // can see multiple contexts.
+ for (final context in collection.contexts) {
+ print('Analyzing ${context.contextRoot.root.path} ...');
+
+ for (final filePath in context.contextRoot.analyzedFiles()) {
+ if (!filePath.endsWith('.dart')) {
+ continue;
+ }
+
+ final errorsResult = await context.currentSession.getErrors(filePath);
+ for (final error in errorsResult.errors) {
+ if (error.errorCode.type != ErrorType.TODO) {
+ print(
+ ' \u001b[1m${error.source.shortName}\u001b[0m ${error.message}');
+ issueCount++;
+ }
+ }
+ }
+ }
+
+ print('$issueCount issues found.');
+}
diff --git a/tools/VERSION b/tools/VERSION
index 6245043..3710e8c 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 12
PATCH 0
-PRERELEASE 188
+PRERELEASE 189
PRERELEASE_PATCH 0
\ No newline at end of file