| 322 | Some((end, Partial::Val(v, line[end..].to_string()))) |
| 323 | } |
| 324 | fn match_selector(v: &IDLValue, prefix: &str) -> Vec<Pair> { |
| 325 | match v { |
| 326 | IDLValue::Opt(_) => vec![Pair { |
| 327 | display: "?".to_string(), |
| 328 | replacement: "?".to_string(), |
| 329 | }], |
| 330 | IDLValue::Blob(b) => vec![ |
| 331 | Pair { |
| 332 | display: "blob".to_string(), |
| 333 | replacement: "".to_string(), |
| 334 | }, |
| 335 | Pair { |
| 336 | display: format!("index should be less than {}", b.len()), |
| 337 | replacement: "".to_string(), |
| 338 | }, |
| 339 | ], |
| 340 | IDLValue::Vec(vs) => vec![ |
| 341 | Pair { |
| 342 | display: "vec".to_string(), |
| 343 | replacement: "".to_string(), |
| 344 | }, |
| 345 | Pair { |
| 346 | display: format!("index should be less than {}", vs.len()), |
| 347 | replacement: "".to_string(), |
| 348 | }, |
| 349 | ], |
| 350 | IDLValue::Record(fs) => fs.iter().filter_map(|f| match_field(f, prefix)).collect(), |
| 351 | IDLValue::Variant(VariantValue(f, _)) => { |
| 352 | if let Some(pair) = match_field(f, prefix) { |
| 353 | vec![pair] |
| 354 | } else { |
| 355 | Vec::new() |
| 356 | } |
| 357 | } |
| 358 | _ => Vec::new(), |
| 359 | } |
| 360 | } |
| 361 | fn match_field(f: &IDLField, prefix: &str) -> Option<Pair> { |
| 362 | match &f.id { |
| 363 | Label::Named(name) |