git.delta.rocks / jrsonnet / refs/commits / 04bd9e467c66

difftreelog

refactor remove lsp for now

Yaroslav Bolyukin2024-03-03parent: #627070c.patch.diff
in: master
It was kept to be a consumer of jrsonnet-parser, but wasn't really
working, in future a proper LSP implementation will be developed.

3 files changed

modifiedCargo.lockdiffbeforeafterboth
283 "libc",283 "libc",
284]284]
285
286[[package]]
287name = "crossbeam-channel"
288version = "0.5.11"
289source = "registry+https://github.com/rust-lang/crates.io-index"
290checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b"
291dependencies = [
292 "crossbeam-utils",
293]
294
295[[package]]
296name = "crossbeam-utils"
297version = "0.8.19"
298source = "registry+https://github.com/rust-lang/crates.io-index"
299checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
300285
301[[package]]286[[package]]
302name = "crypto-common"287name = "crypto-common"
389source = "registry+https://github.com/rust-lang/crates.io-index"374source = "registry+https://github.com/rust-lang/crates.io-index"
390checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"375checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
391
392[[package]]
393name = "form_urlencoded"
394version = "1.2.1"
395source = "registry+https://github.com/rust-lang/crates.io-index"
396checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
397dependencies = [
398 "percent-encoding",
399]
400376
401[[package]]377[[package]]
402name = "generic-array"378name = "generic-array"
460 "smallvec",436 "smallvec",
461]437]
462
463[[package]]
464name = "idna"
465version = "0.5.0"
466source = "registry+https://github.com/rust-lang/crates.io-index"
467checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
468dependencies = [
469 "unicode-bidi",
470 "unicode-normalization",
471]
472438
473[[package]]439[[package]]
474name = "indexmap"440name = "indexmap"
629 "structdump",595 "structdump",
630]596]
631
632[[package]]
633name = "jrsonnet-lsp"
634version = "0.5.0-pre96"
635dependencies = [
636 "anyhow",
637 "jrsonnet-evaluator",
638 "jrsonnet-rowan-parser",
639 "lsp-server",
640 "lsp-types",
641 "serde",
642 "serde_json",
643]
644597
645[[package]]598[[package]]
646name = "jrsonnet-macros"599name = "jrsonnet-macros"
763 "scopeguard",716 "scopeguard",
764]717]
765
766[[package]]
767name = "log"
768version = "0.4.20"
769source = "registry+https://github.com/rust-lang/crates.io-index"
770checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
771718
772[[package]]719[[package]]
773name = "logos"720name = "logos"
811 "hashbrown 0.14.3",758 "hashbrown 0.14.3",
812]759]
813
814[[package]]
815name = "lsp-server"
816version = "0.7.6"
817source = "registry+https://github.com/rust-lang/crates.io-index"
818checksum = "248f65b78f6db5d8e1b1604b4098a28b43d21a8eb1deeca22b1c421b276c7095"
819dependencies = [
820 "crossbeam-channel",
821 "log",
822 "serde",
823 "serde_json",
824]
825
826[[package]]
827name = "lsp-types"
828version = "0.95.0"
829source = "registry+https://github.com/rust-lang/crates.io-index"
830checksum = "158c1911354ef73e8fe42da6b10c0484cb65c7f1007f28022e847706c1ab6984"
831dependencies = [
832 "bitflags 1.3.2",
833 "serde",
834 "serde_json",
835 "serde_repr",
836 "url",
837]
838760
839[[package]]761[[package]]
840name = "md5"762name = "md5"
1022source = "registry+https://github.com/rust-lang/crates.io-index"944source = "registry+https://github.com/rust-lang/crates.io-index"
1023checksum = "36bae92c60fa2398ce4678b98b2c4b5a7c61099961ca1fa305aec04a9ad28922"945checksum = "36bae92c60fa2398ce4678b98b2c4b5a7c61099961ca1fa305aec04a9ad28922"
1024
1025[[package]]
1026name = "percent-encoding"
1027version = "2.3.1"
1028source = "registry+https://github.com/rust-lang/crates.io-index"
1029checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
1030946
1031[[package]]947[[package]]
1032name = "ppv-lite86"948name = "ppv-lite86"
1219 "serde",1135 "serde",
1220]1136]
1221
1222[[package]]
1223name = "serde_repr"
1224version = "0.1.18"
1225source = "registry+https://github.com/rust-lang/crates.io-index"
1226checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb"
1227dependencies = [
1228 "proc-macro2",
1229 "quote",
1230 "syn 2.0.50",
1231]
12321137
1233[[package]]1138[[package]]
1234name = "serde_yaml_with_quirks"1139name = "serde_yaml_with_quirks"
1438 "syn 2.0.50",1343 "syn 2.0.50",
1439]1344]
1440
1441[[package]]
1442name = "tinyvec"
1443version = "1.6.0"
1444source = "registry+https://github.com/rust-lang/crates.io-index"
1445checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
1446dependencies = [
1447 "tinyvec_macros",
1448]
1449
1450[[package]]
1451name = "tinyvec_macros"
1452version = "0.1.1"
1453source = "registry+https://github.com/rust-lang/crates.io-index"
1454checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
14551345
1456[[package]]1346[[package]]
1457name = "typenum"1347name = "typenum"
1465source = "registry+https://github.com/rust-lang/crates.io-index"1355source = "registry+https://github.com/rust-lang/crates.io-index"
1466checksum = "a3e5df347f0bf3ec1d670aad6ca5c6a1859cd9ea61d2113125794654ccced68f"1356checksum = "a3e5df347f0bf3ec1d670aad6ca5c6a1859cd9ea61d2113125794654ccced68f"
1467
1468[[package]]
1469name = "unicode-bidi"
1470version = "0.3.15"
1471source = "registry+https://github.com/rust-lang/crates.io-index"
1472checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
14731357
1474[[package]]1358[[package]]
1475name = "unicode-ident"1359name = "unicode-ident"
1483source = "registry+https://github.com/rust-lang/crates.io-index"1367source = "registry+https://github.com/rust-lang/crates.io-index"
1484checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"1368checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
1485
1486[[package]]
1487name = "unicode-normalization"
1488version = "0.1.23"
1489source = "registry+https://github.com/rust-lang/crates.io-index"
1490checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5"
1491dependencies = [
1492 "tinyvec",
1493]
14941369
1495[[package]]1370[[package]]
1496name = "unicode-width"1371name = "unicode-width"
1497version = "0.1.11"1372version = "0.1.11"
1498source = "registry+https://github.com/rust-lang/crates.io-index"1373source = "registry+https://github.com/rust-lang/crates.io-index"
1499checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"1374checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
1500
1501[[package]]
1502name = "url"
1503version = "2.5.0"
1504source = "registry+https://github.com/rust-lang/crates.io-index"
1505checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633"
1506dependencies = [
1507 "form_urlencoded",
1508 "idna",
1509 "percent-encoding",
1510 "serde",
1511]
15121375
1513[[package]]1376[[package]]
1514name = "utf8parse"1377name = "utf8parse"
deletedcmds/jrsonnet-lsp/Cargo.tomldiffbeforeafterboth
--- a/cmds/jrsonnet-lsp/Cargo.toml
+++ /dev/null
@@ -1,13 +0,0 @@
-[package]
-name = "jrsonnet-lsp"
-version.workspace = true
-edition = "2021"
-
-[dependencies]
-anyhow.workspace = true
-jrsonnet-evaluator.workspace = true
-jrsonnet-rowan-parser.workspace = true
-lsp-server.workspace = true
-lsp-types.workspace = true
-serde.workspace = true
-serde_json.workspace = true
deletedcmds/jrsonnet-lsp/src/main.rsdiffbeforeafterboth
--- a/cmds/jrsonnet-lsp/src/main.rs
+++ /dev/null
@@ -1,188 +0,0 @@
-use std::{fs::File, io::Write, path::PathBuf, str::FromStr};
-
-use lsp_server::{Connection, ErrorCode, Message, Request, RequestId, Response};
-use lsp_types::{
-	notification::{DidChangeTextDocument, DidOpenTextDocument, Notification},
-	request::{DocumentLinkRequest, HoverRequest},
-	CompletionOptions, DidChangeTextDocumentParams, DidOpenTextDocumentParams, DocumentLink,
-	DocumentLinkOptions, ServerCapabilities, TextDocumentSyncCapability, TextDocumentSyncKind,
-	TextDocumentSyncOptions, Url, WorkDoneProgressOptions,
-};
-
-fn main() {
-	let mut log = File::create("test").unwrap();
-	writeln!(log, "start").unwrap();
-	let (connection, io_threads) = Connection::stdio();
-	let capabilities = serde_json::to_value(ServerCapabilities {
-		completion_provider: Some(CompletionOptions::default()),
-		definition_provider: Some(lsp_types::OneOf::Left(true)),
-		document_link_provider: Some(DocumentLinkOptions {
-			resolve_provider: Some(false),
-			work_done_progress_options: WorkDoneProgressOptions::default(),
-		}),
-		hover_provider: Some(lsp_types::HoverProviderCapability::Simple(true)),
-		text_document_sync: Some(TextDocumentSyncCapability::Options(
-			TextDocumentSyncOptions {
-				change: Some(TextDocumentSyncKind::FULL),
-				open_close: Some(true),
-				..TextDocumentSyncOptions::default()
-			},
-		)),
-		..ServerCapabilities::default()
-	})
-	.expect("failed to convert capabilities to json");
-
-	connection
-		.initialize(capabilities)
-		.expect("failed to initialize connection");
-
-	writeln!(log, "initialized").unwrap();
-
-	main_loop(&mut log, &connection).expect("main loop failed");
-
-	io_threads.join().expect("failed to join io_threads");
-}
-fn main_loop(log: &mut File, connection: &Connection) -> anyhow::Result<()> {
-	// let mut es = EvaluationState::default();
-	// es.set_import_resolver(Box::new(FileImportResolver::default()));
-
-	let reply = |response: Response| {
-		connection
-			.sender
-			.send(Message::Response(response))
-			.expect("failed to respond");
-	};
-
-	for msg in &connection.receiver {
-		match msg {
-			Message::Response(_) => (),
-			Message::Request(req) => {
-				if connection.handle_shutdown(&req)? {
-					return Ok(());
-				}
-				if let Some((id, params)) = cast::<DocumentLinkRequest>(&req) {
-					reply(Response::new_ok(id, <Vec<DocumentLink>>::new()));
-				} else if let Some((id, params)) = cast::<HoverRequest>(&req) {
-					let pos = params
-						.text_document_position_params
-						.text_document
-						.uri
-						.path();
-					let buf = PathBuf::from_str(pos).unwrap();
-				// let pos = es
-				// 	.map_from_source_location(
-				// 		&buf,
-				// 		params.text_document_position_params.position.line as usize + 1,
-				// 		params.text_document_position_params.position.character as usize + 1,
-				// 	)
-				// 	.unwrap();
-				// let el = ExprLocation(buf.clone().into(), pos as usize, pos as usize);
-				// let es2 = es.clone();
-				// reply(Response::new_ok(
-				// 	id,
-				// 	Some(Hover {
-				// 		range: None,
-				// 		contents: HoverContents::Markup(MarkupContent {
-				// 			kind: MarkupKind::Markdown,
-				// 			value: es
-				// 				.run_in_state_with_breakpoint(el, move || {
-				// 					es2.reset_evaluation_state(&buf);
-				// 					es2.import_file(&PathBuf::new(), &buf)?
-				// 						.to_string()
-				// 						.map(|_| ())
-				// 				})
-				// 				.unwrap()
-				// 				.unwrap_or_else(|| Val::Null)
-				// 				.value_type()
-				// 				.to_string(),
-				// 		}),
-				// 	}),
-				// ));
-				} else {
-					reply(Response::new_err(
-						req.id,
-						ErrorCode::MethodNotFound as i32,
-						format!("unrecognized request {}", req.method),
-					))
-				}
-				/*
-				if let Some((id, params)) = cast::<DocumentLinkRequest>(&req) {
-					 let links = handle_links(&files, params).unwrap_or_default();
-					 reply(Response::new_ok(id, links));
-				} else if let Some((id, params)) = cast::<GotoDefinition>(&req) {
-					 if let Some(loc) = handle_goto(&files, params) {
-						  reply(Response::new_ok(id, loc))
-					 } else {
-						  reply(Response::new_ok(id, ()))
-					 }
-				} else if let Some((id, params)) = cast::<HoverRequest>(&req) {
-					 match handle_hover(&files, params) {
-						  Some((range, markdown)) => {
-								reply(Response::new_ok(
-									 id,
-									 Hover {
-										  contents: HoverContents::Markup(MarkupContent {
-												kind: MarkupKind::Markdown,
-												value: markdown,
-										  }),
-										  range,
-									 },
-								));
-						  }
-						  None => {
-								reply(Response::new_ok(id, ()));
-						  }
-					 }
-				} else if let Some((id, params)) = cast::<Completion>(&req) {
-					 let completions = handle_completion(&files, params.text_document_position)
-						  .unwrap_or_default();
-					 reply(Response::new_ok(id, completions));
-				} else
-				*/
-			}
-			Message::Notification(req) => {
-				let mut handle = |text: String, uri: Url| {
-					writeln!(log, "updated file: {:?}", uri).unwrap();
-					let path = match PathBuf::from_str(uri.path()) {
-						Ok(x) => x,
-						Err(_) => return,
-					};
-					let (ast, errors) = jrsonnet_rowan_parser::parse(&text);
-					// es.add_parsed_file(path.into(), text.into(), parsed)
-					// 	.unwrap();
-					writeln!(log, "parsed: {:?}", uri).unwrap();
-				};
-
-				match &*req.method {
-					DidOpenTextDocument::METHOD => {
-						let params: DidOpenTextDocumentParams =
-							match serde_json::from_value(req.params) {
-								Ok(x) => x,
-								Err(_) => continue,
-							};
-						handle(params.text_document.text, params.text_document.uri);
-					}
-					DidChangeTextDocument::METHOD => {
-						let params: DidChangeTextDocumentParams =
-							match serde_json::from_value(req.params) {
-								Ok(x) => x,
-								Err(_) => continue,
-							};
-						for change in params.content_changes.into_iter() {
-							handle(change.text, params.text_document.uri.clone());
-						}
-					}
-					_ => continue,
-				}
-			}
-		}
-	}
-	Ok(())
-}
-fn cast<R>(req: &Request) -> Option<(RequestId, R::Params)>
-where
-	R: lsp_types::request::Request,
-	R::Params: serde::de::DeserializeOwned,
-{
-	req.clone().extract(R::METHOD).ok()
-}