Unverified Commit e816f64b authored by Devon Carew's avatar Devon Carew Committed by GitHub

remove the option to pass in the --no-preview-dart-2 flag to analysis (#20041)

remove the option to pass in the --no-preview-dart-2 flag to analysis
parent 7ba2a84a
...@@ -26,8 +26,6 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -26,8 +26,6 @@ class AnalyzeCommand extends FlutterCommand {
argParser.addFlag('watch', argParser.addFlag('watch',
help: 'Run analysis continuously, watching the filesystem for changes.', help: 'Run analysis continuously, watching the filesystem for changes.',
negatable: false); negatable: false);
argParser.addFlag('preview-dart-2',
defaultsTo: true, help: 'Preview Dart 2.0 functionality.');
argParser.addOption('write', argParser.addOption('write',
valueHelp: 'file', valueHelp: 'file',
help: 'Also output the results to a file. This is useful with --watch ' help: 'Also output the results to a file. This is useful with --watch '
...@@ -87,7 +85,6 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -87,7 +85,6 @@ class AnalyzeCommand extends FlutterCommand {
argResults, argResults,
runner.getRepoRoots(), runner.getRepoRoots(),
runner.getRepoPackages(), runner.getRepoPackages(),
previewDart2: argResults['preview-dart-2'],
).analyze(); ).analyze();
} else { } else {
return new AnalyzeOnce( return new AnalyzeOnce(
...@@ -95,7 +92,6 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -95,7 +92,6 @@ class AnalyzeCommand extends FlutterCommand {
runner.getRepoRoots(), runner.getRepoRoots(),
runner.getRepoPackages(), runner.getRepoPackages(),
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
previewDart2: argResults['preview-dart-2'],
).analyze(); ).analyze();
} }
} }
......
...@@ -19,13 +19,10 @@ import '../globals.dart'; ...@@ -19,13 +19,10 @@ import '../globals.dart';
import 'analyze_base.dart'; import 'analyze_base.dart';
class AnalyzeContinuously extends AnalyzeBase { class AnalyzeContinuously extends AnalyzeBase {
AnalyzeContinuously(ArgResults argResults, this.repoRoots, this.repoPackages, { AnalyzeContinuously(ArgResults argResults, this.repoRoots, this.repoPackages) : super(argResults);
this.previewDart2 = false,
}) : super(argResults);
final List<String> repoRoots; final List<String> repoRoots;
final List<Directory> repoPackages; final List<Directory> repoPackages;
final bool previewDart2;
String analysisTarget; String analysisTarget;
bool firstAnalysis = true; bool firstAnalysis = true;
...@@ -60,7 +57,7 @@ class AnalyzeContinuously extends AnalyzeBase { ...@@ -60,7 +57,7 @@ class AnalyzeContinuously extends AnalyzeBase {
final String sdkPath = argResults['dart-sdk'] ?? sdk.dartSdkPath; final String sdkPath = argResults['dart-sdk'] ?? sdk.dartSdkPath;
final AnalysisServer server = new AnalysisServer(sdkPath, directories, previewDart2: previewDart2); final AnalysisServer server = new AnalysisServer(sdkPath, directories);
server.onAnalyzing.listen((bool isAnalyzing) => _handleAnalysisStatus(server, isAnalyzing)); server.onAnalyzing.listen((bool isAnalyzing) => _handleAnalysisStatus(server, isAnalyzing));
server.onErrors.listen(_handleAnalysisErrors); server.onErrors.listen(_handleAnalysisErrors);
......
...@@ -24,7 +24,6 @@ class AnalyzeOnce extends AnalyzeBase { ...@@ -24,7 +24,6 @@ class AnalyzeOnce extends AnalyzeBase {
this.repoRoots, this.repoRoots,
this.repoPackages, { this.repoPackages, {
this.workingDirectory, this.workingDirectory,
this.previewDart2 = false,
}) : super(argResults); }) : super(argResults);
final List<String> repoRoots; final List<String> repoRoots;
...@@ -33,8 +32,6 @@ class AnalyzeOnce extends AnalyzeBase { ...@@ -33,8 +32,6 @@ class AnalyzeOnce extends AnalyzeBase {
/// The working directory for testing analysis using dartanalyzer. /// The working directory for testing analysis using dartanalyzer.
final Directory workingDirectory; final Directory workingDirectory;
final bool previewDart2;
@override @override
Future<Null> analyze() async { Future<Null> analyze() async {
final String currentDirectory = final String currentDirectory =
...@@ -88,11 +85,7 @@ class AnalyzeOnce extends AnalyzeBase { ...@@ -88,11 +85,7 @@ class AnalyzeOnce extends AnalyzeBase {
final String sdkPath = argResults['dart-sdk'] ?? sdk.dartSdkPath; final String sdkPath = argResults['dart-sdk'] ?? sdk.dartSdkPath;
final AnalysisServer server = new AnalysisServer( final AnalysisServer server = new AnalysisServer(sdkPath, directories.toList());
sdkPath,
directories.toList(),
previewDart2: previewDart2,
);
StreamSubscription<bool> subscription; StreamSubscription<bool> subscription;
subscription = server.onAnalyzing.listen((bool isAnalyzing) { subscription = server.onAnalyzing.listen((bool isAnalyzing) {
......
...@@ -14,11 +14,10 @@ import '../base/utils.dart'; ...@@ -14,11 +14,10 @@ import '../base/utils.dart';
import '../globals.dart'; import '../globals.dart';
class AnalysisServer { class AnalysisServer {
AnalysisServer(this.sdkPath, this.directories, {this.previewDart2 = false}); AnalysisServer(this.sdkPath, this.directories);
final String sdkPath; final String sdkPath;
final List<String> directories; final List<String> directories;
final bool previewDart2;
Process _process; Process _process;
final StreamController<bool> _analyzingController = final StreamController<bool> _analyzingController =
...@@ -38,12 +37,6 @@ class AnalysisServer { ...@@ -38,12 +37,6 @@ class AnalysisServer {
sdkPath, sdkPath,
]; ];
if (previewDart2) {
command.add('--preview-dart-2');
} else {
command.add('--no-preview-dart-2');
}
printTrace('dart ${command.skip(1).join(' ')}'); printTrace('dart ${command.skip(1).join(' ')}');
_process = await processManager.start(command); _process = await processManager.start(command);
// This callback hookup can't throw. // This callback hookup can't throw.
......
...@@ -70,43 +70,21 @@ void main() { ...@@ -70,43 +70,21 @@ void main() {
OperatingSystemUtils: () => os OperatingSystemUtils: () => os
}); });
testUsingContext('--preview-dart-2', () async { testUsingContext('analyze', () async {
const String contents = "StringBuffer bar = StringBuffer('baz');"; const String contents = "StringBuffer bar = StringBuffer('baz');";
tempDir.childFile('main.dart').writeAsStringSync(contents); tempDir.childFile('main.dart').writeAsStringSync(contents);
server = new AnalysisServer(dartSdkPath, <String>[tempDir.path], previewDart2: true); server = new AnalysisServer(dartSdkPath, <String>[tempDir.path]);
int errorCount = 0; int errorCount = 0;
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first; final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first;
server.onErrors.listen((FileAnalysisErrors errors) { server.onErrors.listen((FileAnalysisErrors errors) {
errorCount += errors.errors.length; errorCount += errors.errors.length;
}); });
await server.start(); await server.start();
await onDone; await onDone;
expect(errorCount, 0); expect(errorCount, 0);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
OperatingSystemUtils: () => os OperatingSystemUtils: () => os
}); });
testUsingContext('no --preview-dart-2 shows errors', () async {
const String contents = "StringBuffer bar = StringBuffer('baz');";
tempDir.childFile('main.dart').writeAsStringSync(contents);
server = new AnalysisServer(dartSdkPath, <String>[tempDir.path], previewDart2: false);
int errorCount = 0;
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first;
server.onErrors.listen((FileAnalysisErrors errors) {
errorCount += errors.errors.length;
});
await server.start();
await onDone;
expect(errorCount, 1);
}, overrides: <Type, Generator>{
OperatingSystemUtils: () => os
});
} }
void _createSampleProject(Directory directory, { bool brokenCode = false }) { void _createSampleProject(Directory directory, { bool brokenCode = false }) {
......
...@@ -168,44 +168,22 @@ void bar() { ...@@ -168,44 +168,22 @@ void bar() {
} }
}); });
testUsingContext('--preview-dart-2', () async { testUsingContext('analyze', () async {
const String contents = ''' const String contents = '''
StringBuffer bar = StringBuffer('baz'); StringBuffer bar = StringBuffer('baz');
'''; ''';
final Directory tempDir = fs.systemTempDirectory.createTempSync(); final Directory tempDir = fs.systemTempDirectory.createTempSync();
tempDir.childFile('main.dart').writeAsStringSync(contents); tempDir.childFile('main.dart').writeAsStringSync(contents);
try { try {
await runCommand( await runCommand(
command: new AnalyzeCommand(workingDirectory: fs.directory(tempDir)), command: new AnalyzeCommand(workingDirectory: fs.directory(tempDir)),
arguments: <String>['analyze', '--preview-dart-2'], arguments: <String>['analyze'],
statusTextContains: <String>['No issues found!'], statusTextContains: <String>['No issues found!'],
); );
} finally { } finally {
tempDir.deleteSync(recursive: true); tempDir.deleteSync(recursive: true);
} }
}); });
testUsingContext('no --preview-dart-2 shows errors', () async {
const String contents = '''
StringBuffer bar = StringBuffer('baz');
''';
final Directory tempDir = fs.systemTempDirectory.createTempSync();
tempDir.childFile('main.dart').writeAsStringSync(contents);
try {
await runCommand(
command: new AnalyzeCommand(workingDirectory: fs.directory(tempDir)),
arguments: <String>['analyze', '--no-preview-dart-2'],
statusTextContains: <String>['1 issue found.'],
toolExit: true,
);
} finally {
tempDir.deleteSync(recursive: true);
}
});
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment