Skip to content

Commit

Permalink
Do not put dots on operators
Browse files Browse the repository at this point in the history
  • Loading branch information
farmaazon committed Mar 5, 2025
1 parent 8649995 commit ad03676
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,13 @@ export function useComponentBrowserInput(
}

function applySourceNode(text: string) {
return sourceNodeIdentifier.value ? `${sourceNodeIdentifier.value}.${text}` : text
return (
sourceNodeIdentifier.value ?
/^[a-zA-Z]/.test(text) ?
`${sourceNodeIdentifier.value}.${text}`
: `${sourceNodeIdentifier.value} ${text}`
: text
)
}

return proxyRefs({
Expand Down
19 changes: 18 additions & 1 deletion app/rust-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ pub fn is_ident_or_operator(code: &str) -> u32 {
}
}

#[wasm_bindgen]
pub fn is_ident_or_operator(code: &str) -> u32 {
let parsed = enso_parser::lexer::run(code);
if parsed.internal_error.is_some() {
return 0;
}
let token = match &parsed.value[..] {
[token] => token,
_ => return 0,
};
match &token.variant {
enso_parser::syntax::token::Variant::Ident(_) => 1,
enso_parser::syntax::token::Variant::Operator(_) => 2,
_ => 0,
}
}

#[wasm_bindgen]
pub fn is_numeric_literal(code: &str) -> bool {
let parsed = PARSER.with(|parser| parser.parse_block(code));
Expand Down Expand Up @@ -74,7 +91,7 @@ mod tests {
use super::*;

#[test]
fn test_is_ident_or_operator() {
fn test_is_numeric_literal() {
assert!(is_numeric_literal("1234"));
assert!(is_numeric_literal("-1234"));
assert!(!is_numeric_literal(""));
Expand Down

0 comments on commit ad03676

Please sign in to comment.