From 8831279ee142d4cb7eead9e609eb922a66880ac5 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Sun, 19 May 2024 03:22:37 +0000 Subject: [PATCH] remove unused map property from parsers --- crates/compiler/src/evaluate/visitor.rs | 12 +++--------- crates/compiler/src/lib.rs | 12 ++++++------ crates/compiler/src/parse/css.rs | 10 +--------- crates/compiler/src/parse/sass.rs | 10 +--------- crates/compiler/src/parse/scss.rs | 10 +--------- crates/compiler/src/parse/stylesheet.rs | 3 +-- 6 files changed, 13 insertions(+), 44 deletions(-) diff --git a/crates/compiler/src/evaluate/visitor.rs b/crates/compiler/src/evaluate/visitor.rs index d022999..234ab4f 100644 --- a/crates/compiler/src/evaluate/visitor.rs +++ b/crates/compiler/src/evaluate/visitor.rs @@ -875,15 +875,9 @@ impl<'a> Visitor<'a> { empty_span: Span, ) -> SassResult { match InputSyntax::for_path(path) { - InputSyntax::Scss => { - ScssParser::new(lexer, self.map, self.options, empty_span, path).__parse() - } - InputSyntax::Sass => { - SassParser::new(lexer, self.map, self.options, empty_span, path).__parse() - } - InputSyntax::Css => { - CssParser::new(lexer, self.map, self.options, empty_span, path).__parse() - } + InputSyntax::Scss => ScssParser::new(lexer, self.options, empty_span, path).__parse(), + InputSyntax::Sass => SassParser::new(lexer, self.options, empty_span, path).__parse(), + InputSyntax::Css => CssParser::new(lexer, self.options, empty_span, path).__parse(), } } diff --git a/crates/compiler/src/lib.rs b/crates/compiler/src/lib.rs index 63318f0..d801063 100644 --- a/crates/compiler/src/lib.rs +++ b/crates/compiler/src/lib.rs @@ -147,13 +147,13 @@ pub fn parse_stylesheet>( let stylesheet = match input_syntax { InputSyntax::Scss => { - ScssParser::new(lexer, &mut map, options, empty_span, file_name.as_ref()).__parse() + ScssParser::new(lexer, options, empty_span, file_name.as_ref()).__parse() } InputSyntax::Sass => { - SassParser::new(lexer, &mut map, options, empty_span, file_name.as_ref()).__parse() + SassParser::new(lexer, options, empty_span, file_name.as_ref()).__parse() } InputSyntax::Css => { - CssParser::new(lexer, &mut map, options, empty_span, file_name.as_ref()).__parse() + CssParser::new(lexer, options, empty_span, file_name.as_ref()).__parse() } }; @@ -182,13 +182,13 @@ fn from_string_with_file_name>( let stylesheet = match input_syntax { InputSyntax::Scss => { - ScssParser::new(lexer, &mut map, options, empty_span, file_name.as_ref()).__parse() + ScssParser::new(lexer, options, empty_span, file_name.as_ref()).__parse() } InputSyntax::Sass => { - SassParser::new(lexer, &mut map, options, empty_span, file_name.as_ref()).__parse() + SassParser::new(lexer, options, empty_span, file_name.as_ref()).__parse() } InputSyntax::Css => { - CssParser::new(lexer, &mut map, options, empty_span, file_name.as_ref()).__parse() + CssParser::new(lexer, options, empty_span, file_name.as_ref()).__parse() } }; diff --git a/crates/compiler/src/parse/css.rs b/crates/compiler/src/parse/css.rs index 621faaa..aff8e68 100644 --- a/crates/compiler/src/parse/css.rs +++ b/crates/compiler/src/parse/css.rs @@ -1,6 +1,6 @@ use std::{collections::BTreeMap, path::Path, sync::Arc}; -use codemap::{CodeMap, Span, Spanned}; +use codemap::{Span, Spanned}; use crate::{ ast::*, builtin::DISALLOWED_PLAIN_CSS_FUNCTION_NAMES, common::QuoteKind, error::SassResult, @@ -11,8 +11,6 @@ use super::{value::ValueParser, BaseParser, StylesheetParser}; pub(crate) struct CssParser<'a> { pub toks: Lexer<'a>, - // todo: likely superfluous - pub map: &'a mut CodeMap, pub path: &'a Path, pub empty_span: Span, pub flags: ContextFlags, @@ -50,10 +48,6 @@ impl<'a> StylesheetParser<'a> for CssParser<'a> { self.path } - fn map(&mut self) -> &mut CodeMap { - self.map - } - fn options(&self) -> &Options { self.options } @@ -110,14 +104,12 @@ impl<'a> StylesheetParser<'a> for CssParser<'a> { impl<'a> CssParser<'a> { pub fn new( toks: Lexer<'a>, - map: &'a mut CodeMap, options: &'a Options<'a>, empty_span: Span, file_name: &'a Path, ) -> Self { CssParser { toks, - map, path: file_name, empty_span, flags: ContextFlags::empty(), diff --git a/crates/compiler/src/parse/sass.rs b/crates/compiler/src/parse/sass.rs index 4bfe93c..07569fd 100644 --- a/crates/compiler/src/parse/sass.rs +++ b/crates/compiler/src/parse/sass.rs @@ -1,6 +1,6 @@ use std::path::Path; -use codemap::{CodeMap, Span}; +use codemap::Span; use crate::{ast::*, error::SassResult, lexer::Lexer, ContextFlags, Options, Token}; @@ -8,8 +8,6 @@ use super::{BaseParser, StylesheetParser}; pub(crate) struct SassParser<'a> { pub toks: Lexer<'a>, - // todo: likely superfluous - pub map: &'a mut CodeMap, pub path: &'a Path, pub empty_span: Span, pub flags: ContextFlags, @@ -83,10 +81,6 @@ impl<'a> StylesheetParser<'a> for SassParser<'a> { self.path } - fn map(&mut self) -> &mut CodeMap { - self.map - } - fn options(&self) -> &Options { self.options } @@ -351,7 +345,6 @@ impl<'a> StylesheetParser<'a> for SassParser<'a> { impl<'a> SassParser<'a> { pub fn new( toks: Lexer<'a>, - map: &'a mut CodeMap, options: &'a Options<'a>, empty_span: Span, file_name: &'a Path, @@ -362,7 +355,6 @@ impl<'a> SassParser<'a> { SassParser { toks, - map, path: file_name, empty_span, flags, diff --git a/crates/compiler/src/parse/scss.rs b/crates/compiler/src/parse/scss.rs index f0de209..fe59f0f 100644 --- a/crates/compiler/src/parse/scss.rs +++ b/crates/compiler/src/parse/scss.rs @@ -1,6 +1,6 @@ use std::path::Path; -use codemap::{CodeMap, Span}; +use codemap::Span; use crate::{lexer::Lexer, ContextFlags, Options}; @@ -8,8 +8,6 @@ use super::{BaseParser, StylesheetParser}; pub(crate) struct ScssParser<'a> { pub toks: Lexer<'a>, - // todo: likely superfluous - pub map: &'a mut CodeMap, pub path: &'a Path, pub empty_span: Span, pub flags: ContextFlags, @@ -19,7 +17,6 @@ pub(crate) struct ScssParser<'a> { impl<'a> ScssParser<'a> { pub fn new( toks: Lexer<'a>, - map: &'a mut CodeMap, options: &'a Options<'a>, empty_span: Span, file_name: &'a Path, @@ -30,7 +27,6 @@ impl<'a> ScssParser<'a> { ScssParser { toks, - map, path: file_name, empty_span, flags, @@ -62,10 +58,6 @@ impl<'a> StylesheetParser<'a> for ScssParser<'a> { self.path } - fn map(&mut self) -> &mut CodeMap { - self.map - } - fn options(&self) -> &Options { self.options } diff --git a/crates/compiler/src/parse/stylesheet.rs b/crates/compiler/src/parse/stylesheet.rs index e582bd5..85110c6 100644 --- a/crates/compiler/src/parse/stylesheet.rs +++ b/crates/compiler/src/parse/stylesheet.rs @@ -7,7 +7,7 @@ use std::{ sync::Arc, }; -use codemap::{CodeMap, Span, Spanned}; +use codemap::{Span, Spanned}; use crate::{ ast::*, @@ -33,7 +33,6 @@ pub(crate) trait StylesheetParser<'a>: BaseParser<'a> + Sized { fn is_indented(&self) -> bool; fn options(&self) -> &Options; fn path(&self) -> &Path; - fn map(&mut self) -> &mut CodeMap; fn empty_span(&self) -> Span; fn current_indentation(&self) -> usize; fn flags(&self) -> &ContextFlags;