Skip to content

Commit

Permalink
Remove code mappings for attribute expand (temp) (#1657)
Browse files Browse the repository at this point in the history
  • Loading branch information
maciektr authored Oct 24, 2024
1 parent 6efaf21 commit 6798b12
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions scarb/src/compiler/plugin/proc_macro/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use cairo_lang_defs::plugin::{
};
use cairo_lang_defs::plugin::{InlineMacroExprPlugin, InlinePluginResult, PluginDiagnostic};
use cairo_lang_diagnostics::ToOption;
use cairo_lang_filesystem::ids::{CodeMapping, CodeOrigin};
use cairo_lang_filesystem::span::{TextOffset, TextSpan, TextWidth};
use cairo_lang_filesystem::ids::CodeMapping;
use cairo_lang_macro::{
AuxData, Diagnostic, FullPathMarker, ProcMacroResult, Severity, TokenStream,
TokenStreamMetadata,
Expand Down Expand Up @@ -524,7 +523,6 @@ impl ProcMacroHostPlugin {
stream_metadata: TokenStreamMetadata,
) -> Option<PluginResult> {
let stable_ptr = item_ast.clone().stable_ptr().untyped();
let span = item_ast.as_syntax_node().span(db);
let token_stream =
TokenStream::from_syntax_node(db, &item_ast).with_metadata(stream_metadata.clone());

Expand Down Expand Up @@ -571,14 +569,7 @@ impl ProcMacroHostPlugin {
} else {
Some(PluginGeneratedFile {
name: "proc_macro_derive".into(),
code_mappings: vec![CodeMapping {
origin: CodeOrigin::Span(span),
span: TextSpan {
start: TextOffset::default(),
end: TextOffset::default()
.add_width(TextWidth::from_str(&derived_code)),
},
}],
code_mappings: Vec::new(),
content: derived_code,
aux_data: if aux_data.is_empty() {
None
Expand All @@ -603,7 +594,6 @@ impl ProcMacroHostPlugin {
last: bool,
args: TokenStream,
token_stream: TokenStream,
span: TextSpan,
stable_ptr: SyntaxStablePtrId,
) -> PluginResult {
let result = self.instance(input.package_id).generate_code(
Expand Down Expand Up @@ -651,13 +641,7 @@ impl ProcMacroHostPlugin {
PluginResult {
code: Some(PluginGeneratedFile {
name: file_name.into(),
code_mappings: vec![CodeMapping {
origin: CodeOrigin::Span(span),
span: TextSpan {
start: TextOffset::default(),
end: TextOffset::default().add_width(TextWidth::from_str(&content)),
},
}],
code_mappings: Vec::new(),
content,
aux_data: result.aux_data.map(|new_aux_data| {
DynGeneratedFileAuxData::new(EmittedAuxData::new(ProcMacroAuxData::new(
Expand Down Expand Up @@ -940,8 +924,7 @@ impl MacroPlugin for ProcMacroHostPlugin {
}
.map(|(expansion, args, stable_ptr, last)| {
let token_stream = body.with_metadata(stream_metadata.clone());
let span = item_ast.as_syntax_node().span(db);
self.expand_attribute(expansion, last, args, token_stream, span, stable_ptr)
self.expand_attribute(expansion, last, args, token_stream, stable_ptr)
}) {
return result;
}
Expand Down Expand Up @@ -1035,7 +1018,6 @@ impl InlineMacroExprPlugin for ProcMacroInlinePlugin {
syntax: &ast::ExprInlineMacro,
_metadata: &MacroPluginMetadata<'_>,
) -> InlinePluginResult {
let origin = CodeOrigin::Span(syntax.as_syntax_node().span(db));
let stable_ptr = syntax.clone().stable_ptr().untyped();
let token_stream = TokenStream::from_syntax_node(db, syntax);
let result = self.instance().generate_code(
Expand Down Expand Up @@ -1067,13 +1049,7 @@ impl InlineMacroExprPlugin for ProcMacroInlinePlugin {
InlinePluginResult {
code: Some(PluginGeneratedFile {
name: "inline_proc_macro".into(),
code_mappings: vec![CodeMapping {
origin,
span: TextSpan {
start: TextOffset::default(),
end: TextOffset::default().add_width(TextWidth::from_str(&content)),
},
}],
code_mappings: Vec::new(),
content,
aux_data,
}),
Expand Down

0 comments on commit 6798b12

Please sign in to comment.