mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-13 05:46:17 +00:00
remove specs from field on Parser
This commit is contained in:
parent
745b1e40ad
commit
d363087e83
1 changed files with 5 additions and 10 deletions
|
@ -10,16 +10,11 @@ use thiserror::Error;
|
||||||
pub struct Parser {
|
pub struct Parser {
|
||||||
tokens: TokenStream,
|
tokens: TokenStream,
|
||||||
current: usize,
|
current: usize,
|
||||||
specs: HashMap<String, TagSpec>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parser {
|
impl Parser {
|
||||||
pub fn new(tokens: TokenStream) -> Self {
|
pub fn new(tokens: TokenStream) -> Self {
|
||||||
Parser {
|
Parser { tokens, current: 0 }
|
||||||
tokens,
|
|
||||||
current: 0,
|
|
||||||
specs: TagSpec::load_builtin_specs().unwrap_or_default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse(&mut self) -> Result<Ast, ParserError> {
|
pub fn parse(&mut self) -> Result<Ast, ParserError> {
|
||||||
|
@ -165,9 +160,10 @@ impl Parser {
|
||||||
eprintln!("Tag name: {}", tag_name);
|
eprintln!("Tag name: {}", tag_name);
|
||||||
|
|
||||||
eprintln!("Loaded specs: {:?}", self.specs);
|
eprintln!("Loaded specs: {:?}", self.specs);
|
||||||
|
let specs = TagSpec::load_builtin_specs().unwrap_or_default();
|
||||||
|
|
||||||
// Check if this is a closing tag according to ANY spec
|
// Check if this is a closing tag according to ANY spec
|
||||||
for (_, spec) in self.specs.iter() {
|
for (_, spec) in specs.iter() {
|
||||||
if Some(&tag_name) == spec.closing.as_ref() {
|
if Some(&tag_name) == spec.closing.as_ref() {
|
||||||
eprintln!("Found closing tag: {}", tag_name);
|
eprintln!("Found closing tag: {}", tag_name);
|
||||||
return Err(ParserError::ErrorSignal(Signal::SpecialTag(tag_name)));
|
return Err(ParserError::ErrorSignal(Signal::SpecialTag(tag_name)));
|
||||||
|
@ -175,7 +171,7 @@ impl Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if this is an intermediate tag according to ANY spec
|
// Check if this is an intermediate tag according to ANY spec
|
||||||
for (_, spec) in self.specs.iter() {
|
for (_, spec) in specs.iter() {
|
||||||
if let Some(intermediates) = &spec.intermediates {
|
if let Some(intermediates) = &spec.intermediates {
|
||||||
if intermediates.contains(&tag_name) {
|
if intermediates.contains(&tag_name) {
|
||||||
eprintln!("Found intermediate tag: {}", tag_name);
|
eprintln!("Found intermediate tag: {}", tag_name);
|
||||||
|
@ -185,8 +181,7 @@ impl Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the tag spec for this tag
|
// Get the tag spec for this tag
|
||||||
let tag_spec = self.specs.get(tag_name.as_str()).cloned();
|
let tag_spec = specs.get(tag_name.as_str()).cloned();
|
||||||
eprintln!("Tag spec: {:?}", tag_spec);
|
|
||||||
|
|
||||||
let mut children = Vec::new();
|
let mut children = Vec::new();
|
||||||
let mut branches = Vec::new();
|
let mut branches = Vec::new();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue