mirror of https://github.com/AMT-Cheif/drift.git
Some plugin fixes
This commit is contained in:
parent
6d89a7711b
commit
7d56497c18
|
@ -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<FoundFile> waitFileParsed(String path) {
|
||||
Future<FoundFile> 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<FoundFile>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,4 +5,4 @@ include: package:pedantic/analysis_options.yaml
|
|||
|
||||
#analyzer:
|
||||
# plugins:
|
||||
# - moor
|
||||
# - drift
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue