summaryrefslogtreecommitdiff
path: root/cli/lsp
diff options
context:
space:
mode:
Diffstat (limited to 'cli/lsp')
-rw-r--r--cli/lsp/analysis.rs12
-rw-r--r--cli/lsp/client.rs2
-rw-r--r--cli/lsp/completions.rs2
-rw-r--r--cli/lsp/diagnostics.rs17
-rw-r--r--cli/lsp/documents.rs6
-rw-r--r--cli/lsp/language_server.rs7
-rw-r--r--cli/lsp/path_to_regex.rs34
-rw-r--r--cli/lsp/registries.rs14
-rw-r--r--cli/lsp/repl.rs2
-rw-r--r--cli/lsp/tsc.rs23
-rw-r--r--cli/lsp/urls.rs6
11 files changed, 59 insertions, 66 deletions
diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs
index c7f5ba8aa..182ad940e 100644
--- a/cli/lsp/analysis.rs
+++ b/cli/lsp/analysis.rs
@@ -158,7 +158,7 @@ fn check_specifier(
documents: &Documents,
) -> Option<String> {
for ext in SUPPORTED_EXTENSIONS {
- let specifier_with_ext = format!("{}{}", specifier, ext);
+ let specifier_with_ext = format!("{specifier}{ext}");
if documents.contains_import(&specifier_with_ext, referrer) {
return Some(specifier_with_ext);
}
@@ -398,7 +398,7 @@ impl CodeActionCollection {
specifier.clone(),
vec![lsp::TextEdit {
new_text: prepend_whitespace(
- format!("// deno-lint-ignore {}\n", code),
+ format!("// deno-lint-ignore {code}\n"),
line_content,
),
range: lsp::Range {
@@ -414,7 +414,7 @@ impl CodeActionCollection {
}],
);
let ignore_error_action = lsp::CodeAction {
- title: format!("Disable {} for this line", code),
+ title: format!("Disable {code} for this line"),
kind: Some(lsp::CodeActionKind::QUICKFIX),
diagnostics: Some(vec![diagnostic.clone()]),
command: None,
@@ -447,7 +447,7 @@ impl CodeActionCollection {
})
});
- let mut new_text = format!("// deno-lint-ignore-file {}\n", code);
+ let mut new_text = format!("// deno-lint-ignore-file {code}\n");
let mut range = lsp::Range {
start: lsp::Position {
line: 0,
@@ -461,7 +461,7 @@ impl CodeActionCollection {
// If ignore file comment already exists, append the lint code
// to the existing comment.
if let Some(ignore_comment) = maybe_ignore_comment {
- new_text = format!(" {}", code);
+ new_text = format!(" {code}");
// Get the end position of the comment.
let line = maybe_parsed_source
.unwrap()
@@ -479,7 +479,7 @@ impl CodeActionCollection {
let mut changes = HashMap::new();
changes.insert(specifier.clone(), vec![lsp::TextEdit { new_text, range }]);
let ignore_file_action = lsp::CodeAction {
- title: format!("Disable {} for the entire file", code),
+ title: format!("Disable {code} for the entire file"),
kind: Some(lsp::CodeActionKind::QUICKFIX),
diagnostics: Some(vec![diagnostic.clone()]),
command: None,
diff --git a/cli/lsp/client.rs b/cli/lsp/client.rs
index b39678667..cdef1cfbf 100644
--- a/cli/lsp/client.rs
+++ b/cli/lsp/client.rs
@@ -107,7 +107,7 @@ impl Client {
) {
self
.0
- .show_message(message_type, format!("{}", message))
+ .show_message(message_type, format!("{message}"))
.await
}
diff --git a/cli/lsp/completions.rs b/cli/lsp/completions.rs
index a8e7896c5..b89aec6c9 100644
--- a/cli/lsp/completions.rs
+++ b/cli/lsp/completions.rs
@@ -394,7 +394,7 @@ fn get_local_completions(
let filter_text = if full_text.starts_with(current) {
Some(full_text)
} else {
- Some(format!("{}{}", current, label))
+ Some(format!("{current}{label}"))
};
match de.file_type() {
Ok(file_type) if file_type.is_dir() => Some(lsp::CompletionItem {
diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs
index 9f3c409cc..b6dff8682 100644
--- a/cli/lsp/diagnostics.rs
+++ b/cli/lsp/diagnostics.rs
@@ -670,17 +670,14 @@ impl DenoDiagnostic {
let DiagnosticDataImportMapRemap { from, to } =
serde_json::from_value(data)?;
lsp::CodeAction {
- title: format!(
- "Update \"{}\" to \"{}\" to use import map.",
- from, to
- ),
+ title: format!("Update \"{from}\" to \"{to}\" to use import map."),
kind: Some(lsp::CodeActionKind::QUICKFIX),
diagnostics: Some(vec![diagnostic.clone()]),
edit: Some(lsp::WorkspaceEdit {
changes: Some(HashMap::from([(
specifier.clone(),
vec![lsp::TextEdit {
- new_text: format!("\"{}\"", to),
+ new_text: format!("\"{to}\""),
range: diagnostic.range,
}],
)])),
@@ -821,15 +818,15 @@ impl DenoDiagnostic {
pub fn to_lsp_diagnostic(&self, range: &lsp::Range) -> lsp::Diagnostic {
let (severity, message, data) = match self {
Self::DenoWarn(message) => (lsp::DiagnosticSeverity::WARNING, message.to_string(), None),
- Self::ImportMapRemap { from, to } => (lsp::DiagnosticSeverity::HINT, format!("The import specifier can be remapped to \"{}\" which will resolve it via the active import map.", to), Some(json!({ "from": from, "to": to }))),
- Self::InvalidAssertType(assert_type) => (lsp::DiagnosticSeverity::ERROR, format!("The module is a JSON module and expected an assertion type of \"json\". Instead got \"{}\".", assert_type), None),
+ Self::ImportMapRemap { from, to } => (lsp::DiagnosticSeverity::HINT, format!("The import specifier can be remapped to \"{to}\" which will resolve it via the active import map."), Some(json!({ "from": from, "to": to }))),
+ Self::InvalidAssertType(assert_type) => (lsp::DiagnosticSeverity::ERROR, format!("The module is a JSON module and expected an assertion type of \"json\". Instead got \"{assert_type}\"."), None),
Self::NoAssertType => (lsp::DiagnosticSeverity::ERROR, "The module is a JSON module and not being imported with an import assertion. Consider adding `assert { type: \"json\" }` to the import statement.".to_string(), None),
- Self::NoCache(specifier) => (lsp::DiagnosticSeverity::ERROR, format!("Uncached or missing remote URL: \"{}\".", specifier), Some(json!({ "specifier": specifier }))),
+ Self::NoCache(specifier) => (lsp::DiagnosticSeverity::ERROR, format!("Uncached or missing remote URL: \"{specifier}\"."), Some(json!({ "specifier": specifier }))),
Self::NoCacheBlob => (lsp::DiagnosticSeverity::ERROR, "Uncached blob URL.".to_string(), None),
Self::NoCacheData(specifier) => (lsp::DiagnosticSeverity::ERROR, "Uncached data URL.".to_string(), Some(json!({ "specifier": specifier }))),
Self::NoCacheNpm(pkg_ref, specifier) => (lsp::DiagnosticSeverity::ERROR, format!("Uncached or missing npm package: \"{}\".", pkg_ref.req), Some(json!({ "specifier": specifier }))),
- Self::NoLocal(specifier) => (lsp::DiagnosticSeverity::ERROR, format!("Unable to load a local module: \"{}\".\n Please check the file path.", specifier), None),
- Self::Redirect { from, to} => (lsp::DiagnosticSeverity::INFORMATION, format!("The import of \"{}\" was redirected to \"{}\".", from, to), Some(json!({ "specifier": from, "redirect": to }))),
+ Self::NoLocal(specifier) => (lsp::DiagnosticSeverity::ERROR, format!("Unable to load a local module: \"{specifier}\".\n Please check the file path."), None),
+ Self::Redirect { from, to} => (lsp::DiagnosticSeverity::INFORMATION, format!("The import of \"{from}\" was redirected to \"{to}\"."), Some(json!({ "specifier": from, "redirect": to }))),
Self::ResolutionError(err) => (
lsp::DiagnosticSeverity::ERROR,
enhanced_resolution_error_message(err),
diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs
index 03210ebaa..07003a168 100644
--- a/cli/lsp/documents.rs
+++ b/cli/lsp/documents.rs
@@ -838,7 +838,7 @@ impl Documents {
|| {
Err(custom_error(
"NotFound",
- format!("The specifier \"{}\" was not found.", specifier),
+ format!("The specifier \"{specifier}\" was not found."),
))
},
Ok,
@@ -862,7 +862,7 @@ impl Documents {
} else {
return Err(custom_error(
"NotFound",
- format!("The specifier \"{}\" was not found.", specifier),
+ format!("The specifier \"{specifier}\" was not found."),
));
}
}
@@ -1100,7 +1100,7 @@ impl Documents {
} else {
return Err(custom_error(
"NotFound",
- format!("Specifier not found {}", specifier),
+ format!("Specifier not found {specifier}"),
));
}
}
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 0b02115af..58116d49e 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -375,8 +375,7 @@ impl Inner {
self.get_maybe_asset_or_document(specifier).map_or_else(
|| {
Err(LspError::invalid_params(format!(
- "Unable to find asset or document for: {}",
- specifier
+ "Unable to find asset or document for: {specifier}"
)))
},
Ok,
@@ -1296,7 +1295,7 @@ impl Inner {
Ok(Some(text_edits))
}
} else {
- self.client.show_message(MessageType::WARNING, format!("Unable to format \"{}\". Likely due to unrecoverable syntax errors in the file.", specifier)).await;
+ self.client.show_message(MessageType::WARNING, format!("Unable to format \"{specifier}\". Likely due to unrecoverable syntax errors in the file.")).await;
Ok(None)
}
}
@@ -1354,7 +1353,7 @@ impl Inner {
};
let value =
if let Some(docs) = self.module_registries.get_hover(&dep).await {
- format!("{}\n\n---\n\n{}", value, docs)
+ format!("{value}\n\n---\n\n{docs}")
} else {
value
};
diff --git a/cli/lsp/path_to_regex.rs b/cli/lsp/path_to_regex.rs
index a9b4bcdf3..1d766e024 100644
--- a/cli/lsp/path_to_regex.rs
+++ b/cli/lsp/path_to_regex.rs
@@ -220,8 +220,8 @@ pub enum StringOrNumber {
impl fmt::Display for StringOrNumber {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &self {
- Self::Number(n) => write!(f, "{}", n),
- Self::String(s) => write!(f, "{}", s),
+ Self::Number(n) => write!(f, "{n}"),
+ Self::String(s) => write!(f, "{s}"),
}
}
}
@@ -269,9 +269,9 @@ impl StringOrVec {
let mut s = String::new();
for (i, segment) in v.iter().enumerate() {
if omit_initial_prefix && i == 0 {
- write!(s, "{}{}", segment, suffix).unwrap();
+ write!(s, "{segment}{suffix}").unwrap();
} else {
- write!(s, "{}{}{}", prefix, segment, suffix).unwrap();
+ write!(s, "{prefix}{segment}{suffix}").unwrap();
}
}
s
@@ -610,7 +610,7 @@ pub fn tokens_to_regex(
}
} else {
let modifier = key.modifier.clone().unwrap_or_default();
- format!(r"(?:{}{}){}", prefix, suffix, modifier)
+ format!(r"(?:{prefix}{suffix}){modifier}")
}
}
};
@@ -619,10 +619,10 @@ pub fn tokens_to_regex(
if end {
if !strict {
- write!(route, r"{}?", delimiter).unwrap();
+ write!(route, r"{delimiter}?").unwrap();
}
if has_ends_with {
- write!(route, r"(?={})", ends_with).unwrap();
+ write!(route, r"(?={ends_with})").unwrap();
} else {
route.push('$');
}
@@ -640,16 +640,16 @@ pub fn tokens_to_regex(
};
if !strict {
- write!(route, r"(?:{}(?={}))?", delimiter, ends_with).unwrap();
+ write!(route, r"(?:{delimiter}(?={ends_with}))?").unwrap();
}
if !is_end_deliminated {
- write!(route, r"(?={}|{})", delimiter, ends_with).unwrap();
+ write!(route, r"(?={delimiter}|{ends_with})").unwrap();
}
}
let flags = if sensitive { "" } else { "(?i)" };
- let re = FancyRegex::new(&format!("{}{}", flags, route))?;
+ let re = FancyRegex::new(&format!("{flags}{route}"))?;
let maybe_keys = if keys.is_empty() { None } else { Some(keys) };
Ok((re, maybe_keys))
@@ -754,7 +754,7 @@ impl Compiler {
}
}
}
- write!(path, "{}{}{}", prefix, segment, suffix).unwrap();
+ write!(path, "{prefix}{segment}{suffix}").unwrap();
}
}
}
@@ -773,7 +773,7 @@ impl Compiler {
}
let prefix = k.prefix.clone().unwrap_or_default();
let suffix = k.suffix.clone().unwrap_or_default();
- write!(path, "{}{}{}", prefix, s, suffix).unwrap();
+ write!(path, "{prefix}{s}{suffix}").unwrap();
}
None => {
if !optional {
@@ -874,25 +874,23 @@ mod tests {
fixtures: &[Fixture],
) {
let result = string_to_regex(path, maybe_options);
- assert!(result.is_ok(), "Could not parse path: \"{}\"", path);
+ assert!(result.is_ok(), "Could not parse path: \"{path}\"");
let (re, _) = result.unwrap();
for (fixture, expected) in fixtures {
let result = re.find(fixture);
assert!(
result.is_ok(),
- "Find failure for path \"{}\" and fixture \"{}\"",
- path,
- fixture
+ "Find failure for path \"{path}\" and fixture \"{fixture}\""
);
let actual = result.unwrap();
if let Some((text, start, end)) = *expected {
- assert!(actual.is_some(), "Match failure for path \"{}\" and fixture \"{}\". Expected Some got None", path, fixture);
+ assert!(actual.is_some(), "Match failure for path \"{path}\" and fixture \"{fixture}\". Expected Some got None");
let actual = actual.unwrap();
assert_eq!(actual.as_str(), text, "Match failure for path \"{}\" and fixture \"{}\". Expected \"{}\" got \"{}\".", path, fixture, text, actual.as_str());
assert_eq!(actual.start(), start);
assert_eq!(actual.end(), end);
} else {
- assert!(actual.is_none(), "Match failure for path \"{}\" and fixture \"{}\". Expected None got {:?}", path, fixture, actual);
+ assert!(actual.is_none(), "Match failure for path \"{path}\" and fixture \"{fixture}\". Expected None got {actual:?}");
}
}
}
diff --git a/cli/lsp/registries.rs b/cli/lsp/registries.rs
index ca7b6368e..d67068ec7 100644
--- a/cli/lsp/registries.rs
+++ b/cli/lsp/registries.rs
@@ -217,10 +217,10 @@ fn get_endpoint_with_match(
Token::Key(k) if k.name == *key => Some(k),
_ => None,
});
- url = url
- .replace(&format!("${{{}}}", name), &value.to_string(maybe_key, true));
+ url =
+ url.replace(&format!("${{{name}}}"), &value.to_string(maybe_key, true));
url = url.replace(
- &format!("${{{{{}}}}}", name),
+ &format!("${{{{{name}}}}}"),
&percent_encoding::percent_encode(
value.to_string(maybe_key, true).as_bytes(),
COMPONENT,
@@ -278,8 +278,8 @@ fn replace_variable(
let value = maybe_value.unwrap_or("");
if let StringOrNumber::String(name) = &variable.name {
url_str
- .replace(&format!("${{{}}}", name), value)
- .replace(&format! {"${{{{{}}}}}", name}, value)
+ .replace(&format!("${{{name}}}"), value)
+ .replace(&format! {"${{{{{name}}}}}"}, value)
} else {
url_str
}
@@ -723,7 +723,7 @@ impl ModuleRegistry {
}
for (idx, item) in items.into_iter().enumerate() {
let mut label = if let Some(p) = &prefix {
- format!("{}{}", p, item)
+ format!("{p}{item}")
} else {
item.clone()
};
@@ -880,7 +880,7 @@ impl ModuleRegistry {
is_incomplete = true;
}
for (idx, item) in items.into_iter().enumerate() {
- let path = format!("{}{}", prefix, item);
+ let path = format!("{prefix}{item}");
let kind = Some(lsp::CompletionItemKind::FOLDER);
let item_specifier = base.join(&path).ok()?;
let full_text = item_specifier.as_str();
diff --git a/cli/lsp/repl.rs b/cli/lsp/repl.rs
index 81e621c13..41a3f993a 100644
--- a/cli/lsp/repl.rs
+++ b/cli/lsp/repl.rs
@@ -188,7 +188,7 @@ impl ReplLanguageServer {
let new_text = if new_text.ends_with('\n') {
new_text.to_string()
} else {
- format!("{}\n", new_text)
+ format!("{new_text}\n")
};
self.document_version += 1;
let current_line_count =
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index 3619f529c..2f66e2d2d 100644
--- a/cli/lsp/tsc.rs
+++ b/cli/lsp/tsc.rs
@@ -211,7 +211,7 @@ fn new_assets_map() -> Arc<Mutex<AssetsMap>> {
let assets = tsc::LAZILY_LOADED_STATIC_ASSETS
.iter()
.map(|(k, v)| {
- let url_str = format!("asset:///{}", k);
+ let url_str = format!("asset:///{k}");
let specifier = resolve_url(&url_str).unwrap();
let asset = AssetDocument::new(specifier.clone(), v);
(specifier, asset)
@@ -384,9 +384,9 @@ fn get_tag_documentation(
let maybe_text = get_tag_body_text(tag, language_server);
if let Some(text) = maybe_text {
if text.contains('\n') {
- format!("{} \n{}", label, text)
+ format!("{label} \n{text}")
} else {
- format!("{} - {}", label, text)
+ format!("{label} - {text}")
}
} else {
label
@@ -397,7 +397,7 @@ fn make_codeblock(text: &str) -> String {
if CODEBLOCK_RE.is_match(text) {
text.to_string()
} else {
- format!("```\n{}\n```", text)
+ format!("```\n{text}\n```")
}
}
@@ -700,9 +700,9 @@ fn display_parts_to_string(
.unwrap_or_else(|| "".to_string())
});
let link_str = if link.linkcode {
- format!("[`{}`]({})", link_text, specifier)
+ format!("[`{link_text}`]({specifier})")
} else {
- format!("[{}]({})", link_text, specifier)
+ format!("[{link_text}]({specifier})")
};
out.push(link_str);
}
@@ -785,8 +785,7 @@ impl QuickInfo {
.join(" \n\n");
if !tags_preview.is_empty() {
parts.push(lsp::MarkedString::from_markdown(format!(
- "\n\n{}",
- tags_preview
+ "\n\n{tags_preview}"
)));
}
}
@@ -1984,7 +1983,7 @@ impl CompletionEntryDetails {
.map(|tag_info| get_tag_documentation(tag_info, language_server))
.collect::<Vec<String>>()
.join("");
- value = format!("{}\n\n{}", value, tag_documentation);
+ value = format!("{value}\n\n{tag_documentation}");
}
Some(lsp::Documentation::MarkupContent(lsp::MarkupContent {
kind: lsp::MarkupKind::Markdown,
@@ -2486,7 +2485,7 @@ impl SignatureHelpItem {
let documentation =
display_parts_to_string(&self.documentation, language_server);
lsp::SignatureInformation {
- label: format!("{}{}{}", prefix_text, params_text, suffix_text),
+ label: format!("{prefix_text}{params_text}{suffix_text}"),
documentation: Some(lsp::Documentation::MarkupContent(
lsp::MarkupContent {
kind: lsp::MarkupKind::Markdown,
@@ -2844,7 +2843,7 @@ fn start(
.clone()
.unwrap_or_else(|| Url::parse("cache:///").unwrap());
let init_config = json!({ "debug": debug, "rootUri": root_uri });
- let init_src = format!("globalThis.serverInit({});", init_config);
+ let init_src = format!("globalThis.serverInit({init_config});");
runtime.execute_script(&located_script_name!(), &init_src)?;
Ok(())
@@ -3433,7 +3432,7 @@ pub fn request(
(state.performance.clone(), method.to_value(state, id))
};
let mark = performance.mark("request", Some(request_params.clone()));
- let request_src = format!("globalThis.serverRequest({});", request_params);
+ let request_src = format!("globalThis.serverRequest({request_params});");
runtime.execute_script(&located_script_name!(), &request_src)?;
let op_state = runtime.op_state();
diff --git a/cli/lsp/urls.rs b/cli/lsp/urls.rs
index abe83d3cb..4fba0c9ff 100644
--- a/cli/lsp/urls.rs
+++ b/cli/lsp/urls.rs
@@ -104,10 +104,10 @@ impl LspUrlMap {
format!("deno:/asset{}", specifier.path())
} else if specifier.scheme() == "data" {
let data_url = DataUrl::process(specifier.as_str())
- .map_err(|e| uri_error(format!("{:?}", e)))?;
+ .map_err(|e| uri_error(format!("{e:?}")))?;
let mime = data_url.mime_type();
let (media_type, _) =
- map_content_type(specifier, Some(&format!("{}", mime)));
+ map_content_type(specifier, Some(&format!("{mime}")));
let extension = if media_type == MediaType::Unknown {
""
} else {
@@ -128,7 +128,7 @@ impl LspUrlMap {
})
.collect();
path.push_str(&parts.join("/"));
- format!("deno:/{}", path)
+ format!("deno:/{path}")
};
let url = Url::parse(&specifier_str)?;
inner.put(specifier.clone(), url.clone());