locateNode function

({int column, int line, Uri? source})? locateNode(
  1. SAstNode node, {
  2. required Map<String, SCompilationUnit> modules,
  3. Map<String, String>? sources,
})

Where node is — line, column and module — for a D4rtCallStack trace, or null when its module's source was not bundled.

Implementation

({int line, int column, Uri? source})? locateNode(
  SAstNode node, {
  required Map<String, SCompilationUnit> modules,
  Map<String, String>? sources,
}) {
  final uri = moduleContaining(node, modules);
  if (uri == null) return null;
  final source = sources?[uri];
  if (source == null || node.offset < 0 || node.offset > source.length) {
    return null;
  }
  final (line, column) = _lineAndColumn(source, node.offset);
  return (line: line, column: column, source: Uri.tryParse(uri));
}