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
107 changes: 73 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ line-index = "0.1.2"
lsp-server = "0.7.8"
lsp-types = "0.95"
serde-wasm-bindgen = "0.6.5"
wasm-bindgen = "0.2.100"
wasm-bindgen-test = "0.3.34"
web-sys = "0.3.77"
wasm-bindgen = "0.2.114"
wasm-bindgen-test = "0.3.50"
web-sys = "0.3.91"
console_error_panic_hook = "0.1.7"
console_log = "1.0.0"
annotate-snippets = "0.12.4"
Expand All @@ -63,6 +63,7 @@ snapbox = { version = "0.6.0", features = ["diff", "term-svg", "cmd"] }
smallvec = "1.13.2"
tabled = "0.17.0"
etcetera = "0.11.0"
url = "2.5.4"

# local
# we have to make the versions explicit otherwise `cargo publish` won't work
Expand Down
3 changes: 3 additions & 0 deletions crates/squawk_ide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ squawk-linter.workspace = true
rowan.workspace = true
line-index.workspace = true
annotate-snippets.workspace = true
url.workspace = true
salsa.workspace = true
log.workspace = true
smol_str.workspace = true
la-arena.workspace = true
smallvec.workspace = true
itertools.workspace = true
etcetera.workspace = true

[dev-dependencies]
insta.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions crates/squawk_ide/src/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ use squawk_syntax::{SyntaxNodePtr, ast, ast::AstNode};
use crate::scope::{Scope, ScopeId};
use crate::symbols::{Name, Schema, Symbol, SymbolKind};

#[derive(Clone, PartialEq)]
struct SearchPathChange {
position: TextSize,
search_path: Vec<Schema>,
}

#[derive(Clone, PartialEq)]
pub(crate) struct Binder {
// TODO: doesn't seem like we need this with our resolve setup
scopes: Arena<Scope>,
Expand Down
40 changes: 39 additions & 1 deletion crates/squawk_ide/src/builtins.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
pub const BUILTINS_SQL: &str = include_str!("builtins.sql");
#[cfg(not(target_arch = "wasm32"))]
use etcetera::BaseStrategy;
use line_index::LineIndex;
use salsa::Database as Db;
use squawk_syntax::{Parse, SourceFile};
#[cfg(not(target_arch = "wasm32"))]
use url::Url;

use crate::binder::{self, Binder};

pub(crate) const BUILTINS_SQL: &str = include_str!("builtins.sql");

#[salsa::tracked]
pub fn parse_builtins(_db: &dyn Db) -> Parse<SourceFile> {
SourceFile::parse(BUILTINS_SQL)
}

#[salsa::tracked]
pub fn builtins_line_index(_db: &dyn Db) -> LineIndex {
LineIndex::new(BUILTINS_SQL)
}

#[salsa::tracked]
pub fn builtins_binder(db: &dyn Db) -> Binder {
let builtins_tree = parse_builtins(db).tree();
binder::bind(&builtins_tree)
}

#[cfg(not(target_arch = "wasm32"))]
#[salsa::tracked]
pub fn builtins_url(_db: &dyn Db) -> Option<Url> {
let strategy = etcetera::base_strategy::choose_base_strategy().ok()?;
let config_dir = strategy.config_dir();
let cache_dir = config_dir.join("squawk/stubs");
let path = cache_dir.join("builtins.sql");
std::fs::create_dir_all(&cache_dir).ok()?;
std::fs::write(&path, BUILTINS_SQL).ok()?;
Url::from_file_path(path).ok()
}

#[cfg(test)]
mod test {
Expand Down
Loading
Loading