mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
do refact and fix some issue
This commit is contained in:
parent
1ebfa908d5
commit
adac4fc2f2
7 changed files with 72 additions and 60 deletions
|
@ -173,10 +173,21 @@ fn ast_from_text<N: AstNode>(text: &str) -> N {
|
|||
}
|
||||
|
||||
pub mod tokens {
|
||||
use crate::{AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken, T};
|
||||
use crate::{AstNode, Parse, SourceFile, SyntaxKind, SyntaxKind::*, SyntaxToken, T};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
static SOURCE_FILE: Lazy<Parse<SourceFile>> = Lazy::new(|| SourceFile::parse(",\n; ;"));
|
||||
static SOURCE_FILE: Lazy<Parse<SourceFile>> =
|
||||
Lazy::new(|| SourceFile::parse("const C: () = (1 != 1, 2 == 2)\n;"));
|
||||
|
||||
pub fn op(op: SyntaxKind) -> SyntaxToken {
|
||||
SOURCE_FILE
|
||||
.tree()
|
||||
.syntax()
|
||||
.descendants_with_tokens()
|
||||
.filter_map(|it| it.into_token())
|
||||
.find(|it| it.kind() == op)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn comma() -> SyntaxToken {
|
||||
SOURCE_FILE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue