[repo] improve the analysis of the tools/ directory

Change-Id: I4185e3bdc1f0f6f8464ebc2a043254200e3df486
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233502
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
This commit is contained in:
Devon Carew 2022-02-17 19:09:52 +00:00 committed by Commit Bot
parent d25be5f253
commit c4dc032f6c
17 changed files with 133 additions and 99 deletions

View file

@ -22,6 +22,10 @@
// NB: This utility assumes UN*X style line endings, \n, in the LaTeX
// source file received as input; it will not work with other styles.
// @dart = 2.9
// ignore_for_file: constant_identifier_names
import 'dart:convert';
import 'dart:io';
@ -32,15 +36,15 @@ import 'package:crypto/crypto.dart';
// Normalization of the text: removal or normalization of parts that
// do not affect the output from latex, such as white space.
final commentRE = new RegExp(r"[^\\]%.*"); // NB: . does not match \n.
final whitespaceAllRE = new RegExp(r"^\s+$");
final whitespaceRE = new RegExp(r"(?:(?=\s).){2,}"); // \s except end-of-line
final commentRE = RegExp(r"[^\\]%.*"); // NB: . does not match \n.
final whitespaceAllRE = RegExp(r"^\s+$");
final whitespaceRE = RegExp(r"(?:(?=\s).){2,}"); // \s except end-of-line
/// Removes [match]ing part of [line], adjusting that part with the
/// given [startOffset] and [endOffset], bounded to be valid indices
/// into the string if needed, then inserts [glue] where text was
/// removed. If there is no match then [line] is returned.
cutMatch(line, match, {startOffset: 0, endOffset: 0, glue: ""}) {
cutMatch(line, match, {startOffset = 0, endOffset = 0, glue = ""}) {
if (match == null) return line;
var start = match.start + startOffset;
var end = match.end + endOffset;
@ -50,7 +54,7 @@ cutMatch(line, match, {startOffset: 0, endOffset: 0, glue: ""}) {
return line.substring(0, start) + glue + line.substring(end);
}
cutRegexp(line, re, {startOffset: 0, endOffset: 0, glue: ""}) {
cutRegexp(line, re, {startOffset = 0, endOffset = 0, glue = ""}) {
return cutMatch(line, re.firstMatch(line),
startOffset: startOffset, endOffset: endOffset, glue: glue);
}
@ -58,12 +62,12 @@ cutRegexp(line, re, {startOffset: 0, endOffset: 0, glue: ""}) {
/// Removes the rest of [line] starting from the beginning of the
/// given [match], and adjusting with the given [offset]. If there
/// is no match then [line] is returned.
cutFromMatch(line, match, {offset: 0, glue: ""}) {
cutFromMatch(line, match, {offset = 0, glue = ""}) {
if (match == null) return line;
return line.substring(0, match.start + offset) + glue;
}
cutFromRegexp(line, re, {offset: 0, glue: ""}) {
cutFromRegexp(line, re, {offset = 0, glue = ""}) {
return cutFromMatch(line, re.firstMatch(line), offset: offset, glue: glue);
}
@ -175,8 +179,8 @@ sispNormalize(line) => stripComment(line);
// Managing fragments with significant spacing.
final dartCodeBeginRE = new RegExp(r"^\s*\\begin\s*\{dartCode\}");
final dartCodeEndRE = new RegExp(r"^\s*\\end\s*\{dartCode\}");
final dartCodeBeginRE = RegExp(r"^\s*\\begin\s*\{dartCode\}");
final dartCodeEndRE = RegExp(r"^\s*\\end\s*\{dartCode\}");
/// Recognizes beginning of dartCode block.
sispIsDartBegin(line) => line.contains(dartCodeBeginRE);
@ -204,11 +208,10 @@ findEvents(lines, analyzer) {
/// Returns RegExp text for recognizing a command occupying a line
/// of its own, given the part of the RegExp that recognizes the
/// command name, [cmdNameRE]
lineCommandRE(cmdNameRE) =>
new RegExp(r"^\s*\\" + cmdNameRE + r"\s*\{.*\}%?\s*$");
lineCommandRE(cmdNameRE) => RegExp(r"^\s*\\" + cmdNameRE + r"\s*\{.*\}%?\s*$");
final hashLabelStartRE = new RegExp(r"^\s*\\LMLabel\s*\{");
final hashLabelEndRE = new RegExp(r"\}\s*$");
final hashLabelStartRE = RegExp(r"^\s*\\LMLabel\s*\{");
final hashLabelEndRE = RegExp(r"\}\s*$");
final hashMarkRE = lineCommandRE("LMHash");
final hashLabelRE = lineCommandRE("LMLabel");
@ -259,19 +262,19 @@ abstract class HashEvent {
/// The endLineNumber specifies the end of the block of lines
/// associated with a given event, for event types concerned with
/// blocks of lines rather than single lines.
setEndLineNumber(n) {}
setEndLineNumber(int n) {}
/// Returns null except for \LMHash{} events, where it returns
/// the startLineNumber. This serves to specify a boundary because
/// the preceding \LMHash{} block should stop before the line of
/// this \LMHash{} command. Note that hash blocks may stop earlier,
/// because they cannot contain sectioning commands.
getStartLineNumber() => null;
int getStartLineNumber() => null;
}
class HashMarkerEvent extends HashEvent {
// Line number of first line in block that gets hashed.
var startLineNumber;
int startLineNumber;
// Highest possible number of first line after block that gets
// hashed (where the next \LMHash{} occurs). Note that this value
@ -279,19 +282,21 @@ class HashMarkerEvent extends HashEvent {
// reached), so [endLineNumber] will be initialized in a separate
// scan. Also note that the block may end earlier, because a block
// ends if it would otherwise include a sectioning command.
var endLineNumber;
int endLineNumber;
HashMarkerEvent(this.startLineNumber);
setEndLineNumber(n) {
@override
setEndLineNumber(int n) {
endLineNumber = n;
}
getStartLineNumber() => startLineNumber;
@override
int getStartLineNumber() => startLineNumber;
}
class HashLabelEvent extends HashEvent {
var labelText;
String labelText;
HashLabelEvent(this.labelText);
}
@ -337,10 +342,8 @@ class HashAnalyzer {
return "subsec:";
case PENDING_IS_SUBSUBSECTION:
return "subsubsec:";
case PENDING_IS_PARAGRAPH:
return "par:";
case PENDING_IS_NONE:
throw "\\LMHash{..} should only be used after a sectioning command " +
throw "\\LMHash{..} should only be used after a sectioning command "
"(\\section, \\subsection, \\subsubsection, \\paragraph)";
default:
// set of PENDING_IS_.. was extended, but updates here omitted
@ -351,10 +354,10 @@ class HashAnalyzer {
analyze(line) {
var currentLineNumber = lineNumber++;
if (isHashMarker(line)) {
return new HashMarkerEvent(currentLineNumber);
return HashMarkerEvent(currentLineNumber);
} else if (isHashLabel(line)) {
var labelText = sectioningPrefix() + extractHashLabel(line);
return new HashLabelEvent(labelText);
return HashLabelEvent(labelText);
} else {
// No events to emit, but we may need to note state changes
if (isSectionCommand(line)) {
@ -375,7 +378,7 @@ class HashAnalyzer {
findHashEvents(lines) {
// Create the list of events, omitting endLineNumbers.
var events = findEvents(lines, new HashAnalyzer());
var events = findEvents(lines, HashAnalyzer());
// Set the endLineNumbers.
var currentEndLineNumber = lines.length;
for (var event in events.reversed) {
@ -444,8 +447,8 @@ removeCommand(line, cmdName, startIndex) {
throw "Unmatched braces";
}
final commentaryRE = new RegExp(r"\\commentary\s*\{");
final rationaleRE = new RegExp(r"\\rationale\s*\{");
final commentaryRE = RegExp(r"\\commentary\s*\{");
final rationaleRE = RegExp(r"\\rationale\s*\{");
/// Removes {}-balanced '\commentary{..}' commands from [line].
removeCommentary(line) {
@ -473,7 +476,7 @@ simplifyLine(line) {
// ----------------------------------------------------------------------
// Recognition of line blocks, insertion of block hash into \LMHash{}.
final latexArgumentRE = new RegExp(r"\{.*\}");
final latexArgumentRE = RegExp(r"\{.*\}");
cleanupLine(line) => cutRegexp(line, commentRE, startOffset: 1).trimRight();
@ -530,15 +533,15 @@ main([args]) {
}
// Get LaTeX source.
var inputFile = new File(args[0]);
var inputFile = File(args[0]);
assert(inputFile.existsSync());
var lines = inputFile.readAsLinesSync();
// Will hold LaTeX source with normalized spacing etc., plus hash values.
var outputFile = new File(args[1]);
var outputFile = File(args[1]);
// Will hold hierarchical list of hash values.
var listFile = new File(args[2]);
var listFile = File(args[2]);
var listSink = listFile.openWrite();
// Perform single-line normalization.

View file

@ -0,0 +1,17 @@
include: package:lints/recommended.yaml
analyzer:
exclude:
# This directory isn't intended to be analyzed.
- sdks/**
# There are a fair number of issues in here.
- dart2js/**
- dom/**
- test_generators/**
linter:
rules:
# TODO: Enable this once other issues are addressed.
# - avoid_dynamic_calls
- depend_on_referenced_packages
- directives_ordering

View file

@ -9,8 +9,8 @@
// @dart = 2.9
import '../../pkg/test_runner/bin/compare_results.dart' as compareResults;
import '../../pkg/test_runner/bin/compare_results.dart' as compare_results;
main(List<String> args) {
compareResults.main(args);
compare_results.main(args);
}

View file

@ -63,7 +63,7 @@ main(List<String> args) async {
result['changed'] = true;
}
}
final sink = new File(newResultsPath).openWrite();
final sink = File(newResultsPath).openWrite();
final sorted = results.keys.toList()..sort();
for (final key in sorted) {
sink.writeln(jsonEncode(results[key]));

View file

@ -14,7 +14,7 @@ import 'package:args/args.dart';
import 'package:glob/glob.dart';
void main(List<String> args) async {
final parser = new ArgParser();
final parser = ArgParser();
parser.addMultiOption("builder",
abbr: "b",
help: "Select the builders matching the glob [option is repeatable]",
@ -40,15 +40,15 @@ ${parser.usage}""");
}
int count = int.parse(options["count"]);
final globs = new List<Glob>.from(
options["builder"].map((String pattern) => new Glob(pattern)));
final globs = List<Glob>.from(
options["builder"].map((String pattern) => Glob(pattern)));
// Download the most recent builds from buildbucket.
const maxBuilds = 1000;
final url = Uri.parse("https://cr-buildbucket.appspot.com"
"/prpc/buildbucket.v2.Builds/SearchBuilds");
const maxRetries = 3;
const timeout = const Duration(seconds: 30);
const timeout = Duration(seconds: 30);
final query = jsonEncode({
"predicate": {
"builder": {"project": "dart", "bucket": "ci.sandbox"},
@ -60,7 +60,7 @@ ${parser.usage}""");
late Map<String, dynamic> searchResult;
for (int i = 1; i <= maxRetries; i++) {
try {
final client = new HttpClient();
final client = HttpClient();
final request = await client.postUrl(url).timeout(timeout)
..headers.contentType = ContentType.json
..headers.add(HttpHeaders.acceptHeader, ContentType.json)
@ -74,10 +74,10 @@ ${parser.usage}""");
const prefix = ")]}'";
searchResult = await (response
.cast<List<int>>()
.transform(new Utf8Decoder())
.transform(Utf8Decoder())
.map((event) =>
event.startsWith(prefix) ? event.substring(prefix.length) : event)
.transform(new JsonDecoder())
.transform(JsonDecoder())
.cast<Map<String, dynamic>>()
.first
.timeout(timeout));
@ -132,7 +132,7 @@ ${parser.usage}""");
}
final commit = input["id"] as String;
final buildersForCommit =
buildersForCommits.putIfAbsent(commit, () => new Set<String>());
buildersForCommits.putIfAbsent(commit, () => <String>{});
buildersForCommit.add(builder);
}

View file

@ -74,7 +74,7 @@ class FirestoreDatabase {
path: '$collectionName/$documentName',
query: _currentTransaction == null
? null
: 'transaction=${_escapedCurrentTransaction}'));
: 'transaction=$_escapedCurrentTransaction'));
var response = await _client.get(url, headers: _headers);
if (response.statusCode == HttpStatus.ok) {
var document = jsonDecode(response.body);
@ -123,7 +123,7 @@ class FirestoreDatabase {
}
var body = jsonEncode({
"writes": writes.map((write) => write.data).toList(),
"transaction": "$_currentTransaction"
"transaction": _currentTransaction
});
var response =
await _client.post(_commitUrl, headers: _headers, body: body);
@ -140,7 +140,7 @@ class FirestoreDatabase {
return true;
}
Exception _error(http.Response response, {String message: 'Error'}) {
Exception _error(http.Response response, {String message = 'Error'}) {
throw Exception('$message: ${response.statusCode}: '
'${response.reasonPhrase}:\n${response.body}');
}
@ -154,6 +154,7 @@ abstract class Write {
}
class Update implements Write {
@override
final Map data;
Update(List<String> updateMask, Map document, {String updateTime})
: data = {
@ -188,7 +189,7 @@ class FieldFilter extends Filter {
'fieldFilter': {
'field': {'fieldPath': field},
'op': op,
'value': {'$type': value},
'value': {type: value},
}
});
}

View file

@ -11,9 +11,9 @@
import 'dart:io';
import 'package:args/args.dart';
import 'package:test_runner/bot_results.dart';
import 'lib/src/firestore.dart';
import 'package:test_runner/bot_results.dart';
const newTest = 'new test';
const skippedTest = 'skipped';
@ -23,7 +23,7 @@ const maxAttempts = 20;
FirestoreDatabase database;
class ResultRecord {
final data;
final Map data;
ResultRecord(this.data);
@ -33,7 +33,7 @@ class ResultRecord {
return int.parse(field('blamelist_start_index')['integerValue']);
}
void set blamelistStartIndex(int index) {
set blamelistStartIndex(int index) {
field('blamelist_start_index')['integerValue'] = '$index';
}
@ -109,7 +109,7 @@ void updateBlameLists(
.where((result) => result['document'] != null)
.map((result) => result['document']['name']);
for (var documentPath in documents) {
await database.beginTransaction();
database.beginTransaction();
var documentName = documentPath.split('/').last;
var result =
ResultRecord(await database.getDocument('results', documentName));
@ -181,6 +181,6 @@ main(List<String> arguments) async {
var project = options['staging'] ? 'dart-ci-staging' : 'dart-ci';
database = FirestoreDatabase(
project, await readGcloudAuthToken(options['auth-token']));
await updateBlameLists(configuration, commit, results);
updateBlameLists(configuration, commit, results);
database.closeClient();
}

View file

@ -6,8 +6,8 @@
// @dart = 2.9
import 'dart:async';
import 'dart:io';
import 'dart:convert';
import 'dart:io';
import 'package:args/args.dart';
import 'package:glob/glob.dart';
@ -213,7 +213,7 @@ List<CommonGroup> buildCommonGroups(String commitA, String commitB,
int h = 0;
while (h < diffs.length) {
final d = diffs[h++];
final builders = Set<String>()..add(d.builder);
final builders = <String>{}..add(d.builder);
final gropupDiffs = <Diff>[d];
while (h < diffs.length) {
@ -294,6 +294,7 @@ class Result {
Result(this.commit, this.builderName, this.buildNumber, this.name,
this.expected, this.result);
@override
String toString() => '(expected: $expected, actual: $result)';
bool sameResult(Result other) {
@ -310,7 +311,14 @@ class Result {
return false;
}
@override
int get hashCode => name.hashCode ^ builderName.hashCode;
@override
bool operator ==(Object other) {
// TODO: implement ==
return super == other;
}
}
String currentDate() {
@ -322,7 +330,7 @@ Set<String> loadVmBuildersFromTestMatrix(List<Glob> globs) {
final contents = File('tools/bots/test_matrix.json').readAsStringSync();
final testMatrix = json.decode(contents);
final vmBuilders = Set<String>();
final vmBuilders = <String>{};
for (final config in testMatrix['builder_configurations']) {
for (final builder in config['builders']) {
if (builder.startsWith('vm-') || builder.startsWith('app-')) {
@ -334,7 +342,7 @@ Set<String> loadVmBuildersFromTestMatrix(List<Glob> globs) {
// This one is in the test_matrix.json but we don't run it on CI.
vmBuilders.remove('vm-kernel-asan-linux-release-ia32');
if (!globs.isEmpty) {
if (globs.isNotEmpty) {
vmBuilders.removeWhere((String builder) {
return !globs.any((Glob glob) => glob.matches(builder));
});

View file

@ -8,12 +8,11 @@ import 'dart:io' show File, Platform;
import 'package:yaml/yaml.dart' show YamlMap, loadYaml;
void main() {
YamlMap yaml =
loadYaml(new File.fromUri(computeYamlFile()).readAsStringSync());
YamlMap yaml = loadYaml(File.fromUri(computeYamlFile()).readAsStringSync());
final currentVersion = getAsVersionNumber(yaml['current-version']);
final enumNames = new StringBuffer();
final featureValues = new StringBuffer();
final featureNames = new StringBuffer();
final enumNames = StringBuffer();
final featureValues = StringBuffer();
final featureNames = StringBuffer();
YamlMap features = yaml['features'];
for (var entry in features.entries) {
@ -112,7 +111,9 @@ Uri computeHFile() {
List<num> getAsVersionNumber(dynamic value) {
if (value == null) return null;
final version = List.of("$value".split(".").map(int.parse));
while (version.length < 3) version.add(0);
while (version.length < 3) {
version.add(0);
}
return version;
}

View file

@ -9,10 +9,10 @@ import 'dart:io';
import 'package:path/path.dart' as path;
final oneLineBlock = new RegExp(r'^(\s*)/\*\*\s?(.*)\*/\s*$');
final startBlock = new RegExp(r'^(\s*)/\*\*(.*)$');
final blockLine = new RegExp(r'^\s*\*\s?(.*)$');
final endBlock = new RegExp(r'^\s*\*/\s*$');
final oneLineBlock = RegExp(r'^(\s*)/\*\*\s?(.*)\*/\s*$');
final startBlock = RegExp(r'^(\s*)/\*\*(.*)$');
final blockLine = RegExp(r'^\s*\*\s?(.*)$');
final endBlock = RegExp(r'^\s*\*/\s*$');
main(List<String> args) {
if (args.length != 1) {
@ -23,7 +23,7 @@ main(List<String> args) {
return;
}
var dir = new Directory(args[0]);
var dir = Directory(args[0]);
dir.list(recursive: true, followLinks: false).listen((entity) {
if (entity is File) {
var file = entity.path;
@ -34,19 +34,19 @@ main(List<String> args) {
}
void fixFile(String path) {
var file = new File(path);
var file = File(path);
file.readAsLines().then((lines) => fixContents(lines, path)).then((fixed) {
return new File(path).writeAsString(fixed);
return File(path).writeAsString(fixed);
}).then((file) {
print(file.path);
});
}
String fixContents(List<String> lines, String path) {
var buffer = new StringBuffer();
var buffer = StringBuffer();
var linesOut = 0;
var inBlock = false;
var indent;
String indent;
for (var line in lines) {
var oldLine = line;
@ -104,11 +104,11 @@ String fixContents(List<String> lines, String path) {
// Warn about lines that crossed 80 columns as a result of the change.
if (line.length > 80 && oldLine.length <= 80) {
const _PURPLE = '\u001b[35m';
const _RED = '\u001b[31m';
const _NO_COLOR = '\u001b[0m';
const purple = '\u001b[35m';
const red = '\u001b[31m';
const reset = '\u001b[0m';
print('$_PURPLE$path$_NO_COLOR:$_RED$linesOut$_NO_COLOR: '
print('$purple$path$reset:$red$linesOut$reset: '
'line exceeds 80 cols:\n $line');
}

View file

@ -19,8 +19,8 @@
library bump;
import 'dart:io';
import 'package:args/command_runner.dart';
import 'package:args/command_runner.dart';
import 'package:path/path.dart' as p;
class BumpCommand extends Command<int> {
@ -36,6 +36,7 @@ This will:
4. Prompt to create a CL
''';
@override
String get invocation =>
'./tools/manage_deps.dart bump <path/to/dependency> <options>';

View file

@ -10,7 +10,7 @@ final scriptLine = RegExp(r'^#\!');
final languageMarker = RegExp(r"^\s*//\s*@dart\s*=");
void main(List<String> args) {
if (args.length < 1) {
if (args.isEmpty) {
print('Mark files passed on the command line or under a directory');
print(' passed on the command line as opted out of null safety. Does');
print(' not mark files under directories containing a pubspec.yaml file');

View file

@ -101,6 +101,7 @@ class Package implements Comparable<Package> {
late final String _packageName;
late final Set<String> _declaredDependencies;
late final Set<String> _declaredDevDependencies;
// ignore: unused_field
late final Set<String> _declaredOverrideDependencies;
late final bool _publishToNone;
@ -208,9 +209,9 @@ class Package implements Comparable<Package> {
// print(' dev deps: ${devdeps}');
// }
var out = (String message) {
void out(String message) {
logger.stdout(logger.ansi.emphasized(message));
};
}
var undeclaredRegularUses = Set<String>.from(deps)
..removeAll(_declaredDependencies);
@ -439,6 +440,7 @@ abstract class PubDep {
PubDep(this.name);
@override
String toString() => name;
static PubDep parse(String name, Object dep) {
@ -461,6 +463,7 @@ class SemverPubDep extends PubDep {
SemverPubDep(String name, this.value) : super(name);
@override
String toString() => '$name: $value';
}
@ -469,6 +472,7 @@ class PathPubDep extends PubDep {
PathPubDep(String name, this.path) : super(name);
@override
String toString() => '$name: $path';
}

View file

@ -5,9 +5,9 @@
import 'dart:io';
const String ClassPath = '.:/usr/share/java/antlr3-runtime.jar';
const String MainClass = 'SpecParser';
const String JavaExecutable = 'java';
const String classPath = '.:/usr/share/java/antlr3-runtime.jar';
const String mainClass = 'SpecParser';
const String javaExecutable = 'java';
main([arguments]) {
for (String arg in arguments) {
@ -18,7 +18,7 @@ main([arguments]) {
print(result.stdout);
}
List<String> javaArguments = <String>['-cp', ClassPath, MainClass, arg];
Process.run(JavaExecutable, javaArguments).then(handleResult);
List<String> javaArguments = <String>['-cp', classPath, mainClass, arg];
Process.run(javaExecutable, javaArguments).then(handleResult);
}
}

View file

@ -8,11 +8,12 @@
import 'dart:convert' show jsonDecode;
import 'dart:io' show File, Platform;
import 'package:smith/smith.dart' show TestMatrix;
main() {
var path = Platform.script.resolve("bots/test_matrix.json").toFilePath();
var json;
Map<String, dynamic> json;
try {
json = jsonDecode(File(path).readAsStringSync());
} catch (e) {

View file

@ -297,7 +297,7 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor {
..writeAllLines(lines)
..writeln('}');
} else if (template == 'expression') {
assert(lines.length >= 1);
assert(lines.isNotEmpty);
buffer
..writeln('void main() async =>')
..writeAllLines(lines.take(lines.length - 1))
@ -375,7 +375,7 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor {
print('');
}
} else {
throw 'unexpected result type: ${result}';
throw 'unexpected result type: $result';
}
return;
@ -520,7 +520,7 @@ extension on StringBuffer {
/// Write every line, right-trimmed, of [lines] with a newline after.
void writeAllLines(Iterable<String> lines) {
for (var line in lines) {
this.writeln(line.trimRight());
writeln(line.trimRight());
}
}
}

View file

@ -2,16 +2,14 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io' show File, exit, stderr;
import 'dart:isolate' show RawReceivePort;
import 'dart:convert' show JsonEncoder;
import 'dart:io' show File, exit, stderr;
import 'dart:isolate' show RawReceivePort;
import 'package:yaml/yaml.dart' show loadYaml;
main(List<String> rawArguments) {
var port = new RawReceivePort();
var port = RawReceivePort();
bool check = false;
String? relative;
List<String> arguments = [];
@ -28,12 +26,12 @@ main(List<String> rawArguments) {
stderr.writeln("Usage: yaml2json.dart input.yaml output.json [--check]");
exit(1);
}
Uri input = new File(arguments[0]).absolute.uri;
Uri output = new File(arguments[1]).absolute.uri;
Uri input = File(arguments[0]).absolute.uri;
Uri output = File(arguments[1]).absolute.uri;
String inputString = arguments[0];
String outputString = arguments[1];
if (relative != null) {
String relativeTo = new File(relative).absolute.uri.toString();
String relativeTo = File(relative).absolute.uri.toString();
if (input.toString().startsWith(relativeTo)) {
inputString = input.toString().substring(relativeTo.length);
}
@ -41,15 +39,15 @@ main(List<String> rawArguments) {
outputString = output.toString().substring(relativeTo.length);
}
}
Map yaml = loadYaml(new File.fromUri(input).readAsStringSync());
Map<String, dynamic> result = new Map<String, dynamic>();
Map yaml = loadYaml(File.fromUri(input).readAsStringSync());
Map<String, dynamic> result = <String, dynamic>{};
result["comment:0"] = "NOTE: THIS FILE IS GENERATED. DO NOT EDIT.";
result["comment:1"] =
"Instead modify '$inputString' and follow the instructions therein.";
for (String key in yaml.keys) {
result[key] = yaml[key];
}
File file = new File.fromUri(output);
File file = File.fromUri(output);
String text = const JsonEncoder.withIndent(" ").convert(result);
if (check) {
bool needsUpdate = true;