Unverified Commit b90559cd authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

[turbopack] Remove a bunch of dead code from the source map implementation (#84318)

The `SourceMap::Sectioned` enum was only used recursively.  once i noticed that a bunch of dead code fell out.

Part-of PACK-417
parent 031b8fb8
......@@ -1491,12 +1491,10 @@ pub async fn project_trace_source_operation(
return Ok(Vc::cell(None));
};
let token = map
.lookup_token(
line.saturating_sub(1),
frame.column.unwrap_or(1).saturating_sub(1),
)
.await?;
let token = map.lookup_token(
line.saturating_sub(1),
frame.column.unwrap_or(1).saturating_sub(1),
);
let (original_file, line, column, method_name) = match token {
Token::Original(token) => (
......
......@@ -232,7 +232,7 @@ async fn resolve_source_mapping(
let Some(sm) = &*SourceMap::new_from_rope_cached(sm).await? else {
return Ok(ResolvedSourceMapping::NoSourceMap);
};
let trace = trace_source_map(sm, line, column, name.map(|s| &**s)).await?;
let trace = trace_source_map(sm, line, column, name.map(|s| &**s));
match trace {
TraceResult::Found(frame) => {
let lib_code = frame.file.contains("/node_modules/");
......
use std::{borrow::Cow, fmt::Display};
use anyhow::Result;
use serde::{Deserialize, Serialize};
use turbopack_core::source_map::{SourceMap, Token};
use turbopack_ecmascript::magic_identifier::unmangle_identifiers;
......@@ -91,16 +90,14 @@ pub enum TraceResult {
/// memory hog, it'd be so much faster if we could just directly access
/// the individual sections of the JS file's map without the
/// serialization.
pub async fn trace_source_map(
pub fn trace_source_map(
map: &SourceMap,
line: u32,
column: u32,
name: Option<&str>,
) -> Result<TraceResult> {
let token = map
.lookup_token(line.saturating_sub(1), column.saturating_sub(1))
.await?;
let result = match token {
) -> TraceResult {
let token = map.lookup_token(line.saturating_sub(1), column.saturating_sub(1));
match token {
Token::Original(t) => TraceResult::Found(StackFrame {
file: Cow::Owned(t.original_file.into_owned()),
line: Some(t.original_line.saturating_add(1)),
......@@ -113,7 +110,5 @@ pub async fn trace_source_map(
.map(Cow::Owned),
}),
_ => TraceResult::NotFound,
};
Ok(result)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment