mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
This commit add Cargo-style project discovery for Buck and Bazel users.
This feature requires the user to add a command that generates a `rust-project.json` from a set of files. Project discovery can be invoked in two ways: 1. At extension activation time, which includes the generated `rust-project.json` as part of the linkedProjects argument in InitializeParams 2. Through a new command titled "Add current file to workspace", which makes use of a new, rust-analyzer specific LSP request that adds the workspace without erasing any existing workspaces. I think that the command-running functionality _could_ merit being placed into its own extension (and expose it via extension contribution points), if only provide build-system idiomatic progress reporting and status handling, but I haven't (yet) made an extension that does this.
This commit is contained in:
parent
9549753352
commit
8af3d6367e
14 changed files with 258 additions and 25 deletions
91
editors/code/src/rust_project.ts
Normal file
91
editors/code/src/rust_project.ts
Normal file
|
@ -0,0 +1,91 @@
|
|||
interface JsonProject {
|
||||
/// Path to the directory with *source code* of
|
||||
/// sysroot crates.
|
||||
///
|
||||
/// It should point to the directory where std,
|
||||
/// core, and friends can be found:
|
||||
///
|
||||
/// https://github.com/rust-lang/rust/tree/master/library.
|
||||
///
|
||||
/// If provided, rust-analyzer automatically adds
|
||||
/// dependencies on sysroot crates. Conversely,
|
||||
/// if you omit this path, you can specify sysroot
|
||||
/// dependencies yourself and, for example, have
|
||||
/// several different "sysroots" in one graph of
|
||||
/// crates.
|
||||
sysroot_src?: string;
|
||||
/// The set of crates comprising the current
|
||||
/// project. Must include all transitive
|
||||
/// dependencies as well as sysroot crate (libstd,
|
||||
/// libcore and such).
|
||||
crates: Crate[];
|
||||
}
|
||||
|
||||
interface Crate {
|
||||
/// Optional crate name used for display purposes,
|
||||
/// without affecting semantics. See the `deps`
|
||||
/// key for semantically-significant crate names.
|
||||
display_name?: string;
|
||||
/// Path to the root module of the crate.
|
||||
root_module: string;
|
||||
/// Edition of the crate.
|
||||
edition: "2015" | "2018" | "2021";
|
||||
/// Dependencies
|
||||
deps: Dep[];
|
||||
/// Should this crate be treated as a member of
|
||||
/// current "workspace".
|
||||
///
|
||||
/// By default, inferred from the `root_module`
|
||||
/// (members are the crates which reside inside
|
||||
/// the directory opened in the editor).
|
||||
///
|
||||
/// Set this to `false` for things like standard
|
||||
/// library and 3rd party crates to enable
|
||||
/// performance optimizations (rust-analyzer
|
||||
/// assumes that non-member crates don't change).
|
||||
is_workspace_member?: boolean;
|
||||
/// Optionally specify the (super)set of `.rs`
|
||||
/// files comprising this crate.
|
||||
///
|
||||
/// By default, rust-analyzer assumes that only
|
||||
/// files under `root_module.parent` can belong
|
||||
/// to a crate. `include_dirs` are included
|
||||
/// recursively, unless a subdirectory is in
|
||||
/// `exclude_dirs`.
|
||||
///
|
||||
/// Different crates can share the same `source`.
|
||||
///
|
||||
/// If two crates share an `.rs` file in common,
|
||||
/// they *must* have the same `source`.
|
||||
/// rust-analyzer assumes that files from one
|
||||
/// source can't refer to files in another source.
|
||||
source?: {
|
||||
include_dirs: string[],
|
||||
exclude_dirs: string[],
|
||||
},
|
||||
/// The set of cfgs activated for a given crate, like
|
||||
/// `["unix", "feature=\"foo\"", "feature=\"bar\""]`.
|
||||
cfg: string[];
|
||||
/// Target triple for this Crate.
|
||||
///
|
||||
/// Used when running `rustc --print cfg`
|
||||
/// to get target-specific cfgs.
|
||||
target?: string;
|
||||
/// Environment variables, used for
|
||||
/// the `env!` macro
|
||||
env: { [key: string]: string; },
|
||||
|
||||
/// Whether the crate is a proc-macro crate.
|
||||
is_proc_macro: boolean;
|
||||
/// For proc-macro crates, path to compiled
|
||||
/// proc-macro (.so file).
|
||||
proc_macro_dylib_path?: string;
|
||||
}
|
||||
|
||||
interface Dep {
|
||||
/// Index of a crate in the `crates` array.
|
||||
crate: number,
|
||||
/// Name as should appear in the (implicit)
|
||||
/// `extern crate name` declaration.
|
||||
name: string,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue