Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/lsp/src/file_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::sync::Arc;
use lsp_types::{Position, Range, Url};
use rowan::TextSize;

use syntax::syntax_node::{SyntaxNode, SyntaxToken};
use syntax::node::{SyntaxNode, SyntaxToken};

// File identity is owned by the `vfs` crate (a path-interned `u32` index), so aliased paths
// collapse to one id via interning rather than via a path hash. Re-exported here for callers that
Expand Down
4 changes: 2 additions & 2 deletions crates/lsp/src/global_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rowan::TextSize;
use syntax::abstract_syntax_tree::{
AstCircomProgram, AstComponentCall, AstComponentDecl, AstMainComponent,
};
use syntax::syntax_node::SyntaxToken;
use syntax::node::SyntaxToken;

use std::path::PathBuf;

Expand Down Expand Up @@ -304,7 +304,7 @@ impl GlobalState {
pub(crate) fn find_occurrences(
&self,
target: &(FileId, ResolvedSymbol),
) -> Vec<syntax::syntax_node::SyntaxToken> {
) -> Vec<syntax::node::SyntaxToken> {
let (def_file, sym) = target;
let Some(ast) = self.source_db.ast(*def_file) else {
return Vec::new();
Expand Down
4 changes: 2 additions & 2 deletions crates/lsp/src/handler/goto_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use lsp_types::{Location, Range, Url};
use rowan::ast::AstNode;

use syntax::abstract_syntax_tree::AstInclude;
use syntax::syntax_node::SyntaxToken;
use syntax::node::SyntaxToken;
use vfs::Vfs;

use crate::file_db::FileDB;
Expand Down Expand Up @@ -80,7 +80,7 @@ mod tests {
use rowan::ast::AstNode;
use syntax::{
abstract_syntax_tree::{AstCircomProgram, AstInputSignalDecl, AstTemplateDef},
syntax::syntax_tree,
tree::syntax_tree,
};

use crate::file_db::FileDB;
Expand Down
2 changes: 1 addition & 1 deletion crates/lsp/src/handler/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ mod tests {
use crate::file_db::{FileDB, FileId};
use crate::global_state::GlobalState;
use parser::token_kind::TokenKind;
use syntax::syntax::syntax_tree;
use syntax::tree::syntax_tree;

use super::handle;
use lsp_types::{
Expand Down
4 changes: 2 additions & 2 deletions crates/lsp/src/handler/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ mod tests {
use rowan::ast::AstNode;

use syntax::abstract_syntax_tree::AstCircomProgram;
use syntax::syntax::syntax_tree;
use syntax::tree::syntax_tree;

use crate::file_db::{FileDB, FileId};
use crate::resolver::{occurrences_in, resolve};
use crate::semantic::SymbolTable;
use crate::symbol_table::SymbolTable;

/// Times the `references` pipeline (parse, `SymbolTable::build`, `occurrences_in`) on a large
/// synthetic circuit to split inherent cost (reparse) from avoidable cost (build/occurrences).
Expand Down
4 changes: 2 additions & 2 deletions crates/lsp/src/handler/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::file_db::FileId;
use crate::global_state::{CursorContext, GlobalState};
use crate::resolver::{identifier_at, ResolvedSymbol};
use crate::source_db::SourceDatabase;
use syntax::syntax_node::SyntaxToken;
use syntax::node::SyntaxToken;

/// Entry point for `textDocument/rename`. Returns `None` (no edits) when the cursor isn't on a
/// renamable `Identifier`, `new_name` isn't a legal circom identifier, or the file is unknown.
Expand Down Expand Up @@ -109,7 +109,7 @@ mod tests {
};

use parser::token_kind::TokenKind;
use syntax::syntax::syntax_tree;
use syntax::tree::syntax_tree;

use crate::file_db::{FileDB, FileId};
use crate::global_state::GlobalState;
Expand Down
2 changes: 1 addition & 1 deletion crates/lsp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub mod file_db;
pub mod global_state;
pub mod handler;
pub mod resolver;
pub mod semantic;
pub mod source_db;
pub mod symbol_table;

fn main() -> Result<(), Box<dyn Error + Sync + Send>> {
// All logging must go to stderr — stdout is the LSP message channel.
Expand Down
12 changes: 6 additions & 6 deletions crates/lsp/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ use rowan::ast::AstNode;
use rowan::TextSize;

use syntax::abstract_syntax_tree::{AstCall, AstCircomProgram, AstComponentCall};
use syntax::syntax_node::{SyntaxNode, SyntaxToken};
use syntax::node::{SyntaxNode, SyntaxToken};

use crate::semantic::{Symbol, SymbolTable};
use crate::symbol_table::{Symbol, SymbolTable};

pub use crate::semantic::SymbolKind;
pub use crate::symbol_table::SymbolKind;

// --- cursor/token navigation (shared by goto-definition, references, rename) -----------------

Expand Down Expand Up @@ -174,11 +174,11 @@ mod tests {
AstCircomProgram, AstComponentCall, AstComponentDecl, AstInputSignalDecl, AstSignalDecl,
AstVarDecl,
};
use syntax::syntax::syntax_tree;
use syntax::syntax_node::{CircomLanguage, SyntaxToken};
use syntax::node::{CircomLanguage, SyntaxToken};
use syntax::tree::syntax_tree;

use crate::file_db::{FileDB, FileId};
use crate::semantic::SymbolTable;
use crate::symbol_table::SymbolTable;

use super::{resolve, SymbolKind};

Expand Down
6 changes: 3 additions & 3 deletions crates/lsp/src/source_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ use std::sync::Arc;
use lsp_types::Url;
use rowan::ast::AstNode;
use syntax::abstract_syntax_tree::AstCircomProgram;
use syntax::syntax::syntax_tree;
use syntax::syntax_node::SyntaxNode;
use syntax::node::SyntaxNode;
use syntax::tree::syntax_tree;
use vfs::{ChangedFile, Vfs, VfsPath};

use crate::file_db::{FileDB, FileId};
use crate::semantic::SymbolTable;
use crate::symbol_table::SymbolTable;

/// Source-level queries over open files, keyed by [`FileId`] — inputs (`file_text`) or
/// content-derived values (`parse`/`ast`/`file_db`/`symbol_table`). All `&self` with memoization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use lsp_types::Range;
use parser::token_kind::TokenKind;
use rowan::ast::AstNode;
use rowan::{TextRange, TextSize};
use syntax::syntax_node::SyntaxNode;
use syntax::node::SyntaxNode;

use syntax::abstract_syntax_tree::{
AstCircomProgram, AstComponentDecl, AstIdentifier, AstInputSignalDecl, AstOutputSignalDecl,
Expand Down
2 changes: 1 addition & 1 deletion crates/syntax/src/abstract_syntax_tree/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use parser::token_kind::TokenKind;
use parser::token_kind::TokenKind::*;
use rowan::ast::{support, AstNode};

use crate::syntax_node::{CircomLanguage, SyntaxNode};
use crate::node::{CircomLanguage, SyntaxNode};

use super::name::Named;

Expand Down
2 changes: 1 addition & 1 deletion crates/syntax/src/abstract_syntax_tree/declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use parser::token_kind::TokenKind;
use parser::token_kind::TokenKind::*;
use rowan::ast::{support, AstNode};

use crate::syntax_node::{CircomLanguage, SyntaxNode};
use crate::node::{CircomLanguage, SyntaxNode};

use super::definition::AstTemplateName;
use super::name::{AstComplexIdentifier, AstIdentifier, Named};
Expand Down
2 changes: 1 addition & 1 deletion crates/syntax/src/abstract_syntax_tree/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use parser::token_kind::TokenKind;
use parser::token_kind::TokenKind::*;
use rowan::ast::{support, AstNode};

use crate::syntax_node::{CircomLanguage, SyntaxNode};
use crate::node::{CircomLanguage, SyntaxNode};

use super::block::{AstBlock, AstStatementList};
use super::name::{AstIdentifier, AstParameterList, Named};
Expand Down
2 changes: 1 addition & 1 deletion crates/syntax/src/abstract_syntax_tree/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use parser::token_kind::TokenKind::*;
use rowan::ast::support;
use rowan::ast::AstNode;

use crate::syntax_node::{CircomLanguage, SyntaxNode};
use crate::node::{CircomLanguage, SyntaxNode};

use super::name::{AstComplexIdentifier, AstIdentifier};

Expand Down
2 changes: 1 addition & 1 deletion crates/syntax/src/abstract_syntax_tree/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use parser::token_kind::TokenKind;
use parser::token_kind::TokenKind::*;
use rowan::ast::{support, AstNode};

use crate::syntax_node::{CircomLanguage, SyntaxNode};
use crate::node::{CircomLanguage, SyntaxNode};

/// A node that declares a nameable symbol and exposes its leaf identifier token — the `a` in
/// `signal input a;`, the `T` in `template T() {}`. Implementing it lets a declaration be looked up
Expand Down
2 changes: 1 addition & 1 deletion crates/syntax/src/abstract_syntax_tree/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use parser::token_kind::TokenKind;
use parser::token_kind::TokenKind::*;
use rowan::ast::{support, AstNode};

use crate::syntax_node::{CircomLanguage, SyntaxNode};
use crate::node::{CircomLanguage, SyntaxNode};

use super::definition::{AstBusDef, AstFunctionDef, AstTemplateDef, AstTemplateName};
use super::expression::AstExpression;
Expand Down
2 changes: 1 addition & 1 deletion crates/syntax/src/abstract_syntax_tree/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use parser::token_kind::TokenKind;
use parser::token_kind::TokenKind::*;
use rowan::ast::{support, AstNode};

use crate::syntax_node::{CircomLanguage, SyntaxNode};
use crate::node::{CircomLanguage, SyntaxNode};

use super::block::AstBlock;
use super::expression::AstExpression;
Expand Down
6 changes: 3 additions & 3 deletions crates/syntax/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod abstract_syntax_tree;
pub mod syntax;
pub mod syntax_node;
pub mod abstract_syntax_tree;
pub mod node;
pub mod tree;
File renamed without changes.
8 changes: 4 additions & 4 deletions crates/syntax/src/syntax.rs → crates/syntax/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub use rowan::{
WalkEvent,
};

use crate::syntax_node::SyntaxNode;
use crate::node::SyntaxNode;

/// Parse `source` as a whole circom program and build its syntax tree.
pub fn syntax_tree(source: &str) -> SyntaxNode {
Expand Down Expand Up @@ -113,8 +113,8 @@ mod test_utils;
mod tests {
use parser::grammar::entry::Scope;

use crate::syntax::test_utils::view_ast;
use crate::test_syntax;
use crate::tree::test_utils::view_ast;

#[test]
fn pragma_happy_test() {
Expand All @@ -126,12 +126,12 @@ mod tests {
// Regression: circom permits pragma/include/template/function/main in any order. A program
// with an `include` *after* a definition must parse the include (not treat it as a stray
// top-level token) and produce no error node for it.
use crate::syntax::WalkEvent;
use crate::tree::WalkEvent;
use parser::token_kind::TokenKind;
use rowan::NodeOrToken;

let src = "pragma circom 2.0.0;\ntemplate T() {}\ninclude \"lib.circom\";\n";
let tree = crate::syntax::syntax_tree(src);
let tree = crate::tree::syntax_tree(src);

let mut has_include = false;
let mut has_error = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use rowan::{NodeOrToken, WalkEvent};

use crate::syntax_node::SyntaxNode;
use crate::node::SyntaxNode;

#[macro_export]
macro_rules! test_syntax {
Expand All @@ -9,7 +9,7 @@ macro_rules! test_syntax {

let full_path = format!("{}{}", crate_path, $file_path);
let source = std::fs::read_to_string(full_path).expect("Should not failed");
let syntax = $crate::syntax::syntax_node_from_source(&source, $scope);
let syntax = $crate::tree::syntax_node_from_source(&source, $scope);
insta::assert_snapshot!($file_path, view_ast(&syntax));
};
}
Expand Down
4 changes: 2 additions & 2 deletions crates/syntax/tests/ast_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use rowan::ast::AstNode;
use syntax::abstract_syntax_tree::{
AstCircomProgram, AstInlineArray, AstParallelExpr, AstTupleExpr, Named,
};
use syntax::syntax::syntax_tree;
use syntax::syntax_node::{CircomLanguage, SyntaxNode};
use syntax::node::{CircomLanguage, SyntaxNode};
use syntax::tree::syntax_tree;

/// Parse `src` as a full program and return the typed root.
fn program(src: &str) -> AstCircomProgram {
Expand Down
2 changes: 1 addition & 1 deletion crates/syntax/tests/grammar_gaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use parser::lexer::tokenize;
use parser::token_kind::TokenKind;
use syntax::syntax::syntax_tree;
use syntax::tree::syntax_tree;

// --- shared harness ---------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions crates/syntax/tests/grammar_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
//! gap is documented and surfaces the moment support lands.

use parser::token_kind::TokenKind;
use syntax::syntax::syntax_tree;
use syntax::syntax_node::SyntaxNode;
use syntax::node::SyntaxNode;
use syntax::tree::syntax_tree;

// --- harness ------------------------------------------------------------------------------------

Expand Down
Loading