mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
* The ungram file is now taken from the rust-analyzer dependencies pulled in by bazel * the grammar parsing code is not published, so it must be taken directly from rust-analyzer code. That part should be less prone to be updated than the ungram file, so it does not necessarily need to be in sync with the rust-analyzer version is used elsewhere. * both need some patches. The former is patched during build, the latter during loading in `MODULE.bazel`.
58 lines
1.8 KiB
Diff
58 lines
1.8 KiB
Diff
diff --git a/xtask/src/codegen/grammar.rs b/xtask/src/codegen/grammar.rs
|
|
index e7534582f2..8bc9237737 100644
|
|
--- a/xtask/src/codegen/grammar.rs
|
|
+++ b/xtask/src/codegen/grammar.rs
|
|
@@ -3,6 +3,7 @@
|
|
//! Specifically, it generates the `SyntaxKind` enum and a number of newtype
|
|
//! wrappers around `SyntaxNode` which implement `syntax::AstNode`.
|
|
|
|
+#![allow(warnings)]
|
|
#![allow(clippy::disallowed_types)]
|
|
|
|
use std::{
|
|
@@ -23,7 +24,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 +625,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 +637,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 +683,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 +700,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"
|