Autocomplete rsx (#2421)

* autocomplete rsx

* hide the completions module

* fix autocomplete for identifiers that start with a raw identifier

* add field completion hints for props

* remove extra import

* Revert "add field completion hints for props"

This reverts commit 194899c73783e0f9b5d601d53365746d838f2048.

* fix autocomplete inside raw expressions

* fix autofmt

* feat: just use regular ifmt if it's compatible

reuses the tokens for ifmt so RA provides its HIR lowering on simple formatted strings

* fix merging ifmt strings

* add a better error message for components called like functions

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Evan AlmloffandJonathan Kelley authored and GitHub committed 2024-05-22 07:24:50 -05:00
1 parent 245003a5d4
commit 2523581cf4
21 files changed
+788 -217

No files matched your search

+5 -1
View File
@@ -52,6 +52,10 @@ impl Writer<'_> {
..
} = el;
let brace = brace
.as_ref()
.expect("braces should always be present in strict mode");
/*
1. Write the tag
2. Write the key
@@ -426,7 +430,7 @@ impl Writer<'_> {
}
}
fn get_expr_length(expr: &Expr) -> Option<usize> {
fn get_expr_length(expr: &impl Spanned) -> Option<usize> {
let span = expr.span();
let (start, end) = (span.start(), span.end());
if start.line == end.line {
+4 -4
View File
@@ -9,7 +9,7 @@ use collect_macros::byte_offset;
use dioxus_rsx::{BodyNode, CallBody, IfmtInput};
use proc_macro2::LineColumn;
use quote::ToTokens;
use syn::{ExprMacro, MacroDelimiter};
use syn::{parse::Parser, ExprMacro, MacroDelimiter};
mod buffer;
mod collect_macros;
@@ -77,7 +77,7 @@ pub fn fmt_file(contents: &str, indent: IndentOptions) -> Vec<FormattedBlock> {
continue;
}
let body = item.parse_body::<CallBody>().unwrap();
let body = item.parse_body_with(CallBody::parse_strict).unwrap();
let rsx_start = macro_path.span().start();
@@ -153,7 +153,7 @@ fn write_body(buf: &mut Writer, body: &CallBody) {
}
pub fn fmt_block_from_expr(raw: &str, expr: ExprMacro) -> Option<String> {
let body = syn::parse2::<CallBody>(expr.mac.tokens).unwrap();
let body = CallBody::parse_strict.parse2(expr.mac.tokens).unwrap();
let mut buf = Writer::new(raw);
@@ -163,7 +163,7 @@ pub fn fmt_block_from_expr(raw: &str, expr: ExprMacro) -> Option<String> {
}
pub fn fmt_block(block: &str, indent_level: usize, indent: IndentOptions) -> Option<String> {
let body = syn::parse_str::<dioxus_rsx::CallBody>(block).unwrap();
let body = CallBody::parse_strict.parse_str(block).unwrap();
let mut buf = Writer::new(block);