diff --git a/drift_dev/lib/src/backends/common/driver.dart b/drift_dev/lib/src/backends/common/driver.dart index c1686ca3..38419c5c 100644 --- a/drift_dev/lib/src/backends/common/driver.dart +++ b/drift_dev/lib/src/backends/common/driver.dart @@ -43,7 +43,9 @@ class MoorDriver { } bool _ownsFile(String path) => - path.endsWith('.moor') || path.endsWith('.dart'); + path.endsWith('.moor') || + path.endsWith('.drift') || + path.endsWith('.dart'); FoundFile pathToFoundFile(String path) { final uri = _resourceProvider.pathContext.toUri(path); @@ -99,21 +101,34 @@ class MoorDriver { /// Waits for the file at [path] to be parsed. If the file is neither a Dart /// or a moor file, returns `null`. - Future waitFileParsed(String path) { + Future waitFileParsed(String path) async { if (!_ownsFile(path)) { - return Future.value(null); + return null; } final found = pathToFoundFile(path); if (found.isParsed) { - return Future.value(found); + return found; } else { - _runTask(path); + final result = Completer(); - return session + unawaited(session .completedFiles() - .firstWhere((file) => file == found && file.isParsed); + .firstWhere((file) => file == found && file.isParsed) + .then((file) { + if (!result.isCompleted) { + result.complete(file); + } + })); + + try { + await _runTask(path); + } on Exception { + result.complete(null); + } + + return result.future; } } diff --git a/extras/plugin_example/analysis_options.yaml b/extras/plugin_example/analysis_options.yaml index 2b07d7b1..6069f392 100644 --- a/extras/plugin_example/analysis_options.yaml +++ b/extras/plugin_example/analysis_options.yaml @@ -5,4 +5,4 @@ include: package:pedantic/analysis_options.yaml #analyzer: # plugins: -# - moor \ No newline at end of file +# - drift diff --git a/extras/plugin_example/lib/test.moor b/extras/plugin_example/lib/test.drift similarity index 100% rename from extras/plugin_example/lib/test.moor rename to extras/plugin_example/lib/test.drift diff --git a/extras/plugin_example/pubspec.yaml b/extras/plugin_example/pubspec.yaml index 7a8482b3..519030c5 100644 --- a/extras/plugin_example/pubspec.yaml +++ b/extras/plugin_example/pubspec.yaml @@ -5,8 +5,8 @@ environment: sdk: '>=2.4.0 <3.0.0' dependencies: - moor: - path: ../../moor + drift: + path: ../../drift dev_dependencies: pedantic: ^1.7.0