Use featureSet parameter to configure the parser. (#816)
* Use featureSet parameter to configure the parser.
This helps prepare for the next major version of the analyzer package.
* Bump version to 1.2.8-dev
diff --git a/lib/src/dart_formatter.dart b/lib/src/dart_formatter.dart
index 4824302..2cf93c4 100644
--- a/lib/src/dart_formatter.dart
+++ b/lib/src/dart_formatter.dart
@@ -6,6 +6,7 @@
import 'dart:math' as math;
+import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/error/error.dart';
@@ -88,6 +89,12 @@
SourceCode formatSource(SourceCode source) {
var errorListener = ErrorListener();
+ // Enable all features that are enabled by default in the current analyzer
+ // version.
+ // TODO(paulberry): consider plumbing in experiment enable flags from the
+ // command line.
+ var featureSet = FeatureSet.fromEnableFlags([]);
+
// Tokenize the source.
var reader = CharSequenceReader(source.text);
var stringSource = StringSource(source.text, source.uri);
@@ -111,11 +118,9 @@
errorListener.throwIfErrors();
// Parse it.
- var parser = Parser(stringSource, errorListener);
+ var parser = Parser(stringSource, errorListener, featureSet: featureSet);
parser.enableOptionalNewAndConst = true;
parser.enableSetLiterals = true;
- parser.enableSpreadCollections = true;
- parser.enableControlFlowCollections = true;
AstNode node;
if (source.isCompilationUnit) {
diff --git a/pubspec.yaml b/pubspec.yaml
index fec1a76..b1d58e5 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: dart_style
# Note: See tool/grind.dart for how to bump the version.
-version: 1.2.7
+version: 1.2.8-dev
author: Dart Team <misc@dartlang.org>
description: >-
Opinionated, automatic Dart source code formatter.
@@ -11,7 +11,7 @@
sdk: '>=2.1.0 <3.0.0'
dependencies:
- analyzer: '>=0.36.0 <0.37.0'
+ analyzer: '>=0.36.3 <0.37.0'
args: '>=0.12.1 <2.0.0'
path: ^1.0.0
source_span: ^1.4.0