forked from denoland/deno_lint
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
temp
- Loading branch information
1 parent
09f2fc1
commit 2410472
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright 2020 the Deno authors. All rights reserved. MIT license. | ||
|
||
#![allow(unused)] | ||
|
||
use std::cell::RefCell; | ||
use std::collections::HashMap; | ||
use std::fmt; | ||
use std::rc::Rc; | ||
use swc_ecma_ast::AssignExpr; | ||
use swc_ecma_ast::Decl; | ||
use swc_ecma_ast::Expr; | ||
use swc_ecma_ast::ExprStmt; | ||
use swc_ecma_ast::Module; | ||
use swc_ecma_ast::ModuleItem; | ||
use swc_ecma_ast::Pat; | ||
use swc_ecma_ast::Stmt; | ||
use swc_ecma_visit::Node; | ||
use swc_ecma_visit::Visit; | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum ScopeKind { | ||
Program, | ||
Module, | ||
Function, | ||
Block, | ||
Loop, | ||
Class, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct Scope { | ||
pub kind: ScopeKind, | ||
pub span: Span, | ||
pub child_scopes: Vec<Scope>, | ||
} | ||
|
||
struct ScopeVisitor { | ||
|
||
} | ||
|
||
impl Visit for ScopeVisitor { | ||
fn visit_module(&mut self, module: &swc_ecma_ast::Module, parent: &dyn Node) { | ||
let mut program_scope = Scope { | ||
kind: ScopeKind::Program, | ||
span: module.span, | ||
child_scopes: vec![], | ||
}; | ||
|
||
let module_scope = Scope { | ||
kind: ScopeKind::Module, | ||
span: module.span, | ||
child_scopes: vec![], | ||
}; | ||
program_scope.child_scopes.push(module_scope); | ||
|
||
swc_ecma_visit::visit_module(self, module, parent); | ||
} | ||
} | ||
|
||
|
||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn scopes() { | ||
let scope_visitor = ScopeVisitor { | ||
|
||
}; | ||
|
||
scope_visitor.visit_module(module, module); | ||
} | ||
} |