From 55fceb80cb3b2e77ef9bdb37a32ddefea564f7cc Mon Sep 17 00:00:00 2001 From: Andrew Morris Date: Wed, 22 Mar 2023 14:39:32 +1100 Subject: [PATCH] Store mutations by span --- valuescript_compiler/src/scope_analysis.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/valuescript_compiler/src/scope_analysis.rs b/valuescript_compiler/src/scope_analysis.rs index 11c8735..fadd6f7 100644 --- a/valuescript_compiler/src/scope_analysis.rs +++ b/valuescript_compiler/src/scope_analysis.rs @@ -1,4 +1,9 @@ -use std::{cell::RefCell, collections::HashMap, collections::HashSet, rc::Rc}; +use std::{ + cell::RefCell, + collections::HashMap, + collections::{BTreeMap, HashSet}, + rc::Rc, +}; use swc_common::Spanned; use valuescript_common::BUILTIN_NAMES; @@ -53,6 +58,7 @@ pub struct ScopeAnalysis { pub names: HashMap, pub owners: HashMap>, pub captures: HashMap>, + pub mutations: BTreeMap, pub diagnostics: Vec, } @@ -1259,6 +1265,7 @@ impl ScopeAnalysis { }; name.mutations.push(ident.span); + self.mutations.insert(ident.span, name_id); } fn ident(&mut self, scope: &XScope, ident: &swc_ecma_ast::Ident) {