resolveFile static method

Future<ResolvedUnitResult> resolveFile(
  1. String filePath, {
  2. String? sdkPath,
})

Convenience method to resolve a single file in a temporary context.

Implementation

static Future<ResolvedUnitResult> resolveFile(
  String filePath, {
  String? sdkPath,
}) async {
  final absPath = p.normalize(p.absolute(filePath));
  final file = File(absPath);
  if (!file.existsSync()) {
    throw FileSystemException('Target file does not exist', filePath);
  }
  final helper = AnalysisContextHelper(
    includedPaths: [absPath],
    sdkPath: sdkPath,
  );
  return helper.getRequiredResolvedUnit(absPath);
}