RuntimeUtils class

Utility class for reflection-related operations in JetLeaf.

Provides helper methods for:

  • URI and package resolution
  • File exclusion/inclusion checks
  • Source code analysis
  • JetLeaf-specific filtering

{@template reflect_utils_example} Example usage:

final utils = ReflectUtils();

// Check if a URI should be excluded
final shouldExclude = await ReflectUtils.shouldNotIncludeLibrary(
  Uri.parse('package:some_pkg/file.dart'),
  loader,
  print,
);

// Get package name from URI
final pkgName = ReflectUtils.getPackageNameFromUri('package:html/html.dart');

{@endtemplate}

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

getPackageNameFromUri(dynamic uri) String?
Extracts the package name from a URI, handling both Dart core and pub packages.
hasMirrorImport(String content) bool
Checks if content imports dart:mirrors.
isBuiltInDartLibrary(Uri uri) bool
Checks if a uri points to a built-in Dart library.
isListType(Type type) bool
Determines if the type is a list type.
isMapType(Type type) bool
Determines if the type is a map type or a generic key-value container type.
isNonLoadableJetLeafFile(Uri uri) bool
Determines if a JetLeaf file should not be loaded.
isPartOf(String content) bool
Checks if content contains a part of directive.
isSkippableJetLeafPackage(Uri identifier) bool
Determines if a JetLeaf package should be skipped during scanning.
isStringAListType(String type) bool
Determines if the type is a list type.
isStringAMapType(String type) bool
Determines if the type string represents a map or key-value container type.
isTest(String content) bool
Checks if content is a test file.
matchesAnyFile(String filePath, List<File> files) bool
Matches a file path against a list of files.
matchesAnyPattern(String input, List<String> patterns) bool
Matches input against a list of patterns.
resolveUri(Uri uri) Future<Uri?>
Resolves a package URI to its file system location.
shouldNotIncludeLibrary(Uri uri, RuntimeScannerConfiguration loader) Future<bool>
Determines if a library should be excluded based on loader configuration.
shouldNotIncludePath(Uri uri, File file, RuntimeScannerConfiguration loader) Future<bool>
Determines if a path should be excluded based on loader configuration.
stripComments(String code) String
Strip comments from source code