|
1 | 1 | #![allow(dead_code, unused)]
|
2 | 2 |
|
3 | 3 | use std::borrow::BorrowMut;
|
4 |
| -use std::env; |
5 | 4 | use std::hash::Hash;
|
6 | 5 | use std::{borrow::Borrow, fmt, mem};
|
| 6 | +use std::{env, string}; |
7 | 7 |
|
8 | 8 | use crate::utils::{calls_method, eq_prop_name};
|
9 | 9 | use forge_file_resolver::{FileResolver, ForgeResolver};
|
@@ -146,6 +146,12 @@ pub fn run_resolver(
|
146 | 146 |
|
147 | 147 | // This for loop parses each token of each code statement in the file.
|
148 | 148 | for (curr_mod, module) in modules.iter_enumerated() {
|
| 149 | + |
| 150 | + let mut string_collector = StringCollector { strings: vec![] }; |
| 151 | + |
| 152 | + module.visit_children_with(&mut string_collector); |
| 153 | + environment.all_strings.extend(string_collector.strings); |
| 154 | + |
149 | 155 | let mut export_collector = ExportCollector {
|
150 | 156 | res_table: &mut environment.resolver,
|
151 | 157 | curr_mod,
|
@@ -583,6 +589,7 @@ pub struct Environment {
|
583 | 589 | pub defs: Definitions,
|
584 | 590 | default_exports: FxHashMap<ModId, DefId>,
|
585 | 591 | pub resolver: ResolverTable,
|
| 592 | + pub all_strings: Vec<Atom>, |
586 | 593 | }
|
587 | 594 |
|
588 | 595 | struct ImportCollector<'cx> {
|
@@ -3298,6 +3305,23 @@ impl Visit for GlobalCollector<'_> {
|
3298 | 3305 | }
|
3299 | 3306 | }
|
3300 | 3307 |
|
| 3308 | +struct StringCollector { |
| 3309 | + strings: Vec<Atom>, |
| 3310 | +} |
| 3311 | + |
| 3312 | +impl Visit for StringCollector { |
| 3313 | + fn visit_str(&mut self, n: &Str) { |
| 3314 | + self.add_str(n); |
| 3315 | + } |
| 3316 | +} |
| 3317 | + |
| 3318 | +impl StringCollector { |
| 3319 | + pub fn add_str(&mut self, n: &Str) { |
| 3320 | + let a = n.value.clone(); |
| 3321 | + self.strings.push(a); |
| 3322 | + } |
| 3323 | +} |
| 3324 | + |
3301 | 3325 | impl Visit for ExportCollector<'_> {
|
3302 | 3326 | noop_visit_type!();
|
3303 | 3327 | fn visit_export_decl(&mut self, n: &ExportDecl) {
|
|
0 commit comments