4405: Make some stuff public so that they can be reused by other tools r=pksunkara a=pksunkara

So, my little experiment of building a code analysis tool using rust-analyzer is successful. I am going to proceed to build the tool now. This PR makes the needed things public.

I know there were some things about trying to change stuff regarding loading workspaces, which would make it more easier for other tools to reuse. But, until then, it should be okay using this `load_cargo` fn.

Btw, if I were publish my tool, I would need the `ra` crates to be released. Since @matklad told me that he doesn't want to care about breaking stuff, I would propose the following.

Every monday, during the weekly release, we release a new pre v1 minor version of all the crates. That way, we don't need to care about breaking stuff but still have rust-analyzer on crates.io.

I made https://github.com/pksunkara/cargo-workspaces to help release workspace crates easily.

So, coming week, we start with `0.1.0`, then week after that, we release `0.2.0` and then `0.3.0` etc.. until we decide on `1.0.0` which is probably when the compiler team also starts using the crates. There is no limit to the minor versions (we can even have `0.150.0` or `0.1500.0`), so I don't see anything wrong with this strategy.

Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
This commit is contained in:
bors[bot] 2020-05-14 09:23:34 +00:00 committed by GitHub
commit 5148d6dc66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 10 deletions

View File

@ -176,14 +176,10 @@ impl AnalysisHost {
pub fn request_cancellation(&mut self) { pub fn request_cancellation(&mut self) {
self.db.request_cancellation(); self.db.request_cancellation();
} }
pub fn raw_database( pub fn raw_database(&self) -> &RootDatabase {
&self,
) -> &(impl hir::db::HirDatabase + salsa::Database + ra_db::SourceDatabaseExt) {
&self.db &self.db
} }
pub fn raw_database_mut( pub fn raw_database_mut(&mut self) -> &mut RootDatabase {
&mut self,
) -> &mut (impl hir::db::HirDatabase + salsa::Database + ra_db::SourceDatabaseExt) {
&mut self.db &mut self.db
} }
} }

View File

@ -35,7 +35,7 @@ pub enum ProjectWorkspace {
/// `PackageRoot` describes a package root folder. /// `PackageRoot` describes a package root folder.
/// Which may be an external dependency, or a member of /// Which may be an external dependency, or a member of
/// the current workspace. /// the current workspace.
#[derive(Clone)] #[derive(Debug, Clone)]
pub struct PackageRoot { pub struct PackageRoot {
/// Path to the root folder /// Path to the root folder
path: PathBuf, path: PathBuf,

View File

@ -21,7 +21,7 @@ pub struct TextEdit {
indels: Vec<Indel>, indels: Vec<Indel>,
} }
#[derive(Debug, Default)] #[derive(Debug, Default, Clone)]
pub struct TextEditBuilder { pub struct TextEditBuilder {
indels: Vec<Indel>, indels: Vec<Indel>,
} }

View File

@ -16,6 +16,7 @@ use ra_syntax::{AstNode, SourceFile};
pub use analysis_bench::{analysis_bench, BenchWhat, Position}; pub use analysis_bench::{analysis_bench, BenchWhat, Position};
pub use analysis_stats::analysis_stats; pub use analysis_stats::analysis_stats;
pub use diagnostics::diagnostics; pub use diagnostics::diagnostics;
pub use load_cargo::load_cargo;
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum Verbosity { pub enum Verbosity {

View File

@ -22,7 +22,7 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId {
SourceRootId(r.0) SourceRootId(r.0)
} }
pub(crate) fn load_cargo( pub fn load_cargo(
root: &Path, root: &Path,
load_out_dirs_from_check: bool, load_out_dirs_from_check: bool,
with_proc_macro: bool, with_proc_macro: bool,

View File

@ -11,7 +11,7 @@ export function ssr(ctx: Ctx): Cmd {
const options: vscode.InputBoxOptions = { const options: vscode.InputBoxOptions = {
value: "() ==>> ()", value: "() ==>> ()",
prompt: "EnteR request, for example 'Foo($a:expr) ==> Foo::new($a)' ", prompt: "Enter request, for example 'Foo($a:expr) ==> Foo::new($a)' ",
validateInput: async (x: string) => { validateInput: async (x: string) => {
try { try {
await client.sendRequest(ra.ssr, { query: x, parseOnly: true }); await client.sendRequest(ra.ssr, { query: x, parseOnly: true });