angularArtifactsForKythe function

Future<AngularArtifacts?>? angularArtifactsForKythe(
  1. LibraryElement element, {
  2. UncaughtExceptionHandler? uncaughtExceptionHandler,
})

Implementation

Future<AngularArtifacts?>? angularArtifactsForKythe(LibraryElement element,
    {UncaughtExceptionHandler? uncaughtExceptionHandler}) {
  final assetId = _toAssetId(element.identifier);
  if (assetId == null) return null;
  final exceptionHandler = ComponentVisitorExceptionHandler();
  return runWithContext(
      CompileContext(
        assetId,
        policyExceptions: {},
        policyExceptionsInPackages: {},
        isNullSafe: element.isNonNullableByDefault,
        enableDevTools: false,
      ), () async {
    try {
      return findComponentsAndDirectives(
          LibraryReader(element), exceptionHandler);
    } catch (e, s) {
      if (uncaughtExceptionHandler?.call(e, s) ?? false) {
        return null;
      } else {
        rethrow;
      }
    }
  });
}