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 { ...@@ -363,53 +363,52 @@ class AnalyzeCommand extends FlutterCommand {
String errorMessage = groups[2]; String errorMessage = groups[2];
int lineNumber = int.parse(groups[4]); int lineNumber = int.parse(groups[4]);
int colNumber = int.parse(groups[5]); int colNumber = int.parse(groups[5]);
File source = new File(filename);
List<String> sourceLines = source.readAsLinesSync();
String sourceLine;
try { try {
File source = new File(filename);
List<String> sourceLines = source.readAsLinesSync();
if (lineNumber > sourceLines.length) if (lineNumber > sourceLines.length)
throw new FileChanged(); throw new FileChanged();
sourceLine = sourceLines[lineNumber-1]; String sourceLine = sourceLines[lineNumber-1];
if (colNumber > sourceLine.length) if (colNumber > sourceLine.length)
throw new FileChanged(); throw new FileChanged();
} on FileChanged { bool shouldIgnore = false;
if (changedFiles.add(filename)) if (documentAllMembersPattern.firstMatch(errorMessage) != null) {
printError('[warning] File shrank during analysis ($filename)'); // https://github.com/dart-lang/linter/issues/207
sourceLine = ''; // https://github.com/dart-lang/linter/issues/208
lineNumber = 1; if (isFlutterLibrary(filename)) {
colNumber = 1; if (!argResults['dartdocs']) {
} membersMissingDocumentation += 1;
bool shouldIgnore = false; shouldIgnore = true;
if (documentAllMembersPattern.firstMatch(errorMessage) != null) { }
// https://github.com/dart-lang/linter/issues/207 } else {
// https://github.com/dart-lang/linter/issues/208
if (isFlutterLibrary(filename)) {
if (!argResults['dartdocs']) {
membersMissingDocumentation += 1;
shouldIgnore = true; 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; shouldIgnore = true;
} }
} else if (filename == mainFile.path) { if (shouldIgnore)
Match libs = conflictingNamesPattern.firstMatch(errorMessage); continue;
Match missing = missingFilePattern.firstMatch(errorMessage); } on FileSystemException catch (exception) {
if (libs != null) { if (changedFiles.add(filename))
errorLine = '[$level] $errorMessage (${dartFiles[lineNumber-1]})'; // strip the reference to the generated main.dart printError('[warning] Could not read file (${exception.message}${ exception.osError != null ? "; ${exception.osError}" : ""}) ($filename)');
} else if (missing != null) { } on FileChanged {
errorLine = '[$level] File does not exist (${missing[1]})'; if (changedFiles.add(filename))
} else { printError('[warning] File shrank during analysis ($filename)');
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;
} }
printError(errorLine); printError(errorLine);
errorCount += 1; 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