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 {
argParser.addFlag('watch',
help: 'Run analysis continuously, watching the filesystem for changes.',
negatable: false);
argParser.addFlag('preview-dart-2',
defaultsTo: true, help: 'Preview Dart 2.0 functionality.');
argParser.addOption('write',
valueHelp: 'file',
help: 'Also output the results to a file. This is useful with --watch '
......@@ -87,7 +85,6 @@ class AnalyzeCommand extends FlutterCommand {
argResults,
runner.getRepoRoots(),
runner.getRepoPackages(),
previewDart2: argResults['preview-dart-2'],
).analyze();
} else {
return new AnalyzeOnce(
......@@ -95,7 +92,6 @@ class AnalyzeCommand extends FlutterCommand {
runner.getRepoRoots(),
runner.getRepoPackages(),
workingDirectory: workingDirectory,
previewDart2: argResults['preview-dart-2'],
).analyze();
}
}
......
......@@ -19,13 +19,10 @@ import '../globals.dart';
import 'analyze_base.dart';
class AnalyzeContinuously extends AnalyzeBase {
AnalyzeContinuously(ArgResults argResults, this.repoRoots, this.repoPackages, {
this.previewDart2 = false,
}) : super(argResults);
AnalyzeContinuously(ArgResults argResults, this.repoRoots, this.repoPackages) : super(argResults);
final List<String> repoRoots;
final List<Directory> repoPackages;
final bool previewDart2;
String analysisTarget;
bool firstAnalysis = true;
......@@ -60,7 +57,7 @@ class AnalyzeContinuously extends AnalyzeBase {
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.onErrors.listen(_handleAnalysisErrors);
......
......@@ -24,7 +24,6 @@ class AnalyzeOnce extends AnalyzeBase {
this.repoRoots,
this.repoPackages, {
this.workingDirectory,
this.previewDart2 = false,
}) : super(argResults);
final List<String> repoRoots;
......@@ -33,8 +32,6 @@ class AnalyzeOnce extends AnalyzeBase {
/// The working directory for testing analysis using dartanalyzer.
final Directory workingDirectory;
final bool previewDart2;
@override
Future<Null> analyze() async {
final String currentDirectory =
......@@ -88,11 +85,7 @@ class AnalyzeOnce extends AnalyzeBase {
final String sdkPath = argResults['dart-sdk'] ?? sdk.dartSdkPath;
final AnalysisServer server = new AnalysisServer(
sdkPath,
directories.toList(),
previewDart2: previewDart2,
);
final AnalysisServer server = new AnalysisServer(sdkPath, directories.toList());
StreamSubscription<bool> subscription;
subscription = server.onAnalyzing.listen((bool isAnalyzing) {
......
......@@ -14,11 +14,10 @@ import '../base/utils.dart';
import '../globals.dart';
class AnalysisServer {
AnalysisServer(this.sdkPath, this.directories, {this.previewDart2 = false});
AnalysisServer(this.sdkPath, this.directories);
final String sdkPath;
final List<String> directories;
final bool previewDart2;
Process _process;
final StreamController<bool> _analyzingController =
......@@ -38,12 +37,6 @@ class AnalysisServer {
sdkPath,
];
if (previewDart2) {
command.add('--preview-dart-2');
} else {
command.add('--no-preview-dart-2');
}
printTrace('dart ${command.skip(1).join(' ')}');
_process = await processManager.start(command);
// This callback hookup can't throw.
......
......@@ -70,43 +70,21 @@ void main() {
OperatingSystemUtils: () => os
});
testUsingContext('--preview-dart-2', () async {
testUsingContext('analyze', () async {
const String contents = "StringBuffer bar = StringBuffer('baz');";
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;
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, 0);
}, overrides: <Type, Generator>{
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 }) {
......
......@@ -168,44 +168,22 @@ void bar() {
}
});
testUsingContext('--preview-dart-2', () async {
testUsingContext('analyze', () 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', '--preview-dart-2'],
arguments: <String>['analyze'],
statusTextContains: <String>['No issues found!'],
);
} finally {
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