Eliminate use of new keyword in licence tool (flutter/engine#7266)
This eliminates the use of the now-optional new keyword and enforces the unnecessary_new lint.
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
Signature: d2c90af3896928c85f00e941ad07ce23
|
||||
Signature: 44f83506f783ec3ec678f053b2757fc7
|
||||
|
||||
|
||||
@@ -53,4 +53,5 @@ linter:
|
||||
- unawaited_futures
|
||||
- unnecessary_brace_in_string_interps
|
||||
- unnecessary_getters_setters
|
||||
- unnecessary_new
|
||||
- package_names
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'dart:collection';
|
||||
|
||||
Map<Key, dynamic> _cache = new LinkedHashMap<Key, dynamic>();
|
||||
Map<Key, dynamic> _cache = LinkedHashMap<Key, dynamic>();
|
||||
const int _maxSize = 10;
|
||||
|
||||
T cache<T>(Key key, T getter()) {
|
||||
|
||||
@@ -313,7 +313,7 @@ mixin UTF8TextFile implements TextFile {
|
||||
@override
|
||||
String readString() {
|
||||
try {
|
||||
return cache(new UTF8Of(this), () => utf8.decode(readBytes()));
|
||||
return cache(UTF8Of(this), () => utf8.decode(readBytes()));
|
||||
} on FormatException {
|
||||
print(fullName);
|
||||
rethrow;
|
||||
@@ -324,13 +324,13 @@ mixin UTF8TextFile implements TextFile {
|
||||
mixin Latin1TextFile implements TextFile {
|
||||
@override
|
||||
String readString() {
|
||||
return cache(new Latin1Of(this), () {
|
||||
return cache(Latin1Of(this), () {
|
||||
final List<int> bytes = readBytes();
|
||||
if (bytes.any((int byte) => byte == 0x00))
|
||||
throw '$fullName contains a U+0000 NULL and is probably not actually encoded as Win1252';
|
||||
bool isUTF8 = false;
|
||||
try {
|
||||
cache(new UTF8Of(this), () => utf8.decode(readBytes()));
|
||||
cache(UTF8Of(this), () => utf8.decode(readBytes()));
|
||||
isUTF8 = true;
|
||||
} on FormatException {
|
||||
}
|
||||
@@ -355,7 +355,7 @@ mixin ZipFile on File implements Directory {
|
||||
@override
|
||||
Iterable<IoNode> get walk {
|
||||
try {
|
||||
_root ??= ArchiveDirectory.parseArchive(new a.ZipDecoder().decodeBytes(readBytes()), fullName);
|
||||
_root ??= ArchiveDirectory.parseArchive(a.ZipDecoder().decodeBytes(readBytes()), fullName);
|
||||
return _root.walk;
|
||||
} catch (exception) {
|
||||
print('failed to parse archive:\n$fullName');
|
||||
@@ -370,7 +370,7 @@ mixin TarFile on File implements Directory {
|
||||
@override
|
||||
Iterable<IoNode> get walk {
|
||||
try {
|
||||
_root ??= ArchiveDirectory.parseArchive(new a.TarDecoder().decodeBytes(readBytes()), fullName);
|
||||
_root ??= ArchiveDirectory.parseArchive(a.TarDecoder().decodeBytes(readBytes()), fullName);
|
||||
return _root.walk;
|
||||
} catch (exception) {
|
||||
print('failed to parse archive:\n$fullName');
|
||||
@@ -386,7 +386,7 @@ mixin GZipFile on File implements Directory {
|
||||
Iterable<IoNode> get walk sync* {
|
||||
try {
|
||||
String innerName = path.basenameWithoutExtension(fullName);
|
||||
_data ??= InMemoryFile.parse(fullName + '!' + innerName, new a.GZipDecoder().decodeBytes(readBytes()));
|
||||
_data ??= InMemoryFile.parse(fullName + '!' + innerName, a.GZipDecoder().decodeBytes(readBytes()));
|
||||
if (_data != null)
|
||||
yield _data;
|
||||
} catch (exception) {
|
||||
@@ -403,7 +403,7 @@ mixin BZip2File on File implements Directory {
|
||||
Iterable<IoNode> get walk sync* {
|
||||
try {
|
||||
String innerName = path.basenameWithoutExtension(fullName);
|
||||
_data ??= InMemoryFile.parse(fullName + '!' + innerName, new a.BZip2Decoder().decodeBytes(readBytes()));
|
||||
_data ??= InMemoryFile.parse(fullName + '!' + innerName, a.BZip2Decoder().decodeBytes(readBytes()));
|
||||
if (_data != null)
|
||||
yield _data;
|
||||
} catch (exception) {
|
||||
@@ -420,7 +420,7 @@ class FileSystemDirectory extends IoNode implements Directory {
|
||||
FileSystemDirectory(this._directory);
|
||||
|
||||
factory FileSystemDirectory.fromPath(String name) {
|
||||
return new FileSystemDirectory(new io.Directory(name));
|
||||
return FileSystemDirectory(io.Directory(name));
|
||||
}
|
||||
|
||||
final io.Directory _directory;
|
||||
@@ -432,7 +432,7 @@ class FileSystemDirectory extends IoNode implements Directory {
|
||||
String get fullName => _directory.path;
|
||||
|
||||
List<int> _readBytes(io.File file) {
|
||||
return cache/*List<int>*/(new BytesOf(file), () => file.readAsBytesSync());
|
||||
return cache/*List<int>*/(BytesOf(file), () => file.readAsBytesSync());
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -441,21 +441,21 @@ class FileSystemDirectory extends IoNode implements Directory {
|
||||
list.sort((io.FileSystemEntity a, io.FileSystemEntity b) => a.path.compareTo(b.path));
|
||||
for (io.FileSystemEntity entity in list) {
|
||||
if (entity is io.Directory) {
|
||||
yield new FileSystemDirectory(entity);
|
||||
yield FileSystemDirectory(entity);
|
||||
} else if (entity is io.Link) {
|
||||
yield new FileSystemLink(entity);
|
||||
yield FileSystemLink(entity);
|
||||
} else {
|
||||
assert(entity is io.File);
|
||||
io.File fileEntity = entity;
|
||||
if (fileEntity.lengthSync() > 0) {
|
||||
switch (identifyFile(fileEntity.path, () => _readBytes(fileEntity))) {
|
||||
case FileType.binary: yield new FileSystemFile(fileEntity); break;
|
||||
case FileType.zip: yield new FileSystemZipFile(fileEntity); break;
|
||||
case FileType.tar: yield new FileSystemTarFile(fileEntity); break;
|
||||
case FileType.gz: yield new FileSystemGZipFile(fileEntity); break;
|
||||
case FileType.bzip2: yield new FileSystemBZip2File(fileEntity); break;
|
||||
case FileType.text: yield new FileSystemUTF8TextFile(fileEntity); break;
|
||||
case FileType.latin1Text: yield new FileSystemLatin1TextFile(fileEntity); break;
|
||||
case FileType.binary: yield FileSystemFile(fileEntity); break;
|
||||
case FileType.zip: yield FileSystemZipFile(fileEntity); break;
|
||||
case FileType.tar: yield FileSystemTarFile(fileEntity); break;
|
||||
case FileType.gz: yield FileSystemGZipFile(fileEntity); break;
|
||||
case FileType.bzip2: yield FileSystemBZip2File(fileEntity); break;
|
||||
case FileType.text: yield FileSystemUTF8TextFile(fileEntity); break;
|
||||
case FileType.latin1Text: yield FileSystemLatin1TextFile(fileEntity); break;
|
||||
case FileType.metadata: break; // ignore this file
|
||||
}
|
||||
}
|
||||
@@ -489,7 +489,7 @@ class FileSystemFile extends IoNode implements File {
|
||||
|
||||
@override
|
||||
List<int> readBytes() {
|
||||
return cache(new BytesOf(_file), () => _file.readAsBytesSync());
|
||||
return cache(BytesOf(_file), () => _file.readAsBytesSync());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ class ArchiveDirectory extends IoNode implements Directory {
|
||||
@override
|
||||
final String name;
|
||||
|
||||
Map<String, ArchiveDirectory> _subdirectories = new SplayTreeMap<String, ArchiveDirectory>();
|
||||
Map<String, ArchiveDirectory> _subdirectories = SplayTreeMap<String, ArchiveDirectory>();
|
||||
List<ArchiveFile> _files = <ArchiveFile>[];
|
||||
|
||||
void _add(a.ArchiveFile entry, List<String> remainingPath) {
|
||||
@@ -537,19 +537,19 @@ class ArchiveDirectory extends IoNode implements Directory {
|
||||
final String subdirectoryName = remainingPath.removeAt(0);
|
||||
_subdirectories.putIfAbsent(
|
||||
subdirectoryName,
|
||||
() => new ArchiveDirectory('$fullName/$subdirectoryName', subdirectoryName)
|
||||
() => ArchiveDirectory('$fullName/$subdirectoryName', subdirectoryName)
|
||||
)._add(entry, remainingPath);
|
||||
} else {
|
||||
if (entry.size > 0) {
|
||||
final String entryFullName = fullName + '/' + path.basename(entry.name);
|
||||
switch (identifyFile(entry.name, () => entry.content)) {
|
||||
case FileType.binary: _files.add(new ArchiveFile(entryFullName, entry)); break;
|
||||
case FileType.zip: _files.add(new ArchiveZipFile(entryFullName, entry)); break;
|
||||
case FileType.tar: _files.add(new ArchiveTarFile(entryFullName, entry)); break;
|
||||
case FileType.gz: _files.add(new ArchiveGZipFile(entryFullName, entry)); break;
|
||||
case FileType.bzip2: _files.add(new ArchiveBZip2File(entryFullName, entry)); break;
|
||||
case FileType.text: _files.add(new ArchiveUTF8TextFile(entryFullName, entry)); break;
|
||||
case FileType.latin1Text: _files.add(new ArchiveLatin1TextFile(entryFullName, entry)); break;
|
||||
case FileType.binary: _files.add(ArchiveFile(entryFullName, entry)); break;
|
||||
case FileType.zip: _files.add(ArchiveZipFile(entryFullName, entry)); break;
|
||||
case FileType.tar: _files.add(ArchiveTarFile(entryFullName, entry)); break;
|
||||
case FileType.gz: _files.add(ArchiveGZipFile(entryFullName, entry)); break;
|
||||
case FileType.bzip2: _files.add(ArchiveBZip2File(entryFullName, entry)); break;
|
||||
case FileType.text: _files.add(ArchiveUTF8TextFile(entryFullName, entry)); break;
|
||||
case FileType.latin1Text: _files.add(ArchiveLatin1TextFile(entryFullName, entry)); break;
|
||||
case FileType.metadata: break; // ignore this file
|
||||
}
|
||||
}
|
||||
@@ -557,7 +557,7 @@ class ArchiveDirectory extends IoNode implements Directory {
|
||||
}
|
||||
|
||||
static ArchiveDirectory parseArchive(a.Archive archive, String ownerPath) {
|
||||
final ArchiveDirectory root = new ArchiveDirectory('$ownerPath!', '');
|
||||
final ArchiveDirectory root = ArchiveDirectory('$ownerPath!', '');
|
||||
for (a.ArchiveFile file in archive.files) {
|
||||
if (file.size > 0)
|
||||
root._add(file, file.name.split('/'));
|
||||
@@ -623,13 +623,13 @@ class InMemoryFile extends IoNode implements File {
|
||||
if (bytes.isEmpty)
|
||||
return null;
|
||||
switch (identifyFile(fullName, () => bytes)) {
|
||||
case FileType.binary: return new InMemoryFile(fullName, bytes); break;
|
||||
case FileType.zip: return new InMemoryZipFile(fullName, bytes); break;
|
||||
case FileType.tar: return new InMemoryTarFile(fullName, bytes); break;
|
||||
case FileType.gz: return new InMemoryGZipFile(fullName, bytes); break;
|
||||
case FileType.bzip2: return new InMemoryBZip2File(fullName, bytes); break;
|
||||
case FileType.text: return new InMemoryUTF8TextFile(fullName, bytes); break;
|
||||
case FileType.latin1Text: return new InMemoryLatin1TextFile(fullName, bytes); break;
|
||||
case FileType.binary: return InMemoryFile(fullName, bytes); break;
|
||||
case FileType.zip: return InMemoryZipFile(fullName, bytes); break;
|
||||
case FileType.tar: return InMemoryTarFile(fullName, bytes); break;
|
||||
case FileType.gz: return InMemoryGZipFile(fullName, bytes); break;
|
||||
case FileType.bzip2: return InMemoryBZip2File(fullName, bytes); break;
|
||||
case FileType.text: return InMemoryUTF8TextFile(fullName, bytes); break;
|
||||
case FileType.latin1Text: return InMemoryLatin1TextFile(fullName, bytes); break;
|
||||
case FileType.metadata: break; // ignore this file
|
||||
}
|
||||
assert(false);
|
||||
|
||||
@@ -109,7 +109,7 @@ abstract class License implements Comparable<License> {
|
||||
factory License.unique(String body, LicenseType type, { bool reformatted: false, String origin, bool yesWeKnowWhatItLooksLikeButItIsNot: false }) {
|
||||
if (!reformatted)
|
||||
body = _reformat(body);
|
||||
License result = _registry.putIfAbsent(body, () => new UniqueLicense._(body, type, origin: origin, yesWeKnowWhatItLooksLikeButItIsNot: yesWeKnowWhatItLooksLikeButItIsNot));
|
||||
License result = _registry.putIfAbsent(body, () => UniqueLicense._(body, type, origin: origin, yesWeKnowWhatItLooksLikeButItIsNot: yesWeKnowWhatItLooksLikeButItIsNot));
|
||||
assert(() {
|
||||
if (result is! UniqueLicense || result.type != type)
|
||||
throw 'tried to add a UniqueLicense $type, but it was a duplicate of a ${result.runtimeType} ${result.type}';
|
||||
@@ -121,7 +121,7 @@ abstract class License implements Comparable<License> {
|
||||
factory License.template(String body, LicenseType type, { bool reformatted: false, String origin }) {
|
||||
if (!reformatted)
|
||||
body = _reformat(body);
|
||||
License result = _registry.putIfAbsent(body, () => new TemplateLicense._(body, type, origin: origin));
|
||||
License result = _registry.putIfAbsent(body, () => TemplateLicense._(body, type, origin: origin));
|
||||
assert(() {
|
||||
if (result is! TemplateLicense || result.type != type)
|
||||
throw 'tried to add a TemplateLicense $type, but it was a duplicate of a ${result.runtimeType} ${result.type}';
|
||||
@@ -133,7 +133,7 @@ abstract class License implements Comparable<License> {
|
||||
factory License.message(String body, LicenseType type, { bool reformatted: false, String origin }) {
|
||||
if (!reformatted)
|
||||
body = _reformat(body);
|
||||
License result = _registry.putIfAbsent(body, () => new MessageLicense._(body, type, origin: origin));
|
||||
License result = _registry.putIfAbsent(body, () => MessageLicense._(body, type, origin: origin));
|
||||
assert(() {
|
||||
if (result is! MessageLicense || result.type != type)
|
||||
throw 'tried to add a MessageLicense $type, but it was a duplicate of a ${result.runtimeType} ${result.type}';
|
||||
@@ -143,7 +143,7 @@ abstract class License implements Comparable<License> {
|
||||
}
|
||||
|
||||
factory License.blank(String body, LicenseType type, { String origin }) {
|
||||
License result = _registry.putIfAbsent(body, () => new BlankLicense._(_reformat(body), type, origin: origin));
|
||||
License result = _registry.putIfAbsent(body, () => BlankLicense._(_reformat(body), type, origin: origin));
|
||||
assert(() {
|
||||
if (result is! BlankLicense || result.type != type)
|
||||
throw 'tried to add a BlankLicense $type, but it was a duplicate of a ${result.runtimeType} ${result.type}';
|
||||
@@ -154,7 +154,7 @@ abstract class License implements Comparable<License> {
|
||||
|
||||
factory License.fromMultipleBlocks(List<String> bodies, LicenseType type) {
|
||||
final String body = bodies.map((String s) => _reformat(s)).join('\n\n');
|
||||
return _registry.putIfAbsent(body, () => new UniqueLicense._(body, type));
|
||||
return _registry.putIfAbsent(body, () => UniqueLicense._(body, type));
|
||||
}
|
||||
|
||||
factory License.fromBodyAndType(String body, LicenseType type, { bool reformatted: false, String origin }) {
|
||||
@@ -166,10 +166,10 @@ abstract class License implements Comparable<License> {
|
||||
case LicenseType.mit:
|
||||
case LicenseType.zlib:
|
||||
case LicenseType.icu:
|
||||
return new TemplateLicense._(body, type, origin: origin);
|
||||
return TemplateLicense._(body, type, origin: origin);
|
||||
case LicenseType.unknown:
|
||||
case LicenseType.apacheNotice:
|
||||
return new UniqueLicense._(body, type, origin: origin);
|
||||
return UniqueLicense._(body, type, origin: origin);
|
||||
case LicenseType.afl:
|
||||
case LicenseType.mpl:
|
||||
case LicenseType.gpl:
|
||||
@@ -179,11 +179,11 @@ abstract class License implements Comparable<License> {
|
||||
case LicenseType.eclipse:
|
||||
case LicenseType.ijg:
|
||||
case LicenseType.apsl:
|
||||
return new MessageLicense._(body, type, origin: origin);
|
||||
return MessageLicense._(body, type, origin: origin);
|
||||
case LicenseType.openssl:
|
||||
return new MultiLicense._(body, type, origin: origin);
|
||||
return MultiLicense._(body, type, origin: origin);
|
||||
case LicenseType.libpng:
|
||||
return new BlankLicense._(body, type, origin: origin);
|
||||
return BlankLicense._(body, type, origin: origin);
|
||||
}
|
||||
});
|
||||
assert(result.type == type);
|
||||
@@ -195,18 +195,18 @@ abstract class License implements Comparable<License> {
|
||||
LicenseType type = convertLicenseNameToType(name);
|
||||
if (type == LicenseType.unknown)
|
||||
type = convertBodyToType(body);
|
||||
return new License.fromBodyAndType(body, type, origin: origin);
|
||||
return License.fromBodyAndType(body, type, origin: origin);
|
||||
}
|
||||
|
||||
factory License.fromBody(String body, { String origin }) {
|
||||
body = _reformat(body);
|
||||
LicenseType type = convertBodyToType(body);
|
||||
return new License.fromBodyAndType(body, type, reformatted: true, origin: origin);
|
||||
return License.fromBodyAndType(body, type, reformatted: true, origin: origin);
|
||||
}
|
||||
|
||||
factory License.fromCopyrightAndLicense(String copyright, String template, LicenseType type, { String origin }) {
|
||||
String body = '$copyright\n\n$template';
|
||||
return _registry.putIfAbsent(body, () => new TemplateLicense._(body, type, origin: origin));
|
||||
return _registry.putIfAbsent(body, () => TemplateLicense._(body, type, origin: origin));
|
||||
}
|
||||
|
||||
factory License.fromUrl(String url, { String origin }) {
|
||||
@@ -215,60 +215,60 @@ abstract class License implements Comparable<License> {
|
||||
switch (url) {
|
||||
case 'Apache:2.0':
|
||||
case 'http://www.apache.org/licenses/LICENSE-2.0':
|
||||
body = new system.File('data/apache-license-2.0').readAsStringSync();
|
||||
body = system.File('data/apache-license-2.0').readAsStringSync();
|
||||
type = LicenseType.apache;
|
||||
break;
|
||||
case 'https://developers.google.com/open-source/licenses/bsd':
|
||||
body = new system.File('data/google-bsd').readAsStringSync();
|
||||
body = system.File('data/google-bsd').readAsStringSync();
|
||||
type = LicenseType.bsd;
|
||||
break;
|
||||
case 'http://polymer.github.io/LICENSE.txt':
|
||||
body = new system.File('data/polymer-bsd').readAsStringSync();
|
||||
body = system.File('data/polymer-bsd').readAsStringSync();
|
||||
type = LicenseType.bsd;
|
||||
break;
|
||||
case 'http://www.eclipse.org/legal/epl-v10.html':
|
||||
body = new system.File('data/eclipse-1.0').readAsStringSync();
|
||||
body = system.File('data/eclipse-1.0').readAsStringSync();
|
||||
type = LicenseType.eclipse;
|
||||
break;
|
||||
case 'COPYING3:3':
|
||||
body = new system.File('data/gpl-3.0').readAsStringSync();
|
||||
body = system.File('data/gpl-3.0').readAsStringSync();
|
||||
type = LicenseType.gpl;
|
||||
break;
|
||||
case 'COPYING.LIB:2':
|
||||
case 'COPYING.LIother.m_:2': // blame hyatt
|
||||
body = new system.File('data/library-gpl-2.0').readAsStringSync();
|
||||
body = system.File('data/library-gpl-2.0').readAsStringSync();
|
||||
type = LicenseType.lgpl;
|
||||
break;
|
||||
case 'GNU Lesser:2':
|
||||
// there has never been such a license, but the authors said they meant the LGPL2.1
|
||||
case 'GNU Lesser:2.1':
|
||||
body = new system.File('data/lesser-gpl-2.1').readAsStringSync();
|
||||
body = system.File('data/lesser-gpl-2.1').readAsStringSync();
|
||||
type = LicenseType.lgpl;
|
||||
break;
|
||||
case 'COPYING.RUNTIME:3.1':
|
||||
case 'GCC Runtime Library Exception:3.1':
|
||||
body = new system.File('data/gpl-gcc-exception-3.1').readAsStringSync();
|
||||
body = system.File('data/gpl-gcc-exception-3.1').readAsStringSync();
|
||||
break;
|
||||
case 'Academic Free License:3.0':
|
||||
body = new system.File('data/academic-3.0').readAsStringSync();
|
||||
body = system.File('data/academic-3.0').readAsStringSync();
|
||||
type = LicenseType.afl;
|
||||
break;
|
||||
case 'http://mozilla.org/MPL/2.0/:2.0':
|
||||
body = new system.File('data/mozilla-2.0').readAsStringSync();
|
||||
body = system.File('data/mozilla-2.0').readAsStringSync();
|
||||
type = LicenseType.mpl;
|
||||
break;
|
||||
case 'http://opensource.org/licenses/MIT':
|
||||
case 'http://opensource->org/licenses/MIT': // i don't even
|
||||
body = new system.File('data/mit').readAsStringSync();
|
||||
body = system.File('data/mit').readAsStringSync();
|
||||
type = LicenseType.mit;
|
||||
break;
|
||||
case 'http://www.unicode.org/copyright.html':
|
||||
body = new system.File('data/unicode').readAsStringSync();
|
||||
body = system.File('data/unicode').readAsStringSync();
|
||||
type = LicenseType.icu;
|
||||
break;
|
||||
default: throw 'unknown url $url';
|
||||
}
|
||||
return _registry.putIfAbsent(body, () => new License.fromBodyAndType(body, type, origin: origin));
|
||||
return _registry.putIfAbsent(body, () => License.fromBodyAndType(body, type, origin: origin));
|
||||
}
|
||||
|
||||
License._(String body, this.type, { this.origin, bool yesWeKnowWhatItLooksLikeButItIsNot: false }) : body = body, authors = _readAuthors(body) {
|
||||
@@ -352,7 +352,7 @@ abstract class License implements Comparable<License> {
|
||||
|
||||
Iterable<String> get licensees => _licensees;
|
||||
List<String> _licensees = <String>[];
|
||||
Set<String> _libraries = new Set<String>();
|
||||
Set<String> _libraries = Set<String>();
|
||||
|
||||
bool get isUsed => _licensees.isNotEmpty;
|
||||
|
||||
@@ -395,7 +395,7 @@ abstract class License implements Comparable<License> {
|
||||
return prefixes.join('\n') + '\n\n' + body;
|
||||
}
|
||||
|
||||
static final RegExp _copyrightForAuthors = new RegExp(
|
||||
static final RegExp _copyrightForAuthors = RegExp(
|
||||
r'Copyright [-0-9 ,(cC)©]+\b(The .+ Authors)\.',
|
||||
caseSensitive: false
|
||||
);
|
||||
@@ -417,7 +417,7 @@ void clearLicenseRegistry() {
|
||||
_registry.clear();
|
||||
}
|
||||
|
||||
final License missingLicense = new UniqueLicense._('<missing>', LicenseType.unknown);
|
||||
final License missingLicense = UniqueLicense._('<missing>', LicenseType.unknown);
|
||||
|
||||
String _reformat(String body) {
|
||||
// TODO(ianh): ensure that we're stripping the same amount of leading text on each line
|
||||
@@ -491,12 +491,12 @@ Iterable<_LineRange> _walkLinesBackwards(String body, int start) sync* {
|
||||
start -= 1;
|
||||
if (body[start] == '\n') {
|
||||
if (end != null)
|
||||
yield new _LineRange(start + 1, end, body);
|
||||
yield _LineRange(start + 1, end, body);
|
||||
end = start;
|
||||
}
|
||||
}
|
||||
if (end != null)
|
||||
yield new _LineRange(start, end, body);
|
||||
yield _LineRange(start, end, body);
|
||||
}
|
||||
|
||||
Iterable<_LineRange> _walkLinesForwards(String body, { int start: 0, int end }) sync* {
|
||||
@@ -506,13 +506,13 @@ Iterable<_LineRange> _walkLinesForwards(String body, { int start: 0, int end })
|
||||
while (endIndex < end) {
|
||||
if (body[endIndex] == '\n') {
|
||||
if (startIndex != null)
|
||||
yield new _LineRange(startIndex, endIndex, body);
|
||||
yield _LineRange(startIndex, endIndex, body);
|
||||
startIndex = endIndex + 1;
|
||||
}
|
||||
endIndex += 1;
|
||||
}
|
||||
if (startIndex != null)
|
||||
yield new _LineRange(startIndex, endIndex, body);
|
||||
yield _LineRange(startIndex, endIndex, body);
|
||||
}
|
||||
|
||||
class _SplitLicense {
|
||||
@@ -586,7 +586,7 @@ _SplitLicense _splitLicense(String body, { bool verifyResults: true }) {
|
||||
}
|
||||
if (verifyResults && 'Copyright ('.allMatches(body, end).isNotEmpty && !body.startsWith('If you modify libpng'))
|
||||
throw 'the license seems to contain a copyright:\n===copyright===\n${body.substring(0, end)}\n===license===\n${body.substring(end)}\n=========';
|
||||
return new _SplitLicense(body, end);
|
||||
return _SplitLicense(body, end);
|
||||
}
|
||||
|
||||
class _PartialLicenseMatch {
|
||||
@@ -703,7 +703,7 @@ Iterable<_PartialLicenseMatch> _findLicenseBlocks(String body, RegExp pattern, i
|
||||
assert(body[match.start - 1] == '\n');
|
||||
split = match.start - 1;
|
||||
}
|
||||
yield new _PartialLicenseMatch(body, start, split, match.end, match, hasCopyrights: foundAny);
|
||||
yield _PartialLicenseMatch(body, start, split, match.end, match, hasCopyrights: foundAny);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -721,9 +721,9 @@ Iterable<_LicenseMatch> _expand(License template, String copyright, String body,
|
||||
List<License> results = template.expandTemplate(_reformat(copyright), body, origin: origin).toList();
|
||||
if (results.isEmpty)
|
||||
throw 'license could not be expanded';
|
||||
yield new _LicenseMatch(results.first, start, end, debug: 'expanding template for $debug');
|
||||
yield _LicenseMatch(results.first, start, end, debug: 'expanding template for $debug');
|
||||
if (results.length > 1)
|
||||
yield* results.skip(1).map((License license) => new _LicenseMatch(license, start, end, isDuplicate: true, debug: 'expanding subsequent template for $debug'));
|
||||
yield* results.skip(1).map((License license) => _LicenseMatch(license, start, end, isDuplicate: true, debug: 'expanding subsequent template for $debug'));
|
||||
}
|
||||
|
||||
Iterable<_LicenseMatch> _tryNone(String body, String filename, RegExp pattern, LicenseSource parentDirectory) sync* {
|
||||
@@ -732,16 +732,16 @@ Iterable<_LicenseMatch> _tryNone(String body, String filename, RegExp pattern, L
|
||||
if (results == null || results.isEmpty)
|
||||
throw 'no default license file found';
|
||||
// TODO(ianh): use _expand if the license asks for the copyright to be included (e.g. BSD)
|
||||
yield new _LicenseMatch(results.first, match.start, match.end, debug: '_tryNone');
|
||||
yield _LicenseMatch(results.first, match.start, match.end, debug: '_tryNone');
|
||||
if (results.length > 1)
|
||||
yield* results.skip(1).map((License license) => new _LicenseMatch(license, match.start, match.end, isDuplicate: true, debug: 'subsequent _tryNone'));
|
||||
yield* results.skip(1).map((License license) => _LicenseMatch(license, match.start, match.end, isDuplicate: true, debug: 'subsequent _tryNone'));
|
||||
}
|
||||
}
|
||||
|
||||
Iterable<_LicenseMatch> _tryAttribution(String body, RegExp pattern, { String origin }) sync* {
|
||||
for (Match match in pattern.allMatches(body)) {
|
||||
assert(match.groupCount == 2);
|
||||
yield new _LicenseMatch(new License.unique('Thanks to ${match.group(2)}.', LicenseType.unknown, origin: origin), match.start, match.end, debug: '_tryAttribution');
|
||||
yield _LicenseMatch(License.unique('Thanks to ${match.group(2)}.', LicenseType.unknown, origin: origin), match.start, match.end, debug: '_tryAttribution');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,7 +771,7 @@ Iterable<_LicenseMatch> _tryReferenceByFilename(String body, LicenseFileReferenc
|
||||
'block:\n---\n${match.getEntireLicense()}\n---';
|
||||
}
|
||||
if (match.getCopyrights() == '') {
|
||||
yield new _LicenseMatch(template, match.start, match.end, debug: '_tryReferenceByFilename (with failed copyright search) looking for $filename');
|
||||
yield _LicenseMatch(template, match.start, match.end, debug: '_tryReferenceByFilename (with failed copyright search) looking for $filename');
|
||||
} else {
|
||||
yield* _expand(template, match.getCopyrights(), match.getEntireLicense(), match.start, match.end, debug: '_tryReferenceByFilename (with successful copyright search) looking for $filename', origin: origin);
|
||||
}
|
||||
@@ -793,7 +793,7 @@ Iterable<_LicenseMatch> _tryReferenceByType(String body, RegExp pattern, License
|
||||
if (needsCopyright)
|
||||
yield* _expand(template, match.getCopyrights(), match.getEntireLicense(), match.start, match.end, debug: '_tryReferenceByType', origin: origin);
|
||||
else
|
||||
yield new _LicenseMatch(template, match.start, match.end, debug: '_tryReferenceByType (without copyrights) for type $type');
|
||||
yield _LicenseMatch(template, match.start, match.end, debug: '_tryReferenceByType (without copyrights) for type $type');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -803,7 +803,7 @@ License _dereferenceLicense(int groupIndex, String group(int index), MultipleVer
|
||||
String suffix = '';
|
||||
if (pattern.versionIndicies != null && pattern.versionIndicies.containsKey(groupIndex))
|
||||
suffix = ':${group(pattern.versionIndicies[groupIndex])}';
|
||||
result = new License.fromUrl('${group(groupIndex)}$suffix', origin: origin);
|
||||
result = License.fromUrl('${group(groupIndex)}$suffix', origin: origin);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -813,7 +813,7 @@ Iterable<_LicenseMatch> _tryReferenceByUrl(String body, MultipleVersionedLicense
|
||||
bool isDuplicate = false;
|
||||
for (int index in pattern.licenseIndices) {
|
||||
final License result = _dereferenceLicense(index, match.group, pattern, parentDirectory, origin: origin);
|
||||
yield new _LicenseMatch(result, match.start, match.end, isDuplicate: isDuplicate, debug: '_tryReferenceByUrl');
|
||||
yield _LicenseMatch(result, match.start, match.end, isDuplicate: isDuplicate, debug: '_tryReferenceByUrl');
|
||||
isDuplicate = true;
|
||||
}
|
||||
}
|
||||
@@ -826,7 +826,7 @@ Iterable<_LicenseMatch> _tryInline(String body, RegExp pattern, { bool needsCopy
|
||||
// "missingCopyrights: true" if our own "needsCopyright" argument is true.
|
||||
// We use a template license here (not unique) because it's not uncommon for files
|
||||
// to reference license blocks in other files, but with their own copyrights.
|
||||
yield new _LicenseMatch(new License.fromBody(match.getEntireLicense(), origin: origin), match.start, match.end, debug: '_tryInline', missingCopyrights: needsCopyright && !match.hasCopyrights);
|
||||
yield _LicenseMatch(License.fromBody(match.getEntireLicense(), origin: origin), match.start, match.end, debug: '_tryInline', missingCopyrights: needsCopyright && !match.hasCopyrights);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -947,7 +947,7 @@ class TemplateLicense extends License {
|
||||
@override
|
||||
Iterable<License> expandTemplate(String copyright, String licenseBody, { String origin }) sync* {
|
||||
_conditions ??= _splitLicense(body).getConditions();
|
||||
yield new License.fromCopyrightAndLicense(copyright, _conditions, type, origin: '$origin + ${this.origin}');
|
||||
yield License.fromCopyrightAndLicense(copyright, _conditions, type, origin: '$origin + ${this.origin}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -957,8 +957,8 @@ class MultiLicense extends License {
|
||||
|
||||
@override
|
||||
Iterable<License> expandTemplate(String copyright, String licenseBody, { String origin }) sync* {
|
||||
yield new License.fromBody(body, origin: '$origin + ${this.origin}');
|
||||
yield new License.fromBody(licenseBody, origin: '$origin + ${this.origin}');
|
||||
yield License.fromBody(body, origin: '$origin + ${this.origin}');
|
||||
yield License.fromBody(licenseBody, origin: '$origin + ${this.origin}');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,11 +51,11 @@ abstract class _RepositoryLicensedFile extends _RepositoryFile {
|
||||
_RepositoryLicensedFile(_RepositoryDirectory parent, fs.File io) : super(parent, io);
|
||||
|
||||
// file names that we are confident won't be included in the final build product
|
||||
static final RegExp _readmeNamePattern = new RegExp(r'\b_*(?:readme|contributing|patents)_*\b', caseSensitive: false);
|
||||
static final RegExp _buildTimePattern = new RegExp(r'^(?!.*gen$)(?:CMakeLists\.txt|(?:pkgdata)?Makefile(?:\.inc)?(?:\.am|\.in|)|configure(?:\.ac|\.in)?|config\.(?:sub|guess)|.+\.m4|install-sh|.+\.sh|.+\.bat|.+\.pyc?|.+\.pl|icu-configure|.+\.gypi?|.*\.gni?|.+\.mk|.+\.cmake|.+\.gradle|.+\.yaml|pubspec\.lock|\.packages|vms_make\.com|pom\.xml|\.project|source\.properties)$', caseSensitive: false);
|
||||
static final RegExp _docsPattern = new RegExp(r'^(?:INSTALL|NEWS|OWNERS|AUTHORS|ChangeLog(?:\.rst|\.[0-9]+)?|.+\.txt|.+\.md|.+\.log|.+\.css|.+\.1|doxygen\.config|.+\.spec(?:\.in)?)$', caseSensitive: false);
|
||||
static final RegExp _devPattern = new RegExp(r'^(?:codereview\.settings|.+\.~|.+\.~[0-9]+~|\.clang-format|\.gitattributes|\.landmines|\.DS_Store|\.travis\.yml|\.cirrus\.yml)$', caseSensitive: false);
|
||||
static final RegExp _testsPattern = new RegExp(r'^(?:tj(?:bench|example)test\.(?:java\.)?in|example\.c)$', caseSensitive: false);
|
||||
static final RegExp _readmeNamePattern = RegExp(r'\b_*(?:readme|contributing|patents)_*\b', caseSensitive: false);
|
||||
static final RegExp _buildTimePattern = RegExp(r'^(?!.*gen$)(?:CMakeLists\.txt|(?:pkgdata)?Makefile(?:\.inc)?(?:\.am|\.in|)|configure(?:\.ac|\.in)?|config\.(?:sub|guess)|.+\.m4|install-sh|.+\.sh|.+\.bat|.+\.pyc?|.+\.pl|icu-configure|.+\.gypi?|.*\.gni?|.+\.mk|.+\.cmake|.+\.gradle|.+\.yaml|pubspec\.lock|\.packages|vms_make\.com|pom\.xml|\.project|source\.properties)$', caseSensitive: false);
|
||||
static final RegExp _docsPattern = RegExp(r'^(?:INSTALL|NEWS|OWNERS|AUTHORS|ChangeLog(?:\.rst|\.[0-9]+)?|.+\.txt|.+\.md|.+\.log|.+\.css|.+\.1|doxygen\.config|.+\.spec(?:\.in)?)$', caseSensitive: false);
|
||||
static final RegExp _devPattern = RegExp(r'^(?:codereview\.settings|.+\.~|.+\.~[0-9]+~|\.clang-format|\.gitattributes|\.landmines|\.DS_Store|\.travis\.yml|\.cirrus\.yml)$', caseSensitive: false);
|
||||
static final RegExp _testsPattern = RegExp(r'^(?:tj(?:bench|example)test\.(?:java\.)?in|example\.c)$', caseSensitive: false);
|
||||
|
||||
bool get isIncludedInBuildProducts {
|
||||
return !io.name.contains(_readmeNamePattern)
|
||||
@@ -75,7 +75,7 @@ class _RepositorySourceFile extends _RepositoryLicensedFile {
|
||||
@override
|
||||
fs.TextFile get io => super.io;
|
||||
|
||||
static final RegExp _hashBangPattern = new RegExp(r'^#! *(?:/bin/sh|/bin/bash|/usr/bin/env +(?:python|bash))\b');
|
||||
static final RegExp _hashBangPattern = RegExp(r'^#! *(?:/bin/sh|/bin/bash|/usr/bin/env +(?:python|bash))\b');
|
||||
|
||||
@override
|
||||
bool get isShellScript {
|
||||
@@ -170,7 +170,7 @@ abstract class _RepositorySingleLicenseFile extends _RepositoryLicenseFile {
|
||||
|
||||
class _RepositoryGeneralSingleLicenseFile extends _RepositorySingleLicenseFile {
|
||||
_RepositoryGeneralSingleLicenseFile(_RepositoryDirectory parent, fs.TextFile io)
|
||||
: super(parent, io, new License.fromBodyAndName(io.readString(), io.name, origin: io.fullName));
|
||||
: super(parent, io, License.fromBodyAndName(io.readString(), io.name, origin: io.fullName));
|
||||
|
||||
_RepositoryGeneralSingleLicenseFile.fromLicense(_RepositoryDirectory parent, fs.TextFile io, License license)
|
||||
: super(parent, io, license);
|
||||
@@ -190,7 +190,7 @@ class _RepositoryApache4DNoticeFile extends _RepositorySingleLicenseFile {
|
||||
@override
|
||||
License licenseOfType(LicenseType type) => null;
|
||||
|
||||
static final RegExp _pattern = new RegExp(
|
||||
static final RegExp _pattern = RegExp(
|
||||
r'^(// ------------------------------------------------------------------\n'
|
||||
r'// NOTICE file corresponding to the section 4d of The Apache License,\n'
|
||||
r'// Version 2\.0, in this case for (?:.+)\n'
|
||||
@@ -207,7 +207,7 @@ class _RepositoryApache4DNoticeFile extends _RepositorySingleLicenseFile {
|
||||
static License _parseLicense(fs.TextFile io) {
|
||||
final Match match = _pattern.allMatches(io.readString()).single;
|
||||
assert(match.groupCount == 2);
|
||||
return new License.unique(match.group(2), LicenseType.apacheNotice, origin: io.fullName);
|
||||
return License.unique(match.group(2), LicenseType.apacheNotice, origin: io.fullName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ class _RepositoryLicenseRedirectFile extends _RepositorySingleLicenseFile {
|
||||
String contents = io.readString();
|
||||
License license = interpretAsRedirectLicense(contents, parent, origin: io.fullName);
|
||||
if (license != null)
|
||||
return new _RepositoryLicenseRedirectFile(parent, io, license);
|
||||
return _RepositoryLicenseRedirectFile(parent, io, license);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ class _RepositoryLicenseFileWithLeader extends _RepositorySingleLicenseFile {
|
||||
final Match match = leader.firstMatch(body);
|
||||
if (match == null)
|
||||
throw 'failed to strip leader from $io\nleader: /$leader/\nbody:\n---\n$body\n---';
|
||||
return new License.fromBodyAndName(body.substring(match.end), io.name, origin: io.fullName);
|
||||
return License.fromBodyAndName(body.substring(match.end), io.name, origin: io.fullName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ class _RepositoryReadmeIjgFile extends _RepositorySingleLicenseFile {
|
||||
_RepositoryReadmeIjgFile(_RepositoryDirectory parent, fs.TextFile io)
|
||||
: super(parent, io, _parseLicense(io));
|
||||
|
||||
static final RegExp _pattern = new RegExp(
|
||||
static final RegExp _pattern = RegExp(
|
||||
r'Permission is hereby granted to use, copy, modify, and distribute this\n'
|
||||
r'software \(or portions thereof\) for any purpose, without fee, subject to these\n'
|
||||
r'conditions:\n'
|
||||
@@ -272,7 +272,7 @@ class _RepositoryReadmeIjgFile extends _RepositorySingleLicenseFile {
|
||||
String body = io.readString();
|
||||
if (!body.contains(_pattern))
|
||||
throw 'unexpected contents in IJG README';
|
||||
return new License.message(body, LicenseType.ijg, origin: io.fullName);
|
||||
return License.message(body, LicenseType.ijg, origin: io.fullName);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -292,7 +292,7 @@ class _RepositoryDartLicenseFile extends _RepositorySingleLicenseFile {
|
||||
_RepositoryDartLicenseFile(_RepositoryDirectory parent, fs.TextFile io)
|
||||
: super(parent, io, _parseLicense(io));
|
||||
|
||||
static final RegExp _pattern = new RegExp(
|
||||
static final RegExp _pattern = RegExp(
|
||||
r'^This license applies to all parts of Dart that are not externally\n'
|
||||
r'maintained libraries\. The external maintained libraries used by\n'
|
||||
r'Dart are:\n'
|
||||
@@ -310,7 +310,7 @@ class _RepositoryDartLicenseFile extends _RepositorySingleLicenseFile {
|
||||
final Match match = _pattern.firstMatch(io.readString());
|
||||
if (match == null || match.groupCount != 1)
|
||||
throw 'unexpected Dart license file contents';
|
||||
return new License.template(match.group(1), LicenseType.bsd, origin: io.fullName);
|
||||
return License.template(match.group(1), LicenseType.bsd, origin: io.fullName);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -321,7 +321,7 @@ class _RepositoryDartLicenseFile extends _RepositorySingleLicenseFile {
|
||||
|
||||
class _RepositoryLibPngLicenseFile extends _RepositorySingleLicenseFile {
|
||||
_RepositoryLibPngLicenseFile(_RepositoryDirectory parent, fs.TextFile io)
|
||||
: super(parent, io, new License.blank(io.readString(), LicenseType.libpng, origin: io.fullName)) {
|
||||
: super(parent, io, License.blank(io.readString(), LicenseType.libpng, origin: io.fullName)) {
|
||||
_verifyLicense(io);
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ class _RepositoryLibPngLicenseFile extends _RepositorySingleLicenseFile {
|
||||
|
||||
class _RepositoryBlankLicenseFile extends _RepositorySingleLicenseFile {
|
||||
_RepositoryBlankLicenseFile(_RepositoryDirectory parent, fs.TextFile io, String sanityCheck)
|
||||
: super(parent, io, new License.blank(io.readString(), LicenseType.unknown)) {
|
||||
: super(parent, io, License.blank(io.readString(), LicenseType.unknown)) {
|
||||
_verifyLicense(io, sanityCheck);
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ class _RepositoryCatapultApiClientLicenseFile extends _RepositorySingleLicenseFi
|
||||
_RepositoryCatapultApiClientLicenseFile(_RepositoryDirectory parent, fs.TextFile io)
|
||||
: super(parent, io, _parseLicense(io));
|
||||
|
||||
static final RegExp _pattern = new RegExp(
|
||||
static final RegExp _pattern = RegExp(
|
||||
r' *Licensed under the Apache License, Version 2\.0 \(the "License"\);\n'
|
||||
r' *you may not use this file except in compliance with the License\.\n'
|
||||
r' *You may obtain a copy of the License at\n'
|
||||
@@ -381,7 +381,7 @@ class _RepositoryCatapultApiClientLicenseFile extends _RepositorySingleLicenseFi
|
||||
final Match match = _pattern.firstMatch(io.readString());
|
||||
if (match == null || match.groupCount != 1)
|
||||
throw 'unexpected apiclient license file contents';
|
||||
return new License.fromUrl(match.group(1), origin: io.fullName);
|
||||
return License.fromUrl(match.group(1), origin: io.fullName);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -394,7 +394,7 @@ class _RepositoryCatapultCoverageLicenseFile extends _RepositorySingleLicenseFil
|
||||
_RepositoryCatapultCoverageLicenseFile(_RepositoryDirectory parent, fs.TextFile io)
|
||||
: super(parent, io, _parseLicense(io));
|
||||
|
||||
static final RegExp _pattern = new RegExp(
|
||||
static final RegExp _pattern = RegExp(
|
||||
r' *Except where noted otherwise, this software is licensed under the Apache\n'
|
||||
r' *License, Version 2.0 \(the "License"\); you may not use this work except in\n'
|
||||
r' *compliance with the License\. You may obtain a copy of the License at\n'
|
||||
@@ -414,7 +414,7 @@ class _RepositoryCatapultCoverageLicenseFile extends _RepositorySingleLicenseFil
|
||||
final Match match = _pattern.firstMatch(io.readString());
|
||||
if (match == null || match.groupCount != 1)
|
||||
throw 'unexpected coverage license file contents';
|
||||
return new License.fromUrl(match.group(1), origin: io.fullName);
|
||||
return License.fromUrl(match.group(1), origin: io.fullName);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -429,7 +429,7 @@ class _RepositoryLibJpegTurboLicense extends _RepositoryLicenseFile {
|
||||
_parseLicense(io);
|
||||
}
|
||||
|
||||
static final RegExp _pattern = new RegExp(
|
||||
static final RegExp _pattern = RegExp(
|
||||
r'libjpeg-turbo is covered by three compatible BSD-style open source licenses:\n'
|
||||
r'\n'
|
||||
r'- The IJG \(Independent JPEG Group\) License, which is listed in\n'
|
||||
@@ -495,7 +495,7 @@ class _RepositoryFreetypeLicenseFile extends _RepositoryLicenseFile {
|
||||
_RepositoryFreetypeLicenseFile(_RepositoryDirectory parent, fs.TextFile io)
|
||||
: _target = _parseLicense(io), super(parent, io);
|
||||
|
||||
static final RegExp _pattern = new RegExp(
|
||||
static final RegExp _pattern = RegExp(
|
||||
r"The FreeType 2 font engine is copyrighted work and cannot be used\n"
|
||||
r"legally without a software license\. In order to make this project\n"
|
||||
r"usable to a vast majority of developers, we distribute it under two\n"
|
||||
@@ -581,7 +581,7 @@ class _RepositoryIcuLicenseFile extends _RepositoryLicenseFile {
|
||||
|
||||
final List<License> _licenses;
|
||||
|
||||
static final RegExp _pattern = new RegExp(
|
||||
static final RegExp _pattern = RegExp(
|
||||
r'^COPYRIGHT AND PERMISSION NOTICE \(ICU 58 and later\)\n+'
|
||||
r'( *Copyright (?:.|\n)+?)\n+' // 1
|
||||
r'Third-Party Software Licenses\n+'
|
||||
@@ -653,8 +653,8 @@ class _RepositoryIcuLicenseFile extends _RepositoryLicenseFile {
|
||||
caseSensitive: false
|
||||
);
|
||||
|
||||
static final RegExp _unexpectedHash = new RegExp(r'^.+ #', multiLine: true);
|
||||
static final RegExp _newlineHash = new RegExp(r' # ?');
|
||||
static final RegExp _unexpectedHash = RegExp(r'^.+ #', multiLine: true);
|
||||
static final RegExp _newlineHash = RegExp(r' # ?');
|
||||
|
||||
static String _dewrap(String s) {
|
||||
if (!s.startsWith(' # '))
|
||||
@@ -674,16 +674,16 @@ class _RepositoryIcuLicenseFile extends _RepositoryLicenseFile {
|
||||
if (match.group(10).contains(copyrightMentionPattern) || match.group(11).contains('7.'))
|
||||
throw 'unexpected copyright in ICU license file';
|
||||
final List<License> result = <License>[
|
||||
new License.fromBodyAndType(_dewrap(match.group(1)), LicenseType.unknown, origin: io.fullName),
|
||||
new License.fromBodyAndType(_dewrap(match.group(2)), LicenseType.icu, origin: io.fullName),
|
||||
new License.fromBodyAndType(_dewrap(match.group(3)), LicenseType.bsd, origin: io.fullName),
|
||||
new License.fromBodyAndType(_dewrap(match.group(4)), LicenseType.bsd, origin: io.fullName),
|
||||
new License.fromBodyAndType(_dewrap(match.group(5)), LicenseType.bsd, origin: io.fullName),
|
||||
new License.fromBodyAndType(_dewrap(match.group(6)), LicenseType.unknown, origin: io.fullName),
|
||||
new License.fromBodyAndType(_dewrap(match.group(7)), LicenseType.unknown, origin: io.fullName),
|
||||
new License.fromBodyAndType(_dewrap(match.group(8)), LicenseType.bsd, origin: io.fullName),
|
||||
new License.fromBodyAndType(_dewrap(match.group(9)), LicenseType.bsd, origin: io.fullName),
|
||||
new License.fromBodyAndType(_dewrap(match.group(11)), LicenseType.bsd, origin: io.fullName),
|
||||
License.fromBodyAndType(_dewrap(match.group(1)), LicenseType.unknown, origin: io.fullName),
|
||||
License.fromBodyAndType(_dewrap(match.group(2)), LicenseType.icu, origin: io.fullName),
|
||||
License.fromBodyAndType(_dewrap(match.group(3)), LicenseType.bsd, origin: io.fullName),
|
||||
License.fromBodyAndType(_dewrap(match.group(4)), LicenseType.bsd, origin: io.fullName),
|
||||
License.fromBodyAndType(_dewrap(match.group(5)), LicenseType.bsd, origin: io.fullName),
|
||||
License.fromBodyAndType(_dewrap(match.group(6)), LicenseType.unknown, origin: io.fullName),
|
||||
License.fromBodyAndType(_dewrap(match.group(7)), LicenseType.unknown, origin: io.fullName),
|
||||
License.fromBodyAndType(_dewrap(match.group(8)), LicenseType.bsd, origin: io.fullName),
|
||||
License.fromBodyAndType(_dewrap(match.group(9)), LicenseType.bsd, origin: io.fullName),
|
||||
License.fromBodyAndType(_dewrap(match.group(11)), LicenseType.bsd, origin: io.fullName),
|
||||
];
|
||||
return result;
|
||||
}
|
||||
@@ -771,7 +771,7 @@ class _RepositoryMultiLicenseNoticesForFilesFile extends _RepositoryLicenseFile
|
||||
} on FormatException {
|
||||
bodyText = latin1.decode(bodyBytes);
|
||||
}
|
||||
License license = new License.unique(bodyText, LicenseType.unknown, origin: io.fullName);
|
||||
License license = License.unique(bodyText, LicenseType.unknown, origin: io.fullName);
|
||||
for (String name in names) {
|
||||
if (result[name] != null)
|
||||
throw 'conflicting license information for $name in ${io.fullName}';
|
||||
@@ -813,7 +813,7 @@ class _RepositoryCxxStlDualLicenseFile extends _RepositoryLicenseFile {
|
||||
_RepositoryCxxStlDualLicenseFile(_RepositoryDirectory parent, fs.TextFile io)
|
||||
: _licenses = _parseLicenses(io), super(parent, io);
|
||||
|
||||
static final RegExp _pattern = new RegExp(
|
||||
static final RegExp _pattern = RegExp(
|
||||
r'^'
|
||||
r'==============================================================================\n'
|
||||
r'.+ License\n'
|
||||
@@ -838,8 +838,8 @@ class _RepositoryCxxStlDualLicenseFile extends _RepositoryLicenseFile {
|
||||
if (match == null || match.groupCount != 2)
|
||||
throw 'unexpected dual license file contents';
|
||||
return <License>[
|
||||
new License.fromBodyAndType(match.group(1), LicenseType.bsd),
|
||||
new License.fromBodyAndType(match.group(2), LicenseType.mit),
|
||||
License.fromBodyAndType(match.group(1), LicenseType.bsd),
|
||||
License.fromBodyAndType(match.group(2), LicenseType.mit),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -887,7 +887,7 @@ class _RepositoryDirectory extends _RepositoryEntry implements LicenseSource {
|
||||
final Map<String, _RepositoryEntry> _childrenByName = <String, _RepositoryEntry>{};
|
||||
|
||||
// the bit at the beginning excludes files like "license.py".
|
||||
static final RegExp _licenseNamePattern = new RegExp(r'^(?!.*\.py$)(?!.*(?:no|update)-copyright)(?!.*mh-bsd-gcc).*\b_*(?:license(?!\.html)|copying|copyright|notice|l?gpl|bsd|mpl?|ftl\.txt)_*\b', caseSensitive: false);
|
||||
static final RegExp _licenseNamePattern = RegExp(r'^(?!.*\.py$)(?!.*(?:no|update)-copyright)(?!.*mh-bsd-gcc).*\b_*(?:license(?!\.html)|copying|copyright|notice|l?gpl|bsd|mpl?|ftl\.txt)_*\b', caseSensitive: false);
|
||||
|
||||
void crawl() {
|
||||
for (fs.IoNode entry in io.walk) {
|
||||
@@ -943,14 +943,14 @@ class _RepositoryDirectory extends _RepositoryEntry implements LicenseSource {
|
||||
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'third_party')
|
||||
return new _RepositoryGenericThirdPartyDirectory(this, entry);
|
||||
return new _RepositoryDirectory(this, entry);
|
||||
return _RepositoryGenericThirdPartyDirectory(this, entry);
|
||||
return _RepositoryDirectory(this, entry);
|
||||
}
|
||||
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry is fs.TextFile) {
|
||||
if (_RepositoryApache4DNoticeFile.consider(entry)) {
|
||||
return new _RepositoryApache4DNoticeFile(this, entry);
|
||||
return _RepositoryApache4DNoticeFile(this, entry);
|
||||
} else {
|
||||
_RepositoryFile result;
|
||||
if (entry.name == 'NOTICE')
|
||||
@@ -958,17 +958,17 @@ class _RepositoryDirectory extends _RepositoryEntry implements LicenseSource {
|
||||
if (result != null) {
|
||||
return result;
|
||||
} else if (entry.name.contains(_licenseNamePattern)) {
|
||||
return new _RepositoryGeneralSingleLicenseFile(this, entry);
|
||||
return _RepositoryGeneralSingleLicenseFile(this, entry);
|
||||
} else if (entry.name == 'README.ijg') {
|
||||
return new _RepositoryReadmeIjgFile(this, entry);
|
||||
return _RepositoryReadmeIjgFile(this, entry);
|
||||
} else {
|
||||
return new _RepositorySourceFile(this, entry);
|
||||
return _RepositorySourceFile(this, entry);
|
||||
}
|
||||
}
|
||||
} else if (entry.name == 'NOTICE.txt') {
|
||||
return new _RepositoryMultiLicenseNoticesForFilesFile(this, entry);
|
||||
return _RepositoryMultiLicenseNoticesForFilesFile(this, entry);
|
||||
} else {
|
||||
return new _RepositoryBinaryFile(this, entry);
|
||||
return _RepositoryBinaryFile(this, entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1145,7 +1145,7 @@ class _RepositoryDirectory extends _RepositoryEntry implements LicenseSource {
|
||||
if (ignoreCase) {
|
||||
// we get here if we're trying a last-ditch effort at finding a file.
|
||||
// so this should happen only rarely.
|
||||
map = new HashMap<String, _RepositoryEntry>(
|
||||
map = HashMap<String, _RepositoryEntry>(
|
||||
equals: (String n1, String n2) => n1.toLowerCase() == n2.toLowerCase(),
|
||||
hashCode: (String n) => n.toLowerCase().hashCode
|
||||
)
|
||||
@@ -1175,7 +1175,7 @@ class _RepositoryDirectory extends _RepositoryEntry implements LicenseSource {
|
||||
}
|
||||
|
||||
Set<License> getLicenses(_Progress progress) {
|
||||
Set<License> result = new Set<License>();
|
||||
Set<License> result = Set<License>();
|
||||
for (_RepositoryDirectory directory in _subdirectories)
|
||||
result.addAll(directory.getLicenses(progress));
|
||||
for (_RepositoryLicensedFile file in _files) {
|
||||
@@ -1281,7 +1281,7 @@ class _RepositoryReachOutDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (reachOutFilenames.contains(entry.name))
|
||||
return new _RepositoryReachOutFile(this, entry, offset);
|
||||
return _RepositoryReachOutFile(this, entry, offset);
|
||||
return super.createFile(entry);
|
||||
}
|
||||
}
|
||||
@@ -1302,7 +1302,7 @@ class _RepositoryExcludeSubpathDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == paths[index] && (index < paths.length - 1))
|
||||
return new _RepositoryExcludeSubpathDirectory(this, entry, paths, index + 1);
|
||||
return _RepositoryExcludeSubpathDirectory(this, entry, paths, index + 1);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1338,7 +1338,7 @@ class _RepositoryFreetypeDocsDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry.name == 'LICENSE.TXT')
|
||||
return new _RepositoryFreetypeLicenseFile(this, entry);
|
||||
return _RepositoryFreetypeLicenseFile(this, entry);
|
||||
return super.createFile(entry);
|
||||
}
|
||||
|
||||
@@ -1350,7 +1350,7 @@ class _RepositoryFreetypeDocsDirectory extends _RepositoryDirectory {
|
||||
// We don't ship anything in this directory so don't bother looking for licenses there.
|
||||
// However, there are licenses in this directory referenced from elsewhere, so we do
|
||||
// want to crawl it and expose them.
|
||||
return new Set<License>();
|
||||
return Set<License>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1386,7 +1386,7 @@ class _RepositoryFreetypeSrcDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'gzip')
|
||||
return new _RepositoryFreetypeSrcGZipDirectory(this, entry);
|
||||
return _RepositoryFreetypeSrcGZipDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
|
||||
@@ -1431,9 +1431,9 @@ class _RepositoryFreetypeDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'src')
|
||||
return new _RepositoryFreetypeSrcDirectory(this, entry);
|
||||
return _RepositoryFreetypeSrcDirectory(this, entry);
|
||||
if (entry.name == 'docs')
|
||||
return new _RepositoryFreetypeDocsDirectory(this, entry);
|
||||
return _RepositoryFreetypeDocsDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1450,7 +1450,7 @@ class _RepositoryIcuDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry.name == 'LICENSE')
|
||||
return new _RepositoryIcuLicenseFile(this, entry);
|
||||
return _RepositoryIcuLicenseFile(this, entry);
|
||||
return super.createFile(entry);
|
||||
}
|
||||
}
|
||||
@@ -1471,7 +1471,7 @@ class _RepositoryJSR305Directory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'src')
|
||||
return new _RepositoryJSR305SrcDirectory(this, entry);
|
||||
return _RepositoryJSR305SrcDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1499,14 +1499,14 @@ class _RepositoryLibcxxDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'src')
|
||||
return new _RepositoryLibcxxSrcDirectory(this, entry);
|
||||
return _RepositoryLibcxxSrcDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry.name == 'LICENSE.TXT')
|
||||
return new _RepositoryCxxStlDualLicenseFile(this, entry);
|
||||
return _RepositoryCxxStlDualLicenseFile(this, entry);
|
||||
return super.createFile(entry);
|
||||
}
|
||||
}
|
||||
@@ -1517,7 +1517,7 @@ class _RepositoryLibcxxSrcDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'support')
|
||||
return new _RepositoryLibcxxSrcSupportDirectory(this, entry);
|
||||
return _RepositoryLibcxxSrcSupportDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1538,7 +1538,7 @@ class _RepositoryLibcxxabiDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry.name == 'LICENSE.TXT')
|
||||
return new _RepositoryCxxStlDualLicenseFile(this, entry);
|
||||
return _RepositoryCxxStlDualLicenseFile(this, entry);
|
||||
return super.createFile(entry);
|
||||
}
|
||||
}
|
||||
@@ -1549,9 +1549,9 @@ class _RepositoryLibJpegDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry.name == 'README')
|
||||
return new _RepositoryReadmeIjgFile(this, entry);
|
||||
return _RepositoryReadmeIjgFile(this, entry);
|
||||
if (entry.name == 'LICENSE')
|
||||
return new _RepositoryLicenseFileWithLeader(this, entry, new RegExp(r'^\(Copied from the README\.\)\n+-+\n+'));
|
||||
return _RepositoryLicenseFileWithLeader(this, entry, RegExp(r'^\(Copied from the README\.\)\n+-+\n+'));
|
||||
return super.createFile(entry);
|
||||
}
|
||||
}
|
||||
@@ -1562,7 +1562,7 @@ class _RepositoryLibJpegTurboDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry.name == 'LICENSE.md')
|
||||
return new _RepositoryLibJpegTurboLicense(this, entry);
|
||||
return _RepositoryLibJpegTurboLicense(this, entry);
|
||||
return super.createFile(entry);
|
||||
}
|
||||
|
||||
@@ -1581,7 +1581,7 @@ class _RepositoryLibPngDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry.name == 'LICENSE' || entry.name == 'png.h')
|
||||
return new _RepositoryLibPngLicenseFile(this, entry);
|
||||
return _RepositoryLibPngLicenseFile(this, entry);
|
||||
return super.createFile(entry);
|
||||
}
|
||||
}
|
||||
@@ -1604,7 +1604,7 @@ class _RepositoryPkgDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'when')
|
||||
return new _RepositoryPkgWhenDirectory(this, entry);
|
||||
return _RepositoryPkgWhenDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1625,7 +1625,7 @@ class _RepositorySkiaLibWebPDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'webp')
|
||||
return new _RepositoryReachOutDirectory(this, entry, new Set<String>.from(const <String>['config.h']), 3);
|
||||
return _RepositoryReachOutDirectory(this, entry, Set<String>.from(const <String>['config.h']), 3);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1656,13 +1656,13 @@ class _RepositorySkiaThirdPartyDirectory extends _RepositoryGenericThirdPartyDir
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'ktx')
|
||||
return new _RepositoryReachOutDirectory(this, entry, new Set<String>.from(const <String>['ktx.h', 'ktx.cpp']), 2);
|
||||
return _RepositoryReachOutDirectory(this, entry, Set<String>.from(const <String>['ktx.h', 'ktx.cpp']), 2);
|
||||
if (entry.name == 'libmicrohttpd')
|
||||
return new _RepositoryReachOutDirectory(this, entry, new Set<String>.from(const <String>['MHD_config.h']), 2);
|
||||
return _RepositoryReachOutDirectory(this, entry, Set<String>.from(const <String>['MHD_config.h']), 2);
|
||||
if (entry.name == 'libwebp')
|
||||
return new _RepositorySkiaLibWebPDirectory(this, entry);
|
||||
return _RepositorySkiaLibWebPDirectory(this, entry);
|
||||
if (entry.name == 'libsdl')
|
||||
return new _RepositorySkiaLibSdlDirectory(this, entry);
|
||||
return _RepositorySkiaLibSdlDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1681,7 +1681,7 @@ class _RepositorySkiaDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'third_party')
|
||||
return new _RepositorySkiaThirdPartyDirectory(this, entry);
|
||||
return _RepositorySkiaThirdPartyDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1699,7 +1699,7 @@ class _RepositoryVulkanDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'src')
|
||||
return new _RepositoryExcludeSubpathDirectory(this, entry, const <String>['spec']);
|
||||
return _RepositoryExcludeSubpathDirectory(this, entry, const <String>['spec']);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1735,41 +1735,41 @@ class _RepositoryRootThirdPartyDirectory extends _RepositoryGenericThirdPartyDir
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'android_platform')
|
||||
return new _RepositoryAndroidPlatformDirectory(this, entry);
|
||||
return _RepositoryAndroidPlatformDirectory(this, entry);
|
||||
if (entry.name == 'boringssl')
|
||||
return new _RepositoryBoringSSLDirectory(this, entry);
|
||||
return _RepositoryBoringSSLDirectory(this, entry);
|
||||
if (entry.name == 'catapult')
|
||||
return new _RepositoryCatapultDirectory(this, entry);
|
||||
return _RepositoryCatapultDirectory(this, entry);
|
||||
if (entry.name == 'dart')
|
||||
return new _RepositoryDartDirectory(this, entry);
|
||||
return _RepositoryDartDirectory(this, entry);
|
||||
if (entry.name == 'expat')
|
||||
return new _RepositoryExpatDirectory(this, entry);
|
||||
return _RepositoryExpatDirectory(this, entry);
|
||||
if (entry.name == 'freetype-android')
|
||||
throw '//third_party/freetype-android is no longer part of this client: remove it';
|
||||
if (entry.name == 'freetype2')
|
||||
return new _RepositoryFreetypeDirectory(this, entry);
|
||||
return _RepositoryFreetypeDirectory(this, entry);
|
||||
if (entry.name == 'harfbuzz')
|
||||
return new _RepositoryHarfbuzzDirectory(this, entry);
|
||||
return _RepositoryHarfbuzzDirectory(this, entry);
|
||||
if (entry.name == 'icu')
|
||||
return new _RepositoryIcuDirectory(this, entry);
|
||||
return _RepositoryIcuDirectory(this, entry);
|
||||
if (entry.name == 'jsr-305')
|
||||
return new _RepositoryJSR305Directory(this, entry);
|
||||
return _RepositoryJSR305Directory(this, entry);
|
||||
if (entry.name == 'libcxx')
|
||||
return new _RepositoryLibcxxDirectory(this, entry);
|
||||
return _RepositoryLibcxxDirectory(this, entry);
|
||||
if (entry.name == 'libcxxabi')
|
||||
return new _RepositoryLibcxxabiDirectory(this, entry);
|
||||
return _RepositoryLibcxxabiDirectory(this, entry);
|
||||
if (entry.name == 'libjpeg')
|
||||
return new _RepositoryLibJpegDirectory(this, entry);
|
||||
return _RepositoryLibJpegDirectory(this, entry);
|
||||
if (entry.name == 'libjpeg_turbo' || entry.name == 'libjpeg-turbo')
|
||||
return new _RepositoryLibJpegTurboDirectory(this, entry);
|
||||
return _RepositoryLibJpegTurboDirectory(this, entry);
|
||||
if (entry.name == 'libpng')
|
||||
return new _RepositoryLibPngDirectory(this, entry);
|
||||
return _RepositoryLibPngDirectory(this, entry);
|
||||
if (entry.name == 'libwebp')
|
||||
return new _RepositoryLibWebpDirectory(this, entry);
|
||||
return _RepositoryLibWebpDirectory(this, entry);
|
||||
if (entry.name == 'pkg')
|
||||
return new _RepositoryPkgDirectory(this, entry);
|
||||
return _RepositoryPkgDirectory(this, entry);
|
||||
if (entry.name == 'vulkan')
|
||||
return new _RepositoryVulkanDirectory(this, entry);
|
||||
return _RepositoryVulkanDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1802,14 +1802,14 @@ class _RepositoryBoringSSLSourceDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry.name == 'LICENSE')
|
||||
return new _RepositoryOpenSSLLicenseFile(this, entry);
|
||||
return _RepositoryOpenSSLLicenseFile(this, entry);
|
||||
return super.createFile(entry);
|
||||
}
|
||||
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'third_party')
|
||||
return new _RepositoryBoringSSLThirdPartyDirectory(this, entry);
|
||||
return _RepositoryBoringSSLThirdPartyDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1824,7 +1824,7 @@ class _RepositoryBoringSSLSourceDirectory extends _RepositoryDirectory {
|
||||
class _RepositoryOpenSSLLicenseFile extends _RepositorySingleLicenseFile {
|
||||
_RepositoryOpenSSLLicenseFile(_RepositoryDirectory parent, fs.TextFile io)
|
||||
: super(parent, io,
|
||||
new License.fromBodyAndType(
|
||||
License.fromBodyAndType(
|
||||
LineSplitter.split(io.readString())
|
||||
.skip(23)
|
||||
.takeWhile((String s) => !s.startsWith('BoringSSL uses the Chromium test infrastructure to run a continuous build,'))
|
||||
@@ -1854,14 +1854,14 @@ class _RepositoryBoringSSLDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry.name == 'README')
|
||||
return new _RepositoryBlankLicenseFile(this, entry, 'This repository contains the files generated by boringssl for its build.');
|
||||
return _RepositoryBlankLicenseFile(this, entry, 'This repository contains the files generated by boringssl for its build.');
|
||||
return super.createFile(entry);
|
||||
}
|
||||
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'src')
|
||||
return new _RepositoryBoringSSLSourceDirectory(this, entry);
|
||||
return _RepositoryBoringSSLSourceDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1872,7 +1872,7 @@ class _RepositoryCatapultThirdPartyApiClientDirectory extends _RepositoryDirecto
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry.name == 'LICENSE')
|
||||
return new _RepositoryCatapultApiClientLicenseFile(this, entry);
|
||||
return _RepositoryCatapultApiClientLicenseFile(this, entry);
|
||||
return super.createFile(entry);
|
||||
}
|
||||
}
|
||||
@@ -1883,7 +1883,7 @@ class _RepositoryCatapultThirdPartyCoverageDirectory extends _RepositoryDirector
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry.name == 'NOTICE.txt')
|
||||
return new _RepositoryCatapultCoverageLicenseFile(this, entry);
|
||||
return _RepositoryCatapultCoverageLicenseFile(this, entry);
|
||||
return super.createFile(entry);
|
||||
}
|
||||
}
|
||||
@@ -1894,9 +1894,9 @@ class _RepositoryCatapultThirdPartyDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'apiclient')
|
||||
return new _RepositoryCatapultThirdPartyApiClientDirectory(this, entry);
|
||||
return _RepositoryCatapultThirdPartyApiClientDirectory(this, entry);
|
||||
if (entry.name == 'coverage')
|
||||
return new _RepositoryCatapultThirdPartyCoverageDirectory(this, entry);
|
||||
return _RepositoryCatapultThirdPartyCoverageDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1907,7 +1907,7 @@ class _RepositoryCatapultDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'third_party')
|
||||
return new _RepositoryCatapultThirdPartyDirectory(this, entry);
|
||||
return _RepositoryCatapultThirdPartyDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1940,7 +1940,7 @@ class _RepositoryDartThirdPartyDirectory extends _RepositoryGenericThirdPartyDir
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'boringssl')
|
||||
return new _RepositoryBoringSSLDirectory(this, entry);
|
||||
return _RepositoryBoringSSLDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1951,7 +1951,7 @@ class _RepositoryDartRuntimeDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'third_party')
|
||||
return new _RepositoryDartRuntimeThirdPartyDirectory(this, entry);
|
||||
return _RepositoryDartRuntimeThirdPartyDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -1965,7 +1965,7 @@ class _RepositoryDartDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryFile createFile(fs.IoNode entry) {
|
||||
if (entry.name == 'LICENSE')
|
||||
return new _RepositoryDartLicenseFile(this, entry);
|
||||
return _RepositoryDartLicenseFile(this, entry);
|
||||
return super.createFile(entry);
|
||||
}
|
||||
|
||||
@@ -1983,9 +1983,9 @@ class _RepositoryDartDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'third_party')
|
||||
return new _RepositoryDartThirdPartyDirectory(this, entry);
|
||||
return _RepositoryDartThirdPartyDirectory(this, entry);
|
||||
if (entry.name == 'runtime')
|
||||
return new _RepositoryDartRuntimeDirectory(this, entry);
|
||||
return _RepositoryDartRuntimeDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -2014,9 +2014,9 @@ class _RepositoryFlutterDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'sky')
|
||||
return new _RepositoryExcludeSubpathDirectory(this, entry, const <String>['packages', 'sky_engine', 'LICENSE']); // that's the output of this script!
|
||||
return _RepositoryExcludeSubpathDirectory(this, entry, const <String>['packages', 'sky_engine', 'LICENSE']); // that's the output of this script!
|
||||
if (entry.name == 'third_party')
|
||||
return new _RepositoryFlutterThirdPartyDirectory(this, entry);
|
||||
return _RepositoryFlutterThirdPartyDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -2030,7 +2030,7 @@ class _RepositoryFlutterThirdPartyDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'txt')
|
||||
return new _RepositoryFlutterTxtDirectory(this, entry);
|
||||
return _RepositoryFlutterTxtDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -2041,7 +2041,7 @@ class _RepositoryFlutterTxtDirectory extends _RepositoryDirectory {
|
||||
@override
|
||||
_RepositoryDirectory createSubdirectory(fs.Directory entry) {
|
||||
if (entry.name == 'third_party')
|
||||
return new _RepositoryFlutterTxtThirdPartyDirectory(this, entry);
|
||||
return _RepositoryFlutterTxtThirdPartyDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
}
|
||||
@@ -2103,9 +2103,9 @@ class _RepositoryRoot extends _RepositoryDirectory {
|
||||
if (entry.name == 'base')
|
||||
throw '//base is no longer part of this client: remove it';
|
||||
if (entry.name == 'third_party')
|
||||
return new _RepositoryRootThirdPartyDirectory(this, entry);
|
||||
return _RepositoryRootThirdPartyDirectory(this, entry);
|
||||
if (entry.name == 'flutter')
|
||||
return new _RepositoryFlutterDirectory(this, entry);
|
||||
return _RepositoryFlutterDirectory(this, entry);
|
||||
return super.createSubdirectory(entry);
|
||||
}
|
||||
|
||||
@@ -2115,7 +2115,7 @@ class _RepositoryRoot extends _RepositoryDirectory {
|
||||
// is therefore represented as a separate top-level component.
|
||||
fs.Directory thirdPartyNode = io.walk.firstWhere((fs.IoNode node) => node.name == 'third_party');
|
||||
fs.IoNode skiaNode = thirdPartyNode.walk.firstWhere((fs.IoNode node) => node.name == 'skia');
|
||||
return <_RepositoryDirectory>[new _RepositorySkiaDirectory(this, skiaNode)];
|
||||
return <_RepositoryDirectory>[_RepositorySkiaDirectory(this, skiaNode)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2125,7 +2125,7 @@ class _Progress {
|
||||
// This may happen when a git client contains left-over empty component
|
||||
// directories after DEPS file changes.
|
||||
if (max <= 0)
|
||||
throw new ArgumentError('Progress.max must be > 0 but was: $max');
|
||||
throw ArgumentError('Progress.max must be > 0 but was: $max');
|
||||
}
|
||||
|
||||
final int max;
|
||||
@@ -2154,7 +2154,7 @@ class _Progress {
|
||||
Stopwatch _lastUpdate;
|
||||
void update({bool flush = false}) {
|
||||
if (_lastUpdate == null || _lastUpdate.elapsedMilliseconds > 90 || flush) {
|
||||
_lastUpdate ??= new Stopwatch();
|
||||
_lastUpdate ??= Stopwatch();
|
||||
final String line = toString();
|
||||
system.stderr.write('\r$line');
|
||||
if (_lastLength > line.length)
|
||||
@@ -2176,10 +2176,10 @@ class _Progress {
|
||||
/// Reads the signature from a golden file.
|
||||
Future<String> _readSignature(String goldenPath) async {
|
||||
try {
|
||||
system.File goldenFile = new system.File(goldenPath);
|
||||
system.File goldenFile = system.File(goldenPath);
|
||||
String goldenSignature = await goldenFile.openRead()
|
||||
.transform(utf8.decoder).transform(new LineSplitter()).first;
|
||||
final RegExp signaturePattern = new RegExp(r'Signature: (\w+)');
|
||||
.transform(utf8.decoder).transform(LineSplitter()).first;
|
||||
final RegExp signaturePattern = RegExp(r'Signature: (\w+)');
|
||||
Match goldenMatch = signaturePattern.matchAsPrefix(goldenSignature);
|
||||
if (goldenMatch != null)
|
||||
return goldenMatch.group(1);
|
||||
@@ -2204,10 +2204,10 @@ Future<bool> _computeLicenseToolChanges(_RepositoryDirectory root, {String golde
|
||||
final fs.Directory flutterNode = root.io.walk.firstWhere((fs.IoNode node) => node.name == 'flutter');
|
||||
final fs.Directory toolsNode = flutterNode.walk.firstWhere((fs.IoNode node) => node.name == 'tools');
|
||||
final fs.Directory licenseNode = toolsNode.walk.firstWhere((fs.IoNode node) => node.name == 'licenses');
|
||||
final _RepositoryFlutterLicenseToolDirectory licenseToolDirectory = new _RepositoryFlutterLicenseToolDirectory(licenseNode);
|
||||
final _RepositoryFlutterLicenseToolDirectory licenseToolDirectory = _RepositoryFlutterLicenseToolDirectory(licenseNode);
|
||||
|
||||
final String toolSignature = await licenseToolDirectory.signature;
|
||||
system.IOSink sink = new system.File(outputSignaturePath).openWrite();
|
||||
system.IOSink sink = system.File(outputSignaturePath).openWrite();
|
||||
_writeSignature(toolSignature, sink);
|
||||
await sink.close();
|
||||
|
||||
@@ -2233,14 +2233,14 @@ Future<void> _collectLicensesForComponent(_RepositoryDirectory componentRoot, {
|
||||
return;
|
||||
}
|
||||
|
||||
_Progress progress = new _Progress(componentRoot.fileCount);
|
||||
_Progress progress = _Progress(componentRoot.fileCount);
|
||||
|
||||
system.File outFile = new system.File(outputGoldenPath);
|
||||
system.File outFile = system.File(outputGoldenPath);
|
||||
system.IOSink sink = outFile.openWrite();
|
||||
if (writeSignature)
|
||||
_writeSignature(signature, sink);
|
||||
|
||||
List<License> licenses = new Set<License>.from(componentRoot.getLicenses(progress).toList()).toList();
|
||||
List<License> licenses = Set<License>.from(componentRoot.getLicenses(progress).toList()).toList();
|
||||
|
||||
sink.writeln('UNUSED LICENSES:\n');
|
||||
List<String> unusedLicenses = licenses
|
||||
@@ -2268,7 +2268,7 @@ Future<void> _collectLicensesForComponent(_RepositoryDirectory componentRoot, {
|
||||
// MAIN
|
||||
|
||||
Future<Null> main(List<String> arguments) async {
|
||||
final ArgParser parser = new ArgParser()
|
||||
final ArgParser parser = ArgParser()
|
||||
..addOption('src', help: 'The root of the engine source')
|
||||
..addOption('out', help: 'The directory where output is written')
|
||||
..addOption('golden', help: 'The directory containing golden results')
|
||||
@@ -2292,20 +2292,20 @@ Future<Null> main(List<String> arguments) async {
|
||||
print(parser.usage);
|
||||
system.exit(1);
|
||||
}
|
||||
system.Directory out = new system.Directory(argResults['out']);
|
||||
system.Directory out = system.Directory(argResults['out']);
|
||||
if (!out.existsSync())
|
||||
out.createSync(recursive: true);
|
||||
}
|
||||
|
||||
try {
|
||||
system.stderr.writeln('Finding files...');
|
||||
fs.FileSystemDirectory rootDirectory = new fs.FileSystemDirectory.fromPath(argResults['src']);
|
||||
final _RepositoryDirectory root = new _RepositoryRoot(rootDirectory);
|
||||
fs.FileSystemDirectory rootDirectory = fs.FileSystemDirectory.fromPath(argResults['src']);
|
||||
final _RepositoryDirectory root = _RepositoryRoot(rootDirectory);
|
||||
|
||||
if (releaseMode) {
|
||||
system.stderr.writeln('Collecting licenses...');
|
||||
_Progress progress = new _Progress(root.fileCount);
|
||||
List<License> licenses = new Set<License>.from(root.getLicenses(progress).toList()).toList();
|
||||
_Progress progress = _Progress(root.fileCount);
|
||||
List<License> licenses = Set<License>.from(root.getLicenses(progress).toList()).toList();
|
||||
if (progress.hadErrors)
|
||||
throw 'Had failures while collecting licenses.';
|
||||
progress.label = 'Dumping results...';
|
||||
@@ -2347,7 +2347,7 @@ Future<Null> main(List<String> arguments) async {
|
||||
// For other components, we need a clean repository that does not
|
||||
// contain any state left over from previous components.
|
||||
clearLicenseRegistry();
|
||||
componentRoot = new _RepositoryRoot(rootDirectory).subdirectories
|
||||
componentRoot = _RepositoryRoot(rootDirectory).subdirectories
|
||||
.firstWhere((_RepositoryDirectory dir) => dir.name == component.name);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user