Skip to content

Add workspace symbols & --eager flag #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions starlark_bin/bin/bazel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ pub(crate) fn main(
prelude: &[PathBuf],
dialect: Dialect,
globals: Globals,
eager: bool,
) -> anyhow::Result<()> {
if !lsp {
return Err(anyhow::anyhow!("Bazel mode only supports `--lsp`"));
Expand All @@ -154,6 +155,7 @@ pub(crate) fn main(
is_interactive,
dialect,
globals,
eager,
)?;

ctx.mode = ContextMode::Check;
Expand All @@ -173,6 +175,7 @@ pub(crate) struct BazelContext {
pub(crate) globals: Globals,
pub(crate) builtin_docs: HashMap<LspUrl, String>,
pub(crate) builtin_symbols: HashMap<String, LspUrl>,
pub(crate) eager: bool,
}

impl BazelContext {
Expand All @@ -187,6 +190,7 @@ impl BazelContext {
module: bool,
dialect: Dialect,
globals: Globals,
eager: bool,
) -> anyhow::Result<Self> {
let prelude: Vec<_> = prelude
.iter()
Expand Down Expand Up @@ -263,6 +267,7 @@ impl BazelContext {
}),
external_output_base: output_base
.map(|output_base| PathBuf::from(output_base).join("external")),
eager,
})
}

Expand Down Expand Up @@ -886,4 +891,8 @@ impl LspContext for BazelContext {

Ok(names)
}

fn is_eager(&self) -> bool {
self.eager
}
}
7 changes: 7 additions & 0 deletions starlark_bin/bin/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub(crate) struct Context {
pub(crate) globals: Globals,
pub(crate) builtin_docs: HashMap<LspUrl, String>,
pub(crate) builtin_symbols: HashMap<String, LspUrl>,
pub(crate) eager: bool,
}

/// The outcome of evaluating (checking, parsing or running) given starlark code.
Expand Down Expand Up @@ -101,6 +102,7 @@ impl Context {
module: bool,
dialect: Dialect,
globals: Globals,
eager: bool,
) -> anyhow::Result<Self> {
let prelude: Vec<_> = prelude
.iter()
Expand Down Expand Up @@ -143,6 +145,7 @@ impl Context {
globals,
builtin_docs,
builtin_symbols,
eager,
})
}

Expand Down Expand Up @@ -379,4 +382,8 @@ impl LspContext for Context {
fn get_environment(&self, _uri: &LspUrl) -> DocModule {
DocModule::default()
}

fn is_eager(&self) -> bool {
self.eager
}
}
5 changes: 5 additions & 0 deletions starlark_bin/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ struct Args {
)]
files: Vec<PathBuf>,

#[arg(long = "eager", help = "In LSP mode, eagerly load all files.")]
eager: bool,

#[arg(
long = "bazel",
help = "Run in Bazel mode (temporary, will be removed)"
Expand Down Expand Up @@ -298,6 +301,7 @@ fn main() -> anyhow::Result<()> {
&prelude,
dialect,
globals,
args.eager,
)?;
return Ok(());
}
Expand All @@ -313,6 +317,7 @@ fn main() -> anyhow::Result<()> {
is_interactive,
dialect,
globals,
args.eager,
)?;

if args.lsp {
Expand Down
Loading