Skip to content

Commit

Permalink
Merge pull request #61 from gersbach/feat/EAS-2573
Browse files Browse the repository at this point in the history
EAS-2573 : Add GraphQL support for the permission scanner
  • Loading branch information
jwong101 authored Jan 11, 2025
2 parents 7fa85d2 + de06b15 commit 531a437
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion crates/forge_analyzer/src/definitions.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![allow(dead_code, unused)]

use std::borrow::BorrowMut;
use std::env;
use std::hash::Hash;
use std::{borrow::Borrow, fmt, mem};
use std::{env, string};

use crate::utils::{calls_method, eq_prop_name};
use forge_file_resolver::{FileResolver, ForgeResolver};
Expand Down Expand Up @@ -146,6 +146,11 @@ pub fn run_resolver(

// This for loop parses each token of each code statement in the file.
for (curr_mod, module) in modules.iter_enumerated() {
let mut string_collector = StringCollector { strings: vec![] };

module.visit_children_with(&mut string_collector);
environment.all_strings.extend(string_collector.strings);

let mut export_collector = ExportCollector {
res_table: &mut environment.resolver,
curr_mod,
Expand Down Expand Up @@ -583,6 +588,7 @@ pub struct Environment {
pub defs: Definitions,
default_exports: FxHashMap<ModId, DefId>,
pub resolver: ResolverTable,
pub all_strings: Vec<String>,
}

struct ImportCollector<'cx> {
Expand Down Expand Up @@ -3299,6 +3305,26 @@ impl Visit for GlobalCollector<'_> {
}
}

struct StringCollector {
strings: Vec<String>,
}

impl Visit for StringCollector {
fn visit_str(&mut self, n: &Str) {
self.add_str(n.value.as_str().to_string());
}

fn visit_tpl(&mut self, n: &Tpl) {
self.add_str(n.quasis.iter().map(|val| val.raw.as_str()).collect());
}
}

impl StringCollector {
pub fn add_str(&mut self, n: String) {
self.strings.push(n);
}
}

impl Visit for ExportCollector<'_> {
noop_visit_type!();
fn visit_export_decl(&mut self, n: &ExportDecl) {
Expand Down

0 comments on commit 531a437

Please sign in to comment.