Skip to content

Commit 0853dea

Browse files
committed
Remove r_ prefix
These functions don't call R
1 parent 994a3d2 commit 0853dea

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

crates/ark/src/lsp/completions/completion_item.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ use std::fs::DirEntry;
1010
use anyhow::bail;
1111
use anyhow::Result;
1212
use harp::r_symbol;
13+
use harp::utils::is_symbol_valid;
1314
use harp::utils::r_env_binding_is_active;
1415
use harp::utils::r_envir_name;
1516
use harp::utils::r_formals;
1617
use harp::utils::r_promise_force_with_rollback;
1718
use harp::utils::r_promise_is_forced;
1819
use harp::utils::r_promise_is_lazy_load_binding;
19-
use harp::utils::r_symbol_quote;
20-
use harp::utils::r_symbol_quote_invalid;
21-
use harp::utils::r_symbol_valid;
2220
use harp::utils::r_typeof;
21+
use harp::utils::sym_quote;
22+
use harp::utils::sym_quote_invalid;
2323
use libr::R_UnboundValue;
2424
use libr::Rf_findVarInFrame;
2525
use libr::Rf_isFunction;
@@ -178,7 +178,7 @@ pub(super) fn completion_item_from_function<T: AsRef<str>>(
178178
let detail = format!("{}({})", name, parameters.joined(", "));
179179
item.detail = Some(detail);
180180

181-
let insert_text = r_symbol_quote_invalid(name);
181+
let insert_text = sym_quote_invalid(name);
182182
item.insert_text_format = Some(InsertTextFormat::SNIPPET);
183183
item.insert_text = Some(format!("{insert_text}($0)"));
184184

@@ -211,8 +211,8 @@ pub(super) unsafe fn completion_item_from_data_variable(
211211

212212
if enquote {
213213
item.insert_text = Some(format!("\"{}\"", name));
214-
} else if !r_symbol_valid(name) {
215-
item.insert_text = Some(r_symbol_quote(name));
214+
} else if !is_symbol_valid(name) {
215+
item.insert_text = Some(sym_quote(name));
216216
}
217217

218218
item.detail = Some(owner.to_string());
@@ -253,8 +253,8 @@ pub(super) unsafe fn completion_item_from_object(
253253
item.detail = Some("(Object)".to_string());
254254
item.kind = Some(CompletionItemKind::STRUCT);
255255

256-
if !r_symbol_valid(name) {
257-
item.insert_text = Some(r_symbol_quote(name));
256+
if !is_symbol_valid(name) {
257+
item.insert_text = Some(sym_quote(name));
258258
}
259259

260260
Ok(item)
@@ -293,8 +293,8 @@ pub(super) unsafe fn completion_item_from_promise(
293293
item.detail = Some("Promise".to_string());
294294
item.kind = Some(CompletionItemKind::STRUCT);
295295

296-
if !r_symbol_valid(name) {
297-
item.insert_text = Some(r_symbol_quote(name));
296+
if !is_symbol_valid(name) {
297+
item.insert_text = Some(sym_quote(name));
298298
}
299299

300300
Ok(item)
@@ -310,8 +310,8 @@ pub(super) fn completion_item_from_active_binding(name: &str) -> Result<Completi
310310
item.detail = Some("Active binding".to_string());
311311
item.kind = Some(CompletionItemKind::STRUCT);
312312

313-
if !r_symbol_valid(name) {
314-
item.insert_text = Some(r_symbol_quote(name));
313+
if !is_symbol_valid(name) {
314+
item.insert_text = Some(sym_quote(name));
315315
}
316316

317317
Ok(item)
@@ -433,7 +433,7 @@ pub(super) fn completion_item_from_parameter(
433433
function: callee.to_string(),
434434
};
435435

436-
let parameter = r_symbol_quote_invalid(parameter);
436+
let parameter = sym_quote_invalid(parameter);
437437

438438
// We want to display to the user the name with the `=`
439439
let label = parameter.clone() + " = ";

crates/ark/src/lsp/completions/sources/unique/custom.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use anyhow::Result;
99
use harp::exec::RFunction;
1010
use harp::exec::RFunctionExt;
1111
use harp::object::RObject;
12-
use harp::utils::r_symbol_quote_invalid;
12+
use harp::utils::sym_quote_invalid;
1313
use harp::utils::r_typeof;
1414
use libr::R_NilValue;
1515
use libr::VECSXP;
@@ -183,7 +183,7 @@ pub fn completions_from_custom_source_impl(
183183
if enquote && !node.is_string() {
184184
item.insert_text = Some(format!("\"{value}\""));
185185
} else {
186-
let mut insert_text = r_symbol_quote_invalid(value.as_str());
186+
let mut insert_text = sym_quote_invalid(value.as_str());
187187

188188
if !append.is_empty() {
189189
insert_text = format!("{insert_text}{append}");

crates/ark/src/lsp/diagnostics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ use harp::exec::RFunctionExt;
1919
use harp::external_ptr::ExternalPointer;
2020
use harp::object::RObject;
2121
use harp::r_symbol;
22+
use harp::utils::is_symbol_valid;
2223
use harp::utils::r_is_null;
23-
use harp::utils::r_symbol_quote_invalid;
24-
use harp::utils::r_symbol_valid;
24+
use harp::utils::sym_quote_invalid;
2525
use libr::R_NilValue;
2626
use libr::Rf_ScalarInteger;
2727
use libr::Rf_allocVector;
@@ -286,10 +286,10 @@ fn generate_diagnostics(doc: &Document, state: &WorldState) -> Vec<Diagnostic> {
286286

287287
for scope in state.console_scopes.lock().iter() {
288288
for name in scope.iter() {
289-
if r_symbol_valid(name.as_str()) {
289+
if is_symbol_valid(name.as_str()) {
290290
context.session_symbols.insert(name.clone());
291291
} else {
292-
let name = r_symbol_quote_invalid(name.as_str());
292+
let name = sym_quote_invalid(name.as_str());
293293
context.session_symbols.insert(name.clone());
294294
}
295295
}

crates/harp/src/utils.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,19 +497,19 @@ pub unsafe fn r_inspect(object: SEXP) {
497497
Rf_eval(internal, R_BaseEnv);
498498
}
499499

500-
pub fn r_symbol_valid(name: &str) -> bool {
500+
pub fn is_symbol_valid(name: &str) -> bool {
501501
RE_SYNTACTIC_IDENTIFIER.is_match(name)
502502
}
503503

504-
pub fn r_symbol_quote_invalid(name: &str) -> String {
505-
if RE_SYNTACTIC_IDENTIFIER.is_match(name) {
504+
pub fn sym_quote_invalid(name: &str) -> String {
505+
if is_symbol_valid(name) {
506506
name.to_string()
507507
} else {
508-
r_symbol_quote(name)
508+
sym_quote(name)
509509
}
510510
}
511511

512-
pub fn r_symbol_quote(name: &str) -> String {
512+
pub fn sym_quote(name: &str) -> String {
513513
format!("`{}`", name.replace("`", "\\`"))
514514
}
515515

0 commit comments

Comments
 (0)