Skip to content

Commit b65ff13

Browse files
committed
Added TODOs
1 parent e80726d commit b65ff13

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

Cargo.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22
name = "simplicityhl-lsp"
33
version = "0.1.3"
44
edition = "2024"
5+
# TODO: add rust-version
56

67
[dependencies]
78
tokio = { version = "1.47.1", features = ["full"] }
89
serde_json = "1.0.143"
910
tower-lsp-server = "0.22.1"
10-
simplicityhl = { git = "https://github.com/BlockstreamResearch/SimplicityHL.git", rev = "e68e1c6" }
11+
12+
# TODO: remove in favor of HashMap pls
1113
dashmap = "6.1.0"
12-
ropey = "1.6.1"
14+
1315
log = "0.4.28"
1416
env_logger = "0.11.8"
15-
miniscript = "12.3.1"
17+
18+
ropey = "1.6.1"
19+
miniscript = "12"
20+
simplicityhl = { git = "https://github.com/BlockstreamResearch/SimplicityHL.git", rev = "e68e1c6" }
21+
22+
# TODO: add `[lints.rust]` and `[lints.clippy]` pls (to enforce consistent lints across users on edition 2024)

src/backend.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ impl LanguageServer for Backend {
6868
)),
6969
completion_provider: Some(CompletionOptions {
7070
resolve_provider: Some(false),
71+
// TODO: maybe use double-colon (via filtering)?
7172
trigger_characters: Some(vec![":".to_string()]),
7273
work_done_progress_options: WorkDoneProgressOptions::default(),
7374
all_commit_characters: None,
@@ -223,6 +224,7 @@ impl Backend {
223224
if let Some(mut doc) = self.document_map.get_mut(uri) {
224225
doc.functions.push(func.to_owned());
225226

227+
// TODO: avoid cloning Rope and repeated Rope conversions
226228
let rope = doc.text.clone();
227229
let start_line =
228230
u32::try_from(func.as_ref().start.line.get()).unwrap_or_default() - 1;
@@ -253,6 +255,7 @@ impl Backend {
253255

254256
match err {
255257
None => {
258+
// TODO: Is this really needed on the INFO level?
256259
self.client
257260
.log_message(MessageType::INFO, "errors not found!".to_string())
258261
.await;
@@ -264,6 +267,7 @@ impl Backend {
264267
let (start, end) = match span_to_positions(err.span()) {
265268
Ok(result) => result,
266269
Err(err) => {
270+
// TODO: Replace dbg! with structured logging to client.log_message
267271
dbg!("catch error: {}", err);
268272
return;
269273
}
@@ -301,6 +305,7 @@ impl Backend {
301305
simplicityhl::simplicity::jet::Elements::from_str(format!("{jet}").as_str())
302306
.ok()?;
303307

308+
// TODO: For consistency use `template.get_signature()` instead of reconstructing
304309
let template = completion::jet::jet_to_template(element);
305310
let description = format!(
306311
"```simplicityhl\nfn jet::{}({}) -> {}\n```\n{}",
@@ -427,6 +432,13 @@ fn find_related_call(
427432
.iter()
428433
.find(|func| span_contains(func.span(), &token_span))?;
429434

435+
// Replace with?
436+
// parse::ExprTree::Expression(func.body())
437+
// .pre_order_iter()
438+
// .filter_map(|expr| if let parse::ExprTree::Call(call) = expr { Some(call) } else { None })
439+
// .filter(|c| span_contains(c.span(), &token_span))
440+
// .last()
441+
430442
let calls = parse::ExprTree::Expression(func.body())
431443
.pre_order_iter()
432444
.filter_map(|expr| match expr {

src/completion/builtin.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pub fn get_builtin_functions() -> Vec<FunctionTemplate> {
4949
}
5050

5151
/// Match [`simplicityhl::parse::CallName`] and return [`FunctionTemplate`]
52-
#[allow(warnings)]
5352
pub fn match_callname(call: CallName) -> Option<FunctionTemplate> {
5453
match call {
5554
CallName::UnwrapLeft(aliased_type) => {
@@ -102,7 +101,7 @@ let y: u8 = unwrap(x); // 5
102101
CallName::IsNone(aliased_type) => {
103102
let ty = aliased_type.to_string();
104103
Some(FunctionTemplate::new(
105-
format!("is_none"),
104+
"is_none".to_string(),
106105
"is_none",
107106
str_vec![format!("{ty}")],
108107
str_vec![format!("Option<{ty}>").as_str()],

0 commit comments

Comments
 (0)