Commit 424a6b1d authored by Ian Hickson's avatar Ian Hickson

Handle files disappearing during analysis (#3390)

parent 29fdc7a4
......@@ -363,53 +363,52 @@ class AnalyzeCommand extends FlutterCommand {
String errorMessage = groups[2];
int lineNumber = int.parse(groups[4]);
int colNumber = int.parse(groups[5]);
File source = new File(filename);
List<String> sourceLines = source.readAsLinesSync();
String sourceLine;
try {
File source = new File(filename);
List<String> sourceLines = source.readAsLinesSync();
if (lineNumber > sourceLines.length)
throw new FileChanged();
sourceLine = sourceLines[lineNumber-1];
String sourceLine = sourceLines[lineNumber-1];
if (colNumber > sourceLine.length)
throw new FileChanged();
} on FileChanged {
if (changedFiles.add(filename))
printError('[warning] File shrank during analysis ($filename)');
sourceLine = '';
lineNumber = 1;
colNumber = 1;
}
bool shouldIgnore = false;
if (documentAllMembersPattern.firstMatch(errorMessage) != null) {
// https://github.com/dart-lang/linter/issues/207
// https://github.com/dart-lang/linter/issues/208
if (isFlutterLibrary(filename)) {
if (!argResults['dartdocs']) {
membersMissingDocumentation += 1;
bool shouldIgnore = false;
if (documentAllMembersPattern.firstMatch(errorMessage) != null) {
// https://github.com/dart-lang/linter/issues/207
// https://github.com/dart-lang/linter/issues/208
if (isFlutterLibrary(filename)) {
if (!argResults['dartdocs']) {
membersMissingDocumentation += 1;
shouldIgnore = true;
}
} else {
shouldIgnore = true;
}
} else {
} else if (filename == mainFile.path) {
Match libs = conflictingNamesPattern.firstMatch(errorMessage);
Match missing = missingFilePattern.firstMatch(errorMessage);
if (libs != null) {
errorLine = '[$level] $errorMessage (${dartFiles[lineNumber-1]})'; // strip the reference to the generated main.dart
} else if (missing != null) {
errorLine = '[$level] File does not exist (${missing[1]})';
} else {
errorLine += ' (Please file a bug on the "flutter analyze" command saying that you saw this message.)';
}
} else if (filename.endsWith('.mojom.dart')) {
// autogenerated code - TODO(ianh): Fix the Dart mojom compiler
shouldIgnore = true;
} else if (sourceLines.first.startsWith('// DO NOT EDIT. This is code generated')) {
// autogenerated code - TODO(ianh): Fix the intl package resource generator
shouldIgnore = true;
}
} else if (filename == mainFile.path) {
Match libs = conflictingNamesPattern.firstMatch(errorMessage);
Match missing = missingFilePattern.firstMatch(errorMessage);
if (libs != null) {
errorLine = '[$level] $errorMessage (${dartFiles[lineNumber-1]})'; // strip the reference to the generated main.dart
} else if (missing != null) {
errorLine = '[$level] File does not exist (${missing[1]})';
} else {
errorLine += ' (Please file a bug on the "flutter analyze" command saying that you saw this message.)';
}
} else if (filename.endsWith('.mojom.dart')) {
// autogenerated code - TODO(ianh): Fix the Dart mojom compiler
shouldIgnore = true;
} else if (sourceLines.first.startsWith('// DO NOT EDIT. This is code generated')) {
// autogenerated code - TODO(ianh): Fix the intl package resource generator
shouldIgnore = true;
if (shouldIgnore)
continue;
} on FileSystemException catch (exception) {
if (changedFiles.add(filename))
printError('[warning] Could not read file (${exception.message}${ exception.osError != null ? "; ${exception.osError}" : ""}) ($filename)');
} on FileChanged {
if (changedFiles.add(filename))
printError('[warning] File shrank during analysis ($filename)');
}
if (shouldIgnore)
continue;
}
printError(errorLine);
errorCount += 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment