Skip to main content

normalize_solc_output

Function normalize_solc_output 

Source
pub fn normalize_solc_output(
    solc_output: Value,
    project_root: Option<&Path>,
) -> Value
Expand description

Normalize raw solc --standard-json output into the canonical shape.

Solc’s native shape is already close to canonical:

  • sources[path] = { id, ast } — kept as-is
  • contracts[path][name] = { abi, evm, ... } — kept as-is
  • errors — kept as-is (defaults to [] if absent)

When project_root is provided, relative source paths are resolved to absolute paths so that downstream code (goto, hover, links) can map AST paths back to file:// URIs. This is necessary because solc_ast() passes a relative path to solc (to fix import resolution), and solc then returns relative paths in the AST absolutePath and source keys.

Constructs source_id_to_path from source IDs for cross-file resolution.

Takes ownership and uses Value::take() to move AST nodes in-place, avoiding expensive clones of multi-MB AST data.