Skip to content

minor fixes for easier contrib #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ members = [
"crates/*",
"xtask/"
]
resolver = "2"

[workspace.package]
rust-version = "1.71"
Expand All @@ -17,4 +18,3 @@ triomphe = { version = "0.1.8", default-features = false, features = ["std"] }
[profile.dev.package]
insta.opt-level = 3
similar.opt-level = 3

12 changes: 11 additions & 1 deletion crates/codegen/src/parser.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use pg_query_proto_parser::ProtoParser;
use quote::quote;
use std::{env, path, path::Path};

use crate::{
get_location::get_location_mod, get_node_properties::get_node_properties_mod,
get_nodes::get_nodes_mod, syntax_kind::syntax_kind_mod,
};

pub fn parser_mod(_item: proc_macro2::TokenStream) -> proc_macro2::TokenStream {
let parser = ProtoParser::new("libpg_query/protobuf/pg_query.proto");
let parser = ProtoParser::new(&proto_file_path());
let proto_file = parser.parse();

let syntax_kind = syntax_kind_mod(&proto_file);
Expand All @@ -32,3 +33,12 @@ pub fn parser_mod(_item: proc_macro2::TokenStream) -> proc_macro2::TokenStream {
#get_nodes
}
}

fn proto_file_path() -> path::PathBuf {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path::new(env!("CARGO_MANIFEST_DIR"))
.ancestors()
.nth(2)
.unwrap()
.join("libpg_query/protobuf/pg_query.proto")
.to_path_buf()
}
4 changes: 2 additions & 2 deletions crates/pg_query_proto_parser/src/proto_parser.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use convert_case::{Case, Casing};
use protobuf::descriptor::{field_descriptor_proto::Label, FileDescriptorProto};
use protobuf_parse::Parser;
use std::path::Path;
use std::{ffi::OsStr, path::Path};

use crate::proto_file::{Field, FieldType, Node, ProtoFile, Token};

Expand All @@ -11,7 +11,7 @@ pub struct ProtoParser {
}

impl ProtoParser {
pub fn new(file_path: &str) -> Self {
pub fn new(file_path: &impl AsRef<OsStr>) -> Self {
let proto_file = Path::new(file_path);
let proto_dir = proto_file.parent().unwrap();

Expand Down
2 changes: 1 addition & 1 deletion crates/postgres_lsp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl LanguageServer for Backend {

async fn semantic_tokens_range(
&self,
params: SemanticTokensRangeParams,
_: SemanticTokensRangeParams,
) -> Result<Option<SemanticTokensRangeResult>> {
return Ok(None);
}
Expand Down
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"