Files
codeql/rust/ast-generator/patches/rust-analyzer.patch
2024-12-19 12:29:27 +01:00

74 lines
2.2 KiB
Diff

diff --git a/xtask/src/codegen/grammar.rs b/xtask/src/codegen/grammar.rs
index e7534582f2..49c96f1be3 100644
--- a/xtask/src/codegen/grammar.rs
+++ b/xtask/src/codegen/grammar.rs
@@ -3,7 +3,9 @@
//! Specifically, it generates the `SyntaxKind` enum and a number of newtype
//! wrappers around `SyntaxNode` which implement `syntax::AstNode`.
-#![allow(clippy::disallowed_types)]
+#![allow(warnings)]
+#![allow(clippy)]
+#![cfg_attr(any(), rustfmt::skip)]
use std::{
collections::{BTreeSet, HashSet},
@@ -23,7 +25,7 @@ use crate::{
project_root,
};
-mod ast_src;
+pub mod ast_src;
use self::ast_src::{AstEnumSrc, AstNodeSrc, AstSrc, Cardinality, Field, KindsSrc};
pub(crate) fn generate(check: bool) {
@@ -624,7 +626,7 @@ fn pluralize(s: &str) -> String {
}
impl Field {
- fn is_many(&self) -> bool {
+ pub fn is_many(&self) -> bool {
matches!(self, Field::Node { cardinality: Cardinality::Many, .. })
}
fn token_kind(&self) -> Option<proc_macro2::TokenStream> {
@@ -636,7 +638,7 @@ impl Field {
_ => None,
}
}
- fn method_name(&self) -> String {
+ pub fn method_name(&self) -> String {
match self {
Field::Token(name) => {
let name = match name.as_str() {
@@ -682,7 +684,7 @@ impl Field {
}
}
}
- fn ty(&self) -> proc_macro2::Ident {
+ pub fn ty(&self) -> proc_macro2::Ident {
match self {
Field::Token(_) => format_ident!("SyntaxToken"),
Field::Node { ty, .. } => format_ident!("{}", ty),
@@ -699,7 +701,7 @@ fn clean_token_name(name: &str) -> String {
}
}
-fn lower(grammar: &Grammar) -> AstSrc {
+pub fn lower(grammar: &Grammar) -> AstSrc {
let mut res = AstSrc {
tokens:
"Whitespace Comment String ByteString CString IntNumber FloatNumber Char Byte Ident"
diff --git a/xtask/src/codegen/grammar/ast_src.rs b/xtask/src/codegen/grammar/ast_src.rs
index 9269d15423..babe7ca1bf 100644
--- a/xtask/src/codegen/grammar/ast_src.rs
+++ b/xtask/src/codegen/grammar/ast_src.rs
@@ -1,5 +1,8 @@
//! Defines input for code generation process.
+#![allow(clippy)]
+#![cfg_attr(any(), rustfmt::skip)]
+
use quote::ToTokens;
use crate::codegen::grammar::to_upper_snake_case;