getResolvedUnitResult method
Return the result of analyzing the file with the given path.
Throw a RequestFailure is the file cannot be analyzed or if the driver
associated with the file is not an AnalysisDriver.
Implementation
Future<ResolvedUnitResult> getResolvedUnitResult(String path) async {
var driver = driverForPath(path);
if (driver is! AnalysisDriver) {
// Return an error from the request.
throw RequestFailure(
RequestErrorFactory.pluginError('Failed to analyze $path', null));
}
var result = await driver.getResult(path);
var state = result.state;
if (state != ResultState.VALID) {
// Return an error from the request.
throw RequestFailure(
RequestErrorFactory.pluginError('Failed to analyze $path', null));
}
return result;
}