Lint fixes (#2004)
Fix lints associated with pedantic v1.8
Enable and fix prefer_generic_function_type_aliases lint
fix associated builder
diff --git a/analysis_options.yaml b/analysis_options.yaml
index e29f308..5bbf4f3 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,4 +1,4 @@
-include: package:pedantic/analysis_options.1.7.0.yaml
+include: package:pedantic/analysis_options.1.8.0.yaml
analyzer:
exclude:
@@ -17,7 +17,8 @@
- directives_ordering
- no_adjacent_strings_in_list
- package_api_docs
- - slash_for_doc_comments
- prefer_final_fields
+ - prefer_generic_function_type_aliases
+ - slash_for_doc_comments
- unawaited_futures
# - unnecessary_brace_in_string_interps
diff --git a/bin/dartdoc.dart b/bin/dartdoc.dart
index 930eba0..9665cd1 100644
--- a/bin/dartdoc.dart
+++ b/bin/dartdoc.dart
@@ -27,16 +27,16 @@
Future<List<DartdocOption>> createDartdocProgramOptions() async {
return <DartdocOption>[
- new DartdocOptionArgOnly<bool>('asyncStackTraces', false,
+ DartdocOptionArgOnly<bool>('asyncStackTraces', false,
help: 'Display coordinated asynchronous stack traces (slow)',
negatable: true),
- new DartdocOptionArgOnly<bool>('generateDocs', true,
+ DartdocOptionArgOnly<bool>('generateDocs', true,
help:
'Generate docs into the output directory (or only display warnings if false).',
negatable: true),
- new DartdocOptionArgOnly<bool>('help', false,
+ DartdocOptionArgOnly<bool>('help', false,
abbr: 'h', help: 'Show command help.', negatable: false),
- new DartdocOptionArgOnly<bool>('version', false,
+ DartdocOptionArgOnly<bool>('version', false,
help: 'Display the version for $name.', negatable: false),
];
}
@@ -76,7 +76,7 @@
DartdocProgramOptionContext config;
try {
- config = new DartdocProgramOptionContext(optionSet, null);
+ config = DartdocProgramOptionContext(optionSet, null);
} on DartdocOptionError catch (e) {
stderr.writeln(' fatal error: ${e.message}');
stderr.writeln('');
@@ -94,7 +94,7 @@
try {
await Chain.capture(() async {
await runZoned(dartdoc.generateDocs,
- zoneSpecification: new ZoneSpecification(
+ zoneSpecification: ZoneSpecification(
print: (Zone self, ZoneDelegate parent, Zone zone, String line) =>
logPrint(line)));
}, onError: (e, Chain chain) {
diff --git a/lib/dartdoc.dart b/lib/dartdoc.dart
index 8b49977..7247245 100644
--- a/lib/dartdoc.dart
+++ b/lib/dartdoc.dart
@@ -48,15 +48,15 @@
/// directory.
class Dartdoc extends PackageBuilder {
final List<Generator> generators;
- final Set<String> writtenFiles = new Set();
+ final Set<String> writtenFiles = Set();
Directory outputDir;
// Fires when the self checks make progress.
final StreamController<String> _onCheckProgress =
- new StreamController(sync: true);
+ StreamController(sync: true);
Dartdoc._(DartdocOptionContext config, this.generators) : super(config) {
- outputDir = new Directory(config.output)..createSync(recursive: true);
+ outputDir = Directory(config.output)..createSync(recursive: true);
generators.forEach((g) => g.onFileCreated.listen(logProgress));
}
@@ -65,19 +65,19 @@
static Future<Dartdoc> withDefaultGenerators(
DartdocGeneratorOptionContext config) async {
List<Generator> generators = await initGenerators(config);
- return new Dartdoc._(config, generators);
+ return Dartdoc._(config, generators);
}
/// An asynchronous factory method that builds
static Future<Dartdoc> withEmptyGenerator(DartdocOptionContext config) async {
List<Generator> generators = await initEmptyGenerators(config);
- return new Dartdoc._(config, generators);
+ return Dartdoc._(config, generators);
}
/// Basic synchronous factory that gives a stripped down Dartdoc that won't
/// use generators. Useful for testing.
factory Dartdoc.withoutGenerators(DartdocOptionContext config) {
- return new Dartdoc._(config, []);
+ return Dartdoc._(config, []);
}
Stream<String> get onCheckProgress => _onCheckProgress.stream;
@@ -90,7 +90,7 @@
/// thrown if dartdoc fails in an expected way, for example if there is an
/// analysis error in the code.
Future<DartdocResults> generateDocsBase() async {
- Stopwatch _stopwatch = new Stopwatch()..start();
+ Stopwatch _stopwatch = Stopwatch()..start();
double seconds;
packageGraph = await buildPackageGraph();
seconds = _stopwatch.elapsedMilliseconds / 1000.0;
@@ -125,8 +125,7 @@
logInfo(
"Documented ${packageGraph.localPublicLibraries.length} public librar${packageGraph.localPublicLibraries.length == 1 ? 'y' : 'ies'} "
"in ${seconds.toStringAsFixed(1)} seconds");
- return new DartdocResults(
- config.topLevelPackageMeta, packageGraph, outputDir);
+ return DartdocResults(config.topLevelPackageMeta, packageGraph, outputDir);
}
Future<DartdocResults> generateDocs() async {
@@ -134,14 +133,13 @@
DartdocResults dartdocResults = await generateDocsBase();
if (dartdocResults.packageGraph.localPublicLibraries.isEmpty) {
- throw new DartdocFailure(
- "dartdoc could not find any libraries to document");
+ throw DartdocFailure("dartdoc could not find any libraries to document");
}
final int errorCount =
dartdocResults.packageGraph.packageWarningCounter.errorCount;
if (errorCount > 0) {
- throw new DartdocFailure(
+ throw DartdocFailure(
"dartdoc encountered $errorCount} errors while processing.");
}
logInfo(
@@ -156,7 +154,7 @@
// Ordinarily this would go in [Package.warn], but we don't actually know what
// ModelElement to warn on yet.
Warnable warnOnElement;
- Set<Warnable> referredFromElements = new Set();
+ Set<Warnable> referredFromElements = Set();
Set<Warnable> warnOnElements;
// Make all paths relative to origin.
@@ -202,7 +200,7 @@
String indexJson = path.joinAll([normalOrigin, 'index.json']);
bool foundIndexJson = false;
for (FileSystemEntity f
- in new Directory(normalOrigin).listSync(recursive: true)) {
+ in Directory(normalOrigin).listSync(recursive: true)) {
var fullPath = path.normalize(f.path);
if (f is Directory) {
continue;
@@ -240,7 +238,7 @@
// This is extracted to save memory during the check; be careful not to hang
// on to anything referencing the full file and doc tree.
Tuple2<Iterable<String>, String> _getStringLinksAndHref(String fullPath) {
- File file = new File("$fullPath");
+ File file = File("$fullPath");
if (!file.existsSync()) {
return null;
}
@@ -256,21 +254,21 @@
.where((href) => href != null)
.toList();
- return new Tuple2(stringLinks, baseHref);
+ return Tuple2(stringLinks, baseHref);
}
void _doSearchIndexCheck(
PackageGraph packageGraph, String origin, Set<String> visited) {
String fullPath = path.joinAll([origin, 'index.json']);
String indexPath = path.joinAll([origin, 'index.html']);
- File file = new File("$fullPath");
+ File file = File("$fullPath");
if (!file.existsSync()) {
return null;
}
- JsonDecoder decoder = new JsonDecoder();
+ JsonDecoder decoder = JsonDecoder();
List jsonData = decoder.convert(file.readAsStringSync());
- Set<String> found = new Set();
+ Set<String> found = Set();
found.add(fullPath);
// The package index isn't supposed to be in the search, so suppress the
// warning.
@@ -322,9 +320,9 @@
// here instead -- occasionally, very large jobs have overflowed
// the stack without this.
// (newPathToCheck, newFullPath)
- Set<Tuple2<String, String>> toVisit = new Set();
+ Set<Tuple2<String, String>> toVisit = Set();
- final RegExp ignoreHyperlinks = new RegExp(r'^(https:|http:|mailto:|ftp:)');
+ final RegExp ignoreHyperlinks = RegExp(r'^(https:|http:|mailto:|ftp:)');
for (String href in stringLinks) {
if (!href.startsWith(ignoreHyperlinks)) {
Uri uri;
@@ -345,7 +343,7 @@
String newFullPath = path.joinAll([origin, newPathToCheck]);
newFullPath = path.normalize(newFullPath);
if (!visited.contains(newFullPath)) {
- toVisit.add(new Tuple2(newPathToCheck, newFullPath));
+ toVisit.add(Tuple2(newPathToCheck, newFullPath));
visited.add(newFullPath);
}
}
@@ -366,7 +364,7 @@
assert(_hrefs == null);
_hrefs = packageGraph.allHrefs;
- final Set<String> visited = new Set();
+ final Set<String> visited = Set();
final String start = 'index.html';
logInfo('Validating docs...');
_doCheck(packageGraph, origin, visited, start);
diff --git a/lib/src/dartdoc_options.dart b/lib/src/dartdoc_options.dart
index 860fa1d..cf05f89 100644
--- a/lib/src/dartdoc_options.dart
+++ b/lib/src/dartdoc_options.dart
@@ -32,8 +32,8 @@
/// Constants to help with type checking, because T is int and so forth
/// don't work in Dart.
const String _kStringVal = '';
-const List<String> _kListStringVal = const <String>[];
-const Map<String, String> _kMapStringVal = const <String, String>{};
+const List<String> _kListStringVal = <String>[];
+const Map<String, String> _kMapStringVal = <String, String>{};
const int _kIntVal = 0;
const double _kDoubleVal = 0.0;
const bool _kBoolVal = true;
@@ -80,7 +80,7 @@
CategoryConfiguration._(this.categoryDefinitions);
static CategoryConfiguration get empty {
- return new CategoryConfiguration._({});
+ return CategoryConfiguration._({});
}
static CategoryConfiguration fromYamlMap(
@@ -97,16 +97,16 @@
if (documentationMarkdown != null) {
documentationMarkdown =
pathContext.canonicalize(documentationMarkdown);
- if (!new File(documentationMarkdown).existsSync()) {
- throw new DartdocFileMissing(
+ if (!File(documentationMarkdown).existsSync()) {
+ throw DartdocFileMissing(
'In categories definition for ${name}, "markdown" resolves to the missing file $documentationMarkdown');
}
}
newCategoryDefinitions[name] =
- new CategoryDefinition(name, displayName, documentationMarkdown);
+ CategoryDefinition(name, displayName, documentationMarkdown);
}
}
- return new CategoryConfiguration._(newCategoryDefinitions);
+ return CategoryConfiguration._(newCategoryDefinitions);
}
}
@@ -243,7 +243,7 @@
if (snapshots.containsKey(toolPath)) {
return snapshots[toolPath];
}
- snapshots[toolPath] = new Snapshot(snapshotCache, toolPath, _serial);
+ snapshots[toolPath] = Snapshot(snapshotCache, toolPath, _serial);
_serial++;
return snapshots[toolPath];
}
@@ -281,7 +281,7 @@
// replace the first argument with the path to the snapshot.
args[0] = snapshotFile.absolute.path;
}
- return new Tuple2(Platform.resolvedExecutable,
+ return Tuple2(Platform.resolvedExecutable,
needsSnapshot ? snapshot.snapshotCompleted : null);
}
@@ -301,7 +301,7 @@
ToolConfiguration._(this.tools);
static ToolConfiguration get empty {
- return new ToolConfiguration._({});
+ return ToolConfiguration._({});
}
// TODO(jcollins-g): consider caching these.
@@ -325,7 +325,7 @@
if (toolMap[commandFrom].value is String) {
command = [toolMap[commandFrom].toString()];
if (command[0].isEmpty) {
- throw new DartdocOptionError(
+ throw DartdocOptionError(
'Tool commands must not be empty. Tool $name command entry '
'"$commandFrom" must contain at least one path.');
}
@@ -334,12 +334,12 @@
.map<String>((node) => node.toString())
.toList();
if (command.isEmpty) {
- throw new DartdocOptionError(
+ throw DartdocOptionError(
'Tool commands must not be empty. Tool $name command entry '
'"$commandFrom" must contain at least one path.');
}
} else {
- throw new DartdocOptionError(
+ throw DartdocOptionError(
'Tool commands must be a path to an executable, or a list of '
'strings that starts with a path to an executable. '
'The tool $name has a $commandFrom entry that is a '
@@ -352,12 +352,12 @@
command = findCommand();
setupCommand = findCommand('setup_');
} else {
- throw new DartdocOptionError(
+ throw DartdocOptionError(
'Tools must be defined as a map of tool names to definitions. Tool '
'$name is not a map.');
}
if (command == null) {
- throw new DartdocOptionError(
+ throw DartdocOptionError(
'At least one of "command" or "${Platform.operatingSystem}" must '
'be defined for the tool $name.');
}
@@ -366,10 +366,10 @@
return (0x1 & ((mode >> 6) | (mode >> 3) | mode)) != 0;
}
- var executableFile = new File(executable);
+ var executableFile = File(executable);
var exeStat = executableFile.statSync();
if (exeStat.type == FileSystemEntityType.notFound) {
- throw new DartdocOptionError('Command executables must exist. '
+ throw DartdocOptionError('Command executables must exist. '
'The file "$executable" does not exist for tool $name.');
}
@@ -377,7 +377,7 @@
// Dart scripts don't need to be executable, because they'll be
// executed with the Dart binary.
if (!isDartCommand && !isExecutable(exeStat.mode)) {
- throw new DartdocOptionError('Non-Dart commands must be '
+ throw DartdocOptionError('Non-Dart commands must be '
'executable. The file "$executable" for tool $name does not have '
'execute permission.');
}
@@ -396,10 +396,10 @@
: [setupExecutable]) +
setupCommand;
}
- newToolDefinitions[name] = new ToolDefinition.fromCommand(
+ newToolDefinitions[name] = ToolDefinition.fromCommand(
[executable] + command, setupCommand, description);
}
- return new ToolConfiguration._(newToolDefinitions);
+ return ToolConfiguration._(newToolDefinitions);
}
}
@@ -436,7 +436,7 @@
_OptionValueWithContext(this.value, String path, {String definingFile}) {
this.definingFile = definingFile;
canonicalDirectoryPath = p.canonicalize(path);
- pathContext = new p.Context(current: canonicalDirectoryPath);
+ pathContext = p.Context(current: canonicalDirectoryPath);
}
/// Assume value is a path, and attempt to resolve it. Throws [UnsupportedError]
@@ -452,11 +452,10 @@
} else if (value is Map<String, String>) {
return (value as Map<String, String>)
.map<String, String>((String key, String value) {
- return new MapEntry(
- key, pathContext.canonicalize(resolveTildePath(value)));
+ return MapEntry(key, pathContext.canonicalize(resolveTildePath(value)));
}) as T;
} else {
- throw new UnsupportedError('Type $T is not supported for resolvedValue');
+ throw UnsupportedError('Type $T is not supported for resolvedValue');
}
}
}
@@ -534,7 +533,7 @@
Map<String, _YamlFileData> get _yamlAtCanonicalPathCache =>
root.__yamlAtCanonicalPathCache;
- final ArgParser __argParser = new ArgParser(usageLineLength: 80);
+ final ArgParser __argParser = ArgParser(usageLineLength: 80);
ArgParser get argParser => root.__argParser;
@@ -570,7 +569,7 @@
"${valueWithContext.value.runtimeType}");
}
for (String path in resolvedPaths) {
- FileSystemEntity f = isDir ? new Directory(path) : new File(path);
+ FileSystemEntity f = isDir ? Directory(path) : File(path);
if (!f.existsSync()) {
_onMissing(valueWithContext, path);
}
@@ -640,13 +639,13 @@
T valueAtCurrent() => valueAt(directoryCurrent);
/// Calls [valueAt] on the directory this element is defined in.
- T valueAtElement(Element element) => valueAt(
- new Directory(p.canonicalize(p.basename(element.source.fullName))));
+ T valueAtElement(Element element) =>
+ valueAt(Directory(p.canonicalize(p.basename(element.source.fullName))));
/// Adds a DartdocOption to the children of this DartdocOption.
void add(DartdocOption option) {
if (_children.containsKey(option.name)) {
- throw new DartdocOptionError(
+ throw DartdocOptionError(
'Tried to add two children with the same name: ${option.name}');
}
_children[option.name] = option;
@@ -796,7 +795,7 @@
T _valueAtFromSynthetic(Directory dir) {
_OptionValueWithContext context =
- new _OptionValueWithContext<T>(_compute(this, dir), dir.path);
+ _OptionValueWithContext<T>(_compute(this, dir), dir.path);
return _handlePathsInContext(context);
}
@@ -809,12 +808,12 @@
_OptionValueWithContext valueWithContext, String missingPath) {
String description =
'Synthetic configuration option ${name} from <internal>';
- throw new DartdocFileMissing(
+ throw DartdocFileMissing(
'$description, computed as ${valueWithContext.value}, resolves to missing path: "${missingPath}"');
}
}
-typedef Future<List<DartdocOption>> OptionGenerator();
+typedef OptionGenerator = Future<List<DartdocOption>> Function();
/// A [DartdocOption] that only contains other [DartdocOption]s and is not an option itself.
class DartdocOptionSet extends DartdocOption<Null> {
@@ -829,7 +828,7 @@
/// [DartdocOption]s that will be added to the new option set.
static Future<DartdocOptionSet> fromOptionGenerators(
String name, Iterable<OptionGenerator> optionGenerators) async {
- DartdocOptionSet optionSet = new DartdocOptionSet(name);
+ DartdocOptionSet optionSet = DartdocOptionSet(name);
for (OptionGenerator generator in optionGenerators) {
optionSet.addAll(await generator());
}
@@ -998,7 +997,7 @@
_OptionValueWithContext valueWithContext, String missingPath) {
String dartdocYaml = p.join(
valueWithContext.canonicalDirectoryPath, valueWithContext.definingFile);
- throw new DartdocFileMissing(
+ throw DartdocFileMissing(
'Field ${fieldName} from ${dartdocYaml}, set to ${valueWithContext.value}, resolves to missing path: "${missingPath}"');
}
@@ -1010,7 +1009,7 @@
return _valueAtFromFiles(dir) ?? defaultsTo;
}
- final Map<String, T> __valueAtFromFiles = new Map();
+ final Map<String, T> __valueAtFromFiles = Map();
// The value of this option from files will not change unless files are
// modified during execution (not allowed in Dartdoc).
@@ -1092,12 +1091,12 @@
};
}
if (_convertYamlToType == null) {
- throw new DartdocOptionError(
+ throw DartdocOptionError(
'Unable to convert yaml to type for option: $fieldName, method not defined');
}
String canonicalDirectoryPath = p.canonicalize(contextPath);
returnData = _convertYamlToType(
- yamlData, new p.Context(current: canonicalDirectoryPath));
+ yamlData, p.Context(current: canonicalDirectoryPath));
} else if (_isDouble) {
if (yamlData is num) {
returnData = yamlData.toDouble();
@@ -1107,30 +1106,28 @@
returnData = yamlData;
}
} else {
- throw new UnsupportedError('Type ${T} is not supported');
+ throw UnsupportedError('Type ${T} is not supported');
}
- return new _OptionValueWithContext(returnData as T, contextPath,
+ return _OptionValueWithContext(returnData as T, contextPath,
definingFile: 'dartdoc_options.yaml');
}
_YamlFileData _yamlAtDirectory(Directory dir) {
List<String> canonicalPaths = [p.canonicalize(dir.path)];
if (!_yamlAtCanonicalPathCache.containsKey(canonicalPaths.first)) {
- _YamlFileData yamlData =
- new _YamlFileData(new Map(), directoryCurrentPath);
+ _YamlFileData yamlData = _YamlFileData(Map(), directoryCurrentPath);
if (dir.existsSync()) {
File dartdocOptionsFile;
while (true) {
- dartdocOptionsFile =
- new File(p.join(dir.path, 'dartdoc_options.yaml'));
+ dartdocOptionsFile = File(p.join(dir.path, 'dartdoc_options.yaml'));
if (dartdocOptionsFile.existsSync() ||
p.equals(dir.parent.path, dir.path)) break;
dir = dir.parent;
canonicalPaths.add(p.canonicalize(dir.path));
}
if (dartdocOptionsFile.existsSync()) {
- yamlData = new _YamlFileData(
+ yamlData = _YamlFileData(
loadYaml(dartdocOptionsFile.readAsStringSync()),
p.canonicalize(dir.path));
}
@@ -1170,7 +1167,7 @@
} else if (_isDouble) {
example = '0.76';
}
- throw new DartdocOptionError(
+ throw DartdocOptionError(
'Invalid argument value: --${argName}, set to "${value}", must be a ${T}. Example: --${argName} ${example}');
}
@@ -1187,7 +1184,7 @@
void _onMissingFromArgs(
_OptionValueWithContext valueWithContext, String missingPath) {
- throw new DartdocFileMissing(
+ throw DartdocFileMissing(
'Argument --${argName}, set to ${valueWithContext.value}, resolves to missing path: "${missingPath}"');
}
@@ -1223,7 +1220,7 @@
} else {
throw UnsupportedError('Type ${T} is not supported');
}
- return new _OptionValueWithContext(retval, directoryCurrentPath);
+ return _OptionValueWithContext(retval, directoryCurrentPath);
}
/// The name of this option as a command line argument.
@@ -1237,7 +1234,7 @@
argName = argName.replaceAll('_', '-');
// Do not consume the lowercase character after the uppercase one, to handle
// two character words.
- final camelCaseRegexp = new RegExp(r'([a-z])([A-Z])(?=([a-z]))');
+ final camelCaseRegexp = RegExp(r'([a-z])([A-Z])(?=([a-z]))');
argName = argName.replaceAllMapped(camelCaseRegexp, (Match m) {
String before = m.group(1);
String after = m.group(2).toLowerCase();
@@ -1280,7 +1277,7 @@
hide: hide,
splitCommas: splitCommas);
} else {
- throw new UnsupportedError('Type ${T} is not supported');
+ throw UnsupportedError('Type ${T} is not supported');
}
}
}
@@ -1316,9 +1313,9 @@
if (entity == null) {
String inputDir = optionSet['inputDir'].valueAt(directoryCurrent) ??
directoryCurrentPath;
- context = new Directory(inputDir);
+ context = Directory(inputDir);
} else {
- context = new Directory(
+ context = Directory(
p.canonicalize(entity is File ? entity.parent.path : entity.path));
}
}
@@ -1327,21 +1324,19 @@
/// location).
factory DartdocOptionContext.fromElement(
DartdocOptionSet optionSet, Element element) {
- return new DartdocOptionContext(
- optionSet, new File(element.source.fullName));
+ return DartdocOptionContext(optionSet, File(element.source.fullName));
}
/// Build a DartdocOptionContext from an existing [DartdocOptionContext] and a new analyzer [Element].
factory DartdocOptionContext.fromContextElement(
DartdocOptionContext optionContext, Element element) {
- return new DartdocOptionContext.fromElement(
- optionContext.optionSet, element);
+ return DartdocOptionContext.fromElement(optionContext.optionSet, element);
}
/// Build a DartdocOptionContext from an existing [DartdocOptionContext].
factory DartdocOptionContext.fromContext(
DartdocOptionContext optionContext, FileSystemEntity entity) {
- return new DartdocOptionContext(optionContext.optionSet, entity);
+ return DartdocOptionContext(optionContext.optionSet, entity);
}
// All values defined in createDartdocOptions should be exposed here.
@@ -1428,27 +1423,26 @@
/// given command line arguments.
Future<List<DartdocOption>> createDartdocOptions() async {
return <DartdocOption>[
- new DartdocOptionArgOnly<bool>('allowTools', false,
+ DartdocOptionArgOnly<bool>('allowTools', false,
help: 'Execute user-defined tools to fill in @tool directives.',
negatable: true),
- new DartdocOptionArgFile<double>(
- 'ambiguousReexportScorerMinConfidence', 0.1,
+ DartdocOptionArgFile<double>('ambiguousReexportScorerMinConfidence', 0.1,
help: 'Minimum scorer confidence to suppress warning on ambiguous '
'reexport.'),
- new DartdocOptionArgOnly<bool>('autoIncludeDependencies', false,
+ DartdocOptionArgOnly<bool>('autoIncludeDependencies', false,
help: 'Include all the used libraries into the docs, even the ones not '
'in the current package or "include-external"',
negatable: true),
- new DartdocOptionArgFile<List<String>>('categoryOrder', [],
+ DartdocOptionArgFile<List<String>>('categoryOrder', [],
help:
"A list of categories (not package names) to place first when grouping symbols on dartdoc's sidebar. "
'Unmentioned categories are sorted after these.'),
- new DartdocOptionFileOnly<CategoryConfiguration>(
+ DartdocOptionFileOnly<CategoryConfiguration>(
'categories', CategoryConfiguration.empty,
convertYamlToType: CategoryConfiguration.fromYamlMap,
help: 'A list of all categories, their display names, and markdown '
'documentation in the order they are to be displayed.'),
- new DartdocOptionSyntheticOnly<List<String>>('dropTextFrom',
+ DartdocOptionSyntheticOnly<List<String>>('dropTextFrom',
(DartdocSyntheticOption<List<String>> option, Directory dir) {
if (option.parent['hideSdkText'].valueAt(dir)) {
return [
@@ -1472,45 +1466,45 @@
}
return [];
}, help: 'Remove text from libraries with the following names.'),
- new DartdocOptionArgFile<String>('examplePathPrefix', null,
+ DartdocOptionArgFile<String>('examplePathPrefix', null,
isDir: true,
help: 'Prefix for @example paths.\n(defaults to the project root)',
mustExist: true),
- new DartdocOptionArgFile<List<String>>('exclude', [],
+ DartdocOptionArgFile<List<String>>('exclude', [],
help: 'Library names to ignore.', splitCommas: true),
- new DartdocOptionArgOnly<List<String>>('excludePackages', [],
+ DartdocOptionArgOnly<List<String>>('excludePackages', [],
help: 'Package names to ignore.', splitCommas: true),
// This could be a ArgOnly, but trying to not provide too many ways
// to set the flutter root.
- new DartdocOptionSyntheticOnly<String>(
+ DartdocOptionSyntheticOnly<String>(
'flutterRoot',
(DartdocSyntheticOption<String> option, Directory dir) =>
resolveTildePath(Platform.environment['FLUTTER_ROOT']),
isDir: true,
help: 'Root of the Flutter SDK, specified from environment.',
mustExist: true),
- new DartdocOptionArgOnly<bool>('hideSdkText', false,
+ DartdocOptionArgOnly<bool>('hideSdkText', false,
hide: true,
help: 'Drop all text for SDK components. Helpful for integration '
'tests for dartdoc, probably not useful for anything else.',
negatable: true),
- new DartdocOptionArgFile<List<String>>('include', [],
+ DartdocOptionArgFile<List<String>>('include', [],
help: 'Library names to generate docs for.', splitCommas: true),
- new DartdocOptionArgFile<List<String>>('includeExternal', null,
+ DartdocOptionArgFile<List<String>>('includeExternal', null,
isFile: true,
help:
'Additional (external) dart files to include; use "dir/fileName", '
'as in lib/material.dart.',
mustExist: true,
splitCommas: true),
- new DartdocOptionArgOnly<bool>('includeSource', true,
+ DartdocOptionArgOnly<bool>('includeSource', true,
help: 'Show source code blocks.', negatable: true),
- new DartdocOptionArgOnly<bool>('injectHtml', false,
+ DartdocOptionArgOnly<bool>('injectHtml', false,
help: 'Allow the use of the {@inject-html} directive to inject raw '
'HTML into dartdoc output.'),
- new DartdocOptionArgOnly<String>('input', directoryCurrentPath,
+ DartdocOptionArgOnly<String>('input', directoryCurrentPath,
isDir: true, help: 'Path to source directory', mustExist: true),
- new DartdocOptionSyntheticOnly<String>('inputDir',
+ DartdocOptionSyntheticOnly<String>('inputDir',
(DartdocSyntheticOption<String> option, Directory dir) {
if (option.parent['sdkDocs'].valueAt(dir)) {
return option.parent['sdkDir'].valueAt(dir);
@@ -1520,16 +1514,16 @@
help: 'Path to source directory (with override if --sdk-docs)',
isDir: true,
mustExist: true),
- new DartdocOptionSet('linkTo')
+ DartdocOptionSet('linkTo')
..addAll([
- new DartdocOptionArgOnly<Map<String, String>>(
+ DartdocOptionArgOnly<Map<String, String>>(
'hosted',
{
'pub.dartlang.org':
'https://pub.dartlang.org/documentation/%n%/%v%'
},
help: 'Specify URLs for hosted pub packages'),
- new DartdocOptionArgOnly<Map<String, String>>(
+ DartdocOptionArgOnly<Map<String, String>>(
'sdks',
{
'Dart': 'https://api.dartlang.org/%b%/%v%',
@@ -1537,7 +1531,7 @@
},
help: 'Specify URLs for SDKs.',
),
- new DartdocOptionFileSynth<String>('url',
+ DartdocOptionFileSynth<String>('url',
(DartdocSyntheticOption<String> option, Directory dir) {
PackageMeta packageMeta =
option.parent.parent['packageMeta'].valueAt(dir);
@@ -1555,70 +1549,69 @@
}
return '';
}, help: 'Url to use for this particular package.'),
- new DartdocOptionArgOnly<bool>('remote', false,
+ DartdocOptionArgOnly<bool>('remote', false,
help: 'Allow links to be generated for packages outside this one.',
negatable: true),
]),
- new DartdocOptionArgOnly<String>('output', p.join('doc', 'api'),
+ DartdocOptionArgOnly<String>('output', p.join('doc', 'api'),
isDir: true, help: 'Path to output directory.'),
- new DartdocOptionSyntheticOnly<PackageMeta>(
+ DartdocOptionSyntheticOnly<PackageMeta>(
'packageMeta',
(DartdocSyntheticOption<PackageMeta> option, Directory dir) {
- PackageMeta packageMeta = new PackageMeta.fromDir(dir);
+ PackageMeta packageMeta = PackageMeta.fromDir(dir);
if (packageMeta == null) {
- throw new DartdocOptionError(
+ throw DartdocOptionError(
'Unable to determine package for directory: ${dir.path}');
}
return packageMeta;
},
),
- new DartdocOptionArgOnly<List<String>>('packageOrder', [],
+ DartdocOptionArgOnly<List<String>>('packageOrder', [],
help:
'A list of package names to place first when grouping libraries in packages. '
'Unmentioned packages are sorted after these.'),
- new DartdocOptionArgOnly<bool>('sdkDocs', false,
+ DartdocOptionArgOnly<bool>('sdkDocs', false,
help: 'Generate ONLY the docs for the Dart SDK.'),
- new DartdocOptionArgSynth<String>('sdkDir',
+ DartdocOptionArgSynth<String>('sdkDir',
(DartdocSyntheticOption<String> option, Directory dir) {
if (!option.parent['sdkDocs'].valueAt(dir) &&
(option.root['topLevelPackageMeta'].valueAt(dir) as PackageMeta)
.requiresFlutter) {
String flutterRoot = option.root['flutterRoot'].valueAt(dir);
if (flutterRoot == null) {
- throw new DartdocOptionError(
+ throw DartdocOptionError(
'Top level package requires Flutter but FLUTTER_ROOT environment variable not set');
}
return p.join(flutterRoot, 'bin', 'cache', 'dart-sdk');
}
return defaultSdkDir.absolute.path;
}, help: 'Path to the SDK directory.', isDir: true, mustExist: true),
- new DartdocOptionArgFile<bool>('showUndocumentedCategories', false,
+ DartdocOptionArgFile<bool>('showUndocumentedCategories', false,
help: "Label categories that aren't documented", negatable: true),
- new DartdocOptionSyntheticOnly<PackageMeta>('topLevelPackageMeta',
+ DartdocOptionSyntheticOnly<PackageMeta>('topLevelPackageMeta',
(DartdocSyntheticOption<PackageMeta> option, Directory dir) {
- PackageMeta packageMeta = new PackageMeta.fromDir(
- new Directory(option.parent['inputDir'].valueAt(dir)));
+ PackageMeta packageMeta = PackageMeta.fromDir(
+ Directory(option.parent['inputDir'].valueAt(dir)));
if (packageMeta == null) {
- throw new DartdocOptionError(
+ throw DartdocOptionError(
'Unable to generate documentation: no package found');
}
if (!packageMeta.isValid) {
final String firstError = packageMeta.getInvalidReasons().first;
- throw new DartdocOptionError('Package is invalid: $firstError');
+ throw DartdocOptionError('Package is invalid: $firstError');
}
return packageMeta;
}, help: 'PackageMeta object for the default package.'),
- new DartdocOptionArgOnly<bool>('useCategories', true,
+ DartdocOptionArgOnly<bool>('useCategories', true,
help: 'Display categories in the sidebar of packages'),
- new DartdocOptionArgOnly<bool>('validateLinks', true,
+ DartdocOptionArgOnly<bool>('validateLinks', true,
help:
'Runs the built-in link checker to display Dart context aware warnings for broken links (slow)',
negatable: true),
- new DartdocOptionArgOnly<bool>('verboseWarnings', true,
+ DartdocOptionArgOnly<bool>('verboseWarnings', true,
help: 'Display extra debugging information and help with warnings.',
negatable: true),
- new DartdocOptionFileOnly<ToolConfiguration>(
- 'tools', ToolConfiguration.empty,
+ DartdocOptionFileOnly<ToolConfiguration>('tools', ToolConfiguration.empty,
convertYamlToType: ToolConfiguration.fromYamlMap,
help: 'A map of tool names to executable paths. Each executable must '
'exist. Executables for different platforms are specified by '
diff --git a/lib/src/element_type.dart b/lib/src/element_type.dart
index bba26f8..0d2598c 100644
--- a/lib/src/element_type.dart
+++ b/lib/src/element_type.dart
@@ -21,10 +21,9 @@
factory ElementType.from(DartType f, PackageGraph packageGraph,
[ElementType returnedFrom]) {
if (f.element == null || f.element.kind == ElementKind.DYNAMIC) {
- return new UndefinedElementType(f, packageGraph, returnedFrom);
+ return UndefinedElementType(f, packageGraph, returnedFrom);
} else {
- ModelElement element =
- new ModelElement.fromElement(f.element, packageGraph);
+ ModelElement element = ModelElement.fromElement(f.element, packageGraph);
assert(f is ParameterizedType || f is TypeParameterType);
bool isGenericTypeAlias =
f.element.enclosingElement is GenericTypeAliasElement;
@@ -32,33 +31,30 @@
assert(f is ParameterizedType);
if (isGenericTypeAlias) {
assert(element is! ModelFunctionAnonymous);
- return new CallableGenericTypeAliasElementType(
+ return CallableGenericTypeAliasElementType(
f, packageGraph, element, returnedFrom);
} else {
if (element is ModelFunctionAnonymous) {
- return new CallableAnonymousElementType(
+ return CallableAnonymousElementType(
f, packageGraph, element, returnedFrom);
} else {
assert(element is! ModelFunctionAnonymous);
- return new CallableElementType(
- f, packageGraph, element, returnedFrom);
+ return CallableElementType(f, packageGraph, element, returnedFrom);
}
}
} else if (isGenericTypeAlias) {
assert(f is TypeParameterType);
assert(element is! ModelFunctionAnonymous);
- return new GenericTypeAliasElementType(
+ return GenericTypeAliasElementType(
f, packageGraph, element, returnedFrom);
}
if (f is TypeParameterType) {
assert(element is! ModelFunctionAnonymous);
- return new TypeParameterElementType(
- f, packageGraph, element, returnedFrom);
+ return TypeParameterElementType(f, packageGraph, element, returnedFrom);
}
assert(f is ParameterizedType);
assert(element is! ModelFunctionAnonymous);
- return new ParameterizedElementType(
- f, packageGraph, element, returnedFrom);
+ return ParameterizedElementType(f, packageGraph, element, returnedFrom);
}
}
@@ -117,7 +113,7 @@
@override
String get linkedName {
if (_linkedName == null) {
- StringBuffer buf = new StringBuffer();
+ StringBuffer buf = StringBuffer();
buf.write(element.linkedName);
@@ -140,7 +136,7 @@
@override
String get nameWithGenerics {
if (_nameWithGenerics == null) {
- StringBuffer buf = new StringBuffer();
+ StringBuffer buf = StringBuffer();
buf.write(element.name);
@@ -212,7 +208,7 @@
ElementType _returnType;
ElementType get returnType {
if (_returnType == null) {
- _returnType = new ElementType.from(type, packageGraph, this);
+ _returnType = ElementType.from(type, packageGraph, this);
}
return _returnType;
}
@@ -225,7 +221,7 @@
if (_typeArguments == null) {
_typeArguments = (type as ParameterizedType)
.typeArguments
- .map((f) => new ElementType.from(f, packageGraph))
+ .map((f) => ElementType.from(f, packageGraph))
.toList();
}
return _typeArguments;
@@ -242,7 +238,7 @@
@override
ElementType get returnType {
if (_returnType == null) {
- _returnType = new ElementType.from(type.returnType, packageGraph, this);
+ _returnType = ElementType.from(type.returnType, packageGraph, this);
}
return _returnType;
}
@@ -268,7 +264,7 @@
}
if (dartTypeArguments != null) {
_typeArguments = dartTypeArguments
- .map((f) => new ElementType.from(f, packageGraph))
+ .map((f) => ElementType.from(f, packageGraph))
.toList();
}
}
@@ -332,8 +328,8 @@
@override
ModelElement get returnElement {
if (_returnElement == null) {
- _returnElement = new ModelElement.fromElement(
- type.element.enclosingElement, packageGraph);
+ _returnElement =
+ ModelElement.fromElement(type.element.enclosingElement, packageGraph);
}
return _returnElement;
}
@@ -341,8 +337,8 @@
@override
ElementType get returnType {
if (_returnType == null) {
- _returnType = new ElementType.from(
- returnElement.modelType.type, packageGraph, this);
+ _returnType =
+ ElementType.from(returnElement.modelType.type, packageGraph, this);
}
return _returnType;
}
diff --git a/lib/src/empty_generator.dart b/lib/src/empty_generator.dart
index 476dd67..92a96b8 100644
--- a/lib/src/empty_generator.dart
+++ b/lib/src/empty_generator.dart
@@ -27,8 +27,7 @@
return null;
}
- final StreamController<void> _onFileCreated =
- new StreamController(sync: true);
+ final StreamController<void> _onFileCreated = StreamController(sync: true);
@override
@@ -37,5 +36,5 @@
Stream<void> get onFileCreated => _onFileCreated.stream;
@override
- Set<String> get writtenFiles => new Set();
+ Set<String> get writtenFiles => Set();
}
diff --git a/lib/src/experiment_options.dart b/lib/src/experiment_options.dart
index 0d9fa2f..b7f65b5 100644
--- a/lib/src/experiment_options.dart
+++ b/lib/src/experiment_options.dart
@@ -24,16 +24,16 @@
Future<List<DartdocOption>> createExperimentOptions() async {
return <DartdocOption>[
// TODO(jcollins-g): Consider loading experiment values from dartdoc_options.yaml?
- new DartdocOptionArgOnly<List<String>>('enable-experiment', [],
+ DartdocOptionArgOnly<List<String>>('enable-experiment', [],
help: 'Enable or disable listed experiments.\n' +
ExperimentStatus.knownFeatures.values
.where((e) => e.documentation != null)
.map((e) =>
' [no-]${e.enableString}: ${e.documentation} (default: ${e.isEnabledByDefault})')
.join('\n')),
- new DartdocOptionSyntheticOnly<ExperimentStatus>(
+ DartdocOptionSyntheticOnly<ExperimentStatus>(
'experimentStatus',
- (option, dir) => new ExperimentStatus.fromStrings(
+ (option, dir) => ExperimentStatus.fromStrings(
option.parent['enable-experiment'].valueAt(dir))),
];
}
diff --git a/lib/src/html/html_generator.dart b/lib/src/html/html_generator.dart
index 89b6402..c4c18ee 100644
--- a/lib/src/html/html_generator.dart
+++ b/lib/src/html/html_generator.dart
@@ -17,7 +17,7 @@
import 'package:dartdoc/src/model.dart';
import 'package:path/path.dart' as path;
-typedef String Renderer(String input);
+typedef Renderer = String Function(String input);
// Generation order for libraries:
// constants
@@ -42,14 +42,13 @@
final HtmlGeneratorOptions _options;
HtmlGeneratorInstance _instance;
- final StreamController<void> _onFileCreated =
- new StreamController(sync: true);
+ final StreamController<void> _onFileCreated = StreamController(sync: true);
@override
Stream<void> get onFileCreated => _onFileCreated.stream;
@override
- final Set<String> writtenFiles = new Set<String>();
+ final Set<String> writtenFiles = Set<String>();
static Future<HtmlGenerator> create(
{HtmlGeneratorOptions options,
@@ -61,8 +60,7 @@
footerPaths: footers,
footerTextPaths: footerTexts);
- return new HtmlGenerator._(
- options ?? new HtmlGeneratorOptions(), templates);
+ return HtmlGenerator._(options ?? HtmlGeneratorOptions(), templates);
}
HtmlGenerator._(this._options, this._templates);
@@ -78,13 +76,13 @@
void write(String filePath, Object content, {bool allowOverwrite}) {
allowOverwrite ??= false;
if (!enabled) {
- throw new StateError('`write` was called after `generate` completed.');
+ throw StateError('`write` was called after `generate` completed.');
}
// If you see this assert, we're probably being called to build non-canonical
// docs somehow. Check data.self.isCanonical and callers for bugs.
assert(allowOverwrite || !writtenFiles.contains(filePath));
- var file = new File(path.join(outputDirectoryPath, filePath));
+ var file = File(path.join(outputDirectoryPath, filePath));
var parent = file.parent;
if (!parent.existsSync()) {
parent.createSync(recursive: true);
@@ -95,7 +93,7 @@
} else if (content is List<int>) {
file.writeAsBytesSync(content);
} else {
- throw new ArgumentError.value(
+ throw ArgumentError.value(
content, 'content', '`content` must be `String` or `List<int>`.');
}
_onFileCreated.add(file);
@@ -104,7 +102,7 @@
try {
_instance =
- new HtmlGeneratorInstance(_options, _templates, packageGraph, write);
+ HtmlGeneratorInstance(_options, _templates, packageGraph, write);
await _instance.generate();
} finally {
enabled = false;
@@ -140,7 +138,7 @@
Future<List<Generator>> initGenerators(GeneratorContext config) async {
// TODO(jcollins-g): Rationalize based on GeneratorContext all the way down
// through the generators.
- HtmlGeneratorOptions options = new HtmlGeneratorOptions(
+ HtmlGeneratorOptions options = HtmlGeneratorOptions(
url: config.hostedUrl,
relCanonicalPrefix: config.relCanonicalPrefix,
toolVersion: dartdocVersion,
@@ -184,23 +182,23 @@
Future<List<DartdocOption>> createGeneratorOptions() async {
await _setSdkFooterCopyrightUri();
return <DartdocOption>[
- new DartdocOptionArgFile<String>('favicon', null,
+ DartdocOptionArgFile<String>('favicon', null,
isFile: true,
help: 'A path to a favicon for the generated docs.',
mustExist: true),
- new DartdocOptionArgFile<List<String>>('footer', [],
+ DartdocOptionArgFile<List<String>>('footer', [],
isFile: true,
help: 'paths to footer files containing HTML text.',
mustExist: true,
splitCommas: true),
- new DartdocOptionArgFile<List<String>>('footerText', [],
+ DartdocOptionArgFile<List<String>>('footerText', [],
isFile: true,
help:
'paths to footer-text files (optional text next to the package name '
'and version).',
mustExist: true,
splitCommas: true),
- new DartdocOptionSyntheticOnly<List<String>>(
+ DartdocOptionSyntheticOnly<List<String>>(
'footerTextPaths',
(DartdocSyntheticOption<List<String>> option, Directory dir) {
final List<String> footerTextPaths = <String>[];
@@ -218,18 +216,18 @@
help: 'paths to footer-text-files (adding special case for SDK)',
mustExist: true,
),
- new DartdocOptionArgFile<List<String>>('header', [],
+ DartdocOptionArgFile<List<String>>('header', [],
isFile: true,
help: 'paths to header files containing HTML text.',
splitCommas: true),
- new DartdocOptionArgOnly<String>('hostedUrl', null,
+ DartdocOptionArgOnly<String>('hostedUrl', null,
help:
'URL where the docs will be hosted (used to generate the sitemap).'),
- new DartdocOptionArgOnly<bool>('prettyIndexJson', false,
+ DartdocOptionArgOnly<bool>('prettyIndexJson', false,
help:
"Generates `index.json` with indentation and newlines. The file is larger, but it's also easier to diff.",
negatable: false),
- new DartdocOptionArgOnly<String>('relCanonicalPrefix', null,
+ DartdocOptionArgOnly<String>('relCanonicalPrefix', null,
help:
'If provided, add a rel="canonical" prefixed with provided value. '
'Consider using if\nbuilding many versions of the docs for public '
diff --git a/lib/src/html/html_generator_instance.dart b/lib/src/html/html_generator_instance.dart
index 6b86232..e542532 100644
--- a/lib/src/html/html_generator_instance.dart
+++ b/lib/src/html/html_generator_instance.dart
@@ -19,7 +19,8 @@
import 'package:mustache/mustache.dart';
import 'package:path/path.dart' as path;
-typedef void FileWriter(String path, Object content, {bool allowOverwrite});
+typedef FileWriter = void Function(String path, Object content,
+ {bool allowOverwrite});
class HtmlGeneratorInstance {
final HtmlGeneratorOptions _options;
@@ -40,7 +41,7 @@
await _copyResources();
if (_options.faviconPath != null) {
- var bytes = new File(_options.faviconPath).readAsBytesSync();
+ var bytes = File(_options.faviconPath).readAsBytesSync();
// Allow overwrite of favicon.
_writer(path.join('static-assets', 'favicon.png'), bytes,
allowOverwrite: true);
@@ -48,7 +49,7 @@
}
void _generateCategoryJson() {
- var encoder = new JsonEncoder.withIndent(' ');
+ var encoder = JsonEncoder.withIndent(' ');
final List<Map> indexItems = _categorizationItems.map((Categorization e) {
Map data = {
'name': e.name,
@@ -79,9 +80,8 @@
List<Categorization> _categorizationItems;
void _generateSearchIndex() {
- var encoder = _options.prettyIndexJson
- ? new JsonEncoder.withIndent(' ')
- : new JsonEncoder();
+ var encoder =
+ _options.prettyIndexJson ? JsonEncoder.withIndent(' ') : JsonEncoder();
_categorizationItems = [];
final List<Map> indexItems = _indexedElements.map((Indexable e) {
@@ -242,8 +242,7 @@
}
void generatePackage(PackageGraph packageGraph, Package package) {
- TemplateData data =
- new PackageTemplateData(_options, packageGraph, package);
+ TemplateData data = PackageTemplateData(_options, packageGraph, package);
logInfo('documenting ${package.name}');
_build('index.html', _templates.indexTemplate, data);
@@ -253,8 +252,7 @@
void generateCategory(PackageGraph packageGraph, Category category) {
logInfo(
'Generating docs for category ${category.name} from ${category.package.fullyQualifiedName}...');
- TemplateData data =
- new CategoryTemplateData(_options, packageGraph, category);
+ TemplateData data = CategoryTemplateData(_options, packageGraph, category);
_build(path.joinAll(category.href.split('/')), _templates.categoryTemplate,
data);
@@ -266,27 +264,25 @@
if (!lib.isAnonymous && !lib.hasDocumentation) {
packageGraph.warnOnElement(lib, PackageWarning.noLibraryLevelDocs);
}
- TemplateData data = new LibraryTemplateData(_options, packageGraph, lib);
+ TemplateData data = LibraryTemplateData(_options, packageGraph, lib);
_build(path.join(lib.dirName, '${lib.fileName}'),
_templates.libraryTemplate, data);
}
void generateClass(PackageGraph packageGraph, Library lib, Class clazz) {
- TemplateData data =
- new ClassTemplateData(_options, packageGraph, lib, clazz);
+ TemplateData data = ClassTemplateData(_options, packageGraph, lib, clazz);
_build(path.joinAll(clazz.href.split('/')), _templates.classTemplate, data);
}
void generateMixins(PackageGraph packageGraph, Library lib, Mixin mixin) {
- TemplateData data =
- new MixinTemplateData(_options, packageGraph, lib, mixin);
+ TemplateData data = MixinTemplateData(_options, packageGraph, lib, mixin);
_build(path.joinAll(mixin.href.split('/')), _templates.mixinTemplate, data);
}
void generateConstructor(PackageGraph packageGraph, Library lib, Class clazz,
Constructor constructor) {
- TemplateData data = new ConstructorTemplateData(
+ TemplateData data = ConstructorTemplateData(
_options, packageGraph, lib, clazz, constructor);
_build(path.joinAll(constructor.href.split('/')),
@@ -294,7 +290,7 @@
}
void generateEnum(PackageGraph packageGraph, Library lib, Enum eNum) {
- TemplateData data = new EnumTemplateData(_options, packageGraph, lib, eNum);
+ TemplateData data = EnumTemplateData(_options, packageGraph, lib, eNum);
_build(path.joinAll(eNum.href.split('/')), _templates.enumTemplate, data);
}
@@ -302,7 +298,7 @@
void generateFunction(
PackageGraph packageGraph, Library lib, ModelFunction function) {
TemplateData data =
- new FunctionTemplateData(_options, packageGraph, lib, function);
+ FunctionTemplateData(_options, packageGraph, lib, function);
_build(path.joinAll(function.href.split('/')), _templates.functionTemplate,
data);
@@ -311,7 +307,7 @@
void generateMethod(
PackageGraph packageGraph, Library lib, Class clazz, Method method) {
TemplateData data =
- new MethodTemplateData(_options, packageGraph, lib, clazz, method);
+ MethodTemplateData(_options, packageGraph, lib, clazz, method);
_build(
path.joinAll(method.href.split('/')), _templates.methodTemplate, data);
@@ -320,7 +316,7 @@
void generateConstant(
PackageGraph packageGraph, Library lib, Class clazz, Field property) {
TemplateData data =
- new ConstantTemplateData(_options, packageGraph, lib, clazz, property);
+ ConstantTemplateData(_options, packageGraph, lib, clazz, property);
_build(path.joinAll(property.href.split('/')), _templates.constantTemplate,
data);
@@ -329,7 +325,7 @@
void generateProperty(
PackageGraph packageGraph, Library lib, Class clazz, Field property) {
TemplateData data =
- new PropertyTemplateData(_options, packageGraph, lib, clazz, property);
+ PropertyTemplateData(_options, packageGraph, lib, clazz, property);
_build(path.joinAll(property.href.split('/')), _templates.propertyTemplate,
data);
@@ -338,7 +334,7 @@
void generateTopLevelProperty(
PackageGraph packageGraph, Library lib, TopLevelVariable property) {
TemplateData data =
- new TopLevelPropertyTemplateData(_options, packageGraph, lib, property);
+ TopLevelPropertyTemplateData(_options, packageGraph, lib, property);
_build(path.joinAll(property.href.split('/')),
_templates.topLevelPropertyTemplate, data);
@@ -347,7 +343,7 @@
void generateTopLevelConstant(
PackageGraph packageGraph, Library lib, TopLevelVariable property) {
TemplateData data =
- new TopLevelConstTemplateData(_options, packageGraph, lib, property);
+ TopLevelConstTemplateData(_options, packageGraph, lib, property);
_build(path.joinAll(property.href.split('/')),
_templates.topLevelConstantTemplate, data);
@@ -356,7 +352,7 @@
void generateTypeDef(
PackageGraph packageGraph, Library lib, Typedef typeDef) {
TemplateData data =
- new TypedefTemplateData(_options, packageGraph, lib, typeDef);
+ TypedefTemplateData(_options, packageGraph, lib, typeDef);
_build(path.joinAll(typeDef.href.split('/')), _templates.typeDefTemplate,
data);
@@ -367,7 +363,7 @@
final prefix = 'package:dartdoc/resources/';
for (String resourcePath in resources.resource_names) {
if (!resourcePath.startsWith(prefix)) {
- throw new StateError('Resource paths must start with $prefix, '
+ throw StateError('Resource paths must start with $prefix, '
'encountered $resourcePath');
}
String destFileName = resourcePath.substring(prefix.length);
diff --git a/lib/src/html/resource_loader.dart b/lib/src/html/resource_loader.dart
index 89e1be6..ec1984f 100644
--- a/lib/src/html/resource_loader.dart
+++ b/lib/src/html/resource_loader.dart
@@ -25,7 +25,7 @@
/// Loads a `package:` resource as an [List<int>].
Future<List<int>> loadAsBytes(String path) async {
if (!path.startsWith('package:')) {
- throw new ArgumentError('path must begin with package:');
+ throw ArgumentError('path must begin with package:');
}
Uri uri = Uri.parse(path);
diff --git a/lib/src/html/resources.g.dart b/lib/src/html/resources.g.dart
index 2d833be..5e78a8c 100644
--- a/lib/src/html/resources.g.dart
+++ b/lib/src/html/resources.g.dart
@@ -1,6 +1,6 @@
// WARNING: This file is auto-generated. Do not taunt.
-const List<String> resource_names = const [
+const List<String> resource_names = [
'package:dartdoc/resources/URI.js',
'package:dartdoc/resources/css/bootstrap.css',
'package:dartdoc/resources/css/bootstrap.css.map',
diff --git a/lib/src/html/templates.dart b/lib/src/html/templates.dart
index ee30023..bcd90c2 100644
--- a/lib/src/html/templates.dart
+++ b/lib/src/html/templates.dart
@@ -10,7 +10,7 @@
import 'package:dartdoc/src/html/resource_loader.dart' as loader;
import 'package:mustache/mustache.dart';
-const _partials = const <String>[
+const _partials = <String>[
'callable',
'callable_multiline',
'categorization',
@@ -52,20 +52,18 @@
String template = await _getTemplateFile(templatePath);
if (templatePath.contains('_head')) {
- String headerValue = headerPaths
- .map((path) => new File(path).readAsStringSync())
- .join('\n');
+ String headerValue =
+ headerPaths.map((path) => File(path).readAsStringSync()).join('\n');
template = template.replaceAll(headerPlaceholder, headerValue);
}
if (templatePath.contains('_footer')) {
- String footerValue = footerPaths
- .map((path) => new File(path).readAsStringSync())
- .join('\n');
+ String footerValue =
+ footerPaths.map((path) => File(path).readAsStringSync()).join('\n');
template = template.replaceAll(footerPlaceholder, footerValue);
String footerTextValue = footerTextPaths
- .map((path) => new File(path).readAsStringSync())
+ .map((path) => File(path).readAsStringSync())
.join('\n');
template = template.replaceAll(footerTextPlaceholder, footerTextValue);
}
@@ -110,7 +108,7 @@
Template _partial(String name) {
String partial = partials[name];
if (partial == null || partial.isEmpty) {
- throw new StateError('Did not find partial "$name"');
+ throw StateError('Did not find partial "$name"');
}
return Template(partial);
}
@@ -138,7 +136,7 @@
var typeDefTemplate = await _loadTemplate('typedef.html');
var mixinTemplate = await _loadTemplate('mixin.html');
- return new Templates._(
+ return Templates._(
indexTemplate,
categoryTemplate,
libraryTemplate,
diff --git a/lib/src/io_utils.dart b/lib/src/io_utils.dart
index d321b1a..9e0c34c 100644
--- a/lib/src/io_utils.dart
+++ b/lib/src/io_utils.dart
@@ -40,18 +40,18 @@
Iterable<FileSystemEntity> listDir(Directory dir)}) {
if (listDir == null) listDir = (Directory dir) => dir.listSync();
- return _doList(dir, new Set<String>(), recursive, listDir);
+ return _doList(dir, Set<String>(), recursive, listDir);
}
Iterable<String> _doList(String dir, Set<String> listedDirectories,
bool recurse, Iterable<FileSystemEntity> listDir(Directory dir)) sync* {
// Avoid recursive symlinks.
- var resolvedPath = new Directory(dir).resolveSymbolicLinksSync();
+ var resolvedPath = Directory(dir).resolveSymbolicLinksSync();
if (!listedDirectories.contains(resolvedPath)) {
- listedDirectories = new Set<String>.from(listedDirectories);
+ listedDirectories = Set<String>.from(listedDirectories);
listedDirectories.add(resolvedPath);
- for (var entity in listDir(new Directory(dir))) {
+ for (var entity in listDir(Directory(dir))) {
// Skip hidden files and directories
if (path.basename(entity.path).startsWith('.')) {
continue;
@@ -76,16 +76,16 @@
String getFileNameFor(String name) =>
'${name.replaceAll(libraryNameRegexp, '-')}.html';
-final libraryNameRegexp = new RegExp('[.:]');
-final partOfRegexp = new RegExp('part of ');
-final newLinePartOfRegexp = new RegExp('\npart of ');
+final libraryNameRegexp = RegExp('[.:]');
+final partOfRegexp = RegExp('part of ');
+final newLinePartOfRegexp = RegExp('\npart of ');
/// Best used with Future<void>.
class MultiFutureTracker<T> {
/// Approximate maximum number of simultaneous active Futures.
final int parallel;
- final Set<Future<T>> _trackedFutures = new Set();
+ final Set<Future<T>> _trackedFutures = Set();
MultiFutureTracker(this.parallel);
diff --git a/lib/src/line_number_cache.dart b/lib/src/line_number_cache.dart
index 3000238..0f5e3b9 100644
--- a/lib/src/line_number_cache.dart
+++ b/lib/src/line_number_cache.dart
@@ -23,7 +23,7 @@
var newlineChar = _getNewlineChar(contents);
var offset = 0;
var lineNumber = 0;
- var result = new SplayTreeMap<int, int>();
+ var result = SplayTreeMap<int, int>();
do {
result[offset] = lineNumber;
@@ -34,7 +34,7 @@
return result;
}
-final LineNumberCache lineNumberCache = new LineNumberCache();
+final LineNumberCache lineNumberCache = LineNumberCache();
// TODO(kevmoo): this could use some testing
class LineNumberCache {
@@ -47,11 +47,11 @@
file, () => _createLineNumbersMap(_fileContents(file)));
var lastKey = lineMap.lastKeyBefore(offset);
if (lastKey != null) {
- return new Tuple2(lineMap[lastKey] + 1, offset - lastKey);
+ return Tuple2(lineMap[lastKey] + 1, offset - lastKey);
}
return null;
}
String _fileContents(String file) =>
- __fileContents.putIfAbsent(file, () => new File(file).readAsStringSync());
+ __fileContents.putIfAbsent(file, () => File(file).readAsStringSync());
}
diff --git a/lib/src/logging.dart b/lib/src/logging.dart
index ae67052..ba162ce 100644
--- a/lib/src/logging.dart
+++ b/lib/src/logging.dart
@@ -9,17 +9,17 @@
import 'package:logging/logging.dart';
-final _logger = new Logger('dartdoc');
+final _logger = Logger('dartdoc');
/// A custom [Level] for tracking file writes and verification.
///
/// Has a value of `501` – one more than [Level.FINE].
-final Level progressLevel = new Level('PROGRESS', 501);
+final Level progressLevel = Level('PROGRESS', 501);
/// A custom [Level] for errant print statements.
///
/// Has a value of `1201` – one more than [Level.SHOUT].
-final Level printLevel = new Level('PRINT', 1201);
+final Level printLevel = Level('PRINT', 1201);
void logWarning(Object message) {
_logger.log(Level.WARNING, message);
@@ -69,7 +69,7 @@
print(json.encode(output));
});
} else {
- final stopwatch = new Stopwatch()..start();
+ final stopwatch = Stopwatch()..start();
// Used to track if we're printing `...` to show progress.
// Allows unified new-line tracking
@@ -121,13 +121,13 @@
Future<List<DartdocOption>> createLoggingOptions() async {
return <DartdocOption>[
- new DartdocOptionArgOnly<bool>('json', false,
+ DartdocOptionArgOnly<bool>('json', false,
help: 'Prints out progress JSON maps. One entry per line.',
negatable: true),
- new DartdocOptionArgOnly<bool>('showProgress', false,
+ DartdocOptionArgOnly<bool>('showProgress', false,
help: 'Display progress indications to console stdout',
negatable: false),
- new DartdocOptionArgSynth<bool>('quiet',
+ DartdocOptionArgSynth<bool>('quiet',
(DartdocSyntheticOption option, Directory dir) {
if (option.root['generateDocs']?.valueAt(dir) == false) {
return true;
diff --git a/lib/src/markdown_processor.dart b/lib/src/markdown_processor.dart
index 368fd31..aac01e2 100644
--- a/lib/src/markdown_processor.dart
+++ b/lib/src/markdown_processor.dart
@@ -16,7 +16,7 @@
import 'package:html/parser.dart' show parse;
import 'package:markdown/markdown.dart' as md;
-const validHtmlTags = const [
+const validHtmlTags = [
"a",
"abbr",
"address",
@@ -118,30 +118,30 @@
];
final RegExp nonHTML =
- new RegExp("</?(?!(${validHtmlTags.join("|")})[> ])\\w+[> ]");
+ RegExp("</?(?!(${validHtmlTags.join("|")})[> ])\\w+[> ]");
// Type parameters and other things to ignore at the end of doc references.
-final RegExp trailingIgnoreStuff = new RegExp(r'(<.*>|\(.*\))$');
+final RegExp trailingIgnoreStuff = RegExp(r'(<.*>|\(.*\))$');
// Things to ignore at the beginning of doc references
final RegExp leadingIgnoreStuff =
- new RegExp(r'^(const|final|var)[\s]+', multiLine: true);
+ RegExp(r'^(const|final|var)[\s]+', multiLine: true);
// If found, this may be intended as a reference to a constructor.
-final RegExp isConstructor = new RegExp(r'(^new[\s]+|\(\)$)', multiLine: true);
+final RegExp isConstructor = RegExp(r'(^new[\s]+|\(\)$)', multiLine: true);
// This is probably not really intended as a doc reference, so don't try or
// warn about them.
// Covers anything with leading digits/symbols, empty string, weird punctuation, spaces.
-final RegExp notARealDocReference = new RegExp(r'''(^[^\w]|^[\d]|[,"'/]|^$)''');
+final RegExp notARealDocReference = RegExp(r'''(^[^\w]|^[\d]|[,"'/]|^$)''');
-final RegExp operatorPrefix = new RegExp(r'^operator[ ]*');
+final RegExp operatorPrefix = RegExp(r'^operator[ ]*');
final HtmlEscape htmlEscape = const HtmlEscape(HtmlEscapeMode.element);
final List<md.InlineSyntax> _markdown_syntaxes = [
- new _InlineCodeSyntax(),
- new _AutolinkWithoutScheme(),
+ _InlineCodeSyntax(),
+ _AutolinkWithoutScheme(),
md.InlineHtmlSyntax(),
md.StrikethroughSyntax(),
md.AutolinkExtensionSyntax(),
@@ -152,11 +152,10 @@
const md.HeaderWithIdSyntax(),
const md.SetextHeaderWithIdSyntax(),
const md.TableSyntax(),
-
];
// Remove these schemas from the display text for hyperlinks.
-final RegExp _hide_schemes = new RegExp('^(http|https)://');
+final RegExp _hide_schemes = RegExp('^(http|https)://');
class MatchingLinkResult {
final ModelElement element;
@@ -198,7 +197,7 @@
if (!codeRef.contains(isConstructor) &&
codeRef.contains(notARealDocReference)) {
// Don't waste our time on things we won't ever find.
- return new MatchingLinkResult(null, warn: false);
+ return MatchingLinkResult(null, warn: false);
}
ModelElement refModelElement;
@@ -206,9 +205,9 @@
// Try expensive not-scoped lookup.
if (refModelElement == null && element is ModelElement) {
Class preferredClass = _getPreferredClass(element);
- refModelElement = new _MarkdownCommentReference(
- codeRef, element, commentRefs, preferredClass)
- .computeReferredElement();
+ refModelElement =
+ _MarkdownCommentReference(codeRef, element, commentRefs, preferredClass)
+ .computeReferredElement();
}
// Did not find it anywhere.
@@ -216,12 +215,12 @@
// TODO(jcollins-g): remove squelching of non-canonical warnings here
// once we no longer process full markdown for
// oneLineDocs (#1417)
- return new MatchingLinkResult(null, warn: element.isCanonical);
+ return MatchingLinkResult(null, warn: element.isCanonical);
}
// Ignore all parameters.
if (refModelElement is Parameter || refModelElement is TypeParameter) {
- return new MatchingLinkResult(null, warn: false);
+ return MatchingLinkResult(null, warn: false);
}
// There have been places in the code which helpfully cache entities
@@ -230,7 +229,7 @@
assert(refModelElement == null ||
refModelElement.packageGraph == element.packageGraph);
if (refModelElement != null) {
- return new MatchingLinkResult(refModelElement);
+ return MatchingLinkResult(refModelElement);
}
// From this point on, we haven't been able to find a canonical ModelElement.
if (!refModelElement.isCanonical) {
@@ -240,7 +239,7 @@
}
// Don't warn about doc references because that's covered by the no
// canonical library found message.
- return new MatchingLinkResult(null, warn: false);
+ return MatchingLinkResult(null, warn: false);
}
// We should never get here unless there's a bug in findCanonicalModelElementFor.
// findCanonicalModelElementFor(searchElement, preferredClass: preferredClass)
@@ -248,7 +247,7 @@
// would return a non-canonical element. However, outside of checked mode,
// at least we have a canonical element, so proceed.
assert(false);
- return new MatchingLinkResult(refModelElement);
+ return MatchingLinkResult(refModelElement);
}
/// Given a set of commentRefs, return the one whose name matches the codeRef.
@@ -356,7 +355,7 @@
/// [element.warn] for [PackageWarning.ambiguousDocReference] if there
/// are more than one, but does not warn otherwise.
ModelElement computeReferredElement() {
- results = new Set();
+ results = Set();
// TODO(jcollins-g): A complex package winds up spending a lot of cycles in here. Optimize.
for (void Function() findMethod in [
// This might be an operator. Strip the operator prefix and try again.
@@ -511,7 +510,7 @@
void _findWithoutLeadingIgnoreStuff() {
if (codeRef.contains(leadingIgnoreStuff)) {
String newCodeRef = codeRef.replaceFirst(leadingIgnoreStuff, '');
- results.add(new _MarkdownCommentReference(
+ results.add(_MarkdownCommentReference(
newCodeRef, element, commentRefs, preferredClass)
.computeReferredElement());
}
@@ -520,7 +519,7 @@
void _findWithoutTrailingIgnoreStuff() {
if (codeRef.contains(trailingIgnoreStuff)) {
String newCodeRef = codeRef.replaceFirst(trailingIgnoreStuff, '');
- results.add(new _MarkdownCommentReference(
+ results.add(_MarkdownCommentReference(
newCodeRef, element, commentRefs, preferredClass)
.computeReferredElement());
}
@@ -529,7 +528,7 @@
void _findWithoutOperatorPrefix() {
if (codeRef.startsWith(operatorPrefix)) {
String newCodeRef = codeRef.replaceFirst(operatorPrefix, '');
- results.add(new _MarkdownCommentReference(
+ results.add(_MarkdownCommentReference(
newCodeRef, element, commentRefs, preferredClass)
.computeReferredElement());
}
@@ -680,7 +679,7 @@
void _findAnalyzerReferences() {
Element refElement = _getRefElementFromCommentRefs(commentRefs, codeRef);
if (refElement != null) {
- ModelElement refModelElement = new ModelElement.fromElement(
+ ModelElement refModelElement = ModelElement.fromElement(
_getRefElementFromCommentRefs(commentRefs, codeRef),
element.packageGraph);
if (refModelElement is Accessor) {
@@ -784,8 +783,8 @@
// Maximum number of characters to display after the beginning of a suspected generic.
const maxPostContext = 30;
-final RegExp allBeforeFirstNewline = new RegExp(r'^.*\n', multiLine: true);
-final RegExp allAfterLastNewline = new RegExp(r'\n.*$', multiLine: true);
+final RegExp allBeforeFirstNewline = RegExp(r'^.*\n', multiLine: true);
+final RegExp allAfterLastNewline = RegExp(r'\n.*$', multiLine: true);
// Generics should be wrapped into `[]` blocks, to avoid handling them as HTML tags
// (like, [Apple<int>]). @Hixie asked for a warning when there's something, that looks
@@ -858,7 +857,7 @@
/// Returns a tuple of longHtml, shortHtml. longHtml is NULL if [processFullDocs] is true.
static Tuple2<String, String> _renderNodesToHtml(
List<md.Node> nodes, bool processFullDocs) {
- var rawHtml = new md.HtmlRenderer().render(nodes);
+ var rawHtml = md.HtmlRenderer().render(nodes);
var asHtmlDocument = parse(rawHtml);
for (var s in asHtmlDocument.querySelectorAll('script')) {
s.remove();
@@ -891,7 +890,7 @@
? ''
: asHtmlDocument.body.children.first.innerHtml;
- return new Tuple2(asHtml, asOneLiner);
+ return Tuple2(asHtml, asOneLiner);
}
// From package:markdown/src/document.dart
@@ -901,7 +900,7 @@
var node = nodes[i];
if (node is md.UnparsedContent) {
List<md.Node> inlineNodes =
- new md.InlineParser(node.textContent, this).parse();
+ md.InlineParser(node.textContent, this).parse();
nodes.removeAt(i);
nodes.insertAll(i, inlineNodes);
i += inlineNodes.length - 1;
@@ -918,7 +917,7 @@
md.Node firstNode;
List<md.Node> nodes = [];
for (md.Node node
- in new IterableBlockParser(lines, this).parseLinesGenerator()) {
+ in IterableBlockParser(lines, this).parseLinesGenerator()) {
if (firstNode != null) {
hasExtendedDocs = true;
if (!processFullDocs) break;
@@ -942,8 +941,7 @@
shortHtml = '';
}
}
- return new Tuple3<String, String, bool>(
- longHtml, shortHtml, hasExtendedDocs);
+ return Tuple3<String, String, bool>(longHtml, shortHtml, hasExtendedDocs);
}
}
@@ -1005,12 +1003,12 @@
if (name.isEmpty) {
return null;
}
- return new md.Text(_linkDocReference(name, _element, commentRefs));
+ return md.Text(_linkDocReference(name, _element, commentRefs));
}
String text = _element.documentation;
_showWarningsForGenericsOutsideSquareBracketsBlocks(text, _element);
- MarkdownDocument document = new MarkdownDocument(
+ MarkdownDocument document = MarkdownDocument(
inlineSyntaxes: _markdown_syntaxes,
blockSyntaxes: _markdown_block_syntaxes,
linkResolver: _linkResolver);
@@ -1024,7 +1022,7 @@
@override
bool onMatch(md.InlineParser parser, Match match) {
- var element = new md.Element.text('code', htmlEscape.convert(match[1]));
+ var element = md.Element.text('code', htmlEscape.convert(match[1]));
parser.addNode(element);
return true;
}
@@ -1035,7 +1033,7 @@
bool onMatch(md.InlineParser parser, Match match) {
var url = match[1];
var text = htmlEscape.convert(url).replaceFirst(_hide_schemes, '');
- var anchor = new md.Element.text('a', text);
+ var anchor = md.Element.text('a', text);
anchor.attributes['href'] = url;
parser.addNode(anchor);
diff --git a/lib/src/model.dart b/lib/src/model.dart
index 183a504..3ffb04d 100644
--- a/lib/src/model.dart
+++ b/lib/src/model.dart
@@ -76,7 +76,7 @@
/// Items mapped to zero will sort alphabetically among custom annotations.
/// Custom annotations are assumed to be any annotation or feature not in this
/// map.
-const Map<String, int> featureOrder = const {
+const Map<String, int> featureOrder = {
'read-only': 1,
'write-only': 1,
'read / write': 1,
@@ -102,26 +102,25 @@
return compareAsciiLowerCaseNatural(a, b);
}
-final RegExp locationSplitter = new RegExp(r'(package:|[\\/;.])');
-final RegExp substituteNameVersion = new RegExp(r'%([bnv])%');
+final RegExp locationSplitter = RegExp(r'(package:|[\\/;.])');
+final RegExp substituteNameVersion = RegExp(r'%([bnv])%');
/// This doc may need to be processed in case it has a template or html
/// fragment.
-final needsPrecacheRegExp = new RegExp(r'{@(template|tool|inject-html)');
+final needsPrecacheRegExp = RegExp(r'{@(template|tool|inject-html)');
-final templateRegExp = new RegExp(
+final templateRegExp = RegExp(
r'[ ]*{@template\s+(.+?)}([\s\S]+?){@endtemplate}[ ]*\n?',
multiLine: true);
-final htmlRegExp = new RegExp(
+final htmlRegExp = RegExp(
r'[ ]*{@inject-html\s*}([\s\S]+?){@end-inject-html}[ ]*\n?',
multiLine: true);
-final htmlInjectRegExp =
- new RegExp(r'<dartdoc-html>([a-f0-9]+)</dartdoc-html>');
+final htmlInjectRegExp = RegExp(r'<dartdoc-html>([a-f0-9]+)</dartdoc-html>');
// Matches all tool directives (even some invalid ones). This is so
// we can give good error messages if the directive is malformed, instead of
// just silently emitting it as-is.
-final basicToolRegExp = new RegExp(
+final basicToolRegExp = RegExp(
r'[ ]*{@tool\s+([^}]+)}\n?([\s\S]+?)\n?{@end-tool}[ ]*\n?',
multiLine: true);
@@ -132,15 +131,15 @@
/// Match group 2 contains the quote character used (which is discarded).
/// Match group 3 is a quoted arg, if any, without the quotes.
/// Match group 4 is the unquoted arg, if any.
-final RegExp argMatcher = new RegExp(r'([a-zA-Z\-_0-9]+=)?' // option name
+final RegExp argMatcher = RegExp(r'([a-zA-Z\-_0-9]+=)?' // option name
r'(?:' // Start a new non-capture group for the two possibilities.
r'''(["'])((?:\\{2})*|(?:.*?[^\\](?:\\{2})*))\2|''' // with quotes.
r'([^ ]+))'); // without quotes.
-final categoryRegexp = new RegExp(
+final categoryRegexp = RegExp(
r'[ ]*{@(api|category|subCategory|image|samples) (.+?)}[ ]*\n?',
multiLine: true);
-final macroRegExp = new RegExp(r'{@macro\s+([^}]+)}');
+final macroRegExp = RegExp(r'{@macro\s+([^}]+)}');
/// Mixin for subclasses of ModelElement representing Elements that can be
/// inherited from one class to another.
@@ -168,7 +167,7 @@
ModelElement get definingEnclosingElement {
if (_definingEnclosingClass == null) {
_definingEnclosingClass =
- new ModelElement.fromElement(element.enclosingElement, packageGraph);
+ ModelElement.fromElement(element.enclosingElement, packageGraph);
}
return _definingEnclosingClass;
}
@@ -328,11 +327,11 @@
InheritableAccessor accessor;
if (element == null) return null;
if (inheritedAccessors.contains(element)) {
- accessor = new ModelElement.from(
+ accessor = ModelElement.from(
element, enclosingClass.library, enclosingClass.packageGraph,
enclosingClass: enclosingClass);
} else {
- accessor = new ModelElement.from(
+ accessor = ModelElement.from(
element, enclosingClass.library, enclosingClass.packageGraph);
}
return accessor;
@@ -382,7 +381,7 @@
accessor = PackageGraph.getBasestElement(accessor);
}
Class parentClass =
- new ModelElement.fromElement(t.element, packageGraph);
+ ModelElement.fromElement(t.element, packageGraph);
List<Field> possibleFields = [];
possibleFields.addAll(parentClass.allInstanceFields);
possibleFields.addAll(parentClass.staticProperties);
@@ -487,8 +486,7 @@
_accessor.enclosingElement.enclosingElement);
}
- return new ModelElement.from(
- _accessor.enclosingElement, library, packageGraph);
+ return ModelElement.from(_accessor.enclosingElement, library, packageGraph);
}
@override
@@ -562,7 +560,7 @@
_superclassConstraints = (element as ClassElement)
.superclassConstraints
.map<ParameterizedElementType>(
- (InterfaceType i) => new ElementType.from(i, packageGraph))
+ (InterfaceType i) => ElementType.from(i, packageGraph))
.toList();
}
return _superclassConstraints;
@@ -608,18 +606,18 @@
packageGraph.specialClasses.addSpecial(this);
_mixins = _cls.mixins
.map((f) {
- DefinedElementType t = new ElementType.from(f, packageGraph);
+ DefinedElementType t = ElementType.from(f, packageGraph);
return t;
})
.where((mixin) => mixin != null)
.toList(growable: false);
if (_cls.supertype != null && _cls.supertype.element.supertype != null) {
- supertype = new ElementType.from(_cls.supertype, packageGraph);
+ supertype = ElementType.from(_cls.supertype, packageGraph);
}
_interfaces = _cls.interfaces
- .map((f) => new ElementType.from(f, packageGraph) as DefinedElementType)
+ .map((f) => ElementType.from(f, packageGraph) as DefinedElementType)
.toList(growable: false);
}
@@ -678,7 +676,7 @@
Map<Element, ModelElement> get allElements {
if (_allElements == null) {
- _allElements = new Map();
+ _allElements = Map();
for (ModelElement me in allModelElements) {
assert(!_allElements.containsKey(me.element));
_allElements[me.element] = me;
@@ -715,10 +713,10 @@
/// for Object.
ModelElement memberByExample(ModelElement example) {
if (_membersByName == null) {
- _membersByName = new Map();
+ _membersByName = Map();
for (ModelElement me in allModelElements) {
if (!_membersByName.containsKey(me.name)) {
- _membersByName[me.name] = new List();
+ _membersByName[me.name] = List();
}
_membersByName[me.name].add(me);
}
@@ -739,7 +737,7 @@
List<ModelElement> get allModelElements {
if (_allModelElements == null) {
- _allModelElements = new List.from(
+ _allModelElements = List.from(
quiver.concat([
allInstanceMethods,
allInstanceFields,
@@ -767,7 +765,7 @@
if (_constructors != null) return _constructors;
_constructors = _cls.constructors.map((e) {
- return new ModelElement.from(e, library, packageGraph) as Constructor;
+ return ModelElement.from(e, library, packageGraph) as Constructor;
}).toList(growable: true)
..sort(byName);
@@ -857,8 +855,8 @@
}).toSet();
for (ExecutableElement e in inheritedMethodElements) {
- Method m = new ModelElement.from(e, library, packageGraph,
- enclosingClass: this);
+ Method m =
+ ModelElement.from(e, library, packageGraph, enclosingClass: this);
_inheritedMethods.add(m);
}
_inheritedMethods.sort(byName);
@@ -882,8 +880,8 @@
!operatorNames.contains(e.name));
}).toSet();
for (ExecutableElement e in inheritedOperatorElements) {
- Operator o = new ModelElement.from(e, library, packageGraph,
- enclosingClass: this);
+ Operator o =
+ ModelElement.from(e, library, packageGraph, enclosingClass: this);
_inheritedOperators.add(o);
}
_inheritedOperators.sort(byName);
@@ -1042,7 +1040,7 @@
if ((parent.type as InterfaceType)?.superclass?.superclass == null) {
parent = null;
} else {
- parent = new ElementType.from(
+ parent = ElementType.from(
(parent.type as InterfaceType).superclass, packageGraph);
}
} else {
@@ -1068,7 +1066,7 @@
Map<String, ExecutableElement> imap = definingLibrary.inheritanceManager
.getMembersInheritedFromInterfaces(// ignore: deprecated_member_use
element);
- __inheritedElements = new List.from(cmap.values)
+ __inheritedElements = List.from(cmap.values)
..addAll(imap.values.where((e) => !cmap.containsKey(e.name)));
}
return __inheritedElements;
@@ -1079,14 +1077,12 @@
List<Field> get _allFields {
if (_fields != null) return _fields;
_fields = [];
- Set<PropertyAccessorElement> inheritedAccessors = new Set()
- ..addAll(_inheritedElements
- .where((e) => e is PropertyAccessorElement)
- .cast<PropertyAccessorElement>());
+ Set<PropertyAccessorElement> inheritedAccessors = Set()
+ ..addAll(_inheritedElements.whereType<PropertyAccessorElement>());
// This structure keeps track of inherited accessors, allowing lookup
// by field name (stripping the '=' from setters).
- Map<String, List<PropertyAccessorElement>> accessorMap = new Map();
+ Map<String, List<PropertyAccessorElement>> accessorMap = Map();
for (PropertyAccessorElement accessorElement in inheritedAccessors) {
String name = accessorElement.name.replaceFirst('=', '');
accessorMap.putIfAbsent(name, () => []);
@@ -1137,9 +1133,9 @@
Set<PropertyAccessorElement> inheritedAccessors,
[FieldElement f]) {
InheritableAccessor getter =
- new InheritableAccessor.from(getterElement, inheritedAccessors, this);
+ InheritableAccessor.from(getterElement, inheritedAccessors, this);
InheritableAccessor setter =
- new InheritableAccessor.from(setterElement, inheritedAccessors, this);
+ InheritableAccessor.from(setterElement, inheritedAccessors, this);
// Rebind getterElement/setterElement as ModelElement.from can resolve
// MultiplyInheritedExecutableElements or resolve Members.
getterElement = getter?.element;
@@ -1170,14 +1166,14 @@
if ((getter == null || getter.isInherited) &&
(setter == null || setter.isInherited)) {
// Field is 100% inherited.
- field = new ModelElement.from(f, library, packageGraph,
+ field = ModelElement.from(f, library, packageGraph,
enclosingClass: this, getter: getter, setter: setter);
} else {
// Field is <100% inherited (could be half-inherited).
// TODO(jcollins-g): Navigation is probably still confusing for
// half-inherited fields when traversing the inheritance tree. Make
// this better, somehow.
- field = new ModelElement.from(f, library, packageGraph,
+ field = ModelElement.from(f, library, packageGraph,
getter: getter, setter: setter);
}
_fields.add(field);
@@ -1189,7 +1185,7 @@
if (_allMethods != null) return _allMethods;
_allMethods = _cls.methods.map((e) {
- return new ModelElement.from(e, library, packageGraph) as Method;
+ return ModelElement.from(e, library, packageGraph) as Method;
}).toList(growable: false)
..sort(byName);
@@ -1203,8 +1199,8 @@
List<TypeParameter> get typeParameters {
if (_typeParameters == null) {
_typeParameters = _cls.typeParameters.map((f) {
- var lib = new Library(f.enclosingElement.library, packageGraph);
- return new ModelElement.from(f, lib, packageGraph) as TypeParameter;
+ var lib = Library(f.enclosingElement.library, packageGraph);
+ return ModelElement.from(f, lib, packageGraph) as TypeParameter;
}).toList();
}
return _typeParameters;
@@ -1231,8 +1227,8 @@
(enclosingElement as Class).typeParameters;
@override
- ModelElement get enclosingElement => new ModelElement.from(
- _constructor.enclosingElement, library, packageGraph);
+ ModelElement get enclosingElement =>
+ ModelElement.from(_constructor.enclosingElement, library, packageGraph);
String get fullKind {
if (isConst) return 'const $kind';
@@ -1341,8 +1337,8 @@
/// out that information from the given comments and returning the stripped
/// version.
String _stripAndSetDartdocCategories(String rawDocs) {
- Set<String> _categorySet = new Set();
- Set<String> _subCategorySet = new Set();
+ Set<String> _categorySet = Set();
+ Set<String> _subCategorySet = Set();
_hasCategorization = false;
rawDocs = rawDocs.replaceAllMapped(categoryRegexp, (match) {
@@ -1537,7 +1533,7 @@
}
ScoredCandidate scoreElementWithLibrary(Library lib) {
- ScoredCandidate scoredCandidate = new ScoredCandidate(this, lib);
+ ScoredCandidate scoredCandidate = ScoredCandidate(this, lib);
Iterable<String> resplit(Set<String> items) sync* {
for (String item in items) {
for (String subItem in item.split('_')) {
@@ -1593,7 +1589,7 @@
ModelElement get canonicalModelElement => null;
@override
- ModelElement get enclosingElement => throw new UnsupportedError('');
+ ModelElement get enclosingElement => throw UnsupportedError('');
/// And similiarly, even if someone references it directly it can have
/// no hyperlink.
@@ -1625,7 +1621,7 @@
if (_instanceProperties == null) {
_instanceProperties = super
.instanceProperties
- .map((Field p) => new ModelElement.from(
+ .map((Field p) => ModelElement.from(
p.element, p.library, p.packageGraph,
getter: p.getter, setter: p.setter) as EnumField)
.toList(growable: false);
@@ -1737,7 +1733,7 @@
PackageGraph packageGraph,
Accessor getter,
Accessor setter) {
- Field newField = new Field(element, library, packageGraph, getter, setter);
+ Field newField = Field(element, library, packageGraph, getter, setter);
newField._isInherited = true;
newField._enclosingClass = enclosingClass;
// Can't set _isInherited to true if this is the defining element, because
@@ -1751,7 +1747,7 @@
// Verify that hasSetter and hasGetterNoSetter are mutually exclusive,
// to prevent displaying more or less than one summary.
if (isPublic) {
- Set<bool> assertCheck = new Set()
+ Set<bool> assertCheck = Set()
..addAll([hasPublicSetter, hasPublicGetterNoSetter]);
assert(assertCheck.containsAll([true, false]));
}
@@ -1763,7 +1759,7 @@
ModelElement get enclosingElement {
if (_enclosingClass == null) {
_enclosingClass =
- new ModelElement.from(_field.enclosingElement, library, packageGraph);
+ ModelElement.from(_field.enclosingElement, library, packageGraph);
}
return _enclosingClass;
}
@@ -1804,7 +1800,7 @@
@override
List<String> get annotations {
- List<String> all_annotations = new List<String>();
+ List<String> all_annotations = List<String>();
all_annotations.addAll(super.annotations);
if (element is PropertyInducingElement) {
@@ -1862,7 +1858,7 @@
String fieldSourceCode = modelNode.sourceCode ?? '';
String getterSourceCode = getter?.sourceCode ?? '';
String setterSourceCode = setter?.sourceCode ?? '';
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
if (fieldSourceCode.isNotEmpty) {
buffer.write(fieldSourceCode);
}
@@ -1902,7 +1898,7 @@
}
Set<String> get comboFeatures {
- Set<String> allFeatures = new Set();
+ Set<String> allFeatures = Set();
if (hasExplicitGetter && hasPublicGetter) {
allFeatures.addAll(getter.features);
}
@@ -1933,8 +1929,7 @@
.toString();
Element staticElement =
(constantInitializer as InstanceCreationExpression).staticElement;
- Constructor target =
- new ModelElement.fromElement(staticElement, packageGraph);
+ Constructor target = ModelElement.fromElement(staticElement, packageGraph);
Class targetClass = target.enclosingElement;
// TODO(jcollins-g): this logic really should be integrated into Constructor,
// but that's not trivial because of linkedName's usage.
@@ -2001,7 +1996,7 @@
if (!hasAccessorsWithDocs) {
_oneLineDoc = computeOneLineDoc();
} else {
- StringBuffer buffer = new StringBuffer();
+ StringBuffer buffer = StringBuffer();
if (hasPublicGetter && getter.oneLineDoc.isNotEmpty) {
buffer.write('${getter.oneLineDoc}');
}
@@ -2015,7 +2010,7 @@
}
String get getterSetterDocumentationComment {
- var buffer = new StringBuffer();
+ var buffer = StringBuffer();
if (hasPublicGetter && !getter.isSynthetic) {
assert(getter.documentationFrom.length == 1);
@@ -2143,18 +2138,18 @@
Library._(ResolvedLibraryResult libraryResult, PackageGraph packageGraph,
this._package)
: super(libraryResult.element, null, packageGraph, null) {
- if (element == null) throw new ArgumentError.notNull('element');
+ if (element == null) throw ArgumentError.notNull('element');
// Initialize [packageGraph]'s cache of ModelNodes for relevant
// elements in this library.
- Map<String, CompilationUnit> _compilationUnitMap = new Map();
+ Map<String, CompilationUnit> _compilationUnitMap = Map();
_compilationUnitMap.addEntries(libraryResult.units
- .map((ResolvedUnitResult u) => new MapEntry(u.path, u.unit)));
+ .map((ResolvedUnitResult u) => MapEntry(u.path, u.unit)));
_HashableChildLibraryElementVisitor((Element e) =>
packageGraph._populateModelNodeFor(e, _compilationUnitMap))
.visitElement(element);
_exportedNamespace =
- new NamespaceBuilder().createExportNamespaceForLibrary(element);
+ NamespaceBuilder().createExportNamespaceForLibrary(element);
_package._allLibraries.add(this);
}
@@ -2183,15 +2178,13 @@
Accessor setter;
if (e is GetterSetterCombo) {
if (e.hasGetter) {
- getter =
- new ModelElement.fromElement(e.getter.element, packageGraph);
+ getter = ModelElement.fromElement(e.getter.element, packageGraph);
}
if (e.hasSetter) {
- setter =
- new ModelElement.fromElement(e.setter.element, packageGraph);
+ setter = ModelElement.fromElement(e.setter.element, packageGraph);
}
}
- return new ModelElement.from(
+ return ModelElement.from(
e.element,
packageGraph.findButDoNotCreateLibraryFor(e.element),
packageGraph,
@@ -2253,7 +2246,7 @@
// more than one package.
Set<Library> get packageImportedExportedLibraries {
if (_packageImportedExportedLibraries == null) {
- _packageImportedExportedLibraries = new Set();
+ _packageImportedExportedLibraries = Set();
packageGraph.publicLibraries
.where((l) => l.packageName == packageName)
.forEach((l) {
@@ -2269,14 +2262,14 @@
/// recursively.
Set<Library> get importedExportedLibraries {
if (_importedExportedLibraries == null) {
- _importedExportedLibraries = new Set();
- Set<LibraryElement> importedExportedLibraryElements = new Set();
+ _importedExportedLibraries = Set();
+ Set<LibraryElement> importedExportedLibraryElements = Set();
importedExportedLibraryElements
.addAll((element as LibraryElement).importedLibraries);
importedExportedLibraryElements
.addAll((element as LibraryElement).exportedLibraries);
for (LibraryElement l in importedExportedLibraryElements) {
- Library lib = new ModelElement.from(l, library, packageGraph);
+ Library lib = ModelElement.from(l, library, packageGraph);
_importedExportedLibraries.add(lib);
_importedExportedLibraries.addAll(lib.importedExportedLibraries);
}
@@ -2294,9 +2287,9 @@
for (ImportElement i in (element as LibraryElement).imports) {
// Ignore invalid imports.
if (i.prefix?.name != null && i.importedLibrary != null) {
- _prefixToLibrary.putIfAbsent(i.prefix?.name, () => new Set());
- _prefixToLibrary[i.prefix?.name].add(
- new ModelElement.from(i.importedLibrary, library, packageGraph));
+ _prefixToLibrary.putIfAbsent(i.prefix?.name, () => Set());
+ _prefixToLibrary[i.prefix?.name]
+ .add(ModelElement.from(i.importedLibrary, library, packageGraph));
}
}
}
@@ -2334,9 +2327,9 @@
@override
String _buildDocumentationAddition(String rawDocs) {
rawDocs = super._buildDocumentationAddition(rawDocs);
- Set<String> newCanonicalFor = new Set();
- Set<String> notFoundInAllModelElements = new Set();
- final canonicalRegExp = new RegExp(r'{@canonicalFor\s([^}]+)}');
+ Set<String> newCanonicalFor = Set();
+ Set<String> notFoundInAllModelElements = Set();
+ final canonicalRegExp = RegExp(r'{@canonicalFor\s([^}]+)}');
rawDocs = rawDocs.replaceAllMapped(canonicalRegExp, (Match match) {
newCanonicalFor.add(match.group(1));
notFoundInAllModelElements.add(match.group(1));
@@ -2365,11 +2358,10 @@
if (_enums != null) return _enums;
List<ClassElement> enumClasses = [];
enumClasses.addAll(_exportedNamespace.definedNames.values
- .where((e) => e is ClassElement)
- .cast<ClassElement>()
+ .whereType<ClassElement>()
.where((element) => element.isEnum));
_enums = enumClasses
- .map((e) => new ModelElement.from(e, this, packageGraph) as Enum)
+ .map((e) => ModelElement.from(e, this, packageGraph) as Enum)
.toList(growable: false)
..sort(byName);
@@ -2387,7 +2379,7 @@
.whereType<ClassElement>()
.where((ClassElement c) => c.isMixin));
_mixins = mixinClasses
- .map((e) => new ModelElement.from(e, this, packageGraph) as Mixin)
+ .map((e) => ModelElement.from(e, this, packageGraph) as Mixin)
.toList(growable: false)
..sort(byName);
return _mixins;
@@ -2408,17 +2400,16 @@
List<ModelFunction> get functions {
if (_functions != null) return _functions;
- Set<FunctionElement> elements = new Set();
+ Set<FunctionElement> elements = Set();
elements.addAll(_libraryElement.definingCompilationUnit.functions);
for (CompilationUnitElement cu in _libraryElement.parts) {
elements.addAll(cu.functions);
}
- elements.addAll(_exportedNamespace.definedNames.values
- .where((e) => e is FunctionElement)
- .cast<FunctionElement>());
+ elements.addAll(
+ _exportedNamespace.definedNames.values.whereType<FunctionElement>());
_functions = elements.map((e) {
- return new ModelElement.from(e, this, packageGraph) as ModelFunction;
+ return ModelElement.from(e, this, packageGraph) as ModelFunction;
}).toList(growable: false)
..sort(byName);
@@ -2440,7 +2431,7 @@
InheritanceManager get inheritanceManager {
if (_inheritanceManager == null) {
// ignore: deprecated_member_use
- _inheritanceManager = new InheritanceManager(element);
+ _inheritanceManager = InheritanceManager(element);
}
return _inheritanceManager;
}
@@ -2486,7 +2477,7 @@
PackageMeta get packageMeta {
if (_packageMeta == null) {
- _packageMeta = new PackageMeta.fromElement(element, config);
+ _packageMeta = PackageMeta.fromElement(element, config);
}
return _packageMeta;
}
@@ -2505,7 +2496,7 @@
List<Typedef> get typedefs {
if (_typedefs != null) return _typedefs;
- Set<FunctionTypeAliasElement> elements = new Set();
+ Set<FunctionTypeAliasElement> elements = Set();
elements
.addAll(_libraryElement.definingCompilationUnit.functionTypeAliases);
for (CompilationUnitElement cu in _libraryElement.parts) {
@@ -2513,10 +2504,9 @@
}
elements.addAll(_exportedNamespace.definedNames.values
- .where((e) => e is FunctionTypeAliasElement)
- .cast<FunctionTypeAliasElement>());
+ .whereType<FunctionTypeAliasElement>());
_typedefs = elements
- .map((e) => new ModelElement.from(e, this, packageGraph) as Typedef)
+ .map((e) => ModelElement.from(e, this, packageGraph) as Typedef)
.toList(growable: false)
..sort(byName);
@@ -2526,7 +2516,7 @@
List<Class> get _allClasses {
if (_classes != null) return _classes;
- Set<ClassElement> types = new Set();
+ Set<ClassElement> types = Set();
types.addAll(_libraryElement.definingCompilationUnit.types);
for (CompilationUnitElement cu in _libraryElement.parts) {
types.addAll(cu.types);
@@ -2543,7 +2533,7 @@
.where((element) => !element.isEnum));
_classes = types
- .map((e) => new ModelElement.from(e, this, packageGraph) as Class)
+ .map((e) => ModelElement.from(e, this, packageGraph) as Class)
.toList(growable: false)
..sort(byName);
@@ -2560,7 +2550,7 @@
List<TopLevelVariable> _getVariables() {
if (_variables != null) return _variables;
- Set<TopLevelVariableElement> elements = new Set();
+ Set<TopLevelVariableElement> elements = Set();
elements.addAll(_libraryElement.definingCompilationUnit.topLevelVariables);
for (CompilationUnitElement cu in _libraryElement.parts) {
elements.addAll(cu.topLevelVariables);
@@ -2574,13 +2564,13 @@
for (TopLevelVariableElement element in elements) {
Accessor getter;
if (element.getter != null) {
- getter = new ModelElement.from(element.getter, this, packageGraph);
+ getter = ModelElement.from(element.getter, this, packageGraph);
}
Accessor setter;
if (element.setter != null) {
- setter = new ModelElement.from(element.setter, this, packageGraph);
+ setter = ModelElement.from(element.setter, this, packageGraph);
}
- ModelElement me = new ModelElement.from(element, this, packageGraph,
+ ModelElement me = ModelElement.from(element, this, packageGraph,
getter: getter, setter: setter);
_variables.add(me);
}
@@ -2651,10 +2641,10 @@
/// in this library. Used for code reference lookups.
Map<String, Set<ModelElement>> get modelElementsNameMap {
if (_modelElementsNameMap == null) {
- _modelElementsNameMap = new Map<String, Set<ModelElement>>();
+ _modelElementsNameMap = Map<String, Set<ModelElement>>();
allModelElements.forEach((ModelElement modelElement) {
_modelElementsNameMap.putIfAbsent(
- modelElement.fullyQualifiedNameWithoutLibrary, () => new Set());
+ modelElement.fullyQualifiedNameWithoutLibrary, () => Set());
_modelElementsNameMap[modelElement.fullyQualifiedNameWithoutLibrary]
.add(modelElement);
});
@@ -2690,12 +2680,12 @@
]);
}),
]);
- _modelElementsMap = new Map<Element, Set<ModelElement>>();
+ _modelElementsMap = Map<Element, Set<ModelElement>>();
results.forEach((modelElement) {
- _modelElementsMap.putIfAbsent(modelElement.element, () => new Set());
+ _modelElementsMap.putIfAbsent(modelElement.element, () => Set());
_modelElementsMap[modelElement.element].add(modelElement);
});
- _modelElementsMap.putIfAbsent(element, () => new Set());
+ _modelElementsMap.putIfAbsent(element, () => Set());
_modelElementsMap[element].add(this);
}
return _modelElementsMap;
@@ -2744,15 +2734,15 @@
void _calcTypeParameters() {
typeParameters = _method.typeParameters.map((f) {
- return new ModelElement.from(f, library, packageGraph) as TypeParameter;
+ return ModelElement.from(f, library, packageGraph) as TypeParameter;
}).toList();
}
@override
ModelElement get enclosingElement {
if (_enclosingClass == null) {
- _enclosingClass = new ModelElement.from(
- _method.enclosingElement, library, packageGraph);
+ _enclosingClass =
+ ModelElement.from(_method.enclosingElement, library, packageGraph);
}
return _enclosingClass;
}
@@ -2803,7 +2793,7 @@
Element e = t.getMethod(element.name);
if (e != null) {
assert(e.enclosingElement is ClassElement);
- return new ModelElement.fromElement(e, packageGraph);
+ return ModelElement.fromElement(e, packageGraph);
}
}
return null;
@@ -2858,8 +2848,8 @@
Library library,
PackageGraph packageGraph,
Class enclosingClass) {
- Iterable<Inheritable> inheritables = e.inheritedElements.map(
- (ee) => new ModelElement.fromElement(ee, packageGraph) as Inheritable);
+ Iterable<Inheritable> inheritables = e.inheritedElements
+ .map((ee) => ModelElement.fromElement(ee, packageGraph) as Inheritable);
Inheritable foundInheritable;
int lowIndex = enclosingClass.inheritanceChain.length;
for (var inheritable in inheritables) {
@@ -2870,7 +2860,7 @@
lowIndex = index;
}
}
- return new ModelElement.from(foundInheritable.element, library, packageGraph,
+ return ModelElement.from(foundInheritable.element, library, packageGraph,
enclosingClass: enclosingClass);
}
@@ -2933,12 +2923,10 @@
Accessor getter;
Accessor setter;
if (e is PropertyInducingElement) {
- getter =
- e.getter != null ? new ModelElement.from(e.getter, lib, p) : null;
- setter =
- e.setter != null ? new ModelElement.from(e.setter, lib, p) : null;
+ getter = e.getter != null ? ModelElement.from(e.getter, lib, p) : null;
+ setter = e.setter != null ? ModelElement.from(e.setter, lib, p) : null;
}
- return new ModelElement.from(e, lib, p, getter: getter, setter: setter);
+ return ModelElement.from(e, lib, p, getter: getter, setter: setter);
}
// TODO(jcollins-g): this way of using the optional parameter is messy,
@@ -2974,8 +2962,7 @@
originalMember = e;
e = basest;
}
- Tuple3<Element, Library, Class> key =
- new Tuple3(e, library, enclosingClass);
+ Tuple3<Element, Library, Class> key = Tuple3(e, library, enclosingClass);
ModelElement newModelElement;
if (e.kind != ElementKind.DYNAMIC &&
packageGraph._allConstructedModelElements.containsKey(key)) {
@@ -2983,86 +2970,83 @@
assert(newModelElement.element is! MultiplyInheritedExecutableElement);
} else {
if (e.kind == ElementKind.DYNAMIC) {
- newModelElement = new Dynamic(e, packageGraph);
+ newModelElement = Dynamic(e, packageGraph);
}
if (e is MultiplyInheritedExecutableElement) {
newModelElement = resolveMultiplyInheritedElement(
e, library, packageGraph, enclosingClass);
} else {
if (e is LibraryElement) {
- newModelElement = new Library(e, packageGraph);
+ newModelElement = Library(e, packageGraph);
}
// Also handles enums
if (e is ClassElement) {
if (e.isMixin) {
- newModelElement = new Mixin(e, library, packageGraph);
+ newModelElement = Mixin(e, library, packageGraph);
} else if (e.isEnum) {
- newModelElement = new Enum(e, library, packageGraph);
+ newModelElement = Enum(e, library, packageGraph);
} else {
- newModelElement = new Class(e, library, packageGraph);
+ newModelElement = Class(e, library, packageGraph);
}
}
if (e is FunctionElement) {
- newModelElement = new ModelFunction(e, library, packageGraph);
+ newModelElement = ModelFunction(e, library, packageGraph);
} else if (e is GenericFunctionTypeElement) {
if (e is FunctionTypeAliasElement) {
assert(e.name != '');
- newModelElement =
- new ModelFunctionTypedef(e, library, packageGraph);
+ newModelElement = ModelFunctionTypedef(e, library, packageGraph);
} else {
if (e.enclosingElement is GenericTypeAliasElement) {
assert(e.enclosingElement.name != '');
- newModelElement =
- new ModelFunctionTypedef(e, library, packageGraph);
+ newModelElement = ModelFunctionTypedef(e, library, packageGraph);
} else {
// Allowing null here is allowed as a workaround for
// dart-lang/sdk#32005.
assert(e.name == '' || e.name == null);
- newModelElement = new ModelFunctionAnonymous(e, packageGraph);
+ newModelElement = ModelFunctionAnonymous(e, packageGraph);
}
}
}
if (e is FunctionTypeAliasElement) {
- newModelElement = new Typedef(e, library, packageGraph);
+ newModelElement = Typedef(e, library, packageGraph);
}
if (e is FieldElement) {
if (enclosingClass == null) {
if (e.isEnumConstant) {
int index =
e.computeConstantValue().getField(e.name).toIntValue();
- newModelElement = new EnumField.forConstant(
+ newModelElement = EnumField.forConstant(
index, e, library, packageGraph, getter);
// ignore: unnecessary_cast
} else if ((e.enclosingElement as ClassElement).isEnum) {
newModelElement =
- new EnumField(e, library, packageGraph, getter, setter);
+ EnumField(e, library, packageGraph, getter, setter);
} else {
- newModelElement =
- new Field(e, library, packageGraph, getter, setter);
+ newModelElement = Field(e, library, packageGraph, getter, setter);
}
} else {
// EnumFields can't be inherited, so this case is simpler.
- newModelElement = new Field.inherited(
+ newModelElement = Field.inherited(
e, enclosingClass, library, packageGraph, getter, setter);
}
}
if (e is ConstructorElement) {
- newModelElement = new Constructor(e, library, packageGraph);
+ newModelElement = Constructor(e, library, packageGraph);
}
if (e is MethodElement && e.isOperator) {
if (enclosingClass == null) {
- newModelElement = new Operator(e, library, packageGraph);
+ newModelElement = Operator(e, library, packageGraph);
} else {
- newModelElement = new Operator.inherited(
+ newModelElement = Operator.inherited(
e, enclosingClass, library, packageGraph,
originalMember: originalMember);
}
}
if (e is MethodElement && !e.isOperator) {
if (enclosingClass == null) {
- newModelElement = new Method(e, library, packageGraph);
+ newModelElement = Method(e, library, packageGraph);
} else {
- newModelElement = new Method.inherited(
+ newModelElement = Method.inherited(
e, enclosingClass, library, packageGraph,
originalMember: originalMember);
}
@@ -3070,29 +3054,28 @@
if (e is TopLevelVariableElement) {
assert(getter != null || setter != null);
newModelElement =
- new TopLevelVariable(e, library, packageGraph, getter, setter);
+ TopLevelVariable(e, library, packageGraph, getter, setter);
}
if (e is PropertyAccessorElement) {
// TODO(jcollins-g): why test for ClassElement in enclosingElement?
if (e.enclosingElement is ClassElement ||
e is MultiplyInheritedExecutableElement) {
if (enclosingClass == null) {
- newModelElement =
- new InheritableAccessor(e, library, packageGraph);
+ newModelElement = InheritableAccessor(e, library, packageGraph);
} else {
- newModelElement = new InheritableAccessor.inherited(
+ newModelElement = InheritableAccessor.inherited(
e, library, packageGraph, enclosingClass,
originalMember: originalMember);
}
} else {
- newModelElement = new Accessor(e, library, packageGraph, null);
+ newModelElement = Accessor(e, library, packageGraph, null);
}
}
if (e is TypeParameterElement) {
- newModelElement = new TypeParameter(e, library, packageGraph);
+ newModelElement = TypeParameter(e, library, packageGraph);
}
if (e is ParameterElement) {
- newModelElement = new Parameter(e, library, packageGraph,
+ newModelElement = Parameter(e, library, packageGraph,
originalMember: originalMember);
}
}
@@ -3105,9 +3088,9 @@
if (library != null && newModelElement is! Parameter) {
library.packageGraph._allConstructedModelElements[key] = newModelElement;
if (newModelElement is Inheritable) {
- Tuple2<Element, Library> iKey = new Tuple2(e, library);
+ Tuple2<Element, Library> iKey = Tuple2(e, library);
library.packageGraph._allInheritableElements
- .putIfAbsent(iKey, () => new Set());
+ .putIfAbsent(iKey, () => Set());
library.packageGraph._allInheritableElements[iKey].add(newModelElement);
}
}
@@ -3162,7 +3145,7 @@
annotationElement != null &&
annotationClassElement != null) {
annotationClass =
- new ModelElement.fromElement(annotationClassElement, packageGraph)
+ ModelElement.fromElement(annotationClassElement, packageGraph)
as Class;
}
// Some annotations are intended to be invisible (@pragma)
@@ -3226,22 +3209,22 @@
@override
DartdocOptionContext get config {
if (_config == null) {
- _config = new DartdocOptionContext.fromContextElement(
- packageGraph.config, element);
+ _config =
+ DartdocOptionContext.fromContextElement(packageGraph.config, element);
}
return _config;
}
@override
Set<String> get locationPieces {
- return new Set.from(element.location
+ return Set.from(element.location
.toString()
.split(locationSplitter)
.where((s) => s.isNotEmpty));
}
Set<String> _baseFeatures() {
- Set<String> allFeatures = new Set<String>();
+ Set<String> allFeatures = Set<String>();
allFeatures.addAll(annotations);
// Replace the @override annotation with a feature that explicitly
@@ -3298,7 +3281,7 @@
String _sourceHref;
String get sourceHref {
- _sourceHref ??= new SourceLinker.fromElement(this).href();
+ _sourceHref ??= SourceLinker.fromElement(this).href();
return _sourceHref;
}
@@ -3321,7 +3304,7 @@
Inheritable thisInheritable = (this as Inheritable);
Class definingEnclosingClass =
thisInheritable.definingEnclosingElement as Class;
- ModelElement fromThis = new ModelElement.fromElement(
+ ModelElement fromThis = ModelElement.fromElement(
element, definingEnclosingClass.packageGraph);
docFrom = fromThis.documentationFrom;
} else {
@@ -3459,7 +3442,7 @@
// Start with our top-level element.
ModelElement warnable =
- new ModelElement.fromElement(topLevelElement, packageGraph);
+ ModelElement.fromElement(topLevelElement, packageGraph);
if (candidateLibraries.length > 1) {
// Heuristic scoring to determine which library a human likely
// considers this element to be primarily 'from', and therefore,
@@ -3687,11 +3670,11 @@
(_originalMember is ExecutableMember ||
_originalMember is ParameterMember)) {
if (_originalMember is ExecutableMember) {
- _modelType = new ElementType.from(
+ _modelType = ElementType.from(
(_originalMember as ExecutableMember).type, packageGraph);
} else {
// ParameterMember
- _modelType = new ElementType.from(
+ _modelType = ElementType.from(
(_originalMember as ParameterMember).type, packageGraph);
}
} else if (element is ExecutableElement ||
@@ -3699,8 +3682,7 @@
element is ParameterElement ||
element is TypeDefiningElement ||
element is PropertyInducingElement) {
- _modelType =
- new ElementType.from((element as dynamic).type, packageGraph);
+ _modelType = ElementType.from((element as dynamic).type, packageGraph);
}
}
return _modelType;
@@ -3742,8 +3724,8 @@
// elsewhere as appropriate?
List<Parameter> get allParameters {
if (_allParameters == null) {
- final Set<Parameter> recursedParameters = new Set();
- final Set<Parameter> newParameters = new Set();
+ final Set<Parameter> recursedParameters = Set();
+ final Set<Parameter> newParameters = Set();
if (this is GetterSetterCombo &&
(this as GetterSetterCombo).setter != null) {
newParameters.addAll((this as GetterSetterCombo).setter.parameters);
@@ -3765,7 +3747,7 @@
List<Parameter> get parameters {
if (!canHaveParameters) {
- throw new StateError("$element cannot have parameters");
+ throw StateError("$element cannot have parameters");
}
if (_parameters == null) {
@@ -3787,9 +3769,8 @@
}
}
- _parameters = new UnmodifiableListView<Parameter>(params
- .map((p) =>
- new ModelElement.from(p, library, packageGraph) as Parameter)
+ _parameters = UnmodifiableListView<Parameter>(params
+ .map((p) => ModelElement.from(p, library, packageGraph) as Parameter)
.toList());
}
return _parameters;
@@ -3828,7 +3809,7 @@
Documentation get _documentation {
if (__documentation != null) return __documentation;
- __documentation = new Documentation.forElement(this);
+ __documentation = Documentation.forElement(this);
return __documentation;
}
@@ -3846,7 +3827,7 @@
String renderParam(
Parameter param, String suffix, bool showMetadata, bool showNames) {
- StringBuffer buf = new StringBuffer();
+ StringBuffer buf = StringBuffer();
ElementType paramModelType = param.modelType;
buf.write('<span class="parameter" id="${param.htmlId}">');
@@ -3915,7 +3896,7 @@
List<Parameter> namedParams =
parameters.where((Parameter p) => p.isOptionalNamed).toList();
- StringBuffer builder = new StringBuffer();
+ StringBuffer builder = StringBuffer();
// prefix
if (requiredParams.isEmpty && positionalParams.isNotEmpty) {
@@ -4013,7 +3994,7 @@
///
String _injectExamples(String rawdocs) {
final dirPath = package.packageMeta.dir.path;
- RegExp exampleRE = new RegExp(r'{@example\s+([^}]+)}');
+ RegExp exampleRE = RegExp(r'{@example\s+([^}]+)}');
return rawdocs.replaceAllMapped(exampleRE, (match) {
var args = _getExampleArgs(match[1]);
if (args == null) {
@@ -4025,7 +4006,7 @@
var replacement = match[0]; // default to fully matched string.
- var fragmentFile = new File(path.join(dirPath, args['file']));
+ var fragmentFile = File(path.join(dirPath, args['file']));
if (fragmentFile.existsSync()) {
replacement = fragmentFile.readAsStringSync();
if (lang.isNotEmpty) {
@@ -4045,7 +4026,7 @@
static Future<String> _replaceAllMappedAsync(
String string, Pattern exp, Future<String> replace(Match match)) async {
- StringBuffer replaced = new StringBuffer();
+ StringBuffer replaced = StringBuffer();
int currentIndex = 0;
for (Match match in exp.allMatches(string)) {
String prefix = match.input.substring(currentIndex, match.start);
@@ -4176,14 +4157,14 @@
// Matches all youtube directives (even some invalid ones). This is so
// we can give good error messages if the directive is malformed, instead of
// just silently emitting it as-is.
- final RegExp basicAnimationRegExp = new RegExp(r'''{@youtube\s+([^}]+)}''');
+ final RegExp basicAnimationRegExp = RegExp(r'''{@youtube\s+([^}]+)}''');
// Matches YouTube IDs from supported YouTube URLs.
final RegExp validYouTubeUrlRegExp =
- new RegExp('https://www\.youtube\.com/watch\\?v=([^&]+)\$');
+ RegExp('https://www\.youtube\.com/watch\\?v=([^&]+)\$');
return rawDocs.replaceAllMapped(basicAnimationRegExp, (basicMatch) {
- final ArgParser parser = new ArgParser();
+ final ArgParser parser = ArgParser();
final ArgResults args = _parseArgs(basicMatch[1], parser, 'youtube');
if (args == null) {
// Already warned about an invalid parameter if this happens.
@@ -4276,13 +4257,12 @@
// Matches all animation directives (even some invalid ones). This is so
// we can give good error messages if the directive is malformed, instead of
// just silently emitting it as-is.
- final RegExp basicAnimationRegExp =
- new RegExp(r'''{@animation\s+([^}]+)}''');
+ final RegExp basicAnimationRegExp = RegExp(r'''{@animation\s+([^}]+)}''');
// Matches valid javascript identifiers.
- final RegExp validIdRegExp = new RegExp(r'^[a-zA-Z_]\w*$');
+ final RegExp validIdRegExp = RegExp(r'^[a-zA-Z_]\w*$');
- final Set<String> uniqueIds = new Set<String>();
+ final Set<String> uniqueIds = Set<String>();
String getUniqueId(String base) {
int count = 1;
String id = '$base$count';
@@ -4294,7 +4274,7 @@
}
return rawDocs.replaceAllMapped(basicAnimationRegExp, (basicMatch) {
- final ArgParser parser = new ArgParser();
+ final ArgParser parser = ArgParser();
parser.addOption('id');
final ArgResults args = _parseArgs(basicMatch[1], parser, 'animation');
if (args == null) {
@@ -4589,7 +4569,7 @@
/// The computed file path, constructed from 'src' and 'region' will have key
/// 'file'.
Map<String, String> _getExampleArgs(String argsAsString) {
- ArgParser parser = new ArgParser();
+ ArgParser parser = ArgParser();
parser.addOption('lang');
parser.addOption('region');
ArgResults results = _parseArgs(argsAsString, parser, 'example');
@@ -4657,7 +4637,7 @@
ModelElement get enclosingElement {
// These are not considered to be a part of libraries, so we can simply
// blindly instantiate a ModelElement for their enclosing element.
- return new ModelElement.fromElement(element.enclosingElement, packageGraph);
+ return ModelElement.fromElement(element.enclosingElement, packageGraph);
}
@override
@@ -4705,7 +4685,7 @@
void _calcTypeParameters() {
typeParameters = _func.typeParameters.map((f) {
- return new ModelElement.from(f, library, packageGraph) as TypeParameter;
+ return ModelElement.from(f, library, packageGraph) as TypeParameter;
}).toList();
}
@@ -4746,7 +4726,7 @@
Set<String> get namePieces {
if (_namePieces == null) {
- _namePieces = new Set()
+ _namePieces = Set()
..addAll(name.split(locationSplitter).where((s) => s.isNotEmpty));
}
return _namePieces;
@@ -4778,7 +4758,7 @@
}
class Operator extends Method {
- static const Map<String, String> friendlyNames = const {
+ static const Map<String, String> friendlyNames = {
"[]": "get",
"[]=": "put",
"~": "bitwise_negate",
@@ -4839,10 +4819,10 @@
this.config, this.driver, this.sdk, this.hasEmbedderSdk)
: packageMeta = config.topLevelPackageMeta,
session = driver.currentSession {
- _packageWarningCounter = new PackageWarningCounter(this);
+ _packageWarningCounter = PackageWarningCounter(this);
// Make sure the default package exists, even if it has no libraries.
// This can happen for packages that only contain embedder SDKs.
- new Package.fromPackageMeta(packageMeta, this);
+ Package.fromPackageMeta(packageMeta, this);
}
/// Call during initialization to add a library to this [PackageGraph].
@@ -4853,9 +4833,9 @@
void addLibraryToGraph(ResolvedLibraryResult result) {
assert(!allLibrariesAdded);
LibraryElement element = result.element;
- var packageMeta = new PackageMeta.fromElement(element, config);
- var lib = new Library._(
- result, this, new Package.fromPackageMeta(packageMeta, this));
+ var packageMeta = PackageMeta.fromElement(element, config);
+ var lib =
+ Library._(result, this, Package.fromPackageMeta(packageMeta, this));
packageMap[packageMeta.name]._libraries.add(lib);
allLibraries[element] = lib;
}
@@ -4875,7 +4855,7 @@
assert(!_localDocumentationBuilt);
// From here on in, we might find special objects. Initialize the
// specialClasses handler so when we find them, they get added.
- specialClasses = new SpecialClasses();
+ specialClasses = SpecialClasses();
// Go through docs of every ModelElement in package to pre-build the macros
// index. Uses toList() in order to get all the precaching on the stack.
List<Future> precacheFutures = precacheLocalDocs().toList();
@@ -4904,7 +4884,7 @@
/// Generate a list of futures for any docs that actually require precaching.
Iterable<Future> precacheLocalDocs() sync* {
// Prevent reentrancy.
- Set<ModelElement> precachedElements = new Set();
+ Set<ModelElement> precachedElements = Set();
Iterable<Future> precacheOneElement(ModelElement m) sync* {
for (ModelElement d
@@ -4961,13 +4941,13 @@
Map<String, Set<ModelElement>> get findRefElementCache {
if (_findRefElementCache == null) {
assert(packageGraph.allLibrariesAdded);
- _findRefElementCache = new Map();
+ _findRefElementCache = Map();
for (final modelElement
in filterNonDocumented(packageGraph.allLocalModelElements)) {
_findRefElementCache.putIfAbsent(
- modelElement.fullyQualifiedNameWithoutLibrary, () => new Set());
+ modelElement.fullyQualifiedNameWithoutLibrary, () => Set());
_findRefElementCache.putIfAbsent(
- modelElement.fullyQualifiedName, () => new Set());
+ modelElement.fullyQualifiedName, () => Set());
_findRefElementCache[modelElement.fullyQualifiedName].add(modelElement);
_findRefElementCache[modelElement.fullyQualifiedNameWithoutLibrary]
.add(modelElement);
@@ -4977,21 +4957,21 @@
}
// All library objects related to this package; a superset of _libraries.
- final Map<LibraryElement, Library> allLibraries = new Map();
+ final Map<LibraryElement, Library> allLibraries = Map();
/// Keep track of warnings
PackageWarningCounter _packageWarningCounter;
/// All ModelElements constructed for this package; a superset of [allModelElements].
final Map<Tuple3<Element, Library, Class>, ModelElement>
- _allConstructedModelElements = new Map();
+ _allConstructedModelElements = Map();
/// Anything that might be inheritable, place here for later lookup.
final Map<Tuple2<Element, Library>, Set<ModelElement>>
- _allInheritableElements = new Map();
+ _allInheritableElements = Map();
/// Map of Class.href to a list of classes implementing that class
- final Map<String, List<Class>> _implementors = new Map();
+ final Map<String, List<Class>> _implementors = Map();
/// PackageMeta for the default package.
final PackageMeta packageMeta;
@@ -5006,7 +4986,7 @@
Package get defaultPackage {
if (_defaultPackage == null) {
- _defaultPackage = new Package.fromPackageMeta(packageMeta, this);
+ _defaultPackage = Package.fromPackageMeta(packageMeta, this);
}
return _defaultPackage;
}
@@ -5027,7 +5007,7 @@
Map<Source, SdkLibrary> get sdkLibrarySources {
if (_sdkLibrarySources == null) {
- _sdkLibrarySources = new Map();
+ _sdkLibrarySources = Map();
for (SdkLibrary lib in sdk?.sdkLibraries) {
_sdkLibrarySources[sdk.mapDartUri(lib.shortName)] = lib;
}
@@ -5048,7 +5028,7 @@
bool packageDocumentedFor(ModelElement element) {
if (_allRootDirs == null) {
- _allRootDirs = new Set()
+ _allRootDirs = Set()
..addAll(publicLibraries.map((l) => l.packageMeta?.resolvedDir));
}
return (_allRootDirs.contains(element.library.packageMeta?.resolvedDir));
@@ -5056,14 +5036,13 @@
PackageWarningCounter get packageWarningCounter => _packageWarningCounter;
- final Set<Tuple3<Element, PackageWarning, String>> _warnAlreadySeen =
- new Set();
+ final Set<Tuple3<Element, PackageWarning, String>> _warnAlreadySeen = Set();
void warnOnElement(Warnable warnable, PackageWarning kind,
{String message,
Iterable<Locatable> referredFrom,
Iterable<String> extendedDebug}) {
- var newEntry = new Tuple3(warnable?.element, kind, message);
+ var newEntry = Tuple3(warnable?.element, kind, message);
if (_warnAlreadySeen.contains(newEntry)) {
return;
}
@@ -5270,16 +5249,16 @@
Iterable<Package> get documentedPackages =>
packages.where((p) => p.documentedWhere != DocumentLocation.missing);
- Map<LibraryElement, Set<Library>> _libraryElementReexportedBy = new Map();
+ Map<LibraryElement, Set<Library>> _libraryElementReexportedBy = Map();
/// Prevent cycles from breaking our stack.
- Set<Tuple2<Library, LibraryElement>> _reexportsTagged = new Set();
+ Set<Tuple2<Library, LibraryElement>> _reexportsTagged = Set();
void _tagReexportsFor(
final Library topLevelLibrary, final LibraryElement libraryElement,
[ExportElement lastExportedElement]) {
Tuple2<Library, LibraryElement> key =
- new Tuple2(topLevelLibrary, libraryElement);
+ Tuple2(topLevelLibrary, libraryElement);
if (_reexportsTagged.contains(key)) {
return;
}
@@ -5294,7 +5273,7 @@
referredFrom: <Locatable>[topLevelLibrary]);
return;
}
- _libraryElementReexportedBy.putIfAbsent(libraryElement, () => new Set());
+ _libraryElementReexportedBy.putIfAbsent(libraryElement, () => Set());
_libraryElementReexportedBy[libraryElement].add(topLevelLibrary);
for (ExportElement exportedElement in libraryElement.exports) {
_tagReexportsFor(
@@ -5308,8 +5287,8 @@
// Table must be reset if we're still in the middle of adding libraries.
if (allLibraries.keys.length != _lastSizeOfAllLibraries) {
_lastSizeOfAllLibraries = allLibraries.keys.length;
- _libraryElementReexportedBy = new Map<LibraryElement, Set<Library>>();
- _reexportsTagged = new Set();
+ _libraryElementReexportedBy = Map<LibraryElement, Set<Library>>();
+ _reexportsTagged = Set();
for (Library library in publicLibraries) {
_tagReexportsFor(library, library.element);
}
@@ -5323,7 +5302,7 @@
/// on more than just [allLocalModelElements] to make the error messages
/// comprehensive.
Map<String, Set<ModelElement>> get allHrefs {
- Map<String, Set<ModelElement>> hrefMap = new Map();
+ Map<String, Set<ModelElement>> hrefMap = Map();
// TODO(jcollins-g ): handle calculating hrefs causing new elements better
// than toList().
for (ModelElement modelElement
@@ -5336,13 +5315,13 @@
// TODO: see [Accessor.enclosingCombo]
if (modelElement is Accessor) continue;
if (modelElement.href == null) continue;
- hrefMap.putIfAbsent(modelElement.href, () => new Set());
+ hrefMap.putIfAbsent(modelElement.href, () => Set());
hrefMap[modelElement.href].add(modelElement);
}
for (Package package in packageMap.values) {
for (Library library in package.libraries) {
if (library.href == null) continue;
- hrefMap.putIfAbsent(library.href, () => new Set());
+ hrefMap.putIfAbsent(library.href, () => Set());
hrefMap[library.href].add(library);
}
}
@@ -5419,7 +5398,7 @@
/// and the class these inherit from should instead claim implementation.
Set<Class> get inheritThrough {
if (_inheritThrough == null) {
- _inheritThrough = new Set();
+ _inheritThrough = Set();
_inheritThrough.add(specialClasses[SpecialClass.interceptor]);
}
return _inheritThrough;
@@ -5431,7 +5410,7 @@
/// in that we should never count them as documentable annotations.
Set<Class> get invisibleAnnotations {
if (_invisibleAnnotations == null) {
- _invisibleAnnotations = new Set();
+ _invisibleAnnotations = Set();
_invisibleAnnotations.add(specialClasses[SpecialClass.pragma]);
}
return _invisibleAnnotations;
@@ -5440,7 +5419,7 @@
@override
String toString() => 'PackageGraph built from ${defaultPackage.name}';
- final Map<Element, Library> _canonicalLibraryFor = new Map();
+ final Map<Element, Library> _canonicalLibraryFor = Map();
/// Tries to find a top level library that references this element.
Library findCanonicalLibraryFor(Element e) {
@@ -5505,12 +5484,12 @@
// with member elements.
if (e is ClassMemberElement || e is PropertyAccessorElement) {
if (e is Member) e = getBasestElement(e);
- Set<ModelElement> candidates = new Set();
- Tuple2<Element, Library> iKey = new Tuple2(e, lib);
+ Set<ModelElement> candidates = Set();
+ Tuple2<Element, Library> iKey = Tuple2(e, lib);
Tuple4<Element, Library, Class, ModelElement> key =
- new Tuple4(e, lib, null, null);
+ Tuple4(e, lib, null, null);
Tuple4<Element, Library, Class, ModelElement> keyWithClass =
- new Tuple4(e, lib, preferredClass, null);
+ Tuple4(e, lib, preferredClass, null);
if (_allConstructedModelElements.containsKey(key)) {
candidates.add(_allConstructedModelElements[key]);
}
@@ -5528,16 +5507,14 @@
return false;
}));
}
- Set<ModelElement> matches = new Set()
+ Set<ModelElement> matches = Set()
..addAll(candidates.where((me) => me.isCanonical));
// It's possible to find accessors but no combos. Be sure that if we
// have Accessors, we find their combos too.
if (matches.any((me) => me is Accessor)) {
- List<GetterSetterCombo> combos = matches
- .where((me) => me is Accessor)
- .map((a) => (a as Accessor).enclosingCombo)
- .toList();
+ List<GetterSetterCombo> combos =
+ matches.whereType<Accessor>().map((a) => a.enclosingCombo).toList();
matches.addAll(combos);
assert(combos.every((c) => c.isCanonical));
}
@@ -5555,7 +5532,7 @@
!superChain.contains((me as EnclosedElement).enclosingElement));
// Assumed all matches are EnclosedElement because we've been told about a
// preferredClass.
- Set<Class> enclosingElements = new Set()
+ Set<Class> enclosingElements = Set()
..addAll(matches
.map((me) => (me as EnclosedElement).enclosingElement as Class));
for (Class c in superChain.reversed) {
@@ -5582,13 +5559,13 @@
Accessor setter;
if (e is PropertyInducingElement) {
if (e.getter != null) {
- getter = new ModelElement.from(e.getter, lib, packageGraph);
+ getter = ModelElement.from(e.getter, lib, packageGraph);
}
if (e.setter != null) {
- setter = new ModelElement.from(e.setter, lib, packageGraph);
+ setter = ModelElement.from(e.setter, lib, packageGraph);
}
}
- modelElement = new ModelElement.from(e, lib, packageGraph,
+ modelElement = ModelElement.from(e, lib, packageGraph,
getter: getter, setter: setter);
}
assert(modelElement is! Inheritable);
@@ -5626,11 +5603,11 @@
if (result.element.library == null) {
return null;
}
- Library foundLibrary = new Library._(
+ Library foundLibrary = Library._(
result,
this,
- new Package.fromPackageMeta(
- new PackageMeta.fromElement(result.element.library, config),
+ Package.fromPackageMeta(
+ PackageMeta.fromElement(result.element.library, config),
packageGraph));
allLibraries[result.element.library] = foundLibrary;
return foundLibrary;
@@ -5643,11 +5620,11 @@
if (_allModelElements == null) {
_allModelElements = [];
Set<Package> packagesToDo = packages.toSet();
- Set<Package> completedPackages = new Set();
+ Set<Package> completedPackages = Set();
while (packagesToDo.length > completedPackages.length) {
packagesToDo.difference(completedPackages).forEach((Package p) {
Set<Library> librariesToDo = p.allLibraries.toSet();
- Set<Library> completedLibraries = new Set();
+ Set<Library> completedLibraries = Set();
while (librariesToDo.length > completedLibraries.length) {
librariesToDo
.difference(completedLibraries)
@@ -5839,7 +5816,7 @@
Documentation get _documentation {
if (__documentation != null) return __documentation;
- __documentation = new Documentation.forElement(this);
+ __documentation = Documentation.forElement(this);
return __documentation;
}
@@ -5866,7 +5843,7 @@
String get location => path.toUri(documentationFile.file.path).toString();
@override
- Set<String> get locationPieces => new Set.from(<String>[location]);
+ Set<String> get locationPieces => Set.from(<String>[location]);
}
/// A category is a subcategory of a package, containing libraries tagged
@@ -5886,7 +5863,7 @@
final String _name;
@override
DartdocOptionContext config;
- final Set<Categorization> _allItems = new Set();
+ final Set<Categorization> _allItems = Set();
Category(this._name, this.package, this.config) {
_enums = [];
@@ -6015,8 +5992,8 @@
FileContents get documentationFile {
if (_documentationFile == null) {
if (categoryDefinition?.documentationMarkdown != null) {
- _documentationFile = new FileContents(
- new File(categoryDefinition.documentationMarkdown));
+ _documentationFile =
+ FileContents(File(categoryDefinition.documentationMarkdown));
}
}
return _documentationFile;
@@ -6063,8 +6040,8 @@
if (!packageGraph.packageMap.containsKey(packageName) &&
packageGraph.allLibrariesAdded) expectNonLocal = true;
- packageGraph.packageMap.putIfAbsent(packageName,
- () => new Package._(packageName, packageGraph, packageMeta));
+ packageGraph.packageMap.putIfAbsent(
+ packageName, () => Package._(packageName, packageGraph, packageMeta));
// Verify that we don't somehow decide to document locally a package picked
// up after all documented libraries are added, because that breaks the
// assumption that we've picked up all documented libraries and packages
@@ -6091,9 +6068,9 @@
/// Pieces of the location split by [locationSplitter] (removing package: and
/// slashes).
@override
- Set<String> get locationPieces => new Set();
+ Set<String> get locationPieces => Set();
- final Set<Library> _allLibraries = new Set();
+ final Set<Library> _allLibraries = Set();
bool get hasHomepage =>
packageMeta.homepage != null && packageMeta.homepage.isNotEmpty;
@@ -6122,7 +6099,7 @@
@override
String get documentationAsHtml {
if (_documentationAsHtml != null) return _documentationAsHtml;
- _documentationAsHtml = new Documentation.forElement(this).asHtml;
+ _documentationAsHtml = Documentation.forElement(this).asHtml;
return _documentationAsHtml;
}
@@ -6216,7 +6193,7 @@
// elsewhere.
case 'b':
{
- Version version = new Version.parse(packageMeta.version);
+ Version version = Version.parse(packageMeta.version);
return version.isPreRelease
? version.preRelease.first
: 'stable';
@@ -6267,15 +6244,13 @@
if (_nameToCategory.isEmpty) {
Category categoryFor(String category) {
_nameToCategory.putIfAbsent(
- category, () => new Category(category, this, config));
+ category, () => Category(category, this, config));
return _nameToCategory[category];
}
- _nameToCategory[null] = new Category(null, this, config);
- for (Categorization c in libraries.expand((l) => l
- .allCanonicalModelElements
- .where((e) => e is Categorization)
- .cast<Categorization>())) {
+ _nameToCategory[null] = Category(null, this, config);
+ for (Categorization c in libraries.expand(
+ (l) => l.allCanonicalModelElements.whereType<Categorization>())) {
for (String category in c.categoryNames) {
categoryFor(category).addItem(c);
}
@@ -6307,8 +6282,8 @@
@override
DartdocOptionContext get config {
if (_config == null) {
- _config = new DartdocOptionContext.fromContext(
- packageGraph.config, new Directory(packagePath));
+ _config = DartdocOptionContext.fromContext(
+ packageGraph.config, Directory(packagePath));
}
return _config;
}
@@ -6368,7 +6343,7 @@
@override
ModelElement get enclosingElement =>
- new ModelElement.from(_parameter.enclosingElement, library, packageGraph);
+ ModelElement.from(_parameter.enclosingElement, library, packageGraph);
bool get hasDefaultValue {
return _parameter.defaultValueCode != null &&
@@ -6377,7 +6352,7 @@
@override
String get href {
- throw new StateError('href not implemented for parameters');
+ throw StateError('href not implemented for parameters');
}
@override
@@ -6479,7 +6454,7 @@
// Verify that hasSetter and hasGetterNoSetter are mutually exclusive,
// to prevent displaying more or less than one summary.
if (isPublic) {
- Set<bool> assertCheck = new Set()
+ Set<bool> assertCheck = Set()
..addAll([hasPublicSetter, hasPublicGetterNoSetter]);
assert(assertCheck.containsAll([true, false]));
}
@@ -6583,7 +6558,7 @@
@override
List<TypeParameter> get typeParameters => _typedef.typeParameters.map((f) {
- return new ModelElement.from(f, library, packageGraph) as TypeParameter;
+ return ModelElement.from(f, library, packageGraph) as TypeParameter;
}).toList();
}
@@ -6594,7 +6569,7 @@
@override
ModelElement get enclosingElement =>
- new ModelElement.from(element.enclosingElement, library, packageGraph);
+ ModelElement.from(element.enclosingElement, library, packageGraph);
@override
String get href {
@@ -6615,7 +6590,7 @@
if (_boundType == null) {
var bound = _typeParameter.bound;
if (bound != null) {
- _boundType = new ElementType.from(bound, packageGraph);
+ _boundType = ElementType.from(bound, packageGraph);
}
}
return _boundType;
@@ -6657,7 +6632,7 @@
config.topLevelPackageMeta.runPubGet();
}
- PackageGraph newGraph = new PackageGraph.UninitializedPackageGraph(
+ PackageGraph newGraph = PackageGraph.UninitializedPackageGraph(
config, driver, sdk, hasEmbedderSdkFiles);
await getLibraries(newGraph);
await newGraph.initializePackageGraph();
@@ -6668,7 +6643,7 @@
DartSdk get sdk {
if (_sdk == null) {
- _sdk = new FolderBasedDartSdk(PhysicalResourceProvider.INSTANCE,
+ _sdk = FolderBasedDartSdk(PhysicalResourceProvider.INSTANCE,
PhysicalResourceProvider.INSTANCE.getFolder(config.sdkDir));
}
return _sdk;
@@ -6678,15 +6653,15 @@
EmbedderSdk get embedderSdk {
if (_embedderSdk == null && !config.topLevelPackageMeta.isSdk) {
- _embedderSdk = new EmbedderSdk(PhysicalResourceProvider.INSTANCE,
- new EmbedderYamlLocator(packageMap).embedderYamls);
+ _embedderSdk = EmbedderSdk(PhysicalResourceProvider.INSTANCE,
+ EmbedderYamlLocator(packageMap).embedderYamls);
}
return _embedderSdk;
}
static Map<String, List<file_system.Folder>> _calculatePackageMap(
file_system.Folder dir) {
- Map<String, List<file_system.Folder>> map = new Map();
+ Map<String, List<file_system.Folder>> map = Map();
var info = package_config.findPackagesFromFile(dir.toUri());
for (String name in info.packages) {
@@ -6717,21 +6692,21 @@
DartUriResolver get embedderResolver {
if (_embedderResolver == null) {
- _embedderResolver = new DartUriResolver(embedderSdk);
+ _embedderResolver = DartUriResolver(embedderSdk);
}
return _embedderResolver;
}
SourceFactory get sourceFactory {
List<UriResolver> resolvers = [];
- resolvers.add(new SdkExtUriResolver(packageMap));
- final UriResolver packageResolver = new PackageMapUriResolver(
- PhysicalResourceProvider.INSTANCE, packageMap);
+ resolvers.add(SdkExtUriResolver(packageMap));
+ final UriResolver packageResolver =
+ PackageMapUriResolver(PhysicalResourceProvider.INSTANCE, packageMap);
UriResolver sdkResolver;
if (embedderSdk == null || embedderSdk.urlMappings.isEmpty) {
// The embedder uri resolver has no mappings. Use the default Dart SDK
// uri resolver.
- sdkResolver = new DartUriResolver(sdk);
+ sdkResolver = DartUriResolver(sdk);
} else {
// The embedder uri resolver has mappings, use it instead of the default
// Dart SDK uri resolver.
@@ -6742,14 +6717,14 @@
/// never resolve to embedded SDK files, and the resolvers list must still
/// contain a DartUriResolver. This hack won't be necessary once analyzer
/// has a clean public API.
- resolvers.add(new PackageWithoutSdkResolver(packageResolver, sdkResolver));
+ resolvers.add(PackageWithoutSdkResolver(packageResolver, sdkResolver));
resolvers.add(sdkResolver);
resolvers.add(
- new file_system.ResourceUriResolver(PhysicalResourceProvider.INSTANCE));
+ file_system.ResourceUriResolver(PhysicalResourceProvider.INSTANCE));
assert(
resolvers.any((UriResolver resolver) => resolver is DartUriResolver));
- SourceFactory sourceFactory = new SourceFactory(resolvers);
+ SourceFactory sourceFactory = SourceFactory(resolvers);
return sourceFactory;
}
@@ -6757,9 +6732,9 @@
AnalysisDriver get driver {
if (_driver == null) {
- PerformanceLog log = new PerformanceLog(null);
- AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler(log);
- AnalysisOptionsImpl options = new AnalysisOptionsImpl();
+ PerformanceLog log = PerformanceLog(null);
+ AnalysisDriverScheduler scheduler = AnalysisDriverScheduler(log);
+ AnalysisOptionsImpl options = AnalysisOptionsImpl();
// TODO(jcollins-g): pass in an ExperimentStatus instead?
options.enabledExperiments = config.enableExperiment;
@@ -6767,12 +6742,12 @@
// TODO(jcollins-g): Make use of currently not existing API for managing
// many AnalysisDrivers
// TODO(jcollins-g): make use of DartProject isApi()
- _driver = new AnalysisDriver(
+ _driver = AnalysisDriver(
scheduler,
log,
PhysicalResourceProvider.INSTANCE,
- new MemoryByteStore(),
- new FileContentOverlay(),
+ MemoryByteStore(),
+ FileContentOverlay(),
null,
sourceFactory,
options);
@@ -6802,19 +6777,19 @@
name = name.substring(directoryCurrentPath.length);
if (name.startsWith(Platform.pathSeparator)) name = name.substring(1);
}
- JavaFile javaFile = new JavaFile(filePath).getAbsoluteFile();
- Source source = new FileBasedSource(javaFile);
+ JavaFile javaFile = JavaFile(filePath).getAbsoluteFile();
+ Source source = FileBasedSource(javaFile);
// TODO(jcollins-g): remove the manual reversal using embedderSdk when we
// upgrade to analyzer-0.30 (where DartUriResolver implements
// restoreAbsolute)
Uri uri = embedderSdk?.fromFileUri(source.uri)?.uri;
if (uri != null) {
- source = new FileBasedSource(javaFile, uri);
+ source = FileBasedSource(javaFile, uri);
} else {
uri = driver.sourceFactory.restoreUri(source);
if (uri != null) {
- source = new FileBasedSource(javaFile, uri);
+ source = FileBasedSource(javaFile, uri);
}
}
var sourceKind = await driver.getSourceKind(filePath);
@@ -6829,9 +6804,9 @@
}
Set<PackageMeta> _packageMetasForFiles(Iterable<String> files) {
- Set<PackageMeta> metas = new Set();
+ Set<PackageMeta> metas = Set();
for (String filename in files) {
- metas.add(new PackageMeta.fromFilename(filename));
+ metas.add(PackageMeta.fromFilename(filename));
}
return metas;
}
@@ -6848,7 +6823,7 @@
Set<String> files,
[bool Function(LibraryElement) isLibraryIncluded]) async {
isLibraryIncluded ??= (_) => true;
- Set<PackageMeta> lastPass = new Set();
+ Set<PackageMeta> lastPass = Set();
Set<PackageMeta> current;
do {
lastPass = _packageMetasForFiles(files);
@@ -6894,12 +6869,12 @@
[bool filterExcludes = true]) sync* {
final String sep = path.separator;
- Set<String> packageDirs = new Set()..add(basePackageDir);
+ Set<String> packageDirs = Set()..add(basePackageDir);
if (autoIncludeDependencies) {
Map<String, Uri> info = package_config
.findPackagesFromFile(
- new Uri.file(path.join(basePackageDir, 'pubspec.yaml')))
+ Uri.file(path.join(basePackageDir, 'pubspec.yaml')))
.asMap();
for (String packageName in info.keys) {
if (!filterExcludes || !config.exclude.contains(packageName)) {
@@ -6923,7 +6898,7 @@
if (path.isWithin(packageLibDir, lib) &&
!path.isWithin(packageLibSrcDir, lib)) {
// Only add the file if it does not contain 'part of'
- var contents = new File(lib).readAsStringSync();
+ var contents = File(lib).readAsStringSync();
if (contents.contains(newLinePartOfRegexp) ||
contents.startsWith(partOfRegexp)) {
@@ -6944,7 +6919,7 @@
Iterable<String> _includeExternalsFrom(Iterable<String> files) sync* {
for (String file in files) {
DartdocOptionContext fileContext =
- new DartdocOptionContext.fromContext(config, new File(file));
+ DartdocOptionContext.fromContext(config, File(file));
if (fileContext.includeExternal != null) {
yield* fileContext.includeExternal;
}
@@ -6960,7 +6935,7 @@
config.inputDir, config.autoIncludeDependencies);
}
files = quiver.concat([files, _includeExternalsFrom(files)]);
- return new Set.from(files.map((s) => new File(s).absolute.path));
+ return Set.from(files.map((s) => File(s).absolute.path));
}
Iterable<String> getEmbedderSdkFiles() sync* {
@@ -6969,7 +6944,7 @@
!config.topLevelPackageMeta.isSdk) {
for (String dartUri in embedderSdk.urlMappings.keys) {
Source source = embedderSdk.mapDartUri(dartUri);
- yield (new File(source.fullName)).absolute.path;
+ yield (File(source.fullName)).absolute.path;
}
}
}
@@ -6995,14 +6970,14 @@
return true;
}
- Set<LibraryElement> foundLibraries = new Set();
+ Set<LibraryElement> foundLibraries = Set();
await _parseLibraries(uninitializedPackageGraph.addLibraryToGraph,
foundLibraries, files, isLibraryIncluded);
if (config.include.isNotEmpty) {
Iterable knownLibraryNames = foundLibraries.map((l) => l.name);
- Set notFound = new Set.from(config.include)
- .difference(new Set.from(knownLibraryNames))
- .difference(new Set.from(config.exclude));
+ Set notFound = Set.from(config.include)
+ .difference(Set.from(knownLibraryNames))
+ .difference(Set.from(config.exclude));
if (notFound.isNotEmpty) {
throw 'Did not find: [${notFound.join(', ')}] in '
'known libraries: [${knownLibraryNames.join(', ')}]';
diff --git a/lib/src/model_utils.dart b/lib/src/model_utils.dart
index ca9fc98..42711b1 100644
--- a/lib/src/model_utils.dart
+++ b/lib/src/model_utils.dart
@@ -25,7 +25,7 @@
element.nameOffset != -1) {
CompilationUnit unit = compilationUnitMap[element.source.fullName];
if (unit != null) {
- var locator = new NodeLocator2(element.nameOffset);
+ var locator = NodeLocator2(element.nameOffset);
return (locator.searchWithin(unit)?.parent);
}
}
@@ -53,13 +53,13 @@
String getFileContentsFor(Element e) {
var location = e.source.fullName;
if (!_fileContents.containsKey(location)) {
- var contents = new File(location).readAsStringSync();
+ var contents = File(location).readAsStringSync();
_fileContents.putIfAbsent(location, () => contents);
}
return _fileContents[location];
}
-final RegExp slashes = new RegExp('[\/]');
+final RegExp slashes = RegExp('[\/]');
bool hasPrivateName(Element e) {
if (e.name == null) return false;
diff --git a/lib/src/package_meta.dart b/lib/src/package_meta.dart
index ac2dc7d..c6ba1bb 100644
--- a/lib/src/package_meta.dart
+++ b/lib/src/package_meta.dart
@@ -15,10 +15,10 @@
import 'logging.dart';
Map<String, PackageMeta> _packageMetaCache = {};
-Encoding utf8AllowMalformed = new Utf8Codec(allowMalformed: true);
+Encoding utf8AllowMalformed = Utf8Codec(allowMalformed: true);
Directory get defaultSdkDir {
- Directory sdkDir = new File(Platform.resolvedExecutable).parent.parent;
+ Directory sdkDir = File(Platform.resolvedExecutable).parent.parent;
assert(path.equals(sdkDir.path, PackageMeta.sdkDirParent(sdkDir).path));
return sdkDir;
}
@@ -49,8 +49,8 @@
for (List<String> paths in __sdkDirFilePathsPosix) {
List<String> windowsPaths = [];
for (String p in paths) {
- windowsPaths.add(path
- .joinAll(new path.Context(style: path.Style.posix).split(p)));
+ windowsPaths.add(
+ path.joinAll(path.Context(style: path.Style.posix).split(p)));
}
__sdkDirFilePaths.add(windowsPaths);
}
@@ -71,7 +71,7 @@
_sdkDirParent[dirPathCanonical] = null;
while (dir.existsSync()) {
if (_sdkDirFilePaths.every((List<String> l) {
- return l.any((f) => new File(path.join(dir.path, f)).existsSync());
+ return l.any((f) => File(path.join(dir.path, f)).existsSync());
})) {
_sdkDirParent[dirPathCanonical] = dir;
break;
@@ -99,14 +99,14 @@
// context since sdkDir is argOnly and this is supposed to be a temporary
// workaround.
if (libraryElement.isInSdk) {
- return new PackageMeta.fromDir(new Directory(config.sdkDir));
+ return PackageMeta.fromDir(Directory(config.sdkDir));
}
- return new PackageMeta.fromDir(
- new File(path.canonicalize(libraryElement.source.fullName)).parent);
+ return PackageMeta.fromDir(
+ File(path.canonicalize(libraryElement.source.fullName)).parent);
}
factory PackageMeta.fromFilename(String filename) {
- return new PackageMeta.fromDir(new File(filename).parent);
+ return PackageMeta.fromDir(File(filename).parent);
}
/// This factory is guaranteed to return the same object for any given
@@ -117,7 +117,7 @@
Directory original = dir.absolute;
dir = original;
if (!original.existsSync()) {
- throw new PackageMetaFailure(
+ throw PackageMetaFailure(
"fatal error: unable to locate the input directory at ${original.path}.");
}
@@ -126,12 +126,12 @@
// There are pubspec.yaml files inside the SDK. Ignore them.
Directory parentSdkDir = sdkDirParent(dir);
if (parentSdkDir != null) {
- packageMeta = new _SdkMeta(parentSdkDir);
+ packageMeta = _SdkMeta(parentSdkDir);
} else {
while (dir.existsSync()) {
- File pubspec = new File(path.join(dir.path, 'pubspec.yaml'));
+ File pubspec = File(path.join(dir.path, 'pubspec.yaml'));
if (pubspec.existsSync()) {
- packageMeta = new _FilePackageMeta(dir);
+ packageMeta = _FilePackageMeta(dir);
break;
}
// Allow a package to be at root (possible in a Windows setting with
@@ -220,8 +220,7 @@
FileContents._(this.file);
- factory FileContents(File file) =>
- file == null ? null : new FileContents._(file);
+ factory FileContents(File file) => file == null ? null : FileContents._(file);
String get contents => file.readAsStringSync(encoding: utf8AllowMalformed);
@@ -238,7 +237,7 @@
Map _pubspec;
_FilePackageMeta(Directory dir) : super(dir) {
- File f = new File(path.join(dir.path, 'pubspec.yaml'));
+ File f = File(path.join(dir.path, 'pubspec.yaml'));
if (f.existsSync()) {
_pubspec = loadYaml(f.readAsStringSync());
} else {
@@ -267,7 +266,7 @@
String hosted = path.canonicalize(dir.parent.parent.path);
String hostname = path.canonicalize(dir.parent.path);
if (path.basename(hosted) == 'hosted' &&
- new Directory(path.join(pubCacheRoot, '_temp')).existsSync()) {
+ Directory(path.join(pubCacheRoot, '_temp')).existsSync()) {
_hostedAt = path.basename(hostname);
}
}
@@ -280,7 +279,7 @@
@override
bool get needsPubGet =>
- !(new File(path.join(dir.path, '.packages')).existsSync());
+ !(File(path.join(dir.path, '.packages')).existsSync());
@override
void runPubGet() {
@@ -297,10 +296,10 @@
}
if (result.exitCode != 0) {
- StringBuffer buf = new StringBuffer();
+ StringBuffer buf = StringBuffer();
buf.writeln('${result.stdout}');
buf.writeln('${result.stderr}');
- throw new DartdocFailure('pub get failed: ${buf.toString().trim()}');
+ throw DartdocFailure('pub get failed: ${buf.toString().trim()}');
}
}
@@ -323,23 +322,22 @@
@override
FileContents getReadmeContents() {
if (_readme != null) return _readme;
- _readme =
- new FileContents(_locate(dir, ['readme.md', 'readme.txt', 'readme']));
+ _readme = FileContents(_locate(dir, ['readme.md', 'readme.txt', 'readme']));
return _readme;
}
@override
FileContents getLicenseContents() {
if (_license != null) return _license;
- _license = new FileContents(
- _locate(dir, ['license.md', 'license.txt', 'license']));
+ _license =
+ FileContents(_locate(dir, ['license.md', 'license.txt', 'license']));
return _license;
}
@override
FileContents getChangelogContents() {
if (_changelog != null) return _changelog;
- _changelog = new FileContents(
+ _changelog = FileContents(
_locate(dir, ['changelog.md', 'changelog.txt', 'changelog']));
return _changelog;
}
@@ -359,8 +357,7 @@
}
File _locate(Directory dir, List<String> fileNames) {
- List<File> files =
- new List<File>.from(dir.listSync().where((f) => f is File));
+ List<File> files = dir.listSync().whereType<File>().toList();
for (String name in fileNames) {
for (File f in files) {
@@ -396,7 +393,7 @@
@override
String get version {
- File versionFile = new File(path.join(dir.path, 'version'));
+ File versionFile = File(path.join(dir.path, 'version'));
if (versionFile.existsSync()) return versionFile.readAsStringSync().trim();
return 'unknown';
}
@@ -414,11 +411,11 @@
@override
FileContents getReadmeContents() {
- File f = new File(path.join(dir.path, 'lib', 'api_readme.md'));
+ File f = File(path.join(dir.path, 'lib', 'api_readme.md'));
if (!f.existsSync()) {
- f = new File(path.join(dir.path, 'api_readme.md'));
+ f = File(path.join(dir.path, 'api_readme.md'));
}
- return f.existsSync() ? new FileContents(f) : null;
+ return f.existsSync() ? FileContents(f) : null;
}
@override
diff --git a/lib/src/source_linker.dart b/lib/src/source_linker.dart
index cfa64ad..7a2def8 100644
--- a/lib/src/source_linker.dart
+++ b/lib/src/source_linker.dart
@@ -9,7 +9,7 @@
import 'package:dartdoc/src/model.dart';
import 'package:path/path.dart' as path;
-final uriTemplateRegexp = new RegExp(r'(%[frl]%)');
+final uriTemplateRegexp = RegExp(r'(%[frl]%)');
abstract class SourceLinkerOptionContext implements DartdocOptionContextBase {
List<String> get linkToSourceExcludes =>
@@ -27,20 +27,20 @@
Future<List<DartdocOption>> createSourceLinkerOptions() async {
return <DartdocOption>[
- new DartdocOptionSet('linkToSource')
+ DartdocOptionSet('linkToSource')
..addAll([
- new DartdocOptionArgFile<List<String>>('excludes', [],
+ DartdocOptionArgFile<List<String>>('excludes', [],
isDir: true,
help:
'A list of directories to exclude from linking to a source code repository.'),
// TODO(jcollins-g): Use [DartdocOptionArgSynth], possibly in combination with a repository type and the root directory, and get revision number automatically
- new DartdocOptionArgOnly<String>('revision', null,
+ DartdocOptionArgOnly<String>('revision', null,
help: 'Revision number to insert into the URI.'),
- new DartdocOptionArgFile<String>('root', null,
+ DartdocOptionArgFile<String>('root', null,
isDir: true,
help:
'Path to a local directory that is the root of the repository we link to. All source code files under this directory will be linked.'),
- new DartdocOptionArgFile<String>('uriTemplate', null,
+ DartdocOptionArgFile<String>('uriTemplate', null,
help:
'''Substitute into this template to generate a uri for an element's source code.
Dartdoc dynamically substitutes the following fields into the template:
@@ -84,7 +84,7 @@
/// Build a SourceLinker from a ModelElement.
factory SourceLinker.fromElement(ModelElement element) {
SourceLinkerOptionContext config = element.config;
- return new SourceLinker(
+ return SourceLinker(
excludes: config.linkToSourceExcludes,
// TODO(jcollins-g): disallow defaulting? Some elements come back without
// a line number right now.
@@ -108,7 +108,7 @@
return uriTemplate.replaceAllMapped(uriTemplateRegexp, (match) {
switch (match[1]) {
case '%f%':
- var urlContext = new path.Context(style: path.Style.url);
+ var urlContext = path.Context(style: path.Style.url);
return urlContext
.joinAll(path.split(path.relative(sourceFileName, from: root)));
break;
diff --git a/lib/src/special_elements.dart b/lib/src/special_elements.dart
index 9da4bcd..0dceb95 100644
--- a/lib/src/special_elements.dart
+++ b/lib/src/special_elements.dart
@@ -66,12 +66,12 @@
/// The index is a shortcut to reduce processing time for determining if
/// a class might be "special".
final Map<String, _SpecialClassDefinition> _specialClassDefinitions = {
- 'Object': new _SpecialClassDefinition(
+ 'Object': _SpecialClassDefinition(
SpecialClass.object, 'Object', 'dart.core', 'dart:core'),
- 'Interceptor': new _SpecialClassDefinition(SpecialClass.interceptor,
+ 'Interceptor': _SpecialClassDefinition(SpecialClass.interceptor,
'Interceptor', '_interceptors', 'dart:_interceptors',
required: false),
- 'pragma': new _SpecialClassDefinition(
+ 'pragma': _SpecialClassDefinition(
SpecialClass.pragma, 'pragma', 'dart.core', 'dart:core',
required: false),
};
diff --git a/lib/src/tool_runner.dart b/lib/src/tool_runner.dart
index 400e8ec..daf4931 100644
--- a/lib/src/tool_runner.dart
+++ b/lib/src/tool_runner.dart
@@ -17,7 +17,7 @@
/// Set a ceiling on how many tool instances can be in progress at once,
/// limiting both parallelization and the number of open temporary files.
-final MultiFutureTracker _toolTracker = new MultiFutureTracker(4);
+final MultiFutureTracker _toolTracker = MultiFutureTracker(4);
/// Can be called when the ToolRunner is no longer needed.
///
@@ -38,7 +38,7 @@
Future<File> createTemporaryFile() async {
_temporaryFileCount++;
- File tempFile = new File(path.join(
+ File tempFile = File(path.join(
temporaryDirectory.absolute.path, 'input_$_temporaryFileCount'));
await tempFile.create(recursive: true);
return tempFile;
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index d732e50..dd3f5f2 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library dartdoc.utils;
-final RegExp leadingWhiteSpace = new RegExp(r'^([ \t]*)[^ ]');
+final RegExp leadingWhiteSpace = RegExp(r'^([ \t]*)[^ ]');
Iterable<String> stripCommonWhitespace(String str) sync* {
List<String> lines = str.split('\n');
@@ -32,7 +32,7 @@
String stripComments(String str) {
bool cStyle = false;
if (str == null) return null;
- StringBuffer buf = new StringBuffer();
+ StringBuffer buf = StringBuffer();
if (str.startsWith('///')) {
for (String line in stripCommonWhitespace(str)) {
diff --git a/lib/src/warnings.dart b/lib/src/warnings.dart
index f67ab81..1b96459 100644
--- a/lib/src/warnings.dart
+++ b/lib/src/warnings.dart
@@ -25,7 +25,7 @@
Future<List<DartdocOption>> createPackageWarningOptions() async {
return <DartdocOption>[
- new DartdocOptionArgOnly<bool>('allowNonLocalWarnings', false,
+ DartdocOptionArgOnly<bool>('allowNonLocalWarnings', false,
negatable: true,
help: 'Show warnings from packages we are not documenting locally.'),
@@ -33,21 +33,21 @@
// for individual packages are command-line only. This will allow
// meta-packages like Flutter to control whether warnings are displayed for
// packages they don't control.
- new DartdocOptionArgOnly<List<String>>('allowWarningsInPackages', null,
+ DartdocOptionArgOnly<List<String>>('allowWarningsInPackages', null,
help:
'Package names to display warnings for (ignore all others if set).'),
- new DartdocOptionArgOnly<List<String>>('allowErrorsInPackages', null,
+ DartdocOptionArgOnly<List<String>>('allowErrorsInPackages', null,
help: 'Package names to display errors for (ignore all others if set)'),
- new DartdocOptionArgOnly<List<String>>('ignoreWarningsInPackages', null,
+ DartdocOptionArgOnly<List<String>>('ignoreWarningsInPackages', null,
help:
'Package names to ignore warnings for. Takes priority over allow-warnings-in-packages'),
- new DartdocOptionArgOnly<List<String>>('ignoreErrorsInPackages', null,
+ DartdocOptionArgOnly<List<String>>('ignoreErrorsInPackages', null,
help:
'Package names to ignore errors for. Takes priority over allow-errors-in-packages'),
// Options for globally enabling/disabling warnings and errors across
// packages. Loaded from dartdoc_options.yaml, but command line arguments
// will override.
- new DartdocOptionArgFile<List<String>>('errors', null,
+ DartdocOptionArgFile<List<String>>('errors', null,
help:
'Additional warning names to force as errors. Specify an empty list to force defaults (overriding dartdoc_options.yaml)\nDefaults:\n' +
(packageWarningDefinitions.values
@@ -57,7 +57,7 @@
..sort())
.map((d) => ' ${d.warningName}: ${d.shortHelp}')
.join('\n')),
- new DartdocOptionArgFile<List<String>>('ignore', null,
+ DartdocOptionArgFile<List<String>>('ignore', null,
help:
'Additional warning names to ignore. Specify an empty list to force defaults (overriding dartdoc_options.yaml).\nDefaults:\n' +
(packageWarningDefinitions.values
@@ -67,7 +67,7 @@
..sort())
.map((d) => ' ${d.warningName}: ${d.shortHelp}')
.join('\n')),
- new DartdocOptionArgFile<List<String>>('warnings', null,
+ DartdocOptionArgFile<List<String>>('warnings', null,
help:
'Additional warning names to show as warnings (instead of error or ignore, if not warning by default).\nDefaults:\n' +
(packageWarningDefinitions.values
@@ -78,7 +78,7 @@
.map((d) => ' ${d.warningName}: ${d.shortHelp}')
.join('\n')),
// Synthetic option uses a factory to build a PackageWarningOptions from all the above flags.
- new DartdocOptionSyntheticOnly<PackageWarningOptions>(
+ DartdocOptionSyntheticOnly<PackageWarningOptions>(
'packageWarningOptions', PackageWarningOptions.fromOptions),
];
}
@@ -103,22 +103,22 @@
/// Same as [packageWarningDefinitions], except keyed by the warning name.
final Map<String, PackageWarningDefinition> packageWarningsByName =
- new Map.fromEntries(packageWarningDefinitions.values
- .map((definition) => new MapEntry(definition.warningName, definition)));
+ Map.fromEntries(packageWarningDefinitions.values
+ .map((definition) => MapEntry(definition.warningName, definition)));
/// Provides description text and command line flags for warnings.
/// TODO(jcollins-g): Actually use this for command line flags.
final Map<PackageWarning, PackageWarningDefinition> packageWarningDefinitions =
const {
- PackageWarning.ambiguousDocReference: const PackageWarningDefinition(
+ PackageWarning.ambiguousDocReference: PackageWarningDefinition(
PackageWarning.ambiguousDocReference,
"ambiguous-doc-reference",
"A comment reference could refer to two or more different objects"),
- PackageWarning.ambiguousReexport: const PackageWarningDefinition(
+ PackageWarning.ambiguousReexport: PackageWarningDefinition(
PackageWarning.ambiguousReexport,
"ambiguous-reexport",
"A symbol is exported from private to public in more than one library and dartdoc can not determine which one is canonical",
- longHelp: const [
+ longHelp: [
"Use {@canonicalFor @@name@@} in the desired library's documentation to resolve",
"the ambiguity and/or override dartdoc's decision, or structure your package ",
"so the reexport is less ambiguous. The symbol will still be referenced in ",
@@ -127,71 +127,64 @@
"The flag --ambiguous-reexport-scorer-min-confidence allows you to set the",
"threshold at which this warning will appear."
]),
- PackageWarning.ignoredCanonicalFor: const PackageWarningDefinition(
+ PackageWarning.ignoredCanonicalFor: PackageWarningDefinition(
PackageWarning.ignoredCanonicalFor,
"ignored-canonical-for",
"A @canonicalFor tag refers to a library which this symbol can not be canonical for"),
- PackageWarning.noCanonicalFound: const PackageWarningDefinition(
+ PackageWarning.noCanonicalFound: PackageWarningDefinition(
PackageWarning.noCanonicalFound,
"no-canonical-found",
"A symbol is part of the public interface for this package, but no library documented with this package documents it so dartdoc can not link to it"),
- PackageWarning.noLibraryLevelDocs: const PackageWarningDefinition(
+ PackageWarning.noLibraryLevelDocs: PackageWarningDefinition(
PackageWarning.noLibraryLevelDocs,
"no-library-level-docs",
"There are no library level docs for this library"),
- PackageWarning.packageOrderGivesMissingPackageName:
- const PackageWarningDefinition(
- PackageWarning.packageOrderGivesMissingPackageName,
- "category-order-gives-missing-package-name",
- "The category-order flag on the command line was given the name of a nonexistent package"),
- PackageWarning.reexportedPrivateApiAcrossPackages: const PackageWarningDefinition(
+ PackageWarning.packageOrderGivesMissingPackageName: PackageWarningDefinition(
+ PackageWarning.packageOrderGivesMissingPackageName,
+ "category-order-gives-missing-package-name",
+ "The category-order flag on the command line was given the name of a nonexistent package"),
+ PackageWarning.reexportedPrivateApiAcrossPackages: PackageWarningDefinition(
PackageWarning.reexportedPrivateApiAcrossPackages,
"reexported-private-api-across-packages",
"One or more libraries reexports private API members from outside its own package"),
- PackageWarning.unresolvedDocReference: const PackageWarningDefinition(
+ PackageWarning.unresolvedDocReference: PackageWarningDefinition(
PackageWarning.unresolvedDocReference,
"unresolved-doc-reference",
"A comment reference could not be found in parameters, enclosing class, enclosing library, or at the top level of any documented library with the package"),
- PackageWarning.brokenLink: const PackageWarningDefinition(
- PackageWarning.brokenLink,
- "broken-link",
- "Dartdoc generated a link to a non-existent file"),
- PackageWarning.unknownMacro: const PackageWarningDefinition(
+ PackageWarning.brokenLink: PackageWarningDefinition(PackageWarning.brokenLink,
+ "broken-link", "Dartdoc generated a link to a non-existent file"),
+ PackageWarning.unknownMacro: PackageWarningDefinition(
PackageWarning.unknownMacro,
"unknown-macro",
"A comment reference contains an unknown macro"),
- PackageWarning.orphanedFile: const PackageWarningDefinition(
+ PackageWarning.orphanedFile: PackageWarningDefinition(
PackageWarning.orphanedFile,
"orphaned-file",
"Dartdoc generated files that are unreachable from the index"),
- PackageWarning.unknownFile: const PackageWarningDefinition(
+ PackageWarning.unknownFile: PackageWarningDefinition(
PackageWarning.unknownFile,
"unknown-file",
"A leftover file exists in the tree that dartdoc did not write in this pass"),
- PackageWarning.missingFromSearchIndex: const PackageWarningDefinition(
+ PackageWarning.missingFromSearchIndex: PackageWarningDefinition(
PackageWarning.missingFromSearchIndex,
"missing-from-search-index",
"A file generated by dartdoc is not present in the generated index.json"),
- PackageWarning.typeAsHtml: const PackageWarningDefinition(
+ PackageWarning.typeAsHtml: PackageWarningDefinition(
PackageWarning.typeAsHtml,
"type-as-html",
"Use of <> in a comment for type parameters is being treated as HTML by markdown",
defaultWarningMode: PackageWarningMode.ignore),
- PackageWarning.invalidParameter: const PackageWarningDefinition(
+ PackageWarning.invalidParameter: PackageWarningDefinition(
PackageWarning.invalidParameter,
"invalid-parameter",
"A parameter given to a dartdoc directive was invalid.",
defaultWarningMode: PackageWarningMode.error),
- PackageWarning.toolError: const PackageWarningDefinition(
- PackageWarning.toolError,
- "tool-error",
- "Unable to execute external tool.",
+ PackageWarning.toolError: PackageWarningDefinition(PackageWarning.toolError,
+ "tool-error", "Unable to execute external tool.",
defaultWarningMode: PackageWarningMode.error),
- PackageWarning.deprecated: const PackageWarningDefinition(
- PackageWarning.deprecated,
- "deprecated",
- "A dartdoc directive has a deprecated format."),
- PackageWarning.unresolvedExport: const PackageWarningDefinition(
+ PackageWarning.deprecated: PackageWarningDefinition(PackageWarning.deprecated,
+ "deprecated", "A dartdoc directive has a deprecated format."),
+ PackageWarning.unresolvedExport: PackageWarningDefinition(
PackageWarning.unresolvedExport,
"unresolved-export",
"An export refers to a URI that cannot be resolved.",
@@ -258,7 +251,7 @@
/// In particular, this set should not include warnings around public/private
/// or canonicalization problems, because those can break the isDocumented()
/// check.
-final Set<PackageWarning> skipWarningIfNotDocumentedFor = new Set()
+final Set<PackageWarning> skipWarningIfNotDocumentedFor = Set()
..addAll([PackageWarning.unresolvedDocReference, PackageWarning.typeAsHtml]);
class PackageWarningOptions {
@@ -292,7 +285,7 @@
DartdocSyntheticOption<PackageWarningOptions> option, Directory dir) {
// First, initialize defaults.
PackageWarningOptions newOptions = PackageWarningOptions();
- PackageMeta packageMeta = new PackageMeta.fromDir(dir);
+ PackageMeta packageMeta = PackageMeta.fromDir(dir);
// Interpret errors/warnings/ignore options. In the event of conflict, warning overrides error and
// ignore overrides warning.
@@ -357,8 +350,7 @@
}
class PackageWarningCounter {
- final countedWarnings =
- new Map<Element, Set<Tuple2<PackageWarning, String>>>();
+ final countedWarnings = Map<Element, Set<Tuple2<PackageWarning, String>>>();
final _items = <Jsonable>[];
final _displayedWarningCounts = <PackageWarning, int>{};
final PackageGraph packageGraph;
@@ -393,7 +385,7 @@
entry = '$entry$verboseOut';
}
assert(entry == entry.trimRight());
- _items.add(new _JsonWarning(type, kind, fullMessage, entry));
+ _items.add(_JsonWarning(type, kind, fullMessage, entry));
}
for (var item in _items) {
logWarning(item);
@@ -403,7 +395,7 @@
/// Returns true if we've already warned for this.
bool hasWarning(Warnable element, PackageWarning kind, String message) {
- Tuple2<PackageWarning, String> warningData = new Tuple2(kind, message);
+ Tuple2<PackageWarning, String> warningData = Tuple2(kind, message);
if (countedWarnings.containsKey(element?.element)) {
return countedWarnings[element?.element].contains(warningData);
}
@@ -429,8 +421,8 @@
} else if (warningMode == PackageWarningMode.error) {
errorCount += 1;
}
- Tuple2<PackageWarning, String> warningData = new Tuple2(kind, message);
- countedWarnings.putIfAbsent(element?.element, () => new Set());
+ Tuple2<PackageWarning, String> warningData = Tuple2(kind, message);
+ countedWarnings.putIfAbsent(element?.element, () => Set());
countedWarnings[element?.element].add(warningData);
_writeWarning(kind, warningMode, config.verboseWarnings,
element?.fullyQualifiedName, fullMessage);
diff --git a/test/dartdoc_integration_test.dart b/test/dartdoc_integration_test.dart
index 835f5ad..2e65818 100644
--- a/test/dartdoc_integration_test.dart
+++ b/test/dartdoc_integration_test.dart
@@ -30,8 +30,8 @@
setUpAll(() async {
tempDir =
Directory.systemTemp.createTempSync('dartdoc_integration_test.');
- subprocessLauncher = new CoverageSubprocessLauncher(
- 'dartdoc_integration_test-subprocesses');
+ subprocessLauncher =
+ CoverageSubprocessLauncher('dartdoc_integration_test-subprocesses');
});
tearDown(() async {
@@ -128,47 +128,46 @@
contains('Generate HTML documentation for Dart libraries.'));
expect(
outputLines.join('\n'),
- contains(new RegExp('^-h, --help[ ]+Show command help.',
- multiLine: true)));
+ contains(
+ RegExp('^-h, --help[ ]+Show command help.', multiLine: true)));
});
test('Validate missing FLUTTER_ROOT exception is clean', () async {
- StringBuffer output = new StringBuffer();
+ StringBuffer output = StringBuffer();
var args = <String>[dartdocPath];
Future run = subprocessLauncher.runStreamed(
Platform.resolvedExecutable, args,
- environment: new Map.from(Platform.environment)
- ..remove('FLUTTER_ROOT'),
+ environment: Map.from(Platform.environment)..remove('FLUTTER_ROOT'),
includeParentEnvironment: false,
workingDirectory: _testPackageFlutterPluginPath, perLine: (s) {
output.writeln(s);
});
// Asynchronous exception, but we still need the output, too.
- expect(run, throwsA(new TypeMatcher<ProcessException>()));
+ expect(run, throwsA(TypeMatcher<ProcessException>()));
try {
await run;
} on ProcessException catch (_) {}
expect(
output.toString(),
- contains(new RegExp(
+ contains(RegExp(
'Top level package requires Flutter but FLUTTER_ROOT environment variable not set|test_package_flutter_plugin requires the Flutter SDK, version solving failed')));
expect(output.toString(), isNot(contains('asynchronous gap')));
});
test("Validate --version works", () async {
- StringBuffer output = new StringBuffer();
+ StringBuffer output = StringBuffer();
var args = <String>[dartdocPath, '--version'];
await subprocessLauncher.runStreamed(Platform.resolvedExecutable, args,
workingDirectory: _testPackagePath,
perLine: (s) => output.writeln(s));
- PackageMeta dartdocMeta = new PackageMeta.fromFilename(dartdocPath);
+ PackageMeta dartdocMeta = PackageMeta.fromFilename(dartdocPath);
expect(output.toString(),
endsWith('dartdoc version: ${dartdocMeta.version}\n'));
});
test('Check for sample code in examples', () async {
- StringBuffer output = new StringBuffer();
+ StringBuffer output = StringBuffer();
var args = <String>[
dartdocPath,
'--include',
@@ -185,7 +184,7 @@
// Examples are reported as unfound because we (purposefully)
// did not use --example-path-prefix above.
final sep = '.'; // We don't care what the path separator character is
- final firstUnfoundExample = new RegExp('warning: lib${sep}example.dart: '
+ final firstUnfoundExample = RegExp('warning: lib${sep}example.dart: '
'@example file not found.*test_package${sep}dog${sep}food.md');
if (!output.toString().contains(firstUnfoundExample)) {
fail('Should warn about unfound @example files');
@@ -209,12 +208,12 @@
expect(jsonValues, isNotEmpty,
reason: 'All STDOUT lines should be JSON-encoded maps.');
- }, timeout: new Timeout.factor(2));
+ }, timeout: Timeout.factor(2));
test('--footer-text includes text', () async {
String footerTextPath =
path.join(Directory.systemTemp.path, 'footer.txt');
- new File(footerTextPath).writeAsStringSync(' footer text include ');
+ File(footerTextPath).writeAsStringSync(' footer text include ');
var args = <String>[
dartdocPath,
@@ -228,8 +227,8 @@
await subprocessLauncher.runStreamed(Platform.resolvedExecutable, args,
workingDirectory: _testPackagePath);
- File outFile = new File(path.join(tempDir.path, 'index.html'));
+ File outFile = File(path.join(tempDir.path, 'index.html'));
expect(outFile.readAsStringSync(), contains('footer text include'));
});
- }, timeout: new Timeout.factor(4));
+ }, timeout: Timeout.factor(4));
}
diff --git a/test/dartdoc_options_test.dart b/test/dartdoc_options_test.dart
index ef73ab1..fb41b7a 100644
--- a/test/dartdoc_options_test.dart
+++ b/test/dartdoc_options_test.dart
@@ -33,7 +33,7 @@
break;
}
}
- return new ConvertedOption._(p1, p2, contextPath);
+ return ConvertedOption._(p1, p2, contextPath);
}
}
@@ -54,11 +54,11 @@
File firstExisting;
setUpAll(() {
- dartdocOptionSetSynthetic = new DartdocOptionSet('dartdoc');
+ dartdocOptionSetSynthetic = DartdocOptionSet('dartdoc');
dartdocOptionSetSynthetic
- .add(new DartdocOptionArgFile<int>('mySpecialInteger', 91));
+ .add(DartdocOptionArgFile<int>('mySpecialInteger', 91));
dartdocOptionSetSynthetic.add(
- new DartdocOptionSyntheticOnly<List<String>>('vegetableLoader',
+ DartdocOptionSyntheticOnly<List<String>>('vegetableLoader',
(DartdocSyntheticOption<List<String>> option, Directory dir) {
if (option.root['mySpecialInteger'].valueAt(dir) > 20) {
return <String>['existing.dart'];
@@ -67,115 +67,105 @@
}
}));
dartdocOptionSetSynthetic.add(
- new DartdocOptionSyntheticOnly<List<String>>('vegetableLoaderChecked',
+ DartdocOptionSyntheticOnly<List<String>>('vegetableLoaderChecked',
(DartdocSyntheticOption<List<String>> option, Directory dir) {
return option.root['vegetableLoader'].valueAt(dir);
}, isFile: true, mustExist: true));
- dartdocOptionSetSynthetic.add(new DartdocOptionFileSynth<double>('double',
+ dartdocOptionSetSynthetic.add(DartdocOptionFileSynth<double>('double',
(DartdocSyntheticOption<double> option, Directory dir) {
return 3.7 + 4.1;
}));
dartdocOptionSetSynthetic.add(
- new DartdocOptionArgSynth<String>('nonCriticalFileOption',
+ DartdocOptionArgSynth<String>('nonCriticalFileOption',
(DartdocSyntheticOption<String> option, Directory dir) {
return option.root['vegetableLoader'].valueAt(dir).first;
}, isFile: true));
- dartdocOptionSetFiles = new DartdocOptionSet('dartdoc');
+ dartdocOptionSetFiles = DartdocOptionSet('dartdoc');
dartdocOptionSetFiles
- .add(new DartdocOptionFileOnly<List<String>>('categoryOrder', []));
- dartdocOptionSetFiles.add(new DartdocOptionFileOnly<double>('double', 3.0));
+ .add(DartdocOptionFileOnly<List<String>>('categoryOrder', []));
+ dartdocOptionSetFiles.add(DartdocOptionFileOnly<double>('double', 3.0));
dartdocOptionSetFiles
- .add(new DartdocOptionFileOnly<int>('mySpecialInteger', 42));
- dartdocOptionSetFiles.add(new DartdocOptionFileOnly<Map<String, String>>(
+ .add(DartdocOptionFileOnly<int>('mySpecialInteger', 42));
+ dartdocOptionSetFiles.add(DartdocOptionFileOnly<Map<String, String>>(
'mapOption', {'hello': 'world'}));
- dartdocOptionSetFiles.add(new DartdocOptionFileOnly<List<String>>(
+ dartdocOptionSetFiles.add(DartdocOptionFileOnly<List<String>>(
'fileOptionList', [],
isFile: true, mustExist: true));
- dartdocOptionSetFiles.add(new DartdocOptionFileOnly<String>(
- 'fileOption', null,
+ dartdocOptionSetFiles.add(DartdocOptionFileOnly<String>('fileOption', null,
isFile: true, mustExist: true));
- dartdocOptionSetFiles.add(new DartdocOptionFileOnly<String>(
+ dartdocOptionSetFiles.add(DartdocOptionFileOnly<String>(
'parentOverride', 'oops',
parentDirOverridesChild: true));
- dartdocOptionSetFiles.add(new DartdocOptionFileOnly<String>(
+ dartdocOptionSetFiles.add(DartdocOptionFileOnly<String>(
'nonCriticalFileOption', null,
isFile: true));
- dartdocOptionSetFiles.add(new DartdocOptionSet('nestedOption')
- ..addAll([new DartdocOptionFileOnly<bool>('flag', false)]));
- dartdocOptionSetFiles.add(new DartdocOptionFileOnly<String>(
- 'dirOption', null,
+ dartdocOptionSetFiles.add(DartdocOptionSet('nestedOption')
+ ..addAll([DartdocOptionFileOnly<bool>('flag', false)]));
+ dartdocOptionSetFiles.add(DartdocOptionFileOnly<String>('dirOption', null,
isDir: true, mustExist: true));
- dartdocOptionSetFiles.add(new DartdocOptionFileOnly<String>(
+ dartdocOptionSetFiles.add(DartdocOptionFileOnly<String>(
'nonCriticalDirOption', null,
isDir: true));
- dartdocOptionSetFiles.add(new DartdocOptionFileOnly<ConvertedOption>(
+ dartdocOptionSetFiles.add(DartdocOptionFileOnly<ConvertedOption>(
'convertThisMap',
null,
convertYamlToType: ConvertedOption.fromYamlMap,
));
- dartdocOptionSetArgs = new DartdocOptionSet('dartdoc');
+ dartdocOptionSetArgs = DartdocOptionSet('dartdoc');
dartdocOptionSetArgs
- .add(new DartdocOptionArgOnly<bool>('cauliflowerSystem', false));
+ .add(DartdocOptionArgOnly<bool>('cauliflowerSystem', false));
dartdocOptionSetArgs
- .add(new DartdocOptionArgOnly<String>('extraSpecial', 'something'));
+ .add(DartdocOptionArgOnly<String>('extraSpecial', 'something'));
dartdocOptionSetArgs.add(
- new DartdocOptionArgOnly<List<String>>('excludeFiles', ['one', 'two']));
+ DartdocOptionArgOnly<List<String>>('excludeFiles', ['one', 'two']));
dartdocOptionSetArgs
- .add(new DartdocOptionArgOnly<int>('number_of_heads', 3, abbr: 'h'));
+ .add(DartdocOptionArgOnly<int>('number_of_heads', 3, abbr: 'h'));
dartdocOptionSetArgs
- .add(new DartdocOptionArgOnly<double>('respawnProbability', 0.2));
- dartdocOptionSetArgs.add(new DartdocOptionSet('warn')
- ..addAll(
- [new DartdocOptionArgOnly<bool>('unrecognizedVegetable', false)]));
- dartdocOptionSetArgs.add(new DartdocOptionArgOnly<Map<String, String>>(
+ .add(DartdocOptionArgOnly<double>('respawnProbability', 0.2));
+ dartdocOptionSetArgs.add(DartdocOptionSet('warn')
+ ..addAll([DartdocOptionArgOnly<bool>('unrecognizedVegetable', false)]));
+ dartdocOptionSetArgs.add(DartdocOptionArgOnly<Map<String, String>>(
'aFancyMapVariable', {'hello': 'map world'},
splitCommas: true));
- dartdocOptionSetArgs.add(new DartdocOptionArgOnly<List<String>>(
- 'filesFlag', [],
+ dartdocOptionSetArgs.add(DartdocOptionArgOnly<List<String>>('filesFlag', [],
isFile: true, mustExist: true));
- dartdocOptionSetArgs.add(new DartdocOptionArgOnly<String>(
- 'singleFile', 'hello',
+ dartdocOptionSetArgs.add(DartdocOptionArgOnly<String>('singleFile', 'hello',
isFile: true, mustExist: true));
- dartdocOptionSetArgs.add(new DartdocOptionArgOnly<String>(
+ dartdocOptionSetArgs.add(DartdocOptionArgOnly<String>(
'unimportantFile', 'whatever',
isFile: true));
- dartdocOptionSetAll = new DartdocOptionSet('dartdoc');
+ dartdocOptionSetAll = DartdocOptionSet('dartdoc');
dartdocOptionSetAll
- .add(new DartdocOptionArgFile<List<String>>('categoryOrder', []));
- dartdocOptionSetAll
- .add(new DartdocOptionArgFile<int>('mySpecialInteger', 91));
- dartdocOptionSetAll.add(new DartdocOptionSet('warn')
- ..addAll(
- [new DartdocOptionArgFile<bool>('unrecognizedVegetable', false)]));
- dartdocOptionSetAll.add(new DartdocOptionArgFile<Map<String, String>>(
+ .add(DartdocOptionArgFile<List<String>>('categoryOrder', []));
+ dartdocOptionSetAll.add(DartdocOptionArgFile<int>('mySpecialInteger', 91));
+ dartdocOptionSetAll.add(DartdocOptionSet('warn')
+ ..addAll([DartdocOptionArgFile<bool>('unrecognizedVegetable', false)]));
+ dartdocOptionSetAll.add(DartdocOptionArgFile<Map<String, String>>(
'mapOption', {'hi': 'there'}));
dartdocOptionSetAll
- .add(new DartdocOptionArgFile<String>('notInAnyFile', 'so there'));
- dartdocOptionSetAll.add(new DartdocOptionArgFile<String>('fileOption', null,
+ .add(DartdocOptionArgFile<String>('notInAnyFile', 'so there'));
+ dartdocOptionSetAll.add(DartdocOptionArgFile<String>('fileOption', null,
isFile: true, mustExist: true));
tempDir = Directory.systemTemp.createTempSync('options_test');
- firstDir = new Directory(path.join(tempDir.path, 'firstDir'))..createSync();
- firstExisting = new File(path.join(firstDir.path, 'existing.dart'))
+ firstDir = Directory(path.join(tempDir.path, 'firstDir'))..createSync();
+ firstExisting = File(path.join(firstDir.path, 'existing.dart'))
..createSync();
- secondDir = new Directory(path.join(tempDir.path, 'secondDir'))
- ..createSync();
- new File(path.join(secondDir.path, 'existing.dart'))..createSync();
+ secondDir = Directory(path.join(tempDir.path, 'secondDir'))..createSync();
+ File(path.join(secondDir.path, 'existing.dart'))..createSync();
- secondDirFirstSub = new Directory(path.join(secondDir.path, 'firstSub'))
+ secondDirFirstSub = Directory(path.join(secondDir.path, 'firstSub'))
..createSync();
- secondDirSecondSub = new Directory(path.join(secondDir.path, 'secondSub'))
+ secondDirSecondSub = Directory(path.join(secondDir.path, 'secondSub'))
..createSync();
- dartdocOptionsOne =
- new File(path.join(firstDir.path, 'dartdoc_options.yaml'));
- dartdocOptionsTwo =
- new File(path.join(secondDir.path, 'dartdoc_options.yaml'));
+ dartdocOptionsOne = File(path.join(firstDir.path, 'dartdoc_options.yaml'));
+ dartdocOptionsTwo = File(path.join(secondDir.path, 'dartdoc_options.yaml'));
dartdocOptionsTwoFirstSub =
- new File(path.join(secondDirFirstSub.path, 'dartdoc_options.yaml'));
+ File(path.join(secondDirFirstSub.path, 'dartdoc_options.yaml'));
dartdocOptionsOne.writeAsStringSync('''
dartdoc:
diff --git a/test/dartdoc_test.dart b/test/dartdoc_test.dart
index 29779a0..ce1f348 100644
--- a/test/dartdoc_test.dart
+++ b/test/dartdoc_test.dart
@@ -32,8 +32,7 @@
DartdocOptionSet optionSet = await DartdocOptionSet.fromOptionGenerators(
'dartdoc', [createLoggingOptions]);
optionSet.parseArguments([]);
- startLogging(
- new DartdocLoggingOptionContext(optionSet, Directory.current));
+ startLogging(DartdocLoggingOptionContext(optionSet, Directory.current));
});
setUp(() async {
@@ -69,9 +68,9 @@
});
test('generator parameters', () async {
- File favicon = new File(
- path.joinAll([tempDir.path, 'static-assets', 'favicon.png']));
- File index = new File(path.joinAll([tempDir.path, 'index.html']));
+ File favicon =
+ File(path.joinAll([tempDir.path, 'static-assets', 'favicon.png']));
+ File index = File(path.joinAll([tempDir.path, 'index.html']));
expect(favicon.readAsStringSync(),
contains('Not really a png, but a test file'));
String indexString = index.readAsStringSync();
@@ -231,7 +230,7 @@
useSomethingInAnotherPackage.modelType.linkedName,
matches(
'<a href=\"https://pub.dartlang.org/documentation/meta/[^\"]*/meta/Required-class.html\">Required</a>'));
- RegExp stringLink = new RegExp(
+ RegExp stringLink = RegExp(
'https://api.dartlang.org/(dev|stable|edge|be)/${Platform.version.split(' ').first}/dart-core/String-class.html">String</a>');
expect(useSomethingInTheSdk.modelType.linkedName, contains(stringLink));
});
@@ -266,8 +265,8 @@
test('source code links are visible', () async {
// Picked this object as this library explicitly should never contain
// a library directive, so we can predict what line number it will be.
- File anonymousOutput = new File(path.join(tempDir.path,
- 'anonymous_library', 'anonymous_library-library.html'));
+ File anonymousOutput = File(path.join(tempDir.path, 'anonymous_library',
+ 'anonymous_library-library.html'));
expect(anonymousOutput.existsSync(), isTrue);
expect(
anonymousOutput.readAsStringSync(),
@@ -364,5 +363,5 @@
dart_bear.allClasses.map((cls) => cls.name).contains('Bear'), isTrue);
expect(p.packageMap["Dart"].publicLibraries, hasLength(3));
});
- }, timeout: new Timeout.factor(8));
+ }, timeout: Timeout.factor(8));
}
diff --git a/test/experiment_options_test.dart b/test/experiment_options_test.dart
index 5231bb3..6a6f466 100644
--- a/test/experiment_options_test.dart
+++ b/test/experiment_options_test.dart
@@ -53,7 +53,7 @@
test('Defaults work for all options', () {
experimentOptions.parseArguments([]);
DartdocOptionContext tester =
- new DartdocOptionContext(experimentOptions, emptyTempDir);
+ DartdocOptionContext(experimentOptions, emptyTempDir);
if (defaultOnNotExpired != null) {
expect(tester.experimentStatus.isEnabled(defaultOnNotExpired), isTrue);
}
@@ -72,7 +72,7 @@
'${defaultOffNotExpired?.disableString},${defaultOnNotExpired?.disableString},${defaultOnExpired.disableString},${defaultOffExpired.enableString}'
]);
DartdocOptionContext tester =
- new DartdocOptionContext(experimentOptions, emptyTempDir);
+ DartdocOptionContext(experimentOptions, emptyTempDir);
if (defaultOnNotExpired != null) {
expect(tester.experimentStatus.isEnabled(defaultOnNotExpired), isFalse);
}
diff --git a/test/grind_test.dart b/test/grind_test.dart
index f4b8bec..2308754 100644
--- a/test/grind_test.dart
+++ b/test/grind_test.dart
@@ -14,17 +14,16 @@
WarningsCollection originalWithDirs, currentWithDirs;
setUp(() {
original =
- new WarningsCollection('/a/tempdir', '/pubcache/path', 'oldbranch');
+ WarningsCollection('/a/tempdir', '/pubcache/path', 'oldbranch');
original.add('originalwarning');
original.add('morewarning');
original.add('duplicateoriginalwarning');
original.add('duplicateoriginalwarning');
- current =
- new WarningsCollection('/a/tempdir2', '/pubcache/path2', 'current');
+ current = WarningsCollection('/a/tempdir2', '/pubcache/path2', 'current');
current.add('newwarning');
current.add('morewarning');
current.add('duplicateoriginalwarning');
- originalWithDirs = new WarningsCollection(
+ originalWithDirs = WarningsCollection(
'/a/tempdirFOO', '/pubcache/pathFOO', 'DirsOriginal');
originalWithDirs.add(
'originalWarning found in /a/tempdirFOO/some/subdir/program.dart!!!!');
@@ -34,7 +33,7 @@
'insufficent exclamation mark warning found in /pubcache/pathFOO/some/package/lib/thingy.dart.');
originalWithDirs.add(
'another originalWarning found in /a/tempdirFOO/some/subdir/program.dart');
- currentWithDirs = new WarningsCollection(
+ currentWithDirs = WarningsCollection(
'/a/tempdirBAR', '/pubcache/pathBAR', 'DirsCurrent');
currentWithDirs.add(
'originalWarning found in /a/tempdirBAR/some/subdir/program.dart!!!!');
diff --git a/test/html_generator_test.dart b/test/html_generator_test.dart
index 2fe8cc2..e5cb79b 100644
--- a/test/html_generator_test.dart
+++ b/test/html_generator_test.dart
@@ -81,19 +81,19 @@
test('resources are put into the right place', () {
Directory output =
- new Directory(path.join(tempOutput.path, 'static-assets'));
+ Directory(path.join(tempOutput.path, 'static-assets'));
expect(output, doesExist);
for (var resource in resource_names.map((r) =>
path.relative(Uri.parse(r).path, from: 'dartdoc/resources'))) {
- expect(new File(path.join(output.path, resource)), doesExist);
+ expect(File(path.join(output.path, resource)), doesExist);
}
});
});
});
}
-const Matcher doesExist = const _DoesExist();
+const Matcher doesExist = _DoesExist();
class _DoesExist extends Matcher {
const _DoesExist();
diff --git a/test/model_test.dart b/test/model_test.dart
index c5c733b..1ef9067 100644
--- a/test/model_test.dart
+++ b/test/model_test.dart
@@ -132,7 +132,7 @@
expect(typedSet.modelType.typeArguments.map((a) => a.name).toList(),
equals(['String']));
expect(typedSet.constantValue,
- matches(new RegExp(r'const <String>\s?{}')));
+ matches(RegExp(r'const <String>\s?{}')));
});
});
@@ -147,7 +147,7 @@
Method invokeToolPrivateLibrary, invokeToolPrivateLibraryOriginal;
Method invokeToolParentDoc, invokeToolParentDocOriginal;
final RegExp packageInvocationIndexRegexp =
- new RegExp(r'PACKAGE_INVOCATION_INDEX: (\d+)');
+ RegExp(r'PACKAGE_INVOCATION_INDEX: (\d+)');
setUpAll(() {
_NonCanonicalToolUser = fakeLibrary.allClasses
@@ -228,12 +228,10 @@
test('can invoke a tool and pass args and environment', () {
expect(invokeTool.documentation, contains('--file=<INPUT_FILE>'));
- expect(
- invokeTool.documentation,
- contains(
- new RegExp(r'--source=lib[/\\]example\.dart_[0-9]+_[0-9]+, ')));
expect(invokeTool.documentation,
- contains(new RegExp(r'--package-path=<PACKAGE_PATH>, ')));
+ contains(RegExp(r'--source=lib[/\\]example\.dart_[0-9]+_[0-9]+, ')));
+ expect(invokeTool.documentation,
+ contains(RegExp(r'--package-path=<PACKAGE_PATH>, ')));
expect(
invokeTool.documentation, contains('--package-name=test_package, '));
expect(invokeTool.documentation, contains('--library-name=ex, '));
@@ -243,18 +241,18 @@
contains(r'''--special= |\[]!@#\"'$%^&*()_+]'''));
expect(invokeTool.documentation, contains('INPUT: <INPUT_FILE>'));
expect(invokeTool.documentation,
- contains(new RegExp('SOURCE_COLUMN: [0-9]+, ')));
+ contains(RegExp('SOURCE_COLUMN: [0-9]+, ')));
expect(invokeTool.documentation,
- contains(new RegExp(r'SOURCE_PATH: lib[/\\]example\.dart, ')));
+ contains(RegExp(r'SOURCE_PATH: lib[/\\]example\.dart, ')));
expect(invokeTool.documentation,
- contains(new RegExp(r'PACKAGE_PATH: <PACKAGE_PATH>, ')));
+ contains(RegExp(r'PACKAGE_PATH: <PACKAGE_PATH>, ')));
expect(
invokeTool.documentation, contains('PACKAGE_NAME: test_package, '));
expect(invokeTool.documentation, contains('LIBRARY_NAME: ex, '));
expect(invokeTool.documentation,
contains('ELEMENT_NAME: ToolUser.invokeTool, '));
expect(invokeTool.documentation,
- contains(new RegExp('INVOCATION_INDEX: [0-9]+}')));
+ contains(RegExp('INVOCATION_INDEX: [0-9]+}')));
expect(invokeTool.documentation, contains('## `Yes it is a [Dog]!`'));
});
test('can invoke a tool and add a reference link', () {
@@ -529,7 +527,7 @@
List<String> containerNames;
setUpAll(() {
- topLevel = new TestLibraryContainer('topLevel', [], null);
+ topLevel = TestLibraryContainer('topLevel', [], null);
sortOrderBasic = ['theFirst', 'second', 'fruit'];
containerNames = [
'moo',
@@ -544,11 +542,9 @@
test('multiple containers with specified sort order', () {
List<LibraryContainer> containers = [];
for (String name in containerNames) {
- containers
- .add(new TestLibraryContainer(name, sortOrderBasic, topLevel));
+ containers.add(TestLibraryContainer(name, sortOrderBasic, topLevel));
}
- containers
- .add(new TestLibraryContainerSdk('SDK', sortOrderBasic, topLevel));
+ containers.add(TestLibraryContainerSdk('SDK', sortOrderBasic, topLevel));
containers.sort();
expect(
containers.map((c) => c.name),
@@ -566,9 +562,9 @@
test('multiple containers, no specified sort order', () {
List<LibraryContainer> containers = [];
for (String name in containerNames) {
- containers.add(new TestLibraryContainer(name, [], topLevel));
+ containers.add(TestLibraryContainer(name, [], topLevel));
}
- containers.add(new TestLibraryContainerSdk('SDK', [], topLevel));
+ containers.add(TestLibraryContainerSdk('SDK', [], topLevel));
containers.sort();
expect(
containers.map((c) => c.name),
@@ -1342,14 +1338,11 @@
});
test('Verify there is no emoji support', () {
- TopLevelVariable tpvar = fakeLibrary.constants.firstWhere((t) => t.name == 'hasMarkdownInDoc');
+ TopLevelVariable tpvar = fakeLibrary.constants
+ .firstWhere((t) => t.name == 'hasMarkdownInDoc');
docsAsHtml = tpvar.documentationAsHtml;
- expect(
- docsAsHtml.contains(
- '3ffe:2a00:100:7031::1'),
- isTrue);
+ expect(docsAsHtml.contains('3ffe:2a00:100:7031::1'), isTrue);
});
-
});
group('doc references', () {
@@ -1687,8 +1680,8 @@
() {
Field powers = superAwesomeClass.instanceProperties
.firstWhere((p) => p.name == 'powers');
- Iterable<Match> matches = new RegExp('In the super class')
- .allMatches(powers.documentationAsHtml);
+ Iterable<Match> matches =
+ RegExp('In the super class').allMatches(powers.documentationAsHtml);
expect(matches, hasLength(1));
});
@@ -3217,7 +3210,7 @@
test('PRETTY_COLORS', () {
expect(
prettyColorsConstant.constantValue,
- matches(new RegExp(
+ matches(RegExp(
r"const <String>\s?\[COLOR_GREEN, COLOR_ORANGE, 'blue'\]")));
});
@@ -3708,8 +3701,8 @@
r"x100$",
];
for (var i = 1; i < names.length; i++) {
- var a = new StringName(names[i - 1]);
- var b = new StringName(names[i]);
+ var a = StringName(names[i - 1]);
+ var b = StringName(names[i]);
test('"$a" < "$b"', () {
expect(byName(a, a), 0);
expect(byName(b, b), 0);
diff --git a/test/package_meta_test.dart b/test/package_meta_test.dart
index 2b2452d..dd231b6 100644
--- a/test/package_meta_test.dart
+++ b/test/package_meta_test.dart
@@ -16,7 +16,7 @@
setUp(() {
var d = Directory.systemTemp.createTempSync('test_package_not_valid');
- p = new PackageMeta.fromDir(d);
+ p = PackageMeta.fromDir(d);
});
test('is not valid', () {
@@ -25,7 +25,7 @@
});
group('PackageMeta for the test package', () {
- PackageMeta p = new PackageMeta.fromDir(new Directory(
+ PackageMeta p = PackageMeta.fromDir(Directory(
path.join(Directory.current.path, 'testing', 'test_package')));
test('readme with corrupt UTF-8 loads without throwing', () {
@@ -35,7 +35,7 @@
});
group('PackageMeta.fromDir for this package', () {
- PackageMeta p = new PackageMeta.fromDir(Directory.current);
+ PackageMeta p = PackageMeta.fromDir(Directory.current);
test('has a name', () {
expect(p.name, 'dartdoc');
@@ -79,7 +79,7 @@
});
group('PackageMeta.fromSdk', () {
- PackageMeta p = new PackageMeta.fromDir(defaultSdkDir);
+ PackageMeta p = PackageMeta.fromDir(defaultSdkDir);
test('has a name', () {
expect(p.name, 'Dart');
diff --git a/test/source_linker_test.dart b/test/source_linker_test.dart
index e31014a..7c68a8d 100644
--- a/test/source_linker_test.dart
+++ b/test/source_linker_test.dart
@@ -11,7 +11,7 @@
void main() {
group('Source link computations', () {
test('Basic usage', () {
- var sourceLinkerHref = () => new SourceLinker(
+ var sourceLinkerHref = () => SourceLinker(
excludes: [],
lineNumber: 14,
root: 'path',
@@ -24,7 +24,7 @@
});
test('Throw when missing a revision if one is in the template', () {
- var sourceLinkerHref = () => new SourceLinker(
+ var sourceLinkerHref = () => SourceLinker(
excludes: [],
lineNumber: 20,
root: 'path',
@@ -35,7 +35,7 @@
});
test('Allow a missing revision as long as it is not in the template', () {
- var sourceLinkerHref = () => new SourceLinker(
+ var sourceLinkerHref = () => SourceLinker(
excludes: [],
lineNumber: 71,
root: 'path',
@@ -47,7 +47,7 @@
});
test('Throw if only revision specified', () {
- var sourceLinkerHref = () => new SourceLinker(
+ var sourceLinkerHref = () => SourceLinker(
excludes: [],
lineNumber: 20,
revision: '12345',
@@ -56,7 +56,7 @@
});
test('Hide a path inside an exclude', () {
- var sourceLinkerHref = () => new SourceLinker(
+ var sourceLinkerHref = () => SourceLinker(
excludes: ['path/under/exclusion'],
lineNumber: 14,
root: 'path',
@@ -68,7 +68,7 @@
});
test('Check that paths outside exclusions work', () {
- var sourceLinkerHref = () => new SourceLinker(
+ var sourceLinkerHref = () => SourceLinker(
excludes: ['path/under/exclusion'],
lineNumber: 14,
root: 'path',
diff --git a/test/src/utils.dart b/test/src/utils.dart
index 33df91a..8655f8f 100644
--- a/test/src/utils.dart
+++ b/test/src/utils.dart
@@ -14,9 +14,9 @@
import 'package:dartdoc/src/package_meta.dart';
import 'package:path/path.dart' as path;
-final RegExp quotables = new RegExp(r'[ "\r\n\$]');
+final RegExp quotables = RegExp(r'[ "\r\n\$]');
final RegExp observatoryPortRegexp =
- new RegExp(r'^Observatory listening on http://.*:(\d+)');
+ RegExp(r'^Observatory listening on http://.*:(\d+)');
Directory sdkDir;
PackageMeta sdkPackageMeta;
@@ -27,26 +27,25 @@
PackageGraph testPackageGraphErrors;
PackageGraph testPackageGraphSdk;
-final Directory testPackageBadDir = new Directory('testing/test_package_bad');
-final Directory testPackageDir = new Directory('testing/test_package');
+final Directory testPackageBadDir = Directory('testing/test_package_bad');
+final Directory testPackageDir = Directory('testing/test_package');
final Directory testPackageExperimentsDir =
- new Directory('testing/test_package_experiments');
+ Directory('testing/test_package_experiments');
final Directory testPackageMinimumDir =
- new Directory('testing/test_package_minimum');
+ Directory('testing/test_package_minimum');
final Directory testPackageWithEmbedderYaml =
- new Directory('testing/test_package_embedder_yaml');
+ Directory('testing/test_package_embedder_yaml');
final Directory testPackageWithNoReadme =
- new Directory('testing/test_package_small');
+ Directory('testing/test_package_small');
final Directory testPackageIncludeExclude =
- new Directory('testing/test_package_include_exclude');
+ Directory('testing/test_package_include_exclude');
final Directory testPackageImportExportError =
- new Directory('testing/test_package_import_export_error');
-final Directory testPackageOptions =
- new Directory('testing/test_package_options');
+ Directory('testing/test_package_import_export_error');
+final Directory testPackageOptions = Directory('testing/test_package_options');
final Directory testPackageOptionsImporter =
- new Directory('testing/test_package_options_importer');
+ Directory('testing/test_package_options_importer');
final Directory testPackageToolError =
- new Directory('testing/test_package_tool_error');
+ Directory('testing/test_package_tool_error');
/// Convenience factory to build a [DartdocGeneratorOptionContext] and associate
/// it with a [DartdocOptionSet] based on the current working directory and/or
@@ -56,7 +55,7 @@
DartdocOptionSet optionSet = await DartdocOptionSet.fromOptionGenerators(
'dartdoc', [createDartdocOptions, createGeneratorOptions]);
optionSet.parseArguments(argv);
- return new DartdocGeneratorOptionContext(optionSet, null);
+ return DartdocGeneratorOptionContext(optionSet, null);
}
/// Convenience factory to build a [DartdocOptionContext] and associate it with a
@@ -65,12 +64,12 @@
DartdocOptionSet optionSet = await DartdocOptionSet.fromOptionGenerators(
'dartdoc', [createDartdocOptions]);
optionSet.parseArguments(argv);
- return new DartdocOptionContext(optionSet, Directory.current);
+ return DartdocOptionContext(optionSet, Directory.current);
}
void init({List<String> additionalArguments}) async {
sdkDir = defaultSdkDir;
- sdkPackageMeta = new PackageMeta.fromDir(sdkDir);
+ sdkPackageMeta = PackageMeta.fromDir(sdkDir);
additionalArguments ??= <String>[];
testPackageGraph = await bootBasicPackage(
@@ -98,16 +97,16 @@
}
Future<PackageGraph> bootSdkPackage() async {
- return new PackageBuilder(await contextFromArgv(['--input', sdkDir.path]))
+ return PackageBuilder(await contextFromArgv(['--input', sdkDir.path]))
.buildPackageGraph();
}
Future<PackageGraph> bootBasicPackage(
String dirPath, List<String> excludeLibraries,
{List<String> additionalArguments}) async {
- Directory dir = new Directory(dirPath);
+ Directory dir = Directory(dirPath);
additionalArguments ??= <String>[];
- return new PackageBuilder(await contextFromArgv([
+ return PackageBuilder(await contextFromArgv([
'--input',
dir.path,
'--sdk-dir',
@@ -142,7 +141,7 @@
static Directory get tempDir {
if (_tempDir == null) {
if (Platform.environment['DARTDOC_COVERAGE_DATA'] != null) {
- _tempDir = new Directory(Platform.environment['DARTDOC_COVERAGE_DATA']);
+ _tempDir = Directory(Platform.environment['DARTDOC_COVERAGE_DATA']);
} else {
_tempDir = Directory.systemTemp.createTempSync('dartdoc_coverage_data');
}
@@ -192,7 +191,7 @@
executable == Platform.resolvedExecutable,
'Must use dart executable for tracking coverage');
- Completer<String> portAsString = new Completer();
+ Completer<String> portAsString = Completer();
void parsePortAsString(String line) {
if (!portAsString.isCompleted && coverageEnabled) {
Match m = observatoryPortRegexp.matchAsPrefix(line);
@@ -205,7 +204,7 @@
Completer<Iterable<Map>> coverageResult;
if (coverageEnabled) {
- coverageResult = new Completer();
+ coverageResult = Completer();
// This must be added before awaiting in this method.
coverageResults.add(coverageResult.future);
arguments = [
@@ -297,7 +296,7 @@
}
if (result != null) {
if (jsonObjects == null) {
- jsonObjects = new List();
+ jsonObjects = List();
}
jsonObjects.add(result);
if (result.containsKey('message')) {
@@ -363,7 +362,7 @@
int exitCode = await process.exitCode;
if (exitCode != 0) {
- throw new ProcessException(executable, arguments,
+ throw ProcessException(executable, arguments,
"SubprocessLauncher got non-zero exitCode: $exitCode", exitCode);
}
return jsonObjects;
diff --git a/test/template_test.dart b/test/template_test.dart
index 91de138..575e5d2 100644
--- a/test/template_test.dart
+++ b/test/template_test.dart
@@ -19,7 +19,7 @@
if (sitemap == null) {
var templatePath =
path.join(path.current, 'test/templates/sitemap.xml');
- File tmplFile = new File(templatePath);
+ File tmplFile = File(templatePath);
var siteMapTmpl = tmplFile.readAsStringSync();
sitemap = Template(siteMapTmpl);
}
diff --git a/test/tool_runner_test.dart b/test/tool_runner_test.dart
index 6087faa..da33b54 100644
--- a/test/tool_runner_test.dart
+++ b/test/tool_runner_test.dart
@@ -79,10 +79,10 @@
// yaml map (which would fail on a missing executable), or a file is deleted
// during execution,it might, so we test it.
toolMap.tools.addAll({
- 'missing': new ToolDefinition(['/a/missing/executable'], null, "missing"),
+ 'missing': ToolDefinition(['/a/missing/executable'], null, "missing"),
});
- runner = new ToolRunner(toolMap);
+ runner = ToolRunner(toolMap);
errorCallback = (String message) => errors.add(message);
});
tearDownAll(() {
diff --git a/test/utils_test.dart b/test/utils_test.dart
index 9ef899c..5d3dd21 100644
--- a/test/utils_test.dart
+++ b/test/utils_test.dart
@@ -21,7 +21,7 @@
// Trim the left margin of every following line.
.replaceAll('\n$multilineStringMargin ', '\n')
// Trim the last line.
- .replaceFirst(new RegExp('\n$multilineStringMargin\$'), '');
+ .replaceFirst(RegExp('\n$multilineStringMargin\$'), '');
void expectCorrectDocumentation() =>
expect(stripComments(trimMargin(comment)), trimMargin(documentation));
diff --git a/test/warnings_test.dart b/test/warnings_test.dart
index a5b98e0..3dc54b2 100644
--- a/test/warnings_test.dart
+++ b/test/warnings_test.dart
@@ -25,12 +25,12 @@
..createSync();
testPackageThree = Directory(path.join(tempDir.path, 'test_package_three'))
..createSync();
- pubspecYamlOne = new File(path.join(testPackageOne.path, 'pubspec.yaml'));
+ pubspecYamlOne = File(path.join(testPackageOne.path, 'pubspec.yaml'));
pubspecYamlOne.writeAsStringSync('name: test_package_one');
- pubspecYamlTwo = new File(path.join(testPackageTwo.path, 'pubspec.yaml'));
+ pubspecYamlTwo = File(path.join(testPackageTwo.path, 'pubspec.yaml'));
pubspecYamlTwo.writeAsStringSync('name: test_package_two');
dartdocYamlThree =
- new File(path.join(testPackageThree.path, 'dartdoc_options.yaml'));
+ File(path.join(testPackageThree.path, 'dartdoc_options.yaml'));
dartdocYamlThree.writeAsStringSync('''
dartdoc:
warnings:
@@ -41,8 +41,7 @@
ignore:
- ambiguous-reexport
''');
- pubspecYamlThree =
- new File(path.join(testPackageThree.path, 'pubspec.yaml'));
+ pubspecYamlThree = File(path.join(testPackageThree.path, 'pubspec.yaml'));
pubspecYamlThree.writeAsStringSync('name: test_package_three');
});
diff --git a/testing/test_package/bin/drill.dart b/testing/test_package/bin/drill.dart
index 9149504..8217cbf 100644
--- a/testing/test_package/bin/drill.dart
+++ b/testing/test_package/bin/drill.dart
@@ -22,12 +22,12 @@
// Normalize the filenames, since they include random
// and system-specific components, but make sure they
// match the patterns we expect.
- RegExp inputFileRegExp = new RegExp(
- r'(--file=)?(.*)([/\\]dartdoc_tools_)([^/\\]+)([/\\]input_)(\d+)');
- RegExp packagePathRegExp = new RegExp(
- r'(--package-path=)?(.+dartdoc.*[/\\]testing[/\\]test_package)');
+ RegExp inputFileRegExp =
+ RegExp(r'(--file=)?(.*)([/\\]dartdoc_tools_)([^/\\]+)([/\\]input_)(\d+)');
+ RegExp packagePathRegExp =
+ RegExp(r'(--package-path=)?(.+dartdoc.*[/\\]testing[/\\]test_package)');
- final Set<String> variableNames = new Set<String>.from([
+ final Set<String> variableNames = Set<String>.from([
'INPUT',
'SOURCE_COLUMN',
'SOURCE_PATH',
@@ -56,9 +56,9 @@
}
}).toList();
RegExp snapshotCacheRegExp =
- new RegExp(r'.*[/\\]dartdoc_snapshot_cache_[^/\\]+[/\\]snapshot_0');
+ RegExp(r'.*[/\\]dartdoc_snapshot_cache_[^/\\]+[/\\]snapshot_0');
RegExp snapshotFirstRegExp =
- new RegExp(r'.*[/\\]testing[/\\]test_package[/\\]bin[/\\]drill.dart$');
+ RegExp(r'.*[/\\]testing[/\\]test_package[/\\]bin[/\\]drill.dart$');
if (snapshotCacheRegExp.hasMatch(Platform.script.path)) {
print('Script location is in snapshot cache.');
} else if (snapshotFirstRegExp.hasMatch(Platform.script.path)) {
@@ -68,7 +68,7 @@
}
print('Args: $normalized');
if (args['file'] != null) {
- File file = new File(args['file']);
+ File file = File(args['file']);
if (file.existsSync()) {
List<String> lines = file.readAsLinesSync();
for (String line in lines) {
diff --git a/testing/test_package/bin/setup.dart b/testing/test_package/bin/setup.dart
index f67b442..a04713d 100644
--- a/testing/test_package/bin/setup.dart
+++ b/testing/test_package/bin/setup.dart
@@ -10,7 +10,7 @@
void main(List<String> args) {
assert(args.isNotEmpty);
// Just touch the file given on the command line.
- File setupFile = new File(args[0])..createSync(recursive: true);
+ File setupFile = File(args[0])..createSync(recursive: true);
setupFile.writeAsStringSync('setup');
exit(0);
}
diff --git a/testing/test_package/lib/example.dart b/testing/test_package/lib/example.dart
index ea392c6..b464043 100644
--- a/testing/test_package/lib/example.dart
+++ b/testing/test_package/lib/example.dart
@@ -46,7 +46,6 @@
/// {@endtemplate}
bool get isCheck => true;
-
/// A custom annotation.
class aThingToDo {
final String who;
@@ -55,12 +54,8 @@
const aThingToDo(this.who, this.what);
}
-const ConstantCat MY_CAT = const ConstantCat('tabby');
-const List<String> PRETTY_COLORS = const <String>[
- COLOR_GREEN,
- COLOR_ORANGE,
- 'blue'
-];
+const ConstantCat MY_CAT = ConstantCat('tabby');
+const List<String> PRETTY_COLORS = <String>[COLOR_GREEN, COLOR_ORANGE, 'blue'];
@deprecated
int deprecatedField;
@@ -157,7 +152,7 @@
Apple();
factory Apple.fromString(String s) {
- return new Apple._internal(s);
+ return Apple._internal(s);
}
Apple._internal(this._s2);
@@ -300,7 +295,7 @@
static const String aStaticConstField = "A Constant Dog";
/// Verify link substitution in constants (#1535)
- static const ShortName aName = const ExtendedShortName("hello there");
+ static const ShortName aName = ExtendedShortName("hello there");
@protected
final int aProtectedFinalField;
@@ -321,7 +316,7 @@
@override
bool get isImplemented => true;
- int get aGetterReturningRandomThings => (new Random()).nextInt(50);
+ int get aGetterReturningRandomThings => (Random()).nextInt(50);
@override
operator ==(other) => other is Dog && name == other.name;
@@ -330,12 +325,12 @@
@deprecated
List<Apple> getClassA() {
- return [new Apple()];
+ return [Apple()];
}
@Deprecated('before v27.3')
List<Dog> getAnotherClassD() {
- return [new Dog()];
+ return [Dog()];
}
/// A tasty static + final property.
@@ -440,7 +435,7 @@
@Deprecated("Internal use")
static Dog createDog(String s) {
- return new Dog.deprecatedCreate(s);
+ return Dog.deprecatedCreate(s);
}
@override
@@ -511,8 +506,8 @@
/// [MyError] and [MyException] and
/// [List<int>] foo bar.
class ShapeType extends _RetainedEnum {
- static const ShapeType rect = const ShapeType._internal("Rect");
- static const ShapeType ellipse = const ShapeType._internal("Ellipse");
+ static const ShapeType rect = ShapeType._internal("Rect");
+ static const ShapeType ellipse = ShapeType._internal("Ellipse");
const ShapeType._internal(String name) : super(name);
}
diff --git a/testing/test_package/lib/fake.dart b/testing/test_package/lib/fake.dart
index 5797624..5e828e7 100644
--- a/testing/test_package/lib/fake.dart
+++ b/testing/test_package/lib/fake.dart
@@ -180,8 +180,8 @@
/// | [foo] | Not really | "blah" |
/// | [bar] | Maybe | "stuff" |
class DocumentWithATable {
- static const DocumentWithATable foo = const DocumentWithATable();
- static const DocumentWithATable bar = const DocumentWithATable();
+ static const DocumentWithATable foo = DocumentWithATable();
+ static const DocumentWithATable bar = DocumentWithATable();
const DocumentWithATable();
void aMethod(String parameter) {}
@@ -245,7 +245,7 @@
String aProperty;
}
-const _APrivateConstClass CUSTOM_CLASS_PRIVATE = const _APrivateConstClass();
+const _APrivateConstClass CUSTOM_CLASS_PRIVATE = _APrivateConstClass();
/// Type inference mixing with anonymous functions.
final importantComputations = {
@@ -256,7 +256,7 @@
};
// No dart docs on purpose. Also, a non-primitive const class.
-const ConstantClass CUSTOM_CLASS = const ConstantClass('custom');
+const ConstantClass CUSTOM_CLASS = ConstantClass('custom');
/// Up is a direction.
///
@@ -510,7 +510,7 @@
@override
/// Getter doc for explicitGetterImplicitSetter
- List<int> get explicitGetterImplicitSetter => new List<int>();
+ List<int> get explicitGetterImplicitSetter => List<int>();
myCoolTypedef _aFunction;
@@ -546,7 +546,7 @@
set explicitSetter(f(int bar, Cool baz, List<int> macTruck)) {}
/// This property has some docs, too.
- final Set finalProperty = new Set();
+ final Set finalProperty = Set();
Map implicitReadWrite;
@@ -661,8 +661,8 @@
final int index;
const Foo2(this.index);
- static const Foo2 BAR = const Foo2(0);
- static const Foo2 BAZ = const Foo2(1);
+ static const Foo2 BAR = Foo2(0);
+ static const Foo2 BAZ = Foo2(1);
}
class OtherGenericsThing<A> {
@@ -999,7 +999,7 @@
abstract class _MIEEPrivateOverride<K, V> implements MIEEThing<K, V> {
// ignore: annotate_overrides
void operator []=(K key, V value) {
- throw new UnsupportedError("Never use this");
+ throw UnsupportedError("Never use this");
}
}
@@ -1035,7 +1035,8 @@
}
/// The method [invokeToolParentDoc] gets its documentation from an interface class.
-abstract class CanonicalPrivateInheritedToolUser implements ImplementingClassForTool {
+abstract class CanonicalPrivateInheritedToolUser
+ implements ImplementingClassForTool {
@override
void invokeToolParentDoc() {
print('hello, tool world');
diff --git a/testing/test_package_bad/lib/test_package_bad.dart b/testing/test_package_bad/lib/test_package_bad.dart
index 722b02f..72e4c62 100644
--- a/testing/test_package_bad/lib/test_package_bad.dart
+++ b/testing/test_package_bad/lib/test_package_bad.dart
@@ -4,5 +4,5 @@
void myTestFunction() {
print('one');
print('two');
- Foo foo = new Foo('three');
+ Foo foo = Foo('three');
}
diff --git a/testing/test_package_experiments/lib/main.dart b/testing/test_package_experiments/lib/main.dart
index 23c65c0..d037519 100644
--- a/testing/test_package_experiments/lib/main.dart
+++ b/testing/test_package_experiments/lib/main.dart
@@ -1,5 +1,5 @@
const inferredTypeSet = {1, 2.5, 3};
-const Set<int> specifiedSet = const {};
+const Set<int> specifiedSet = {};
const untypedMap = {};
const typedSet = <String>{};
@@ -10,7 +10,8 @@
const AClassContainingLiterals(this.value1, this.value2);
@override
- bool operator==(Object other) => other is AClassContainingLiterals && value1 == other.value1;
+ bool operator ==(Object other) =>
+ other is AClassContainingLiterals && value1 == other.value1;
}
-const aComplexSet = {AClassContainingLiterals(3, 5)};
\ No newline at end of file
+const aComplexSet = {AClassContainingLiterals(3, 5)};
diff --git a/tool/builder.dart b/tool/builder.dart
index a62b693..fa92cef 100644
--- a/tool/builder.dart
+++ b/tool/builder.dart
@@ -11,7 +11,7 @@
String _resourcesFile(Iterable<String> packagePaths) => '''
// WARNING: This file is auto-generated. Do not taunt.
-const List<String> resource_names = const [
+const List<String> resource_names = [
${packagePaths.map((p) => " '$p'").join(',\n')}
];
''';
@@ -20,7 +20,7 @@
final BuilderOptions builderOptions;
ResourceBuilder(this.builderOptions);
- static final _allResources = new Glob('lib/resources/**');
+ static final _allResources = Glob('lib/resources/**');
@override
Future build(BuildStep buildStep) async {
var packagePaths = <String>[];
@@ -29,15 +29,15 @@
}
packagePaths.sort();
await buildStep.writeAsString(
- new AssetId(buildStep.inputId.package,
+ AssetId(buildStep.inputId.package,
path.url.join('lib', 'src', 'html', 'resources.g.dart')),
_resourcesFile(packagePaths));
}
@override
final Map<String, List<String>> buildExtensions = const {
- r'$lib$': const ['src/html/resources.g.dart']
+ r'$lib$': ['src/html/resources.g.dart']
};
}
-Builder resourceBuilder(BuilderOptions options) => new ResourceBuilder(options);
+Builder resourceBuilder(BuilderOptions options) => ResourceBuilder(options);
diff --git a/tool/doc_packages.dart b/tool/doc_packages.dart
index 20903c9..5a8ea81 100644
--- a/tool/doc_packages.dart
+++ b/tool/doc_packages.dart
@@ -47,7 +47,7 @@
}
ArgParser _createArgsParser() {
- var parser = new ArgParser();
+ var parser = ArgParser();
parser.addFlag('help',
abbr: 'h', negatable: false, help: 'Show command help.');
parser.addFlag('list', help: 'Show available pub packages', negatable: false);
@@ -125,7 +125,7 @@
return http
.get('https://pub.dartlang.org/packages.json?page=${page}')
.then((response) {
- return new List<String>.from(json.decode(response.body)['packages']);
+ return List<String>.from(json.decode(response.body)['packages']);
});
}
@@ -134,9 +134,9 @@
return http.get(p).then((response) {
var decodedJson = json.decode(response.body);
String name = decodedJson['name'];
- List<Version> versions = new List<Version>.from(
- decodedJson['versions'].map((v) => new Version.parse(v)));
- return new PackageInfo(name, Version.primary(versions));
+ List<Version> versions = List<Version>.from(
+ decodedJson['versions'].map((v) => Version.parse(v)));
+ return PackageInfo(name, Version.primary(versions));
});
}).toList();
@@ -148,24 +148,23 @@
/// Generate the docs for the given package into _rootDir. Return whether
/// generation was performed or was skipped (due to an older package).
Future<bool> _generateFor(PackageInfo package) async {
- _logBuffer = new StringBuffer();
+ _logBuffer = StringBuffer();
// Get the package archive (tar zxvf foo.tar.gz).
var response = await http.get(package.archiveUrl);
if (response.statusCode != 200) throw response;
- Directory output = new Directory('${_rootDir}/${package.name}');
+ Directory output = Directory('${_rootDir}/${package.name}');
output.createSync(recursive: true);
try {
- new File(output.path + '/archive.tar.gz')
- .writeAsBytesSync(response.bodyBytes);
+ File(output.path + '/archive.tar.gz').writeAsBytesSync(response.bodyBytes);
await _exec('tar', ['zxvf', 'archive.tar.gz'],
cwd: output.path, quiet: true);
// Rule out any old packages (old sdk constraints).
- File pubspecFile = new File(output.path + '/pubspec.yaml');
+ File pubspecFile = File(output.path + '/pubspec.yaml');
var pubspecInfo = loadYaml(pubspecFile.readAsStringSync());
// Check for old versions.
@@ -176,7 +175,7 @@
// Run pub get.
await _exec('pub', ['get'],
- cwd: output.path, timeout: new Duration(seconds: 30));
+ cwd: output.path, timeout: Duration(seconds: 30));
// Run dartdoc.
await _exec('dart', ['../../bin/dartdoc.dart'], cwd: output.path);
@@ -187,8 +186,7 @@
_log(st.toString());
rethrow;
} finally {
- new File(output.path + '/output.txt')
- .writeAsStringSync(_logBuffer.toString());
+ File(output.path + '/output.txt').writeAsStringSync(_logBuffer.toString());
}
}
@@ -224,12 +222,12 @@
if (environment != null) {
var sdk = environment['sdk'];
if (sdk != null) {
- VersionConstraint constraint = new VersionConstraint.parse(sdk);
+ VersionConstraint constraint = VersionConstraint.parse(sdk);
String version = Platform.version;
if (version.contains(' ')) {
version = version.substring(0, version.indexOf(' '));
}
- if (!constraint.allows(new Version.parse(version))) {
+ if (!constraint.allows(Version.parse(version))) {
_log('sdk constraint = ${constraint}');
return true;
} else {
diff --git a/tool/grind.dart b/tool/grind.dart
index 8309e30..2f05c76 100644
--- a/tool/grind.dart
+++ b/tool/grind.dart
@@ -24,13 +24,13 @@
/// Kind of an inefficient grepper for now.
void expectFileContains(String path, List<Pattern> items) {
- File source = new File(path);
+ File source = File(path);
if (!source.existsSync()) {
- throw new GrindTestFailure('file not found: ${path}');
+ throw GrindTestFailure('file not found: ${path}');
}
for (Pattern item in items) {
- if (!new File(path).readAsStringSync().contains(item)) {
- throw new GrindTestFailure('Can not find ${item} in ${path}');
+ if (!File(path).readAsStringSync().contains(item)) {
+ throw GrindTestFailure('Can not find ${item} in ${path}');
}
}
}
@@ -41,7 +41,7 @@
/// Run no more than the number of processors available in parallel.
final MultiFutureTracker testFutures =
- new MultiFutureTracker(Platform.numberOfProcessors);
+ MultiFutureTracker(Platform.numberOfProcessors);
// Directory.systemTemp is not a constant. So wrap it.
Directory createTempSync(String prefix) =>
@@ -58,38 +58,37 @@
if (_cleanFlutterRepo == null) {
// No await is allowed between check of _cleanFlutterRepo and its assignment,
// to prevent reentering this function.
- _cleanFlutterRepo = new Completer();
+ _cleanFlutterRepo = Completer();
// Figure out where the repository is supposed to be and lock updates for
// it.
await cleanFlutterDir.parent.create(recursive: true);
assert(_lockFuture == null);
- _lockFuture = new File(path.join(cleanFlutterDir.parent.path, 'lock'))
+ _lockFuture = File(path.join(cleanFlutterDir.parent.path, 'lock'))
.openSync(mode: FileMode.write)
.lock();
await _lockFuture;
File lastSynced =
- new File(path.join(cleanFlutterDir.parent.path, 'lastSynced'));
+ File(path.join(cleanFlutterDir.parent.path, 'lastSynced'));
FlutterRepo newRepo =
- new FlutterRepo.fromPath(cleanFlutterDir.path, {}, 'clean');
+ FlutterRepo.fromPath(cleanFlutterDir.path, {}, 'clean');
// We have a repository, but is it up to date?
DateTime lastSyncedTime;
if (lastSynced.existsSync()) {
- lastSyncedTime = new DateTime.fromMillisecondsSinceEpoch(
+ lastSyncedTime = DateTime.fromMillisecondsSinceEpoch(
int.parse(lastSynced.readAsStringSync()));
}
if (lastSyncedTime == null ||
- new DateTime.now().difference(lastSyncedTime) >
- new Duration(hours: 4)) {
+ DateTime.now().difference(lastSyncedTime) > Duration(hours: 4)) {
// Rebuild the repository.
if (cleanFlutterDir.existsSync()) {
cleanFlutterDir.deleteSync(recursive: true);
}
cleanFlutterDir.createSync(recursive: true);
await newRepo._init();
- await lastSynced.writeAsString(
- (new DateTime.now()).millisecondsSinceEpoch.toString());
+ await lastSynced
+ .writeAsString((DateTime.now()).millisecondsSinceEpoch.toString());
}
_cleanFlutterRepo.complete(newRepo);
}
@@ -109,7 +108,7 @@
Directory get sdkDocsDir => _sdkDocsDir ??= createTempSync('sdkdocs');
-Directory cleanFlutterDir = new Directory(
+Directory cleanFlutterDir = Directory(
path.join(resolveTildePath('~/.dartdoc_grinder'), 'cleanFlutter'));
Directory _flutterDir;
@@ -117,10 +116,10 @@
Directory get flutterDir => _flutterDir ??= createTempSync('flutter');
Directory get testPackage =>
- new Directory(path.joinAll(['testing', 'test_package']));
+ Directory(path.joinAll(['testing', 'test_package']));
Directory get pluginPackage =>
- new Directory(path.joinAll(['testing', 'test_package_flutter_plugin']));
+ Directory(path.joinAll(['testing', 'test_package_flutter_plugin']));
Directory _testPackageDocsDir;
@@ -147,7 +146,7 @@
/// If DARTDOC_PARAMS is set, add given parameters to the list.
List<String> get extraDartdocParameters {
if (_extraDartdocParams == null) {
- final RegExp whitespace = new RegExp(r'\s+');
+ final RegExp whitespace = RegExp(r'\s+');
_extraDartdocParams = [];
if (Platform.environment.containsKey('DARTDOC_PARAMS')) {
_extraDartdocParams
@@ -158,15 +157,15 @@
}
final Directory flutterDirDevTools =
- new Directory(path.join(flutterDir.path, 'dev', 'tools'));
+ Directory(path.join(flutterDir.path, 'dev', 'tools'));
/// Creates a throwaway pub cache and returns the environment variables
/// necessary to use it.
Map<String, String> _createThrowawayPubCache() {
final Directory pubCache = Directory.systemTemp.createTempSync('pubcache');
- final Directory pubCacheBin = new Directory(path.join(pubCache.path, 'bin'));
+ final Directory pubCacheBin = Directory(path.join(pubCache.path, 'bin'));
pubCacheBin.createSync();
- return new Map.fromIterables([
+ return Map.fromIterables([
'PUB_CACHE',
'PATH'
], [
@@ -176,16 +175,16 @@
}
// TODO(jcollins-g): make a library out of this
-final FilePath _pkgDir = new FilePath('lib/src/third_party/pkg');
+final FilePath _pkgDir = FilePath('lib/src/third_party/pkg');
final FilePath _mustache4dartDir =
- new FilePath('lib/src/third_party/pkg/mustache4dart');
+ FilePath('lib/src/third_party/pkg/mustache4dart');
final RegExp _mustache4dartPatches =
- new RegExp(r'^\d\d\d-mustache4dart-.*[.]patch$');
+ RegExp(r'^\d\d\d-mustache4dart-.*[.]patch$');
@Task('Update third_party forks')
void updateThirdParty() async {
run('rm', arguments: ['-rf', _mustache4dartDir.path]);
- new Directory(_pkgDir.path).createSync(recursive: true);
+ Directory(_pkgDir.path).createSync(recursive: true);
run('git', arguments: [
'clone',
'--branch',
@@ -195,7 +194,7 @@
_mustache4dartDir.path,
]);
run('rm', arguments: ['-rf', path.join(_mustache4dartDir.path, '.git')]);
- for (String patchFileName in new Directory(_pkgDir.path)
+ for (String patchFileName in Directory(_pkgDir.path)
.listSync()
.map((e) => path.basename(e.path))
.where((String filename) => _mustache4dartPatches.hasMatch(filename))
@@ -213,7 +212,7 @@
@Task('Analyze dartdoc to ensure there are no errors and warnings')
void analyze() async {
- await new SubprocessLauncher('analyze').runStreamed(
+ await SubprocessLauncher('analyze').runStreamed(
sdkBin('dartanalyzer'),
[
'--fatal-warnings',
@@ -236,8 +235,7 @@
@Task('Generate docs for the Dart SDK')
Future buildSdkDocs() async {
log('building SDK docs');
- await _buildSdkDocs(
- sdkDocsDir.path, new Future.value(Directory.current.path));
+ await _buildSdkDocs(sdkDocsDir.path, Future.value(Directory.current.path));
}
class WarningsCollection {
@@ -247,7 +245,7 @@
final String pubCachePath;
WarningsCollection(this.tempDir, this.pubCachePath, this.branch)
- : this.warningKeyCounts = new Map();
+ : this.warningKeyCounts = Map();
static const String kPubCachePathReplacement = '_xxxPubDirectoryxxx_';
static const String kTempDirReplacement = '_xxxTempDirectoryxxx_';
@@ -276,12 +274,12 @@
/// Output formatter for comparing warnings. [this] is the original.
String getPrintableWarningDelta(String title, WarningsCollection current) {
- StringBuffer printBuffer = new StringBuffer();
- Set<String> quantityChangedOuts = new Set();
- Set<String> onlyOriginal = new Set();
- Set<String> onlyCurrent = new Set();
- Set<String> identical = new Set();
- Set<String> allKeys = new Set.from([]
+ StringBuffer printBuffer = StringBuffer();
+ Set<String> quantityChangedOuts = Set();
+ Set<String> onlyOriginal = Set();
+ Set<String> onlyCurrent = Set();
+ Set<String> identical = Set();
+ Set<String> allKeys = Set.from([]
..addAll(warningKeyCounts.keys)
..addAll(current.warningKeyCounts.keys));
@@ -336,7 +334,7 @@
WarningsCollection jsonMessageIterableToWarnings(Iterable<Map> messageIterable,
String tempPath, String pubDir, String branch) {
WarningsCollection warningTexts =
- new WarningsCollection(tempPath, pubDir, branch);
+ WarningsCollection(tempPath, pubDir, branch);
if (messageIterable == null) return warningTexts;
for (Map<String, dynamic> message in messageIterable) {
if (message.containsKey('level') &&
@@ -354,7 +352,7 @@
Directory.systemTemp.createTempSync('dartdoc-comparison-sdkdocs');
Future originalDartdoc = createComparisonDartdoc();
Future currentDartdocSdkBuild = _buildSdkDocs(
- sdkDocsDir.path, new Future.value(Directory.current.path), 'current');
+ sdkDocsDir.path, Future.value(Directory.current.path), 'current');
Future originalDartdocSdkBuild =
_buildSdkDocs(originalDartdocSdkDocs.path, originalDartdoc, 'original');
WarningsCollection currentDartdocWarnings = jsonMessageIterableToWarnings(
@@ -373,7 +371,7 @@
/// directory, assumed to be a git repository). Uses [dartdocOriginalBranch]
/// to checkout a branch or tag.
Future<String> createComparisonDartdoc() async {
- var launcher = new SubprocessLauncher('create-comparison-dartdoc');
+ var launcher = SubprocessLauncher('create-comparison-dartdoc');
Directory dartdocClean =
Directory.systemTemp.createTempSync('dartdoc-comparison');
await launcher
@@ -389,7 +387,7 @@
/// directory, assumed to be a git repository), configured to use the head
/// version of the Dart SDK for analyzer, front-end, and kernel.
Future<String> createSdkDartdoc() async {
- var launcher = new SubprocessLauncher('create-sdk-dartdoc');
+ var launcher = SubprocessLauncher('create-sdk-dartdoc');
Directory dartdocSdk = Directory.systemTemp.createTempSync('dartdoc-sdk');
await launcher
.runStreamed('git', ['clone', Directory.current.path, dartdocSdk.path]);
@@ -406,7 +404,7 @@
'https://dart.googlesource.com/sdk.git',
sdkClone.path
]);
- File dartdocPubspec = new File(path.join(dartdocSdk.path, 'pubspec.yaml'));
+ File dartdocPubspec = File(path.join(dartdocSdk.path, 'pubspec.yaml'));
List<String> pubspecLines = await dartdocPubspec.readAsLines();
List<String> pubspecLinesFiltered = [];
for (String line in pubspecLines) {
@@ -435,7 +433,7 @@
@Task('Run grind tasks with the analyzer SDK.')
Future<void> testWithAnalyzerSdk() async {
- var launcher = new SubprocessLauncher('test-with-analyzer-sdk');
+ var launcher = SubprocessLauncher('test-with-analyzer-sdk');
var sdkDartdoc = await createSdkDartdoc();
final String defaultGrindParameter =
Platform.environment['DARTDOC_GRIND_STEP'] ?? 'test';
@@ -448,7 +446,7 @@
[String label]) async {
if (label == null) label = '';
if (label != '') label = '-$label';
- var launcher = new SubprocessLauncher('build-sdk-docs$label');
+ var launcher = SubprocessLauncher('build-sdk-docs$label');
String cwd = await futureCwd;
await launcher.runStreamed(sdkBin('pub'), ['get'], workingDirectory: cwd);
return await launcher.runStreamed(
@@ -470,7 +468,7 @@
[String label]) async {
if (label == null) label = '';
if (label != '') label = '-$label';
- var launcher = new SubprocessLauncher('build-test-package-docs$label');
+ var launcher = SubprocessLauncher('build-test-package-docs$label');
Future testPackagePubGet = launcher.runStreamed(sdkBin('pub'), ['get'],
workingDirectory: testPackage.absolute.path);
String cwd = await futureCwd;
@@ -495,15 +493,15 @@
@Task('Build generated test package docs (with inherited docs and source code)')
Future<void> buildTestPackageDocs() async {
- await _buildTestPackageDocs(testPackageDocsDir.absolute.path,
- new Future.value(Directory.current.path));
+ await _buildTestPackageDocs(
+ testPackageDocsDir.absolute.path, Future.value(Directory.current.path));
}
@Task('Serve test package docs locally with dhttpd on port 8002')
@Depends(buildTestPackageDocs)
Future<void> serveTestPackageDocs() async {
log('launching dhttpd on port 8002 for SDK');
- var launcher = new SubprocessLauncher('serve-test-package-docs');
+ var launcher = SubprocessLauncher('serve-test-package-docs');
await launcher.runStreamed(sdkBin('pub'), [
'run',
'dhttpd',
@@ -516,7 +514,7 @@
Future<void> _serveDocsFrom(String servePath, int port, String context) async {
log('launching dhttpd on port $port for $context');
- var launcher = new SubprocessLauncher(context);
+ var launcher = SubprocessLauncher(context);
await launcher.runStreamed(sdkBin('pub'), ['get']);
await launcher.runStreamed(sdkBin('pub'), ['global', 'activate', 'dhttpd']);
await launcher.runStreamed(
@@ -527,7 +525,7 @@
@Depends(buildSdkDocs)
Future<void> serveSdkDocs() async {
log('launching dhttpd on port 8000 for SDK');
- var launcher = new SubprocessLauncher('serve-sdk-docs');
+ var launcher = SubprocessLauncher('serve-sdk-docs');
await launcher.runStreamed(sdkBin('pub'), [
'run',
'dhttpd',
@@ -546,7 +544,7 @@
Map<String, String> envCurrent = _createThrowawayPubCache();
Map<String, String> envOriginal = _createThrowawayPubCache();
Future currentDartdocFlutterBuild = _buildFlutterDocs(flutterDir.path,
- new Future.value(Directory.current.path), envCurrent, 'docs-current');
+ Future.value(Directory.current.path), envCurrent, 'docs-current');
Future originalDartdocFlutterBuild = _buildFlutterDocs(
originalDartdocFlutter.path,
originalDartdoc,
@@ -567,7 +565,7 @@
'Flutter repo', currentDartdocWarnings));
if (Platform.environment['SERVE_FLUTTER'] == '1') {
- var launcher = new SubprocessLauncher('serve-flutter-docs');
+ var launcher = SubprocessLauncher('serve-flutter-docs');
await launcher.runStreamed(sdkBin('pub'), ['get']);
Future original = launcher.runStreamed(sdkBin('pub'), [
'run',
@@ -593,7 +591,7 @@
@Depends(buildFlutterDocs)
Future<void> serveFlutterDocs() async {
log('launching dhttpd on port 8001 for Flutter');
- var launcher = new SubprocessLauncher('serve-flutter-docs');
+ var launcher = SubprocessLauncher('serve-flutter-docs');
await launcher.runStreamed(sdkBin('pub'), ['get']);
await launcher.runStreamed(sdkBin('pub'), [
'run',
@@ -614,9 +612,9 @@
log('building flutter docs into: $flutterDir');
Map<String, String> env = _createThrowawayPubCache();
await _buildFlutterDocs(
- flutterDir.path, new Future.value(Directory.current.path), env, 'docs');
+ flutterDir.path, Future.value(Directory.current.path), env, 'docs');
String index =
- new File(path.join(flutterDir.path, 'dev', 'docs', 'doc', 'index.html'))
+ File(path.join(flutterDir.path, 'dev', 'docs', 'doc', 'index.html'))
.readAsStringSync();
stdout.write(index);
}
@@ -635,11 +633,11 @@
'${path.join(path.canonicalize(flutterPath), "bin")}:${env['PATH'] ?? Platform.environment['PATH']}';
env['FLUTTER_ROOT'] = flutterPath;
launcher =
- new SubprocessLauncher('flutter${label == null ? "" : "-$label"}', env);
+ SubprocessLauncher('flutter${label == null ? "" : "-$label"}', env);
}
Future<void> _init() async {
- new Directory(flutterPath).createSync(recursive: true);
+ Directory(flutterPath).createSync(recursive: true);
await launcher.runStreamed(
'git', ['clone', 'https://github.com/flutter/flutter.git', '.'],
workingDirectory: flutterPath);
@@ -662,7 +660,7 @@
factory FlutterRepo.fromPath(String flutterPath, Map<String, String> env,
[String label]) {
- FlutterRepo flutterRepo = new FlutterRepo._(flutterPath, env, label);
+ FlutterRepo flutterRepo = FlutterRepo._(flutterPath, env, label);
return flutterRepo;
}
@@ -671,15 +669,14 @@
FlutterRepo origRepo, String flutterPath, Map<String, String> env,
[String label]) async {
await copyPath(origRepo.flutterPath, flutterPath);
- FlutterRepo flutterRepo = new FlutterRepo._(flutterPath, env, label);
+ FlutterRepo flutterRepo = FlutterRepo._(flutterPath, env, label);
return flutterRepo;
}
/// Doesn't actually copy the existing repo; use for read-only operations only.
static Future<FlutterRepo> fromExistingFlutterRepo(FlutterRepo origRepo,
[String label]) async {
- FlutterRepo flutterRepo =
- new FlutterRepo._(origRepo.flutterPath, {}, label);
+ FlutterRepo flutterRepo = FlutterRepo._(origRepo.flutterPath, {}, label);
return flutterRepo;
}
@@ -718,7 +715,7 @@
String pubPackageName, List<String> dartdocParameters,
[String version, String label]) async {
Map<String, String> env = _createThrowawayPubCache();
- var launcher = new SubprocessLauncher(
+ var launcher = SubprocessLauncher(
'build-${pubPackageName}${version == null ? "" : "-$version"}${label == null ? "" : "-$label"}',
env);
List<String> args = <String>['cache', 'add'];
@@ -726,7 +723,7 @@
args.add(pubPackageName);
await launcher.runStreamed('pub', args);
Directory cache =
- new Directory(path.join(env['PUB_CACHE'], 'hosted', 'pub.dartlang.org'));
+ Directory(path.join(env['PUB_CACHE'], 'hosted', 'pub.dartlang.org'));
Directory pubPackageDir =
cache.listSync().firstWhere((e) => e.path.contains(pubPackageName));
await launcher.runStreamed('pub', ['get'],
@@ -760,7 +757,7 @@
@Task('Checks that CHANGELOG mentions current version')
Future<void> checkChangelogHasVersion() async {
- var changelog = new File('CHANGELOG.md');
+ var changelog = File('CHANGELOG.md');
if (!changelog.existsSync()) {
fail('ERROR: No CHANGELOG.md found in ${Directory.current}');
}
@@ -773,7 +770,7 @@
}
String _getPackageVersion() {
- var pubspec = new File('pubspec.yaml');
+ var pubspec = File('pubspec.yaml');
var yamlDoc;
if (pubspec.existsSync()) {
yamlDoc = yaml.loadYaml(pubspec.readAsStringSync());
@@ -787,13 +784,13 @@
@Task('Rebuild generated files')
Future<void> build() async {
- var launcher = new SubprocessLauncher('build');
+ var launcher = SubprocessLauncher('build');
await launcher.runStreamed(sdkBin('pub'),
['run', 'build_runner', 'build', '--delete-conflicting-outputs']);
// TODO(jcollins-g): port to build system?
String version = _getPackageVersion();
- File dartdoc_options = new File('dartdoc_options.yaml');
+ File dartdoc_options = File('dartdoc_options.yaml');
await dartdoc_options.writeAsString('''dartdoc:
linkToSource:
root: '.'
@@ -810,14 +807,14 @@
@Task('Verify generated files are up to date')
Future<void> checkBuild() async {
- var originalFileContents = new Map<String, String>();
+ var originalFileContents = Map<String, String>();
var differentFiles = <String>[];
// Load original file contents into memory before running the builder;
// it modifies them in place.
for (String relPath in _generated_files_list) {
String origPath = path.joinAll(['lib', relPath]);
- File oldVersion = new File(origPath);
+ File oldVersion = File(origPath);
if (oldVersion.existsSync()) {
originalFileContents[relPath] = oldVersion.readAsStringSync();
}
@@ -825,7 +822,7 @@
await build();
for (String relPath in _generated_files_list) {
- File newVersion = new File(path.join('lib', relPath));
+ File newVersion = File(path.join('lib', relPath));
if (!await newVersion.exists()) {
log('${newVersion.path} does not exist\n');
differentFiles.add(relPath);
@@ -846,7 +843,7 @@
@Task('Dry run of publish to pub.dartlang')
@Depends(checkChangelogHasVersion)
Future<void> tryPublish() async {
- var launcher = new SubprocessLauncher('try-publish');
+ var launcher = SubprocessLauncher('try-publish');
await launcher.runStreamed(sdkBin('pub'), ['publish', '-n']);
}
@@ -856,7 +853,7 @@
await testFutures.wait();
}
-List<File> get testFiles => new Directory('test')
+List<File> get testFiles => Directory('test')
.listSync(recursive: true)
.where((e) => e is File && e.path.endsWith('test.dart'))
.cast<File>()
@@ -867,7 +864,7 @@
for (File dartFile in testFiles) {
await testFutures.addFutureFromClosure(() =>
- new CoverageSubprocessLauncher('dart2-${path.basename(dartFile.path)}')
+ CoverageSubprocessLauncher('dart2-${path.basename(dartFile.path)}')
.runStreamed(
Platform.resolvedExecutable,
<String>[]
@@ -875,13 +872,12 @@
..add(dartFile.path)));
}
- return CoverageSubprocessLauncher.generateCoverageToFile(
- new File('lcov.info'));
+ return CoverageSubprocessLauncher.generateCoverageToFile(File('lcov.info'));
}
@Task('Generate docs for dartdoc')
Future<void> testDartdoc() async {
- var launcher = new SubprocessLauncher('test-dartdoc');
+ var launcher = SubprocessLauncher('test-dartdoc');
await launcher.runStreamed(Platform.resolvedExecutable, [
'--enable-asserts',
'bin/dartdoc.dart',
@@ -890,7 +886,7 @@
]);
expectFileContains(path.join(dartdocDocsDir.path, 'index.html'),
['<title>dartdoc - Dart API docs</title>']);
- final RegExp object = new RegExp('<li>Object</li>', multiLine: true);
+ final RegExp object = RegExp('<li>Object</li>', multiLine: true);
expectFileContains(
path.join(dartdocDocsDir.path, 'dartdoc', 'ModelElement-class.html'),
[object]);
@@ -898,8 +894,8 @@
@Task('Generate docs for dartdoc with remote linking')
Future<void> testDartdocRemote() async {
- var launcher = new SubprocessLauncher('test-dartdoc-remote');
- final RegExp object = new RegExp(
+ var launcher = SubprocessLauncher('test-dartdoc-remote');
+ final RegExp object = RegExp(
'<a href="https://api.dartlang.org/(dev|stable)/[^/]*/dart-core/Object-class.html">Object</a>',
multiLine: true);
await launcher.runStreamed(Platform.resolvedExecutable, [