1use anyhow::{Context as _, Result};
2use async_trait::async_trait;
3use collections::HashMap;
4use futures::StreamExt;
5use gpui::{App, AsyncApp, Task};
6use http_client::github::latest_github_release;
7pub use language::*;
8use lsp::{LanguageServerBinary, LanguageServerName};
9use project::Fs;
10use regex::Regex;
11use serde_json::json;
12use smol::fs;
13use std::{
14 any::Any,
15 borrow::Cow,
16 ffi::{OsStr, OsString},
17 ops::Range,
18 path::PathBuf,
19 process::Output,
20 str,
21 sync::{
22 Arc, LazyLock,
23 atomic::{AtomicBool, Ordering::SeqCst},
24 },
25};
26use task::{TaskTemplate, TaskTemplates, TaskVariables, VariableName};
27use util::{ResultExt, fs::remove_matching, maybe};
28
29fn server_binary_arguments() -> Vec<OsString> {
30 vec!["-mode=stdio".into()]
31}
32
33#[derive(Copy, Clone)]
34pub struct GoLspAdapter;
35
36impl GoLspAdapter {
37 const SERVER_NAME: LanguageServerName = LanguageServerName::new_static("gopls");
38}
39
40static VERSION_REGEX: LazyLock<Regex> =
41 LazyLock::new(|| Regex::new(r"\d+\.\d+\.\d+").expect("Failed to create VERSION_REGEX"));
42
43static GO_ESCAPE_SUBTEST_NAME_REGEX: LazyLock<Regex> = LazyLock::new(|| {
44 Regex::new(r#"[.*+?^${}()|\[\]\\]"#).expect("Failed to create GO_ESCAPE_SUBTEST_NAME_REGEX")
45});
46
47const BINARY: &str = if cfg!(target_os = "windows") {
48 "gopls.exe"
49} else {
50 "gopls"
51};
52
53#[async_trait(?Send)]
54impl super::LspAdapter for GoLspAdapter {
55 fn name(&self) -> LanguageServerName {
56 Self::SERVER_NAME.clone()
57 }
58
59 async fn fetch_latest_server_version(
60 &self,
61 delegate: &dyn LspAdapterDelegate,
62 ) -> Result<Box<dyn 'static + Send + Any>> {
63 let release =
64 latest_github_release("golang/tools", false, false, delegate.http_client()).await?;
65 let version: Option<String> = release.tag_name.strip_prefix("gopls/v").map(str::to_string);
66 if version.is_none() {
67 log::warn!(
68 "couldn't infer gopls version from GitHub release tag name '{}'",
69 release.tag_name
70 );
71 }
72 Ok(Box::new(version) as Box<_>)
73 }
74
75 async fn check_if_user_installed(
76 &self,
77 delegate: &dyn LspAdapterDelegate,
78 _: Arc<dyn LanguageToolchainStore>,
79 _: &AsyncApp,
80 ) -> Option<LanguageServerBinary> {
81 let path = delegate.which(Self::SERVER_NAME.as_ref()).await?;
82 Some(LanguageServerBinary {
83 path,
84 arguments: server_binary_arguments(),
85 env: None,
86 })
87 }
88
89 fn will_fetch_server(
90 &self,
91 delegate: &Arc<dyn LspAdapterDelegate>,
92 cx: &mut AsyncApp,
93 ) -> Option<Task<Result<()>>> {
94 static DID_SHOW_NOTIFICATION: AtomicBool = AtomicBool::new(false);
95
96 const NOTIFICATION_MESSAGE: &str =
97 "Could not install the Go language server `gopls`, because `go` was not found.";
98
99 let delegate = delegate.clone();
100 Some(cx.spawn(async move |cx| {
101 if delegate.which("go".as_ref()).await.is_none() {
102 if DID_SHOW_NOTIFICATION
103 .compare_exchange(false, true, SeqCst, SeqCst)
104 .is_ok()
105 {
106 cx.update(|cx| {
107 delegate.show_notification(NOTIFICATION_MESSAGE, cx);
108 })?
109 }
110 anyhow::bail!("cannot install gopls");
111 }
112 Ok(())
113 }))
114 }
115
116 async fn fetch_server_binary(
117 &self,
118 version: Box<dyn 'static + Send + Any>,
119 container_dir: PathBuf,
120 delegate: &dyn LspAdapterDelegate,
121 ) -> Result<LanguageServerBinary> {
122 let go = delegate.which("go".as_ref()).await.unwrap_or("go".into());
123 let go_version_output = util::command::new_smol_command(&go)
124 .args(["version"])
125 .output()
126 .await
127 .context("failed to get go version via `go version` command`")?;
128 let go_version = parse_version_output(&go_version_output)?;
129 let version = version.downcast::<Option<String>>().unwrap();
130 let this = *self;
131
132 if let Some(version) = *version {
133 let binary_path = container_dir.join(format!("gopls_{version}_go_{go_version}"));
134 if let Ok(metadata) = fs::metadata(&binary_path).await {
135 if metadata.is_file() {
136 remove_matching(&container_dir, |entry| {
137 entry != binary_path && entry.file_name() != Some(OsStr::new("gobin"))
138 })
139 .await;
140
141 return Ok(LanguageServerBinary {
142 path: binary_path.to_path_buf(),
143 arguments: server_binary_arguments(),
144 env: None,
145 });
146 }
147 }
148 } else if let Some(path) = this
149 .cached_server_binary(container_dir.clone(), delegate)
150 .await
151 {
152 return Ok(path);
153 }
154
155 let gobin_dir = container_dir.join("gobin");
156 fs::create_dir_all(&gobin_dir).await?;
157 let install_output = util::command::new_smol_command(go)
158 .env("GO111MODULE", "on")
159 .env("GOBIN", &gobin_dir)
160 .args(["install", "golang.org/x/tools/gopls@latest"])
161 .output()
162 .await?;
163
164 if !install_output.status.success() {
165 log::error!(
166 "failed to install gopls via `go install`. stdout: {:?}, stderr: {:?}",
167 String::from_utf8_lossy(&install_output.stdout),
168 String::from_utf8_lossy(&install_output.stderr)
169 );
170 anyhow::bail!(
171 "failed to install gopls with `go install`. Is `go` installed and in the PATH? Check logs for more information."
172 );
173 }
174
175 let installed_binary_path = gobin_dir.join(BINARY);
176 let version_output = util::command::new_smol_command(&installed_binary_path)
177 .arg("version")
178 .output()
179 .await
180 .context("failed to run installed gopls binary")?;
181 let gopls_version = parse_version_output(&version_output)?;
182 let binary_path = container_dir.join(format!("gopls_{gopls_version}_go_{go_version}"));
183 fs::rename(&installed_binary_path, &binary_path).await?;
184
185 Ok(LanguageServerBinary {
186 path: binary_path.to_path_buf(),
187 arguments: server_binary_arguments(),
188 env: None,
189 })
190 }
191
192 async fn cached_server_binary(
193 &self,
194 container_dir: PathBuf,
195 _: &dyn LspAdapterDelegate,
196 ) -> Option<LanguageServerBinary> {
197 get_cached_server_binary(container_dir).await
198 }
199
200 async fn initialization_options(
201 self: Arc<Self>,
202 _: &dyn Fs,
203 _: &Arc<dyn LspAdapterDelegate>,
204 ) -> Result<Option<serde_json::Value>> {
205 Ok(Some(json!({
206 "usePlaceholders": true,
207 "hints": {
208 "assignVariableTypes": true,
209 "compositeLiteralFields": true,
210 "compositeLiteralTypes": true,
211 "constantValues": true,
212 "functionTypeParameters": true,
213 "parameterNames": true,
214 "rangeVariableTypes": true
215 }
216 })))
217 }
218
219 async fn label_for_completion(
220 &self,
221 completion: &lsp::CompletionItem,
222 language: &Arc<Language>,
223 ) -> Option<CodeLabel> {
224 let label = &completion.label;
225
226 // Gopls returns nested fields and methods as completions.
227 // To syntax highlight these, combine their final component
228 // with their detail.
229 let name_offset = label.rfind('.').unwrap_or(0);
230
231 match completion.kind.zip(completion.detail.as_ref()) {
232 Some((lsp::CompletionItemKind::MODULE, detail)) => {
233 let text = format!("{label} {detail}");
234 let source = Rope::from(format!("import {text}").as_str());
235 let runs = language.highlight_text(&source, 7..7 + text.len());
236 return Some(CodeLabel {
237 text,
238 runs,
239 filter_range: 0..label.len(),
240 });
241 }
242 Some((
243 lsp::CompletionItemKind::CONSTANT | lsp::CompletionItemKind::VARIABLE,
244 detail,
245 )) => {
246 let text = format!("{label} {detail}");
247 let source =
248 Rope::from(format!("var {} {}", &text[name_offset..], detail).as_str());
249 let runs = adjust_runs(
250 name_offset,
251 language.highlight_text(&source, 4..4 + text.len()),
252 );
253 return Some(CodeLabel {
254 text,
255 runs,
256 filter_range: 0..label.len(),
257 });
258 }
259 Some((lsp::CompletionItemKind::STRUCT, _)) => {
260 let text = format!("{label} struct {{}}");
261 let source = Rope::from(format!("type {}", &text[name_offset..]).as_str());
262 let runs = adjust_runs(
263 name_offset,
264 language.highlight_text(&source, 5..5 + text.len()),
265 );
266 return Some(CodeLabel {
267 text,
268 runs,
269 filter_range: 0..label.len(),
270 });
271 }
272 Some((lsp::CompletionItemKind::INTERFACE, _)) => {
273 let text = format!("{label} interface {{}}");
274 let source = Rope::from(format!("type {}", &text[name_offset..]).as_str());
275 let runs = adjust_runs(
276 name_offset,
277 language.highlight_text(&source, 5..5 + text.len()),
278 );
279 return Some(CodeLabel {
280 text,
281 runs,
282 filter_range: 0..label.len(),
283 });
284 }
285 Some((lsp::CompletionItemKind::FIELD, detail)) => {
286 let text = format!("{label} {detail}");
287 let source =
288 Rope::from(format!("type T struct {{ {} }}", &text[name_offset..]).as_str());
289 let runs = adjust_runs(
290 name_offset,
291 language.highlight_text(&source, 16..16 + text.len()),
292 );
293 return Some(CodeLabel {
294 text,
295 runs,
296 filter_range: 0..label.len(),
297 });
298 }
299 Some((lsp::CompletionItemKind::FUNCTION | lsp::CompletionItemKind::METHOD, detail)) => {
300 if let Some(signature) = detail.strip_prefix("func") {
301 let text = format!("{label}{signature}");
302 let source = Rope::from(format!("func {} {{}}", &text[name_offset..]).as_str());
303 let runs = adjust_runs(
304 name_offset,
305 language.highlight_text(&source, 5..5 + text.len()),
306 );
307 return Some(CodeLabel {
308 filter_range: 0..label.len(),
309 text,
310 runs,
311 });
312 }
313 }
314 _ => {}
315 }
316 None
317 }
318
319 async fn label_for_symbol(
320 &self,
321 name: &str,
322 kind: lsp::SymbolKind,
323 language: &Arc<Language>,
324 ) -> Option<CodeLabel> {
325 let (text, filter_range, display_range) = match kind {
326 lsp::SymbolKind::METHOD | lsp::SymbolKind::FUNCTION => {
327 let text = format!("func {} () {{}}", name);
328 let filter_range = 5..5 + name.len();
329 let display_range = 0..filter_range.end;
330 (text, filter_range, display_range)
331 }
332 lsp::SymbolKind::STRUCT => {
333 let text = format!("type {} struct {{}}", name);
334 let filter_range = 5..5 + name.len();
335 let display_range = 0..text.len();
336 (text, filter_range, display_range)
337 }
338 lsp::SymbolKind::INTERFACE => {
339 let text = format!("type {} interface {{}}", name);
340 let filter_range = 5..5 + name.len();
341 let display_range = 0..text.len();
342 (text, filter_range, display_range)
343 }
344 lsp::SymbolKind::CLASS => {
345 let text = format!("type {} T", name);
346 let filter_range = 5..5 + name.len();
347 let display_range = 0..filter_range.end;
348 (text, filter_range, display_range)
349 }
350 lsp::SymbolKind::CONSTANT => {
351 let text = format!("const {} = nil", name);
352 let filter_range = 6..6 + name.len();
353 let display_range = 0..filter_range.end;
354 (text, filter_range, display_range)
355 }
356 lsp::SymbolKind::VARIABLE => {
357 let text = format!("var {} = nil", name);
358 let filter_range = 4..4 + name.len();
359 let display_range = 0..filter_range.end;
360 (text, filter_range, display_range)
361 }
362 lsp::SymbolKind::MODULE => {
363 let text = format!("package {}", name);
364 let filter_range = 8..8 + name.len();
365 let display_range = 0..filter_range.end;
366 (text, filter_range, display_range)
367 }
368 _ => return None,
369 };
370
371 Some(CodeLabel {
372 runs: language.highlight_text(&text.as_str().into(), display_range.clone()),
373 text: text[display_range].to_string(),
374 filter_range,
375 })
376 }
377}
378
379fn parse_version_output(output: &Output) -> Result<&str> {
380 let version_stdout =
381 str::from_utf8(&output.stdout).context("version command produced invalid utf8 output")?;
382
383 let version = VERSION_REGEX
384 .find(version_stdout)
385 .with_context(|| format!("failed to parse version output '{version_stdout}'"))?
386 .as_str();
387
388 Ok(version)
389}
390
391async fn get_cached_server_binary(container_dir: PathBuf) -> Option<LanguageServerBinary> {
392 maybe!(async {
393 let mut last_binary_path = None;
394 let mut entries = fs::read_dir(&container_dir).await?;
395 while let Some(entry) = entries.next().await {
396 let entry = entry?;
397 if entry.file_type().await?.is_file()
398 && entry
399 .file_name()
400 .to_str()
401 .map_or(false, |name| name.starts_with("gopls_"))
402 {
403 last_binary_path = Some(entry.path());
404 }
405 }
406
407 let path = last_binary_path.context("no cached binary")?;
408 anyhow::Ok(LanguageServerBinary {
409 path,
410 arguments: server_binary_arguments(),
411 env: None,
412 })
413 })
414 .await
415 .log_err()
416}
417
418fn adjust_runs(
419 delta: usize,
420 mut runs: Vec<(Range<usize>, HighlightId)>,
421) -> Vec<(Range<usize>, HighlightId)> {
422 for (range, _) in &mut runs {
423 range.start += delta;
424 range.end += delta;
425 }
426 runs
427}
428
429pub(crate) struct GoContextProvider;
430
431const GO_PACKAGE_TASK_VARIABLE: VariableName = VariableName::Custom(Cow::Borrowed("GO_PACKAGE"));
432const GO_MODULE_ROOT_TASK_VARIABLE: VariableName =
433 VariableName::Custom(Cow::Borrowed("GO_MODULE_ROOT"));
434const GO_SUBTEST_NAME_TASK_VARIABLE: VariableName =
435 VariableName::Custom(Cow::Borrowed("GO_SUBTEST_NAME"));
436
437impl ContextProvider for GoContextProvider {
438 fn build_context(
439 &self,
440 variables: &TaskVariables,
441 location: &Location,
442 _: Option<HashMap<String, String>>,
443 _: Arc<dyn LanguageToolchainStore>,
444 cx: &mut gpui::App,
445 ) -> Task<Result<TaskVariables>> {
446 let local_abs_path = location
447 .buffer
448 .read(cx)
449 .file()
450 .and_then(|file| Some(file.as_local()?.abs_path(cx)));
451
452 let go_package_variable = local_abs_path
453 .as_deref()
454 .and_then(|local_abs_path| local_abs_path.parent())
455 .map(|buffer_dir| {
456 // Prefer the relative form `./my-nested-package/is-here` over
457 // absolute path, because it's more readable in the modal, but
458 // the absolute path also works.
459 let package_name = variables
460 .get(&VariableName::WorktreeRoot)
461 .and_then(|worktree_abs_path| buffer_dir.strip_prefix(worktree_abs_path).ok())
462 .map(|relative_pkg_dir| {
463 if relative_pkg_dir.as_os_str().is_empty() {
464 ".".into()
465 } else {
466 format!("./{}", relative_pkg_dir.to_string_lossy())
467 }
468 })
469 .unwrap_or_else(|| format!("{}", buffer_dir.to_string_lossy()));
470
471 (GO_PACKAGE_TASK_VARIABLE.clone(), package_name.to_string())
472 });
473
474 let go_module_root_variable = local_abs_path
475 .as_deref()
476 .and_then(|local_abs_path| local_abs_path.parent())
477 .map(|buffer_dir| {
478 // Walk dirtree up until getting the first go.mod file
479 let module_dir = buffer_dir
480 .ancestors()
481 .find(|dir| dir.join("go.mod").is_file())
482 .map(|dir| dir.to_string_lossy().to_string())
483 .unwrap_or_else(|| ".".to_string());
484
485 (GO_MODULE_ROOT_TASK_VARIABLE.clone(), module_dir)
486 });
487
488 let _subtest_name = variables.get(&VariableName::Custom(Cow::Borrowed("_subtest_name")));
489
490 let go_subtest_variable = extract_subtest_name(_subtest_name.unwrap_or(""))
491 .map(|subtest_name| (GO_SUBTEST_NAME_TASK_VARIABLE.clone(), subtest_name));
492
493 Task::ready(Ok(TaskVariables::from_iter(
494 [
495 go_package_variable,
496 go_subtest_variable,
497 go_module_root_variable,
498 ]
499 .into_iter()
500 .flatten(),
501 )))
502 }
503
504 fn associated_tasks(
505 &self,
506 _: Option<Arc<dyn language::File>>,
507 _: &App,
508 ) -> Option<TaskTemplates> {
509 let package_cwd = if GO_PACKAGE_TASK_VARIABLE.template_value() == "." {
510 None
511 } else {
512 Some("$ZED_DIRNAME".to_string())
513 };
514 let module_cwd = Some(GO_MODULE_ROOT_TASK_VARIABLE.template_value());
515
516 Some(TaskTemplates(vec![
517 TaskTemplate {
518 label: format!(
519 "go test {} -run {}",
520 GO_PACKAGE_TASK_VARIABLE.template_value(),
521 VariableName::Symbol.template_value(),
522 ),
523 command: "go".into(),
524 args: vec![
525 "test".into(),
526 "-run".into(),
527 format!("\\^{}\\$", VariableName::Symbol.template_value(),),
528 ],
529 tags: vec!["go-test".to_owned()],
530 cwd: package_cwd.clone(),
531 ..TaskTemplate::default()
532 },
533 TaskTemplate {
534 label: format!("go test {}", GO_PACKAGE_TASK_VARIABLE.template_value()),
535 command: "go".into(),
536 args: vec!["test".into()],
537 cwd: package_cwd.clone(),
538 ..TaskTemplate::default()
539 },
540 TaskTemplate {
541 label: "go test ./...".into(),
542 command: "go".into(),
543 args: vec!["test".into(), "./...".into()],
544 cwd: module_cwd.clone(),
545 ..TaskTemplate::default()
546 },
547 TaskTemplate {
548 label: format!(
549 "go test {} -v -run {}/{}",
550 GO_PACKAGE_TASK_VARIABLE.template_value(),
551 VariableName::Symbol.template_value(),
552 GO_SUBTEST_NAME_TASK_VARIABLE.template_value(),
553 ),
554 command: "go".into(),
555 args: vec![
556 "test".into(),
557 "-v".into(),
558 "-run".into(),
559 format!(
560 "\\^{}\\$/\\^{}\\$",
561 VariableName::Symbol.template_value(),
562 GO_SUBTEST_NAME_TASK_VARIABLE.template_value(),
563 ),
564 ],
565 cwd: package_cwd.clone(),
566 tags: vec!["go-subtest".to_owned()],
567 ..TaskTemplate::default()
568 },
569 TaskTemplate {
570 label: format!(
571 "go test {} -bench {}",
572 GO_PACKAGE_TASK_VARIABLE.template_value(),
573 VariableName::Symbol.template_value()
574 ),
575 command: "go".into(),
576 args: vec![
577 "test".into(),
578 "-benchmem".into(),
579 "-run='^$'".into(),
580 "-bench".into(),
581 format!("\\^{}\\$", VariableName::Symbol.template_value()),
582 ],
583 cwd: package_cwd.clone(),
584 tags: vec!["go-benchmark".to_owned()],
585 ..TaskTemplate::default()
586 },
587 TaskTemplate {
588 label: format!(
589 "go test {} -fuzz=Fuzz -run {}",
590 GO_PACKAGE_TASK_VARIABLE.template_value(),
591 VariableName::Symbol.template_value(),
592 ),
593 command: "go".into(),
594 args: vec![
595 "test".into(),
596 "-fuzz=Fuzz".into(),
597 "-run".into(),
598 format!("\\^{}\\$", VariableName::Symbol.template_value(),),
599 ],
600 tags: vec!["go-fuzz".to_owned()],
601 cwd: package_cwd.clone(),
602 ..TaskTemplate::default()
603 },
604 TaskTemplate {
605 label: format!("go run {}", GO_PACKAGE_TASK_VARIABLE.template_value(),),
606 command: "go".into(),
607 args: vec!["run".into(), ".".into()],
608 cwd: package_cwd.clone(),
609 tags: vec!["go-main".to_owned()],
610 ..TaskTemplate::default()
611 },
612 TaskTemplate {
613 label: format!("go generate {}", GO_PACKAGE_TASK_VARIABLE.template_value()),
614 command: "go".into(),
615 args: vec!["generate".into()],
616 cwd: package_cwd.clone(),
617 tags: vec!["go-generate".to_owned()],
618 ..TaskTemplate::default()
619 },
620 TaskTemplate {
621 label: "go generate ./...".into(),
622 command: "go".into(),
623 args: vec!["generate".into(), "./...".into()],
624 cwd: module_cwd.clone(),
625 ..TaskTemplate::default()
626 },
627 ]))
628 }
629}
630
631fn extract_subtest_name(input: &str) -> Option<String> {
632 let replaced_spaces = input.trim_matches('"').replace(' ', "_");
633
634 Some(
635 GO_ESCAPE_SUBTEST_NAME_REGEX
636 .replace_all(&replaced_spaces, |caps: ®ex::Captures| {
637 format!("\\{}", &caps[0])
638 })
639 .to_string(),
640 )
641}
642
643#[cfg(test)]
644mod tests {
645 use super::*;
646 use crate::language;
647 use gpui::Hsla;
648 use theme::SyntaxTheme;
649
650 #[gpui::test]
651 async fn test_go_label_for_completion() {
652 let adapter = Arc::new(GoLspAdapter);
653 let language = language("go", tree_sitter_go::LANGUAGE.into());
654
655 let theme = SyntaxTheme::new_test([
656 ("type", Hsla::default()),
657 ("keyword", Hsla::default()),
658 ("function", Hsla::default()),
659 ("number", Hsla::default()),
660 ("property", Hsla::default()),
661 ]);
662 language.set_theme(&theme);
663
664 let grammar = language.grammar().unwrap();
665 let highlight_function = grammar.highlight_id_for_name("function").unwrap();
666 let highlight_type = grammar.highlight_id_for_name("type").unwrap();
667 let highlight_keyword = grammar.highlight_id_for_name("keyword").unwrap();
668 let highlight_number = grammar.highlight_id_for_name("number").unwrap();
669
670 assert_eq!(
671 adapter
672 .label_for_completion(
673 &lsp::CompletionItem {
674 kind: Some(lsp::CompletionItemKind::FUNCTION),
675 label: "Hello".to_string(),
676 detail: Some("func(a B) c.D".to_string()),
677 ..Default::default()
678 },
679 &language
680 )
681 .await,
682 Some(CodeLabel {
683 text: "Hello(a B) c.D".to_string(),
684 filter_range: 0..5,
685 runs: vec![
686 (0..5, highlight_function),
687 (8..9, highlight_type),
688 (13..14, highlight_type),
689 ],
690 })
691 );
692
693 // Nested methods
694 assert_eq!(
695 adapter
696 .label_for_completion(
697 &lsp::CompletionItem {
698 kind: Some(lsp::CompletionItemKind::METHOD),
699 label: "one.two.Three".to_string(),
700 detail: Some("func() [3]interface{}".to_string()),
701 ..Default::default()
702 },
703 &language
704 )
705 .await,
706 Some(CodeLabel {
707 text: "one.two.Three() [3]interface{}".to_string(),
708 filter_range: 0..13,
709 runs: vec![
710 (8..13, highlight_function),
711 (17..18, highlight_number),
712 (19..28, highlight_keyword),
713 ],
714 })
715 );
716
717 // Nested fields
718 assert_eq!(
719 adapter
720 .label_for_completion(
721 &lsp::CompletionItem {
722 kind: Some(lsp::CompletionItemKind::FIELD),
723 label: "two.Three".to_string(),
724 detail: Some("a.Bcd".to_string()),
725 ..Default::default()
726 },
727 &language
728 )
729 .await,
730 Some(CodeLabel {
731 text: "two.Three a.Bcd".to_string(),
732 filter_range: 0..9,
733 runs: vec![(12..15, highlight_type)],
734 })
735 );
736 }
737}