addResource method

void addResource(
  1. String fullName,
  2. RT resource
)

Implementation

void addResource(String fullName, RT resource) {
  if (!path.isAbsolute(fullName)) {
    throw HTError.notAbsoluteError(fullName);
  }
  for (final context in contexts) {
    final normalized = context.getAbsolutePath(key: fullName);
    if (context.contains(normalized)) {
      _cachedSources[fullName] = resource;
      if (onRootsUpdated != null) {
        onRootsUpdated!();
      }
      return;
    }
  }
  final root = path.dirname(fullName);
  final context = createContext(root);
  _contextRoots[context.root] = context;
  final normalized = context.getAbsolutePath(key: fullName);
  context.addResource(normalized, resource);
  _cachedSources[fullName] = resource;
  if (onRootsUpdated != null) {
    onRootsUpdated!();
  }
}