MCPcopy Create free account
hub / github.com/csskit/csskit / unexpected_ident

Method unexpected_ident

crates/css_parse/src/diagnostics.rs:132–148  ·  view source on GitHub ↗
(diagnostic: &Diagnostic, source: &str)

Source from the content-addressed store, hash-verified

130 }
131
132 pub fn unexpected_ident(diagnostic: &Diagnostic, source: &str) -> DiagnosticMeta {
133 let cursor = diagnostic.start_cursor;
134 let start = cursor.offset().0 as usize;
135 let len = cursor.token().len() as usize;
136 let message = if start + len <= source.len() {
137 let text = &source[start..start + len];
138 format!("Unexpected identifier '{text}'")
139 } else {
140 "Unexpected identifier".to_string()
141 };
142 DiagnosticMeta {
143 code: "UnexpectedIdent",
144 message,
145 help: "There is an extra word which shouldn't be in this position.".into(),
146 labels: vec![],
147 }
148 }
149
150 pub fn unexpected_delim(diagnostic: &Diagnostic, _source: &str) -> DiagnosticMeta {
151 let cursor = diagnostic.start_cursor;

Callers

nothing calls this directly

Calls 3

offsetMethod · 0.45
lenMethod · 0.45
tokenMethod · 0.45

Tested by

no test coverage detected