mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 05:08:52 +00:00
organizize
This commit is contained in:
parent
26262aaf05
commit
7c67612b8a
376 changed files with 27 additions and 145 deletions
21
Cargo.toml
21
Cargo.toml
|
@ -1,21 +1,2 @@
|
|||
[package]
|
||||
name = "libsyntax2"
|
||||
version = "0.1.0"
|
||||
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[workspace]
|
||||
members = [ "tools", "cli", "libeditor", "libanalysis", "codeless/server" ]
|
||||
|
||||
[dependencies]
|
||||
unicode-xid = "0.1.0"
|
||||
text_unit = "0.1.2"
|
||||
itertools = "0.7.5"
|
||||
drop_bomb = "0.1.4"
|
||||
parking_lot = "0.6.0"
|
||||
|
||||
[dev-dependencies]
|
||||
testutils = { path = "./tests/testutils" }
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
members = [ "crates/*" ]
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
[package]
|
||||
name = "backend"
|
||||
version = "0.1.0"
|
||||
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
|
||||
license = "MIT"
|
||||
build = "build.rs"
|
||||
exclude = ["artifacts.json", "index.node"]
|
||||
[workspace]
|
||||
|
||||
[lib]
|
||||
name = "backend"
|
||||
crate-type = ["dylib"]
|
||||
|
||||
[build-dependencies]
|
||||
neon-build = "0.2.0"
|
||||
|
||||
[dependencies]
|
||||
neon = "0.2.0"
|
||||
libeditor = { path = "../../libeditor" }
|
|
@ -1,7 +0,0 @@
|
|||
extern crate neon_build;
|
||||
|
||||
fn main() {
|
||||
neon_build::setup(); // must be called in build.rs
|
||||
|
||||
// add project-specific build logic here...
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
#[macro_use]
|
||||
extern crate neon;
|
||||
extern crate libeditor;
|
||||
|
||||
use neon::prelude::*;
|
||||
use libeditor::TextRange;
|
||||
|
||||
pub struct Wrapper {
|
||||
inner: libeditor::File,
|
||||
}
|
||||
|
||||
declare_types! {
|
||||
/// A class for generating greeting strings.
|
||||
pub class RustFile for Wrapper {
|
||||
init(mut cx) {
|
||||
let text = cx.argument::<JsString>(0)?.value();
|
||||
Ok(Wrapper {
|
||||
inner: libeditor::File::new(&text)
|
||||
})
|
||||
}
|
||||
|
||||
method syntaxTree(mut cx) {
|
||||
let tree = {
|
||||
let this = cx.this();
|
||||
let guard = cx.lock();
|
||||
let wrapper = this.borrow(&guard);
|
||||
wrapper.inner.syntax_tree()
|
||||
};
|
||||
Ok(cx.string(tree.as_str()).upcast())
|
||||
}
|
||||
|
||||
method highlight(mut cx) {
|
||||
let highlights = {
|
||||
let this = cx.this();
|
||||
let guard = cx.lock();
|
||||
let wrapper = this.borrow(&guard);
|
||||
wrapper.inner.highlight()
|
||||
};
|
||||
let res = cx.empty_array();
|
||||
for (i, hl) in highlights.into_iter().enumerate() {
|
||||
let start: u32 = hl.range.start().into();
|
||||
let end: u32 = hl.range.end().into();
|
||||
let start = cx.number(start);
|
||||
let end = cx.number(end);
|
||||
let tag = cx.string(hl.tag);
|
||||
let hl = cx.empty_array();
|
||||
hl.set(&mut cx, 0, start)?;
|
||||
hl.set(&mut cx, 1, end)?;
|
||||
hl.set(&mut cx, 2, tag)?;
|
||||
res.set(&mut cx, i as u32, hl)?;
|
||||
}
|
||||
|
||||
Ok(res.upcast())
|
||||
}
|
||||
|
||||
method extendSelection(mut cx) {
|
||||
let from_offset = cx.argument::<JsNumber>(0)?.value() as u32;
|
||||
let to_offset = cx.argument::<JsNumber>(1)?.value() as u32;
|
||||
let text_range = TextRange::from_to(from_offset.into(), to_offset.into());
|
||||
let extended_range = {
|
||||
let this = cx.this();
|
||||
let guard = cx.lock();
|
||||
let wrapper = this.borrow(&guard);
|
||||
wrapper.inner.extend_selection(text_range)
|
||||
};
|
||||
|
||||
match extended_range {
|
||||
None => Ok(cx.null().upcast()),
|
||||
Some(range) => {
|
||||
let start: u32 = range.start().into();
|
||||
let end: u32 = range.end().into();
|
||||
let start = cx.number(start);
|
||||
let end = cx.number(end);
|
||||
let arr = cx.empty_array();
|
||||
arr.set(&mut cx, 0, start)?;
|
||||
arr.set(&mut cx, 1, end)?;
|
||||
Ok(arr.upcast())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
register_module!(mut cx, {
|
||||
cx.export_class::<RustFile>("RustFile")
|
||||
});
|
|
@ -8,5 +8,5 @@ log = "0.4.2"
|
|||
failure = "0.1.2"
|
||||
parking_lot = "0.6.3"
|
||||
once_cell = "0.1.4"
|
||||
libsyntax2 = { path = "../" }
|
||||
libsyntax2 = { path = "../libsyntax2" }
|
||||
libeditor = { path = "../libeditor" }
|
|
@ -7,4 +7,4 @@ publish = false
|
|||
[dependencies]
|
||||
itertools = "0.7.8"
|
||||
superslice = "0.1.0"
|
||||
libsyntax2 = { path = "../" }
|
||||
libsyntax2 = { path = "../libsyntax2" }
|
15
crates/libsyntax2/Cargo.toml
Normal file
15
crates/libsyntax2/Cargo.toml
Normal file
|
@ -0,0 +1,15 @@
|
|||
[package]
|
||||
name = "libsyntax2"
|
||||
version = "0.1.0"
|
||||
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
unicode-xid = "0.1.0"
|
||||
text_unit = "0.1.2"
|
||||
itertools = "0.7.5"
|
||||
drop_bomb = "0.1.4"
|
||||
parking_lot = "0.6.0"
|
||||
|
||||
[dev-dependencies]
|
||||
testutils = { path = "./tests/testutils" }
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue