remove unused map property from parsers

This commit is contained in:
Connor Skees 2024-05-19 03:22:37 +00:00
parent a1ca700bff
commit 8831279ee1
6 changed files with 13 additions and 44 deletions

View File

@ -875,15 +875,9 @@ impl<'a> Visitor<'a> {
empty_span: Span, empty_span: Span,
) -> SassResult<StyleSheet> { ) -> SassResult<StyleSheet> {
match InputSyntax::for_path(path) { match InputSyntax::for_path(path) {
InputSyntax::Scss => { InputSyntax::Scss => ScssParser::new(lexer, self.options, empty_span, path).__parse(),
ScssParser::new(lexer, self.map, 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(),
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()
}
} }
} }

View File

@ -147,13 +147,13 @@ pub fn parse_stylesheet<P: AsRef<Path>>(
let stylesheet = match input_syntax { let stylesheet = match input_syntax {
InputSyntax::Scss => { 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 => { 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 => { 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<P: AsRef<Path>>(
let stylesheet = match input_syntax { let stylesheet = match input_syntax {
InputSyntax::Scss => { 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 => { 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 => { 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()
} }
}; };

View File

@ -1,6 +1,6 @@
use std::{collections::BTreeMap, path::Path, sync::Arc}; use std::{collections::BTreeMap, path::Path, sync::Arc};
use codemap::{CodeMap, Span, Spanned}; use codemap::{Span, Spanned};
use crate::{ use crate::{
ast::*, builtin::DISALLOWED_PLAIN_CSS_FUNCTION_NAMES, common::QuoteKind, error::SassResult, 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(crate) struct CssParser<'a> {
pub toks: Lexer<'a>, pub toks: Lexer<'a>,
// todo: likely superfluous
pub map: &'a mut CodeMap,
pub path: &'a Path, pub path: &'a Path,
pub empty_span: Span, pub empty_span: Span,
pub flags: ContextFlags, pub flags: ContextFlags,
@ -50,10 +48,6 @@ impl<'a> StylesheetParser<'a> for CssParser<'a> {
self.path self.path
} }
fn map(&mut self) -> &mut CodeMap {
self.map
}
fn options(&self) -> &Options { fn options(&self) -> &Options {
self.options self.options
} }
@ -110,14 +104,12 @@ impl<'a> StylesheetParser<'a> for CssParser<'a> {
impl<'a> CssParser<'a> { impl<'a> CssParser<'a> {
pub fn new( pub fn new(
toks: Lexer<'a>, toks: Lexer<'a>,
map: &'a mut CodeMap,
options: &'a Options<'a>, options: &'a Options<'a>,
empty_span: Span, empty_span: Span,
file_name: &'a Path, file_name: &'a Path,
) -> Self { ) -> Self {
CssParser { CssParser {
toks, toks,
map,
path: file_name, path: file_name,
empty_span, empty_span,
flags: ContextFlags::empty(), flags: ContextFlags::empty(),

View File

@ -1,6 +1,6 @@
use std::path::Path; use std::path::Path;
use codemap::{CodeMap, Span}; use codemap::Span;
use crate::{ast::*, error::SassResult, lexer::Lexer, ContextFlags, Options, Token}; use crate::{ast::*, error::SassResult, lexer::Lexer, ContextFlags, Options, Token};
@ -8,8 +8,6 @@ use super::{BaseParser, StylesheetParser};
pub(crate) struct SassParser<'a> { pub(crate) struct SassParser<'a> {
pub toks: Lexer<'a>, pub toks: Lexer<'a>,
// todo: likely superfluous
pub map: &'a mut CodeMap,
pub path: &'a Path, pub path: &'a Path,
pub empty_span: Span, pub empty_span: Span,
pub flags: ContextFlags, pub flags: ContextFlags,
@ -83,10 +81,6 @@ impl<'a> StylesheetParser<'a> for SassParser<'a> {
self.path self.path
} }
fn map(&mut self) -> &mut CodeMap {
self.map
}
fn options(&self) -> &Options { fn options(&self) -> &Options {
self.options self.options
} }
@ -351,7 +345,6 @@ impl<'a> StylesheetParser<'a> for SassParser<'a> {
impl<'a> SassParser<'a> { impl<'a> SassParser<'a> {
pub fn new( pub fn new(
toks: Lexer<'a>, toks: Lexer<'a>,
map: &'a mut CodeMap,
options: &'a Options<'a>, options: &'a Options<'a>,
empty_span: Span, empty_span: Span,
file_name: &'a Path, file_name: &'a Path,
@ -362,7 +355,6 @@ impl<'a> SassParser<'a> {
SassParser { SassParser {
toks, toks,
map,
path: file_name, path: file_name,
empty_span, empty_span,
flags, flags,

View File

@ -1,6 +1,6 @@
use std::path::Path; use std::path::Path;
use codemap::{CodeMap, Span}; use codemap::Span;
use crate::{lexer::Lexer, ContextFlags, Options}; use crate::{lexer::Lexer, ContextFlags, Options};
@ -8,8 +8,6 @@ use super::{BaseParser, StylesheetParser};
pub(crate) struct ScssParser<'a> { pub(crate) struct ScssParser<'a> {
pub toks: Lexer<'a>, pub toks: Lexer<'a>,
// todo: likely superfluous
pub map: &'a mut CodeMap,
pub path: &'a Path, pub path: &'a Path,
pub empty_span: Span, pub empty_span: Span,
pub flags: ContextFlags, pub flags: ContextFlags,
@ -19,7 +17,6 @@ pub(crate) struct ScssParser<'a> {
impl<'a> ScssParser<'a> { impl<'a> ScssParser<'a> {
pub fn new( pub fn new(
toks: Lexer<'a>, toks: Lexer<'a>,
map: &'a mut CodeMap,
options: &'a Options<'a>, options: &'a Options<'a>,
empty_span: Span, empty_span: Span,
file_name: &'a Path, file_name: &'a Path,
@ -30,7 +27,6 @@ impl<'a> ScssParser<'a> {
ScssParser { ScssParser {
toks, toks,
map,
path: file_name, path: file_name,
empty_span, empty_span,
flags, flags,
@ -62,10 +58,6 @@ impl<'a> StylesheetParser<'a> for ScssParser<'a> {
self.path self.path
} }
fn map(&mut self) -> &mut CodeMap {
self.map
}
fn options(&self) -> &Options { fn options(&self) -> &Options {
self.options self.options
} }

View File

@ -7,7 +7,7 @@ use std::{
sync::Arc, sync::Arc,
}; };
use codemap::{CodeMap, Span, Spanned}; use codemap::{Span, Spanned};
use crate::{ use crate::{
ast::*, ast::*,
@ -33,7 +33,6 @@ pub(crate) trait StylesheetParser<'a>: BaseParser<'a> + Sized {
fn is_indented(&self) -> bool; fn is_indented(&self) -> bool;
fn options(&self) -> &Options; fn options(&self) -> &Options;
fn path(&self) -> &Path; fn path(&self) -> &Path;
fn map(&mut self) -> &mut CodeMap;
fn empty_span(&self) -> Span; fn empty_span(&self) -> Span;
fn current_indentation(&self) -> usize; fn current_indentation(&self) -> usize;
fn flags(&self) -> &ContextFlags; fn flags(&self) -> &ContextFlags;