Files
sdk/pkg/analysis_server/test/stress/completion/completion.dart
T
Konstantin Shcheglov 1f52372bfa Remove CFE integration from analyzer, analysis_server, and analyzer_cli.
AnalysisDriverResolutionTest is partially updated, about 30 failing
tests added. I will get back to it in a following CL, it is not
directly CFE integration, but updated understanding how we want to
resolve. For example we don't need types for non-expression identifiers.

Change-Id: I3daddbb6c66ffad7a726f3313a1199fd7387aa04
Reviewed-on: https://dart-review.googlesource.com/71883
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-08-29 13:46:45 +00:00

101 lines
2.5 KiB
Dart

// Copyright (c) 2018, 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:args/args.dart';
import 'completion_runner.dart';
/**
* The main entry point for the code completion stress test.
*/
void main(List<String> args) async {
ArgParser parser = createArgParser();
ArgResults result = parser.parse(args);
if (validArguments(parser, result)) {
String analysisRoot = result.rest[0];
CompletionRunner runner = new CompletionRunner(
output: stdout,
printMissing: result['missing'],
printQuality: result['quality'],
timing: result['timing'],
verbose: result['verbose']);
await runner.runAll(analysisRoot);
await stdout.flush();
}
}
/**
* Create a parser that can be used to parse the command-line arguments.
*/
ArgParser createArgParser() {
ArgParser parser = new ArgParser();
parser.addFlag(
'help',
abbr: 'h',
help: 'Print this help message',
negatable: false,
);
parser.addFlag(
'missing',
help: 'Report locations where the current identifier was not suggested',
negatable: false,
);
parser.addFlag(
'quality',
help: 'Report on the quality of the sort order',
negatable: false,
);
parser.addFlag(
'timing',
help: 'Report timing information',
negatable: false,
);
parser.addFlag(
'verbose',
abbr: 'v',
help: 'Produce verbose output',
negatable: false,
);
return parser;
}
/**
* Print usage information for this tool.
*/
void printUsage(ArgParser parser, {String error}) {
if (error != null) {
print(error);
print('');
}
print('usage: dart completion path');
print('');
print('Test the completion engine by requesting completion at the offset of');
print('each identifier in the files contained in the given path. The path');
print('can be either a single Dart file or a directory.');
print('');
print(parser.usage);
}
/**
* Return `true` if the command-line arguments (represented by the [result] and
* parsed by the [parser]) are valid.
*/
bool validArguments(ArgParser parser, ArgResults result) {
if (result.wasParsed('help')) {
printUsage(parser);
return false;
} else if (result.rest.length < 1) {
printUsage(parser, error: 'Missing path to files');
return false;
} else if (result.rest.length > 1) {
printUsage(parser, error: 'Only one file can be analyzed');
return false;
}
return true;
}