Skip to content

Commit 5148d6d

Browse files
bors[bot]pksunkara
andauthored
Merge #4405
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 <[email protected]>
2 parents 6fde7f1 + 9f0a7eb commit 5148d6d

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

crates/ra_ide/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,10 @@ impl AnalysisHost {
176176
pub fn request_cancellation(&mut self) {
177177
self.db.request_cancellation();
178178
}
179-
pub fn raw_database(
180-
&self,
181-
) -> &(impl hir::db::HirDatabase + salsa::Database + ra_db::SourceDatabaseExt) {
179+
pub fn raw_database(&self) -> &RootDatabase {
182180
&self.db
183181
}
184-
pub fn raw_database_mut(
185-
&mut self,
186-
) -> &mut (impl hir::db::HirDatabase + salsa::Database + ra_db::SourceDatabaseExt) {
182+
pub fn raw_database_mut(&mut self) -> &mut RootDatabase {
187183
&mut self.db
188184
}
189185
}

crates/ra_project_model/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub enum ProjectWorkspace {
3535
/// `PackageRoot` describes a package root folder.
3636
/// Which may be an external dependency, or a member of
3737
/// the current workspace.
38-
#[derive(Clone)]
38+
#[derive(Debug, Clone)]
3939
pub struct PackageRoot {
4040
/// Path to the root folder
4141
path: PathBuf,

crates/ra_text_edit/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct TextEdit {
2121
indels: Vec<Indel>,
2222
}
2323

24-
#[derive(Debug, Default)]
24+
#[derive(Debug, Default, Clone)]
2525
pub struct TextEditBuilder {
2626
indels: Vec<Indel>,
2727
}

crates/rust-analyzer/src/cli.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use ra_syntax::{AstNode, SourceFile};
1616
pub use analysis_bench::{analysis_bench, BenchWhat, Position};
1717
pub use analysis_stats::analysis_stats;
1818
pub use diagnostics::diagnostics;
19+
pub use load_cargo::load_cargo;
1920

2021
#[derive(Clone, Copy)]
2122
pub enum Verbosity {

crates/rust-analyzer/src/cli/load_cargo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId {
2222
SourceRootId(r.0)
2323
}
2424

25-
pub(crate) fn load_cargo(
25+
pub fn load_cargo(
2626
root: &Path,
2727
load_out_dirs_from_check: bool,
2828
with_proc_macro: bool,

editors/code/src/commands/ssr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function ssr(ctx: Ctx): Cmd {
1111

1212
const options: vscode.InputBoxOptions = {
1313
value: "() ==>> ()",
14-
prompt: "EnteR request, for example 'Foo($a:expr) ==> Foo::new($a)' ",
14+
prompt: "Enter request, for example 'Foo($a:expr) ==> Foo::new($a)' ",
1515
validateInput: async (x: string) => {
1616
try {
1717
await client.sendRequest(ra.ssr, { query: x, parseOnly: true });

0 commit comments

Comments
 (0)