Skip to content

Commit 531a437

Browse files
authored
Merge pull request #61 from gersbach/feat/EAS-2573
EAS-2573 : Add GraphQL support for the permission scanner
2 parents 7fa85d2 + de06b15 commit 531a437

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

crates/forge_analyzer/src/definitions.rs

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![allow(dead_code, unused)]
22

33
use std::borrow::BorrowMut;
4-
use std::env;
54
use std::hash::Hash;
65
use std::{borrow::Borrow, fmt, mem};
6+
use std::{env, string};
77

88
use crate::utils::{calls_method, eq_prop_name};
99
use forge_file_resolver::{FileResolver, ForgeResolver};
@@ -146,6 +146,11 @@ pub fn run_resolver(
146146

147147
// This for loop parses each token of each code statement in the file.
148148
for (curr_mod, module) in modules.iter_enumerated() {
149+
let mut string_collector = StringCollector { strings: vec![] };
150+
151+
module.visit_children_with(&mut string_collector);
152+
environment.all_strings.extend(string_collector.strings);
153+
149154
let mut export_collector = ExportCollector {
150155
res_table: &mut environment.resolver,
151156
curr_mod,
@@ -583,6 +588,7 @@ pub struct Environment {
583588
pub defs: Definitions,
584589
default_exports: FxHashMap<ModId, DefId>,
585590
pub resolver: ResolverTable,
591+
pub all_strings: Vec<String>,
586592
}
587593

588594
struct ImportCollector<'cx> {
@@ -3299,6 +3305,26 @@ impl Visit for GlobalCollector<'_> {
32993305
}
33003306
}
33013307

3308+
struct StringCollector {
3309+
strings: Vec<String>,
3310+
}
3311+
3312+
impl Visit for StringCollector {
3313+
fn visit_str(&mut self, n: &Str) {
3314+
self.add_str(n.value.as_str().to_string());
3315+
}
3316+
3317+
fn visit_tpl(&mut self, n: &Tpl) {
3318+
self.add_str(n.quasis.iter().map(|val| val.raw.as_str()).collect());
3319+
}
3320+
}
3321+
3322+
impl StringCollector {
3323+
pub fn add_str(&mut self, n: String) {
3324+
self.strings.push(n);
3325+
}
3326+
}
3327+
33023328
impl Visit for ExportCollector<'_> {
33033329
noop_visit_type!();
33043330
fn visit_export_decl(&mut self, n: &ExportDecl) {

0 commit comments

Comments
 (0)